Compare commits
4 Commits
3.1.0
...
release-3.
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`.
|
Option 2 - Open terminal(Linux) and cd to the project dir. Run `./gradlew build`.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Multiple accounts support
|
|
||||||
- Repositories / issues/ org list
|
- Repositories / issues/ org list
|
||||||
- File and directory browser
|
- File and directory browser
|
||||||
- File viewer
|
- File viewer
|
||||||
@ -87,9 +86,9 @@ Thanks to all the open source libraries, contributors and donators.
|
|||||||
- Apache/commons-io
|
- Apache/commons-io
|
||||||
- Caverock/androidsvg
|
- Caverock/androidsvg
|
||||||
- Droidsonroids.gif/android-gif-drawable
|
- Droidsonroids.gif/android-gif-drawable
|
||||||
- Barteksc/androidPdfViewer
|
- Barteksc/AndroidPdfViewer
|
||||||
- Ge0rg/memorizingTrustManager
|
- Ge0rg/MemorizingTrustManager
|
||||||
- Dimezis/blurView
|
- Dimezis/BlurView
|
||||||
- Mikaelhg/urlbuilder
|
- mikaelhg/urlbuilder
|
||||||
|
|
||||||
[Follow me on Fediverse - mastodon.social/@mmarif](https://mastodon.social/@mmarif)
|
[Follow me on Fediverse - mastodon.social/@mmarif](https://mastodon.social/@mmarif)
|
||||||
|
@ -6,8 +6,8 @@ android {
|
|||||||
applicationId "org.mian.gitnex"
|
applicationId "org.mian.gitnex"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 310
|
versionCode 301
|
||||||
versionName "3.1.0"
|
versionName "3.0.1"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
@ -28,9 +28,6 @@ android {
|
|||||||
targetCompatibility = "8"
|
targetCompatibility = "8"
|
||||||
sourceCompatibility = "8"
|
sourceCompatibility = "8"
|
||||||
}
|
}
|
||||||
defaultConfig{
|
|
||||||
vectorDrawables.useSupportLibrary = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
@ -39,14 +36,14 @@ configurations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
def lifecycle_version = "2.3.0-alpha06"
|
def lifecycle_version = "2.3.0-alpha05"
|
||||||
def markwon_version = "4.4.0"
|
def markwon_version = "4.4.0"
|
||||||
def work_version = "2.4.0"
|
def work_version = "2.4.0"
|
||||||
def acra = "5.5.0"
|
def acra = "5.5.0"
|
||||||
|
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation "androidx.appcompat:appcompat:1.3.0-alpha01"
|
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.constraintlayout:constraintlayout:1.1.3"
|
||||||
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
||||||
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
|
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
|
||||||
@ -84,7 +81,7 @@ dependencies {
|
|||||||
implementation "com.hendraanggrian.appcompat:socialview-commons:0.2"
|
implementation "com.hendraanggrian.appcompat:socialview-commons:0.2"
|
||||||
implementation "com.github.HamidrezaAmz:BreadcrumbsView:0.2.9"
|
implementation "com.github.HamidrezaAmz:BreadcrumbsView:0.2.9"
|
||||||
implementation "commons-io:commons-io:20030203.000550"
|
implementation "commons-io:commons-io:20030203.000550"
|
||||||
implementation 'org.apache.commons:commons-lang3:3.11'
|
implementation "org.apache.commons:commons-lang3:3.10"
|
||||||
implementation "com.github.chrisbanes:PhotoView:2.3.0"
|
implementation "com.github.chrisbanes:PhotoView:2.3.0"
|
||||||
implementation "com.github.barteksc:android-pdf-viewer:3.2.0-beta.1"
|
implementation "com.github.barteksc:android-pdf-viewer:3.2.0-beta.1"
|
||||||
implementation "ch.acra:acra-mail:$acra"
|
implementation "ch.acra:acra-mail:$acra"
|
||||||
|
@ -48,6 +48,8 @@
|
|||||||
android:name=".activities.OrganizationDetailActivity"
|
android:name=".activities.OrganizationDetailActivity"
|
||||||
android:label="@string/title_activity_org_detail"
|
android:label="@string/title_activity_org_detail"
|
||||||
android:theme="@style/AppTheme.NoActionBar" />
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
|
<activity android:name=".activities.SponsorsActivity" />
|
||||||
|
<activity android:name=".activities.CreditsActivity" />
|
||||||
<activity android:name=".activities.CreateLabelActivity" />
|
<activity android:name=".activities.CreateLabelActivity" />
|
||||||
<activity android:name=".activities.CreateIssueActivity" />
|
<activity android:name=".activities.CreateIssueActivity" />
|
||||||
<activity android:name=".activities.CreateMilestoneActivity" />
|
<activity android:name=".activities.CreateMilestoneActivity" />
|
||||||
@ -82,8 +84,6 @@
|
|||||||
<activity android:name=".activities.SettingsReportsActivity" />
|
<activity android:name=".activities.SettingsReportsActivity" />
|
||||||
<activity android:name=".activities.AddNewTeamMemberActivity" />
|
<activity android:name=".activities.AddNewTeamMemberActivity" />
|
||||||
<activity android:name=".activities.SettingsDraftsActivity" />
|
<activity android:name=".activities.SettingsDraftsActivity" />
|
||||||
<activity android:name=".activities.RepoForksActivity" />
|
|
||||||
<activity android:name=".activities.AddNewAccountActivity" />
|
|
||||||
|
|
||||||
<!-- Version < 3.0. DeX Mode and Screen Mirroring support -->
|
<!-- Version < 3.0. DeX Mode and Screen Mirroring support -->
|
||||||
<meta-data android:name="com.samsung.android.keepalive.density" android:value="true"/>
|
<meta-data android:name="com.samsung.android.keepalive.density" android:value="true"/>
|
||||||
|
@ -47,7 +47,7 @@ public class CollaboratorActions {
|
|||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
if(response.code() == 204) {
|
if(response.code() == 204) {
|
||||||
|
|
||||||
Toasty.success(context, context.getString(R.string.removeCollaboratorToastText));
|
Toasty.info(context, context.getString(R.string.removeCollaboratorToastText));
|
||||||
((AddCollaboratorToRepositoryActivity)context).finish();
|
((AddCollaboratorToRepositoryActivity)context).finish();
|
||||||
//Log.i("addCollaboratorSearch", addCollaboratorSearch.getText().toString());
|
//Log.i("addCollaboratorSearch", addCollaboratorSearch.getText().toString());
|
||||||
//tinyDb.putBoolean("updateDataSet", true);
|
//tinyDb.putBoolean("updateDataSet", true);
|
||||||
@ -66,17 +66,17 @@ public class CollaboratorActions {
|
|||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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.isSuccessful()) {
|
||||||
if(response.code() == 204) {
|
if(response.code() == 204) {
|
||||||
|
|
||||||
Toasty.success(context, context.getString(R.string.addCollaboratorToastText));
|
Toasty.info(context, context.getString(R.string.addCollaboratorToastText));
|
||||||
((AddCollaboratorToRepositoryActivity)context).finish();
|
((AddCollaboratorToRepositoryActivity)context).finish();
|
||||||
//AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
|
//AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
|
||||||
//usersSearchData.loadUserSearchList(instanceUrl, instanceToken, searchKeyword, context);
|
//usersSearchData.loadUserSearchList(instanceUrl, instanceToken, searchKeyword, context);
|
||||||
@ -134,17 +134,17 @@ public class CollaboratorActions {
|
|||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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.R;
|
||||||
import org.mian.gitnex.activities.ReplyToIssueActivity;
|
import org.mian.gitnex.activities.ReplyToIssueActivity;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.database.api.DraftsApi;
|
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
@ -23,7 +22,7 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class IssueActions {
|
public class IssueActions {
|
||||||
|
|
||||||
public static void editIssueComment(final Context ctx, final int commentId, final String commentBody, long draftIdOnCreate) {
|
public static void editIssueComment(final Context ctx, final int commentId, final String commentBody) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(ctx);
|
final TinyDB tinyDb = new TinyDB(ctx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||||
@ -49,10 +48,6 @@ public class IssueActions {
|
|||||||
|
|
||||||
tinyDb.putBoolean("commentEdited", true);
|
tinyDb.putBoolean("commentEdited", true);
|
||||||
Toasty.info(ctx, ctx.getString(R.string.editCommentUpdatedText));
|
Toasty.info(ctx, ctx.getString(R.string.editCommentUpdatedText));
|
||||||
|
|
||||||
DraftsApi draftsApi = new DraftsApi(ctx);
|
|
||||||
draftsApi.deleteSingleDraft((int) draftIdOnCreate);
|
|
||||||
|
|
||||||
((ReplyToIssueActivity) ctx).finish();
|
((ReplyToIssueActivity) ctx).finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -64,17 +59,17 @@ public class IssueActions {
|
|||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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")) {
|
if(issueState.equals("closed")) {
|
||||||
|
|
||||||
Toasty.success(ctx, ctx.getString(R.string.issueStateClosed));
|
Toasty.info(ctx, ctx.getString(R.string.issueStateClosed));
|
||||||
tinyDb.putString("issueState", "closed");
|
tinyDb.putString("issueState", "closed");
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(issueState.equals("open")) {
|
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");
|
tinyDb.putString("issueState", "open");
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -138,17 +133,17 @@ public class IssueActions {
|
|||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
Toasty.success(ctx, ctx.getString(R.string.subscribedSuccessfully));
|
Toasty.info(ctx, ctx.getString(R.string.subscribedSuccessfully));
|
||||||
tinyDB.putBoolean("issueSubscribed", true);
|
tinyDB.putBoolean("issueSubscribed", true);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 200) {
|
else if(response.code() == 200) {
|
||||||
|
|
||||||
tinyDB.putBoolean("issueSubscribed", true);
|
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 {
|
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
|
@Override
|
||||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
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) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
Toasty.success(ctx, ctx.getString(R.string.unsubscribedSuccessfully));
|
Toasty.info(ctx, ctx.getString(R.string.unsubscribedSuccessfully));
|
||||||
tinyDB.putBoolean("issueSubscribed", false);
|
tinyDB.putBoolean("issueSubscribed", false);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 200) {
|
else if(response.code() == 200) {
|
||||||
|
|
||||||
tinyDB.putBoolean("issueSubscribed", false);
|
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 {
|
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
|
@Override
|
||||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
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()) {
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
Toasty.success(ctx, ctx.getString(R.string.milestoneStatusUpdate));
|
Toasty.info(ctx, ctx.getString(R.string.milestoneStatusUpdate));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
@ -61,7 +61,7 @@ public class MilestoneActions {
|
|||||||
}
|
}
|
||||||
else {
|
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()) {
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
Toasty.success(ctx, ctx.getString(R.string.milestoneStatusUpdate));
|
Toasty.info(ctx, ctx.getString(R.string.milestoneStatusUpdate));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
@ -119,7 +119,7 @@ public class MilestoneActions {
|
|||||||
}
|
}
|
||||||
else {
|
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) {
|
if(response.code() == 204) {
|
||||||
|
|
||||||
tinyDb.putBoolean("repoCreated", true);
|
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) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
if(response.code() == 204) {
|
||||||
|
|
||||||
tinyDb.putBoolean("repoCreated", true);
|
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) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
if(response.code() == 200) {
|
||||||
|
|
||||||
tinyDb.putBoolean("repoCreated", true);
|
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) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
if(response.code() == 204) {
|
||||||
|
|
||||||
tinyDb.putBoolean("repoCreated", true);
|
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) {
|
else if(response.code() == 401) {
|
||||||
@ -253,17 +253,17 @@ public class RepositoryActions {
|
|||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
if(response.code() == 204) {
|
||||||
|
|
||||||
tinyDb.putBoolean("teamActionFlag", true);
|
tinyDb.putBoolean("teamActionFlag", true);
|
||||||
Toasty.success(context, context.getString(R.string.memberRemovedMessage));
|
Toasty.info(context, context.getString(R.string.memberRemovedMessage));
|
||||||
((AddNewTeamMemberActivity)context).finish();
|
((AddNewTeamMemberActivity)context).finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -59,17 +59,17 @@ public class TeamActions {
|
|||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
if(response.code() == 204) {
|
||||||
|
|
||||||
tinyDb.putBoolean("teamActionFlag", true);
|
tinyDb.putBoolean("teamActionFlag", true);
|
||||||
Toasty.success(context, context.getString(R.string.memberAddedMessage));
|
Toasty.info(context, context.getString(R.string.memberAddedMessage));
|
||||||
((AddNewTeamMemberActivity)context).finish();
|
((AddNewTeamMemberActivity)context).finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -125,17 +125,17 @@ public class TeamActions {
|
|||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.error(context, context.getString(R.string.genericError));
|
Toasty.info(context, context.getString(R.string.genericError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,267 +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;
|
|
||||||
|
|
||||||
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.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
|
|
||||||
/**
|
|
||||||
* Author M M Arif
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class AddNewTeamMemberActivity extends BaseActivity {
|
public class AddNewTeamMemberActivity extends BaseActivity {
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
@ -68,7 +64,7 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
|||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
addNewTeamMember = findViewById(R.id.addNewTeamMember);
|
addNewTeamMember = findViewById(R.id.addNewTeamMeber);
|
||||||
mRecyclerView = findViewById(R.id.recyclerViewUserSearch);
|
mRecyclerView = findViewById(R.id.recyclerViewUserSearch);
|
||||||
mProgressBar = findViewById(R.id.progress_bar);
|
mProgressBar = findViewById(R.id.progress_bar);
|
||||||
noData = findViewById(R.id.noData);
|
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);
|
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>() {
|
call.enqueue(new Callback<UserSearch>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -207,17 +207,17 @@ public class AddRemoveAssigneesActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
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) {
|
else if(response2.code() == 401) {
|
||||||
@ -267,17 +267,17 @@ public class AddRemoveAssigneesActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
else if(response2.code() == 403) {
|
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) {
|
else if(response2.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
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) {
|
else if(response.code() == 401) {
|
||||||
@ -278,17 +278,17 @@ public class AddRemoveLabelsActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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;
|
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:
|
default:
|
||||||
setTheme(R.style.AppTheme);
|
setTheme(R.style.AppTheme);
|
||||||
break;
|
break;
|
||||||
|
@ -52,7 +52,6 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
private List<Commits> commitsList;
|
private List<Commits> commitsList;
|
||||||
private CommitsAdapter adapter;
|
private CommitsAdapter adapter;
|
||||||
private ApiInterface api;
|
private ApiInterface api;
|
||||||
private ProgressBar progressLoadMore;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId() {
|
protected int getLayoutResourceId() {
|
||||||
@ -85,7 +84,6 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
noData = findViewById(R.id.noDataCommits);
|
noData = findViewById(R.id.noDataCommits);
|
||||||
progressLoadMore = findViewById(R.id.progressLoadMore);
|
|
||||||
progressBar = findViewById(R.id.progress_bar);
|
progressBar = findViewById(R.id.progress_bar);
|
||||||
SwipeRefreshLayout swipeRefresh = findViewById(R.id.pullToRefresh);
|
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) {
|
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);
|
Call<List<Commits>> call = api.getRepositoryCommits(token, repoOwner, repoName, page, branchName, resultLimit);
|
||||||
|
|
||||||
@ -189,6 +189,9 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
|
//remove loading view
|
||||||
|
commitsList.remove(commitsList.size() - 1);
|
||||||
|
|
||||||
List<Commits> result = response.body();
|
List<Commits> result = response.body();
|
||||||
|
|
||||||
assert result != null;
|
assert result != null;
|
||||||
@ -205,7 +208,6 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
progressLoadMore.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
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.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.models.Branches;
|
import org.mian.gitnex.models.Branches;
|
||||||
import org.mian.gitnex.models.DeleteFile;
|
|
||||||
import org.mian.gitnex.models.EditFile;
|
|
||||||
import org.mian.gitnex.models.NewFile;
|
import org.mian.gitnex.models.NewFile;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -45,12 +45,8 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
private EditText newFileBranchName;
|
private EditText newFileBranchName;
|
||||||
private EditText newFileCommitMessage;
|
private EditText newFileCommitMessage;
|
||||||
private Spinner newFileBranchesSpinner;
|
private Spinner newFileBranchesSpinner;
|
||||||
private String filePath;
|
|
||||||
private String fileSha;
|
|
||||||
private int fileAction = 0; // 0 = create, 1 = delete, 2 = edit
|
|
||||||
final Context ctx = this;
|
final Context ctx = this;
|
||||||
private Context appCtx;
|
private Context appCtx;
|
||||||
private TinyDB tinyDb;
|
|
||||||
|
|
||||||
List<Branches> branchesList = new ArrayList<>();
|
List<Branches> branchesList = new ArrayList<>();
|
||||||
|
|
||||||
@ -64,12 +60,12 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
appCtx = getApplicationContext();
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
|
TinyDB tinyDb = new TinyDB(appCtx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
@ -85,8 +81,6 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
newFileCommitMessage = findViewById(R.id.newFileCommitMessage);
|
newFileCommitMessage = findViewById(R.id.newFileCommitMessage);
|
||||||
TextView branchNameId = findViewById(R.id.branchNameId);
|
TextView branchNameId = findViewById(R.id.branchNameId);
|
||||||
TextView branchNameHintText = findViewById(R.id.branchNameHintText);
|
TextView branchNameHintText = findViewById(R.id.branchNameHintText);
|
||||||
TextView toolbarTitle = findViewById(R.id.toolbarTitle);
|
|
||||||
TextView fileNameHint = findViewById(R.id.fileNameHint);
|
|
||||||
|
|
||||||
newFileName.requestFocus();
|
newFileName.requestFocus();
|
||||||
assert imm != null;
|
assert imm != null;
|
||||||
@ -97,50 +91,11 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
newFileCreate = findViewById(R.id.newFileCreate);
|
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();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
newFileBranchesSpinner = findViewById(R.id.newFileBranchesSpinner);
|
newFileBranchesSpinner = findViewById(R.id.newFileBranchesSpinner);
|
||||||
|
newFileBranchesSpinner.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
|
||||||
getBranches(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
|
getBranches(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
|
||||||
|
|
||||||
newFileBranchesSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
|
newFileBranchesSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
|
||||||
@ -174,10 +129,15 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
newFileCreate.setEnabled(false);
|
newFileCreate.setEnabled(false);
|
||||||
}
|
GradientDrawable shape = new GradientDrawable();
|
||||||
else {
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
newFileCreate.setBackground(shape);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
newFileCreate.setOnClickListener(createFileListener);
|
newFileCreate.setOnClickListener(createFileListener);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -206,14 +166,14 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newFileName_.equals("") || newFileContent_.equals("") || newFileCommitMessage_.equals("")) {
|
if(newFileName_.equals("") || newFileContent_.equals("") || newFileCommitMessage_.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.newFileRequiredFields));
|
Toasty.info(ctx, getString(R.string.newFileRequiredFields));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -221,13 +181,13 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
if(currentBranch.toString().equals("No branch")) {
|
if(currentBranch.toString().equals("No branch")) {
|
||||||
|
|
||||||
if(newFileBranchName_.equals("")) {
|
if(newFileBranchName_.equals("")) {
|
||||||
Toasty.error(ctx, getString(R.string.newFileRequiredFieldNewBranchName));
|
Toasty.info(ctx, getString(R.string.newFileRequiredFieldNewBranchName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!appUtil.checkStringsWithDash(newFileBranchName_)) {
|
if(!appUtil.checkStringsWithDash(newFileBranchName_)) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.newFileInvalidBranchName));
|
Toasty.info(ctx, getString(R.string.newFileInvalidBranchName));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -237,28 +197,13 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(appUtil.charactersLength(newFileCommitMessage_) > 255) {
|
if(appUtil.charactersLength(newFileCommitMessage_) > 255) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.newFileCommitMessageError));
|
Toasty.info(ctx, getString(R.string.newFileCommitMessageError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
|
createNewFile(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, newFileName_, appUtil.encodeBase64(newFileContent_), newFileBranchName_, newFileCommitMessage_, currentBranch.toString());
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +232,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.success(ctx, getString(R.string.newFileSuccessMessage));
|
Toasty.info(ctx, getString(R.string.newFileSuccessMessage));
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -304,11 +249,11 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(response.code() == 404) {
|
if(response.code() == 404) {
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
Toasty.info(ctx, getString(R.string.apiNotFound));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, getString(R.string.orgCreatedError));
|
Toasty.info(ctx, getString(R.string.orgCreatedError));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -317,7 +262,6 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
}
|
}
|
||||||
@ -325,149 +269,6 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteFile(final String instanceUrl, final String token, String repoOwner, String repoName, String fileName, String fileBranchName, String fileCommitMessage, String currentBranch, String fileSha) {
|
|
||||||
|
|
||||||
String branchName;
|
|
||||||
DeleteFile deleteFileJsonStr;
|
|
||||||
if(currentBranch.equals("No branch")) {
|
|
||||||
|
|
||||||
branchName = fileBranchName;
|
|
||||||
deleteFileJsonStr = new DeleteFile("", fileCommitMessage, fileBranchName, fileSha);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
branchName = currentBranch;
|
|
||||||
deleteFileJsonStr = new DeleteFile(currentBranch, fileCommitMessage, "", fileSha);
|
|
||||||
}
|
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
|
||||||
.getInstance(instanceUrl, ctx)
|
|
||||||
.getApiInterface()
|
|
||||||
.deleteFile(token, repoOwner, repoName, fileName, deleteFileJsonStr);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
|
||||||
|
|
||||||
if(response.code() == 200) {
|
|
||||||
|
|
||||||
enableProcessButton();
|
|
||||||
Toasty.info(ctx, getString(R.string.deleteFileMessage, branchName));
|
|
||||||
getIntent().removeExtra("filePath");
|
|
||||||
getIntent().removeExtra("fileSha");
|
|
||||||
getIntent().removeExtra("fileContents");
|
|
||||||
finish();
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(response.code() == 401) {
|
|
||||||
|
|
||||||
enableProcessButton();
|
|
||||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
if(response.code() == 404) {
|
|
||||||
|
|
||||||
enableProcessButton();
|
|
||||||
Toasty.info(ctx, getString(R.string.apiNotFound));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
enableProcessButton();
|
|
||||||
Toasty.info(ctx, getString(R.string.genericError));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
|
||||||
enableProcessButton();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void editFile(final String instanceUrl, final String token, String repoOwner, String repoName, String fileName, String fileContent, String fileBranchName, String fileCommitMessage, String currentBranch, String fileSha) {
|
|
||||||
|
|
||||||
String branchName;
|
|
||||||
EditFile editFileJsonStr;
|
|
||||||
if(currentBranch.equals("No branch")) {
|
|
||||||
|
|
||||||
branchName = fileBranchName;
|
|
||||||
editFileJsonStr = new EditFile("", fileCommitMessage, fileBranchName, fileSha, fileContent);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
branchName = currentBranch;
|
|
||||||
editFileJsonStr = new EditFile(currentBranch, fileCommitMessage, "", fileSha, fileContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
|
||||||
.getInstance(instanceUrl, ctx)
|
|
||||||
.getApiInterface()
|
|
||||||
.editFile(token, repoOwner, repoName, fileName, editFileJsonStr);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
|
||||||
|
|
||||||
if(response.code() == 200) {
|
|
||||||
|
|
||||||
enableProcessButton();
|
|
||||||
Toasty.info(ctx, getString(R.string.editFileMessage, branchName));
|
|
||||||
getIntent().removeExtra("filePath");
|
|
||||||
getIntent().removeExtra("fileSha");
|
|
||||||
getIntent().removeExtra("fileContents");
|
|
||||||
tinyDb.putBoolean("fileModified", true);
|
|
||||||
finish();
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(response.code() == 401) {
|
|
||||||
|
|
||||||
enableProcessButton();
|
|
||||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
if(response.code() == 404) {
|
|
||||||
|
|
||||||
enableProcessButton();
|
|
||||||
Toasty.info(ctx, getString(R.string.apiNotFound));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
enableProcessButton();
|
|
||||||
Toasty.info(ctx, getString(R.string.genericError));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
|
||||||
enableProcessButton();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getBranches(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
private void getBranches(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
||||||
|
|
||||||
Call<List<Branches>> call = RetrofitClient
|
Call<List<Branches>> call = RetrofitClient
|
||||||
@ -525,11 +326,21 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
private void disableProcessButton() {
|
private void disableProcessButton() {
|
||||||
|
|
||||||
newFileCreate.setEnabled(false);
|
newFileCreate.setEnabled(false);
|
||||||
|
GradientDrawable shape = new GradientDrawable();
|
||||||
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
newFileCreate.setBackground(shape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableProcessButton() {
|
private void enableProcessButton() {
|
||||||
|
|
||||||
newFileCreate.setEnabled(true);
|
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.app.DatePickerDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -125,6 +127,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
newIssueDueDate.setOnClickListener(this);
|
newIssueDueDate.setOnClickListener(this);
|
||||||
|
|
||||||
newIssueMilestoneSpinner = findViewById(R.id.newIssueMilestoneSpinner);
|
newIssueMilestoneSpinner = findViewById(R.id.newIssueMilestoneSpinner);
|
||||||
|
newIssueMilestoneSpinner.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
|
||||||
getMilestones(instanceUrl, instanceToken, repoOwner, repoName, loginUid, resultLimit);
|
getMilestones(instanceUrl, instanceToken, repoOwner, repoName, loginUid, resultLimit);
|
||||||
|
|
||||||
getLabels(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
|
getLabels(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
|
||||||
@ -135,10 +138,15 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
createNewIssueButton.setEnabled(false);
|
createNewIssueButton.setEnabled(false);
|
||||||
}
|
GradientDrawable shape = new GradientDrawable();
|
||||||
else {
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
createNewIssueButton.setBackground(shape);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
createNewIssueButton.setOnClickListener(this);
|
createNewIssueButton.setOnClickListener(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -167,21 +175,21 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newIssueTitleForm.equals("")) {
|
if (newIssueTitleForm.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.issueTitleEmpty));
|
Toasty.info(ctx, getString(R.string.issueTitleEmpty));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (newIssueDescriptionForm.equals("")) {
|
/*if (newIssueDescriptionForm.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.issueDescriptionEmpty));
|
Toasty.info(ctx, getString(R.string.issueDescriptionEmpty));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
@ -291,7 +299,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = new TinyDB(appCtx);
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.issueCreated));
|
Toasty.info(ctx, getString(R.string.issueCreated));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
@ -309,7 +317,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.issueCreatedError));
|
Toasty.info(ctx, getString(R.string.issueCreatedError));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
//Log.i("isSuccessful2", String.valueOf(response2.body()));
|
//Log.i("isSuccessful2", String.valueOf(response2.body()));
|
||||||
|
|
||||||
@ -327,8 +335,12 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
onClickListener = new View.OnClickListener() {
|
||||||
onClickListener = view -> finish();
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getMilestones(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid, int resultLimit) {
|
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");
|
multiSelectDialog.show(getSupportFragmentManager(), "multiSelectDialog");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Toasty.warning(ctx, getResources().getString(R.string.noAssigneesFound));
|
Toasty.info(ctx, getResources().getString(R.string.noAssigneesFound));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (v == newIssueLabels) {
|
else if (v == newIssueLabels) {
|
||||||
@ -537,7 +549,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
multiSelectDialogLabels.show(getSupportFragmentManager(), "multiSelectDialogLabels");
|
multiSelectDialogLabels.show(getSupportFragmentManager(), "multiSelectDialogLabels");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Toasty.warning(ctx, getResources().getString(R.string.noLabelsFound));
|
Toasty.info(ctx, getResources().getString(R.string.noLabelsFound));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (v == newIssueDueDate) {
|
else if (v == newIssueDueDate) {
|
||||||
@ -569,10 +581,20 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
private void disableProcessButton() {
|
private void disableProcessButton() {
|
||||||
|
|
||||||
createNewIssueButton.setEnabled(false);
|
createNewIssueButton.setEnabled(false);
|
||||||
|
GradientDrawable shape = new GradientDrawable();
|
||||||
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
createNewIssueButton.setBackground(shape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableProcessButton() {
|
private void enableProcessButton() {
|
||||||
|
|
||||||
createNewIssueButton.setEnabled(true);
|
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.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -117,23 +118,38 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
createLabelButton.setText(getResources().getString(R.string.newUpdateButtonCopy));
|
createLabelButton.setText(getResources().getString(R.string.newUpdateButtonCopy));
|
||||||
|
|
||||||
createLabelButton.setOnClickListener(updateLabelListener);
|
createLabelButton.setOnClickListener(updateLabelListener);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
createLabelButton.setEnabled(false);
|
createLabelButton.setEnabled(false);
|
||||||
}
|
GradientDrawable shape = new GradientDrawable();
|
||||||
else {
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
createLabelButton.setBackground(shape);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
createLabelButton.setOnClickListener(createLabelListener);
|
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() {
|
private void processUpdateLabel() {
|
||||||
|
|
||||||
@ -160,28 +176,27 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(updateLabelName.equals("")) {
|
if(updateLabelName.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.labelEmptyError));
|
Toasty.info(ctx, getString(R.string.labelEmptyError));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!appUtil.checkStrings(updateLabelName)) {
|
if(!appUtil.checkStrings(updateLabelName)) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.labelNameError));
|
Toasty.info(ctx, getString(R.string.labelNameError));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
patchLabel(instanceUrl, instanceToken, repoOwner, repoName, updateLabelName, updateLabelColor, Integer.parseInt(
|
patchLabel(instanceUrl, instanceToken, repoOwner, repoName, updateLabelName, updateLabelColor, Integer.valueOf(getIntent().getStringExtra("labelId")), loginUid);
|
||||||
Objects.requireNonNull(getIntent().getStringExtra("labelId"))), loginUid);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,21 +224,21 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newLabelName.equals("")) {
|
if(newLabelName.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.labelEmptyError));
|
Toasty.info(ctx, getString(R.string.labelEmptyError));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!appUtil.checkStrings(newLabelName)) {
|
if(!appUtil.checkStrings(newLabelName)) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.labelNameError));
|
Toasty.info(ctx, getString(R.string.labelNameError));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -252,7 +267,7 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.labelCreated));
|
Toasty.info(ctx, getString(R.string.labelCreated));
|
||||||
tinyDb.putString("labelColor", "");
|
tinyDb.putString("labelColor", "");
|
||||||
tinyDb.putBoolean("labelsRefresh", true);
|
tinyDb.putBoolean("labelsRefresh", true);
|
||||||
finish();
|
finish();
|
||||||
@ -271,7 +286,7 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
tinyDb.putString("labelColor", "");
|
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
|
@Override
|
||||||
public void onFailure(@NonNull Call<CreateLabel> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<CreateLabel> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
tinyDb.putString("labelColor", "");
|
tinyDb.putString("labelColor", "");
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
@ -308,7 +322,7 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
if(response.code() == 200) {
|
if(response.code() == 200) {
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.labelUpdated));
|
Toasty.info(ctx, getString(R.string.labelUpdated));
|
||||||
tinyDb.putString("labelColor", "");
|
tinyDb.putString("labelColor", "");
|
||||||
tinyDb.putBoolean("labelsRefresh", true);
|
tinyDb.putBoolean("labelsRefresh", true);
|
||||||
tinyDb.putString("labelColorDefault", "");
|
tinyDb.putString("labelColorDefault", "");
|
||||||
@ -334,7 +348,7 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
tinyDb.putString("labelColor", "");
|
tinyDb.putString("labelColor", "");
|
||||||
tinyDb.putString("labelColorDefault", "");
|
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
|
@Override
|
||||||
public void onFailure(@NonNull Call<CreateLabel> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<CreateLabel> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
tinyDb.putString("labelColor", "");
|
tinyDb.putString("labelColor", "");
|
||||||
tinyDb.putString("labelColorDefault", "");
|
tinyDb.putString("labelColorDefault", "");
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
@ -382,7 +395,7 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
if(response.code() == 204) {
|
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);
|
LabelsViewModel.loadLabelsList(instanceUrl, instanceToken, repoOwner, repoName, ctx);
|
||||||
getIntent().removeExtra("labelAction");
|
getIntent().removeExtra("labelAction");
|
||||||
getIntent().removeExtra("labelId");
|
getIntent().removeExtra("labelId");
|
||||||
@ -399,7 +412,7 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
else {
|
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() {
|
private void disableProcessButton() {
|
||||||
|
|
||||||
createLabelButton.setEnabled(false);
|
createLabelButton.setEnabled(false);
|
||||||
|
GradientDrawable shape = new GradientDrawable();
|
||||||
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
createLabelButton.setBackground(shape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableProcessButton() {
|
private void enableProcessButton() {
|
||||||
|
|
||||||
createLabelButton.setEnabled(true);
|
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.app.DatePickerDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -70,15 +71,24 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
createNewMilestoneButton.setEnabled(false);
|
createNewMilestoneButton.setEnabled(false);
|
||||||
}
|
GradientDrawable shape = new GradientDrawable();
|
||||||
else {
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
createNewMilestoneButton.setBackground(shape);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
createNewMilestoneButton.setOnClickListener(createMilestoneListener);
|
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() {
|
private void processNewMilestone() {
|
||||||
|
|
||||||
@ -100,14 +110,14 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newMilestoneTitle.equals("")) {
|
if(newMilestoneTitle.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.milestoneNameErrorEmpty));
|
Toasty.info(ctx, getString(R.string.milestoneNameErrorEmpty));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -115,7 +125,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
if(!newMilestoneDescription.equals("")) {
|
if(!newMilestoneDescription.equals("")) {
|
||||||
if (appUtil.charactersLength(newMilestoneDescription) > 255) {
|
if (appUtil.charactersLength(newMilestoneDescription) > 255) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.milestoneDescError));
|
Toasty.info(ctx, getString(R.string.milestoneDescError));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -123,13 +133,10 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
|
|
||||||
String finalMilestoneDueDate = null;
|
String finalMilestoneDueDate = null;
|
||||||
if(!newMilestoneDueDate.isEmpty()) {
|
if(!newMilestoneDueDate.isEmpty()) {
|
||||||
|
|
||||||
finalMilestoneDueDate = (AppUtil.customDateCombine(AppUtil.customDateFormat(newMilestoneDueDate)));
|
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
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +166,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = new TinyDB(appCtx);
|
||||||
tinyDb.putBoolean("milestoneCreated", true);
|
tinyDb.putBoolean("milestoneCreated", true);
|
||||||
Toasty.success(ctx, getString(R.string.milestoneCreated));
|
Toasty.info(ctx, getString(R.string.milestoneCreated));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
@ -177,7 +184,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
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() {
|
private void initCloseListener() {
|
||||||
|
onClickListener = new View.OnClickListener() {
|
||||||
onClickListener = view -> finish();
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableProcessButton() {
|
private void disableProcessButton() {
|
||||||
|
|
||||||
createNewMilestoneButton.setEnabled(false);
|
createNewMilestoneButton.setEnabled(false);
|
||||||
|
GradientDrawable shape = new GradientDrawable();
|
||||||
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
createNewMilestoneButton.setBackground(shape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableProcessButton() {
|
private void enableProcessButton() {
|
||||||
|
|
||||||
createNewMilestoneButton.setEnabled(true);
|
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;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Patterns;
|
import android.util.Patterns;
|
||||||
@ -68,10 +69,11 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
}
|
|
||||||
else {
|
} else {
|
||||||
|
|
||||||
createUserButton.setOnClickListener(createNewUserListener);
|
createUserButton.setOnClickListener(createNewUserListener);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -92,35 +94,35 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newFullName.equals("") || newUserName.equals("") | newUserEmail.equals("") || newUserPassword.equals("")) {
|
if(newFullName.equals("") || newUserName.equals("") | newUserEmail.equals("") || newUserPassword.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.emptyFields));
|
Toasty.info(ctx, getString(R.string.emptyFields));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!appUtil.checkStrings(newFullName)) {
|
if(!appUtil.checkStrings(newFullName)) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.userInvalidFullName));
|
Toasty.info(ctx, getString(R.string.userInvalidFullName));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!appUtil.checkStringsWithAlphaNumeric(newUserName)) {
|
if(!appUtil.checkStringsWithAlphaNumeric(newUserName)) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.userInvalidUserName));
|
Toasty.info(ctx, getString(R.string.userInvalidUserName));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
|
if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.userInvalidEmail));
|
Toasty.info(ctx, getString(R.string.userInvalidEmail));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -148,7 +150,7 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.userCreatedText));
|
Toasty.info(ctx, getString(R.string.userCreatedText));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
@ -165,25 +167,25 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||||||
else if(response.code() == 403) {
|
else if(response.code() == 403) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 404) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 422) {
|
else if(response.code() == 422) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.userExistsError));
|
Toasty.info(ctx, ctx.getString(R.string.userExistsError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
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
|
@Override
|
||||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
enableProcessButton();
|
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() {
|
private void initCloseListener() {
|
||||||
|
onClickListener = new View.OnClickListener() {
|
||||||
onClickListener = view -> finish();
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableProcessButton() {
|
private void disableProcessButton() {
|
||||||
|
|
||||||
createUserButton.setEnabled(false);
|
createUserButton.setEnabled(false);
|
||||||
|
GradientDrawable shape = new GradientDrawable();
|
||||||
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
createUserButton.setBackground(shape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableProcessButton() {
|
private void enableProcessButton() {
|
||||||
|
|
||||||
createUserButton.setEnabled(true);
|
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;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -66,10 +67,15 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
createOrganizationButton.setEnabled(false);
|
createOrganizationButton.setEnabled(false);
|
||||||
}
|
GradientDrawable shape = new GradientDrawable();
|
||||||
else {
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
createOrganizationButton.setBackground(shape);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
createOrganizationButton.setOnClickListener(createOrgListener);
|
createOrganizationButton.setOnClickListener(createOrgListener);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -103,7 +109,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -111,7 +117,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
if(!newOrgDesc.equals("")) {
|
if(!newOrgDesc.equals("")) {
|
||||||
if (appUtil.charactersLength(newOrgDesc) > 255) {
|
if (appUtil.charactersLength(newOrgDesc) > 255) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.orgDescError));
|
Toasty.info(ctx, getString(R.string.orgDescError));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -119,12 +125,12 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(newOrgName.equals("")) {
|
if(newOrgName.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.orgNameErrorEmpty));
|
Toasty.info(ctx, getString(R.string.orgNameErrorEmpty));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(!appUtil.checkStrings(newOrgName)) {
|
else if(!appUtil.checkStrings(newOrgName)) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.orgNameErrorInvalid));
|
Toasty.info(ctx, getString(R.string.orgNameErrorInvalid));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -155,7 +161,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = new TinyDB(appCtx);
|
||||||
tinyDb.putBoolean("orgCreated", true);
|
tinyDb.putBoolean("orgCreated", true);
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.success(ctx, getString(R.string.orgCreated));
|
Toasty.info(ctx, getString(R.string.orgCreated));
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -171,24 +177,24 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
else if(response.code() == 409) {
|
else if(response.code() == 409) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, getString(R.string.orgExistsError));
|
Toasty.info(ctx, getString(R.string.orgExistsError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 422) {
|
else if(response.code() == 422) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, getString(R.string.orgExistsError));
|
Toasty.info(ctx, getString(R.string.orgExistsError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
if(response.code() == 404) {
|
if(response.code() == 404) {
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
Toasty.info(ctx, getString(R.string.apiNotFound));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
enableProcessButton();
|
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() {
|
private void disableProcessButton() {
|
||||||
|
|
||||||
createOrganizationButton.setEnabled(false);
|
createOrganizationButton.setEnabled(false);
|
||||||
|
GradientDrawable shape = new GradientDrawable();
|
||||||
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
createOrganizationButton.setBackground(shape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableProcessButton() {
|
private void enableProcessButton() {
|
||||||
|
|
||||||
createOrganizationButton.setEnabled(true);
|
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;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -86,6 +88,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
releaseBranch = findViewById(R.id.releaseBranch);
|
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);
|
getBranches(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
||||||
releaseBranch.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
releaseBranch.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -105,15 +108,20 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
}
|
|
||||||
else {
|
} else {
|
||||||
|
|
||||||
createNewRelease.setOnClickListener(createReleaseListener);
|
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() {
|
private void processNewRelease() {
|
||||||
|
|
||||||
@ -137,21 +145,21 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newReleaseTagName.equals("")) {
|
if(newReleaseTagName.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.tagNameErrorEmpty));
|
Toasty.info(ctx, getString(R.string.tagNameErrorEmpty));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newReleaseTitle.equals("")) {
|
if(newReleaseTitle.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.titleErrorEmpty));
|
Toasty.info(ctx, getString(R.string.titleErrorEmpty));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -181,7 +189,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = new TinyDB(appCtx);
|
||||||
tinyDb.putBoolean("updateReleases", true);
|
tinyDb.putBoolean("updateReleases", true);
|
||||||
Toasty.success(ctx, getString(R.string.releaseCreatedText));
|
Toasty.info(ctx, getString(R.string.releaseCreatedText));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
@ -198,19 +206,19 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
else if(response.code() == 403) {
|
else if(response.code() == 403) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 404) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
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() {
|
private void disableProcessButton() {
|
||||||
|
|
||||||
createNewRelease.setEnabled(false);
|
createNewRelease.setEnabled(false);
|
||||||
|
GradientDrawable shape = new GradientDrawable();
|
||||||
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
createNewRelease.setBackground(shape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableProcessButton() {
|
private void enableProcessButton() {
|
||||||
|
|
||||||
createNewRelease.setEnabled(true);
|
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;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -85,8 +87,8 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
spinner = findViewById(R.id.ownerSpinner);
|
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);
|
getOrganizations(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), userLogin);
|
||||||
|
|
||||||
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
@ -105,10 +107,12 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
createRepo.setOnClickListener(createRepoListener);
|
createRepo.setOnClickListener(createRepoListener);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,38 +138,45 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!newRepoDesc.equals("")) {
|
if(!newRepoDesc.equals("")) {
|
||||||
if (appUtil.charactersLength(newRepoDesc) > 255) {
|
if (appUtil.charactersLength(newRepoDesc) > 255) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.repoDescError));
|
Toasty.info(ctx, getString(R.string.repoDescError));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newRepoName.equals("")) {
|
if(newRepoName.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.repoNameErrorEmpty));
|
Toasty.info(ctx, getString(R.string.repoNameErrorEmpty));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(!appUtil.checkStrings(newRepoName)) {
|
else if(!appUtil.checkStrings(newRepoName)) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.repoNameErrorInvalid));
|
Toasty.info(ctx, getString(R.string.repoNameErrorInvalid));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (reservedRepoNames.contains(newRepoName)) {
|
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()) {
|
else if (reservedRepoPatterns.matcher(newRepoName).find()) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.repoNameErrorReservedPatterns));
|
Toasty.info(ctx, getString(R.string.repoNameErrorReservedPatterns));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
createNewRepository(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), loginUid, newRepoName, newRepoDesc, repoOwner, newRepoAccess);
|
createNewRepository(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), loginUid, newRepoName, newRepoDesc, repoOwner, newRepoAccess);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,6 +191,7 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
.getInstance(instanceUrl, ctx)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.createNewUserRepository(token, createRepository);
|
.createNewUserRepository(token, createRepository);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -187,6 +199,7 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
.getInstance(instanceUrl, ctx)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.createNewUserOrgRepository(token, repoOwner, createRepository);
|
.createNewUserOrgRepository(token, repoOwner, createRepository);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
call.enqueue(new Callback<OrganizationRepository>() {
|
call.enqueue(new Callback<OrganizationRepository>() {
|
||||||
@ -198,7 +211,7 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = new TinyDB(appCtx);
|
||||||
tinyDb.putBoolean("repoCreated", true);
|
tinyDb.putBoolean("repoCreated", true);
|
||||||
Toasty.success(ctx, getString(R.string.repoCreated));
|
Toasty.info(ctx, getString(R.string.repoCreated));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@ -209,23 +222,25 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 409) {
|
else if(response.code() == 409) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, getString(R.string.repoExistsError));
|
Toasty.info(ctx, getString(R.string.repoExistsError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, getString(R.string.repoCreatedError));
|
Toasty.info(ctx, getString(R.string.repoCreatedError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<OrganizationRepository> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<OrganizationRepository> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
}
|
}
|
||||||
@ -256,16 +271,13 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
organizationsList.add(new OrgOwner(userLogin));
|
organizationsList.add(new OrgOwner(userLogin));
|
||||||
assert organizationsList_ != null;
|
assert organizationsList_ != null;
|
||||||
if(organizationsList_.size() > 0) {
|
if(organizationsList_.size() > 0) {
|
||||||
|
|
||||||
for (int i = 0; i < organizationsList_.size(); i++) {
|
for (int i = 0; i < organizationsList_.size(); i++) {
|
||||||
|
|
||||||
if(!tinyDb.getString("organizationId").isEmpty()) {
|
if(!tinyDb.getString("organizationId").isEmpty()) {
|
||||||
|
|
||||||
if (Integer.parseInt(tinyDb.getString("organizationId")) == organizationsList_.get(i).getId()) {
|
if (Integer.parseInt(tinyDb.getString("organizationId")) == organizationsList_.get(i).getId()) {
|
||||||
organizationId = i + 1;
|
organizationId = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OrgOwner data = new OrgOwner(
|
OrgOwner data = new OrgOwner(
|
||||||
organizationsList_.get(i).getUsername()
|
organizationsList_.get(i).getUsername()
|
||||||
);
|
);
|
||||||
@ -281,7 +293,6 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
spinner.setAdapter(adapter);
|
spinner.setAdapter(adapter);
|
||||||
|
|
||||||
if (tinyDb.getBoolean("organizationAction") & organizationId != 0) {
|
if (tinyDb.getBoolean("organizationAction") & organizationId != 0) {
|
||||||
|
|
||||||
spinner.setSelection(organizationId);
|
spinner.setSelection(organizationId);
|
||||||
tinyDb.putBoolean("organizationAction", false);
|
tinyDb.putBoolean("organizationAction", false);
|
||||||
}
|
}
|
||||||
@ -297,13 +308,13 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<List<OrgOwner>> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<List<OrgOwner>> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
}
|
}
|
||||||
@ -311,18 +322,32 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
onClickListener = new View.OnClickListener() {
|
||||||
onClickListener = view -> finish();
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableProcessButton() {
|
private void disableProcessButton() {
|
||||||
|
|
||||||
createRepo.setEnabled(false);
|
createRepo.setEnabled(false);
|
||||||
|
GradientDrawable shape = new GradientDrawable();
|
||||||
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
createRepo.setBackground(shape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableProcessButton() {
|
private void enableProcessButton() {
|
||||||
|
|
||||||
createRepo.setEnabled(true);
|
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;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.graphics.drawable.GradientDrawable;
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -97,120 +98,134 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
teamPermission.setOnClickListener(view -> {
|
teamPermission.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
AlertDialog.Builder pBuilder = new AlertDialog.Builder(ctx);
|
AlertDialog.Builder pBuilder = new AlertDialog.Builder(ctx);
|
||||||
|
|
||||||
|
pBuilder.setTitle(R.string.newTeamPermission);
|
||||||
|
if(permissionSelectedChoice != -1) {
|
||||||
|
pBuilder.setCancelable(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pBuilder.setCancelable(false);
|
||||||
|
}
|
||||||
|
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
|
||||||
|
permissionSelectedChoice = i;
|
||||||
|
teamPermission.setText(permissionList[i]);
|
||||||
|
|
||||||
|
if(permissionList[i].equals("Read")) {
|
||||||
|
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||||
|
teamPermissionDetail.setText(R.string.newTeamPermissionRead);
|
||||||
|
}
|
||||||
|
else if(permissionList[i].equals("Write")) {
|
||||||
|
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||||
|
teamPermissionDetail.setText(R.string.newTeamPermissionWrite);
|
||||||
|
}
|
||||||
|
else if(permissionList[i].equals("Admin")) {
|
||||||
|
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||||
|
teamPermissionDetail.setText(R.string.newTeamPermissionAdmin);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
teamPermissionDetail.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dialogInterface.dismiss();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AlertDialog pDialog = pBuilder.create();
|
||||||
|
pDialog.show();
|
||||||
|
|
||||||
pBuilder.setTitle(R.string.newTeamPermission);
|
|
||||||
if(permissionSelectedChoice != -1) {
|
|
||||||
pBuilder.setCancelable(true);
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
pBuilder.setCancelable(false);
|
|
||||||
}
|
|
||||||
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, (dialogInterface, i) -> {
|
|
||||||
|
|
||||||
permissionSelectedChoice = i;
|
|
||||||
teamPermission.setText(permissionList[i]);
|
|
||||||
|
|
||||||
switch(permissionList[i]) {
|
|
||||||
case "Read":
|
|
||||||
|
|
||||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
|
||||||
teamPermissionDetail.setText(R.string.newTeamPermissionRead);
|
|
||||||
break;
|
|
||||||
case "Write":
|
|
||||||
|
|
||||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
|
||||||
teamPermissionDetail.setText(R.string.newTeamPermissionWrite);
|
|
||||||
break;
|
|
||||||
case "Admin":
|
|
||||||
|
|
||||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
|
||||||
teamPermissionDetail.setText(R.string.newTeamPermissionAdmin);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
|
|
||||||
teamPermissionDetail.setVisibility(View.GONE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dialogInterface.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
AlertDialog pDialog = pBuilder.create();
|
|
||||||
pDialog.show();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
teamAccessControls.setOnClickListener(v -> {
|
teamAccessControls.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
teamAccessControls.setText("");
|
teamAccessControls.setText("");
|
||||||
teamAccessControlsArray.setText("");
|
teamAccessControlsArray.setText("");
|
||||||
pushAccessList = Arrays.asList(accessControlsList);
|
pushAccessList = Arrays.asList(accessControlsList);
|
||||||
|
|
||||||
AlertDialog.Builder aDialogBuilder = new AlertDialog.Builder(ctx);
|
AlertDialog.Builder aDialogBuilder = new AlertDialog.Builder(ctx);
|
||||||
|
|
||||||
aDialogBuilder.setMultiChoiceItems(accessControlsList, selectedAccessControlsTrueFalse, (dialog, which, isChecked) -> {
|
aDialogBuilder.setMultiChoiceItems(accessControlsList, selectedAccessControlsTrueFalse, new DialogInterface.OnMultiChoiceClickListener() {
|
||||||
|
|
||||||
})
|
@Override
|
||||||
.setCancelable(false)
|
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||||
.setTitle(R.string.newTeamAccessControls)
|
|
||||||
.setPositiveButton(R.string.okButton, (dialog, which) -> {
|
|
||||||
|
|
||||||
int selectedVal = 0;
|
|
||||||
while(selectedVal < selectedAccessControlsTrueFalse.length)
|
|
||||||
{
|
|
||||||
boolean value = selectedAccessControlsTrueFalse[selectedVal];
|
|
||||||
|
|
||||||
String repoCode = "";
|
|
||||||
if(selectedVal == 0) {
|
|
||||||
repoCode = "repo.code";
|
|
||||||
}
|
|
||||||
if(selectedVal == 1) {
|
|
||||||
repoCode = "repo.issues";
|
|
||||||
}
|
|
||||||
if(selectedVal == 2) {
|
|
||||||
repoCode = "repo.pulls";
|
|
||||||
}
|
|
||||||
if(selectedVal == 3) {
|
|
||||||
repoCode = "repo.releases";
|
|
||||||
}
|
|
||||||
if(selectedVal == 4) {
|
|
||||||
repoCode = "repo.wiki";
|
|
||||||
}
|
|
||||||
if(selectedVal == 5) {
|
|
||||||
repoCode = "repo.ext_wiki";
|
|
||||||
}
|
|
||||||
if(selectedVal == 6) {
|
|
||||||
repoCode = "repo.ext_issues";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(value){
|
})
|
||||||
teamAccessControls.setText(getString(R.string.newTeamPermissionValues, teamAccessControls.getText(), pushAccessList.get(selectedVal)));
|
.setCancelable(false)
|
||||||
teamAccessControlsArray.setText(getString(R.string.newTeamPermissionValuesFinal, teamAccessControlsArray.getText(), repoCode));
|
.setTitle(R.string.newTeamAccessControls)
|
||||||
|
.setPositiveButton(R.string.okButton, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|
||||||
|
int selectedVal = 0;
|
||||||
|
while(selectedVal < selectedAccessControlsTrueFalse.length)
|
||||||
|
{
|
||||||
|
boolean value = selectedAccessControlsTrueFalse[selectedVal];
|
||||||
|
|
||||||
|
String repoCode = "";
|
||||||
|
if(selectedVal == 0) {
|
||||||
|
repoCode = "repo.code";
|
||||||
|
}
|
||||||
|
if(selectedVal == 1) {
|
||||||
|
repoCode = "repo.issues";
|
||||||
|
}
|
||||||
|
if(selectedVal == 2) {
|
||||||
|
repoCode = "repo.pulls";
|
||||||
|
}
|
||||||
|
if(selectedVal == 3) {
|
||||||
|
repoCode = "repo.releases";
|
||||||
|
}
|
||||||
|
if(selectedVal == 4) {
|
||||||
|
repoCode = "repo.wiki";
|
||||||
|
}
|
||||||
|
if(selectedVal == 5) {
|
||||||
|
repoCode = "repo.ext_wiki";
|
||||||
|
}
|
||||||
|
if(selectedVal == 6) {
|
||||||
|
repoCode = "repo.ext_issues";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(value){
|
||||||
|
teamAccessControls.setText(getString(R.string.newTeamPermissionValues, teamAccessControls.getText(), pushAccessList.get(selectedVal)));
|
||||||
|
teamAccessControlsArray.setText(getString(R.string.newTeamPermissionValuesFinal, teamAccessControlsArray.getText(), repoCode));
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedVal++;
|
||||||
|
}
|
||||||
|
|
||||||
|
String data = String.valueOf(teamAccessControls.getText());
|
||||||
|
if(!data.equals("")) {
|
||||||
|
teamAccessControls.setText(data.substring(0, data.length() - 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
String dataArray = String.valueOf(teamAccessControlsArray.getText());
|
||||||
|
if(!dataArray.equals("")) {
|
||||||
|
teamAccessControlsArray.setText(dataArray.substring(0, dataArray.length() - 2));
|
||||||
|
}
|
||||||
|
//Log.i("orgName", String.valueOf(teamAccessControlsArray.getText()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedVal++;
|
|
||||||
}
|
|
||||||
|
|
||||||
String data = String.valueOf(teamAccessControls.getText());
|
});
|
||||||
if(!data.equals("")) {
|
|
||||||
teamAccessControls.setText(data.substring(0, data.length() - 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
String dataArray = String.valueOf(teamAccessControlsArray.getText());
|
AlertDialog aDialog = aDialogBuilder.create();
|
||||||
if(!dataArray.equals("")) {
|
aDialog.show();
|
||||||
teamAccessControlsArray.setText(dataArray.substring(0, dataArray.length() - 2));
|
}
|
||||||
}
|
|
||||||
//Log.i("orgName", String.valueOf(teamAccessControlsArray.getText()));
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
AlertDialog aDialog = aDialogBuilder.create();
|
|
||||||
aDialog.show();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
createTeamButton.setEnabled(false);
|
createTeamButton.setEnabled(false);
|
||||||
@ -249,21 +264,21 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newTeamName.equals("")) {
|
if (newTeamName.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.teamNameEmpty));
|
Toasty.info(ctx, getString(R.string.teamNameEmpty));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!appUtil.checkStringsWithAlphaNumericDashDotUnderscore(newTeamName)) {
|
if(!appUtil.checkStringsWithAlphaNumericDashDotUnderscore(newTeamName)) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.teamNameError));
|
Toasty.info(ctx, getString(R.string.teamNameError));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -271,12 +286,12 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
if(!newTeamDesc.equals("")) {
|
if(!newTeamDesc.equals("")) {
|
||||||
|
|
||||||
if(!appUtil.checkStrings(newTeamDesc)) {
|
if(!appUtil.checkStrings(newTeamDesc)) {
|
||||||
Toasty.warning(ctx, getString(R.string.teamDescError));
|
Toasty.info(ctx, getString(R.string.teamDescError));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newTeamDesc.length() > 100) {
|
if(newTeamDesc.length() > 100) {
|
||||||
Toasty.warning(ctx, getString(R.string.teamDescLimit));
|
Toasty.info(ctx, getString(R.string.teamDescLimit));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +299,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
|
|
||||||
if (newTeamPermission.equals("")) {
|
if (newTeamPermission.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.teamPermissionEmpty));
|
Toasty.info(ctx, getString(R.string.teamPermissionEmpty));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -321,14 +336,16 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = new TinyDB(appCtx);
|
||||||
tinyDb.putBoolean("resumeTeams", true);
|
tinyDb.putBoolean("resumeTeams", true);
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.teamCreated));
|
Toasty.info(ctx, getString(R.string.teamCreated));
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response2.code() == 404) {
|
else if(response2.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
Toasty.info(ctx, getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response2.code() == 401) {
|
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.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.teamCreatedError));
|
Toasty.info(ctx, getString(R.string.teamCreatedError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -354,15 +373,19 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
if(v == createTeamButton) {
|
if(v == createTeamButton) {
|
||||||
processCreateTeam();
|
processCreateTeam();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
onClickListener = new View.OnClickListener() {
|
||||||
onClickListener = view -> finish();
|
@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.annotation.SuppressLint;
|
||||||
import android.app.DatePickerDialog;
|
import android.app.DatePickerDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -107,6 +109,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
loadCollaboratorsList();
|
loadCollaboratorsList();
|
||||||
|
|
||||||
editIssueMilestoneSpinner = findViewById(R.id.editIssueMilestoneSpinner);
|
editIssueMilestoneSpinner = findViewById(R.id.editIssueMilestoneSpinner);
|
||||||
|
editIssueMilestoneSpinner.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
|
||||||
|
|
||||||
editIssueDescription.setMentionAdapter(defaultMentionAdapter);
|
editIssueDescription.setMentionAdapter(defaultMentionAdapter);
|
||||||
|
|
||||||
@ -214,14 +217,14 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editIssueTitleForm.equals("")) {
|
if (editIssueTitleForm.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.issueTitleEmpty));
|
Toasty.info(ctx, getString(R.string.issueTitleEmpty));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -264,10 +267,10 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
if(tinyDb.getString("issueType").equalsIgnoreCase("Pull")) {
|
if(tinyDb.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||||
Toasty.success(ctx, getString(R.string.editPrSuccessMessage));
|
Toasty.info(ctx, getString(R.string.editPrSuccessMessage));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Toasty.success(ctx, getString(R.string.editIssueSuccessMessage));
|
Toasty.info(ctx, getString(R.string.editIssueSuccessMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
tinyDb.putBoolean("issueEdited", true);
|
tinyDb.putBoolean("issueEdited", true);
|
||||||
@ -287,7 +290,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
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");
|
@SuppressLint("SimpleDateFormat") DateFormat formatter = new SimpleDateFormat("yyyy-M-dd");
|
||||||
String dueDate = formatter.format(response.body().getDue_date());
|
String dueDate = formatter.format(response.body().getDue_date());
|
||||||
editIssueDueDate.setText(dueDate);
|
editIssueDueDate.setText(dueDate);
|
||||||
|
|
||||||
}
|
}
|
||||||
//enableProcessButton();
|
//enableProcessButton();
|
||||||
|
|
||||||
@ -434,10 +438,12 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
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() {
|
private void disableProcessButton() {
|
||||||
|
|
||||||
editIssueButton.setEnabled(false);
|
editIssueButton.setEnabled(false);
|
||||||
|
GradientDrawable shape = new GradientDrawable();
|
||||||
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
editIssueButton.setBackground(shape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableProcessButton() {
|
private void enableProcessButton() {
|
||||||
|
|
||||||
editIssueButton.setEnabled(true);
|
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
|
// fallback for old gitea instances
|
||||||
if(new Version(tinyDb.getString("giteaVersion")).less("1.13.0")) {
|
if(new Version(tinyDb.getString("giteaVersion")).less("1.13.0")) {
|
||||||
|
|
||||||
apiCall = false;
|
apiCall = false;
|
||||||
instanceUrl = instanceUrl.substring(0, instanceUrl.lastIndexOf("api/v1/"));
|
instanceUrl = tinyDb.getString("instanceUrlWithProtocol");
|
||||||
}
|
}
|
||||||
|
|
||||||
getPullDiffContent(instanceUrl, repoOwner, repoName, pullIndex, instanceToken, apiCall);
|
getPullDiffContent(instanceUrl, repoOwner, repoName, pullIndex, instanceToken, apiCall);
|
||||||
@ -140,17 +139,17 @@ public class FileDiffActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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() {
|
private void initCloseListener() {
|
||||||
|
|
||||||
onClickListener = view -> {
|
onClickListener = new View.OnClickListener() {
|
||||||
|
|
||||||
getIntent().removeExtra("singleFileName");
|
@Override
|
||||||
finish();
|
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.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Spanned;
|
|
||||||
import android.text.method.ScrollingMovementMethod;
|
import android.text.method.ScrollingMovementMethod;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -43,24 +42,7 @@ import java.io.IOException;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
|
||||||
import io.noties.markwon.Markwon;
|
|
||||||
import io.noties.markwon.core.CorePlugin;
|
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
|
||||||
import io.noties.markwon.ext.tables.TablePlugin;
|
|
||||||
import io.noties.markwon.ext.tasklist.TaskListPlugin;
|
|
||||||
import io.noties.markwon.html.HtmlPlugin;
|
|
||||||
import io.noties.markwon.image.DefaultMediaDecoder;
|
|
||||||
import io.noties.markwon.image.ImageItem;
|
|
||||||
import io.noties.markwon.image.ImagesPlugin;
|
|
||||||
import io.noties.markwon.image.SchemeHandler;
|
|
||||||
import io.noties.markwon.image.gif.GifMediaDecoder;
|
|
||||||
import io.noties.markwon.image.svg.SvgMediaDecoder;
|
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -83,10 +65,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
private LinearLayout pdfViewFrame;
|
private LinearLayout pdfViewFrame;
|
||||||
private byte[] decodedPdf;
|
private byte[] decodedPdf;
|
||||||
private Boolean pdfNightMode;
|
private Boolean pdfNightMode;
|
||||||
private String singleFileName;
|
|
||||||
private String fileSha;
|
|
||||||
private AppUtil appUtil;
|
|
||||||
private TinyDB tinyDb;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId() {
|
protected int getLayoutResourceId() {
|
||||||
@ -99,12 +77,11 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
appCtx = getApplicationContext();
|
||||||
appUtil = new AppUtil();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String repoBranch = tinyDb.getString("repoBranch");
|
String repoBranch = tinyDb.getString("repoBranch");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
@ -114,8 +91,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
tinyDb.putBoolean("enableMarkdownInFileView", false);
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
singleFileContents = findViewById(R.id.singleFileContents);
|
singleFileContents = findViewById(R.id.singleFileContents);
|
||||||
singleCodeContents = findViewById(R.id.singleCodeContents);
|
singleCodeContents = findViewById(R.id.singleCodeContents);
|
||||||
@ -125,7 +100,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
pdfViewFrame = findViewById(R.id.pdfViewFrame);
|
pdfViewFrame = findViewById(R.id.pdfViewFrame);
|
||||||
singleFileContentsFrame = findViewById(R.id.singleFileContentsFrame);
|
singleFileContentsFrame = findViewById(R.id.singleFileContentsFrame);
|
||||||
|
|
||||||
singleFileName = getIntent().getStringExtra("singleFileName");
|
String singleFileName = getIntent().getStringExtra("singleFileName");
|
||||||
|
|
||||||
TextView toolbar_title = findViewById(R.id.toolbar_title);
|
TextView toolbar_title = findViewById(R.id.toolbar_title);
|
||||||
toolbar_title.setMovementMethod(new ScrollingMovementMethod());
|
toolbar_title.setMovementMethod(new ScrollingMovementMethod());
|
||||||
@ -144,6 +119,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
}
|
}
|
||||||
catch(UnsupportedEncodingException e) {
|
catch(UnsupportedEncodingException e) {
|
||||||
|
|
||||||
|
assert singleFileName != null;
|
||||||
Log.i("singleFileName", singleFileName);
|
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) {
|
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<Files> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getSingleFileContents(token, owner, repo, filename, ref);
|
||||||
|
|
||||||
call.enqueue(new Callback<Files>() {
|
call.enqueue(new Callback<Files>() {
|
||||||
@ -186,6 +143,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
|
|
||||||
if(response.code() == 200) {
|
if(response.code() == 200) {
|
||||||
|
|
||||||
|
AppUtil appUtil = new AppUtil();
|
||||||
assert response.body() != null;
|
assert response.body() != null;
|
||||||
|
|
||||||
if(!response.body().getContent().equals("")) {
|
if(!response.body().getContent().equals("")) {
|
||||||
@ -193,8 +151,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
String fileExtension = FileUtils.getExtension(filename);
|
String fileExtension = FileUtils.getExtension(filename);
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mProgressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
fileSha = response.body().getSha();
|
|
||||||
|
|
||||||
// download file meta
|
// download file meta
|
||||||
tinyDb.putString("downloadFileName", filename);
|
tinyDb.putString("downloadFileName", filename);
|
||||||
tinyDb.putString("downloadFileContents", response.body().getContent());
|
tinyDb.putString("downloadFileContents", response.body().getContent());
|
||||||
@ -291,17 +247,17 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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();
|
MenuInflater inflater = getMenuInflater();
|
||||||
inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,82 +287,11 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
|
|
||||||
switch(id) {
|
switch(id) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
case R.id.genericMenu:
|
case R.id.genericMenu:
|
||||||
|
|
||||||
BottomSheetFileViewerFragment bottomSheet = new BottomSheetFileViewerFragment();
|
BottomSheetFileViewerFragment bottomSheet = new BottomSheetFileViewerFragment();
|
||||||
bottomSheet.show(getSupportFragmentManager(), "fileViewerBottomSheet");
|
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;
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
@ -427,48 +305,15 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
if("downloadFile".equals(text)) {
|
if("downloadFile".equals(text)) {
|
||||||
|
|
||||||
requestFileDownload();
|
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() {
|
private void requestFileDownload() {
|
||||||
|
|
||||||
|
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||||
|
|
||||||
if(!tinyDb.getString("downloadFileContents").isEmpty()) {
|
if(!tinyDb.getString("downloadFileContents").isEmpty()) {
|
||||||
|
|
||||||
int CREATE_REQUEST_CODE = 40;
|
int CREATE_REQUEST_CODE = 40;
|
||||||
@ -485,8 +330,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Toasty.error(ctx, getString(R.string.waitLoadingDownloadFile));
|
||||||
Toasty.warning(ctx, getString(R.string.waitLoadingDownloadFile));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -496,7 +340,9 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
if(requestCode == 40 && resultCode == RESULT_OK) {
|
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||||
|
|
||||||
|
if (requestCode == 40 && resultCode == RESULT_OK) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -512,11 +358,10 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
outputStream.write(dataAsBytes);
|
outputStream.write(dataAsBytes);
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.downloadFileSaved));
|
Toasty.info(ctx, getString(R.string.downloadFileSaved));
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(IOException e) {
|
catch (IOException e) {
|
||||||
|
|
||||||
Log.e("errorFileDownloading", Objects.requireNonNull(e.getMessage()));
|
Log.e("errorFileDownloading", Objects.requireNonNull(e.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,6 +375,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
|
|
||||||
getIntent().removeExtra("singleFileName");
|
getIntent().removeExtra("singleFileName");
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
import com.amulyakhare.textdrawable.TextDrawable;
|
||||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
|
||||||
import com.vdurmont.emoji.EmojiParser;
|
import com.vdurmont.emoji.EmojiParser;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.adapters.IssueCommentsAdapter;
|
import org.mian.gitnex.adapters.IssueCommentsAdapter;
|
||||||
@ -97,7 +96,7 @@ public class IssueDetailActivity extends BaseActivity {
|
|||||||
private HorizontalScrollView assigneesScrollView;
|
private HorizontalScrollView assigneesScrollView;
|
||||||
private ScrollView scrollViewComments;
|
private ScrollView scrollViewComments;
|
||||||
private TextView issueModified;
|
private TextView issueModified;
|
||||||
private ExtendedFloatingActionButton createNewComment;
|
private ImageView createNewComment;
|
||||||
final Context ctx = this;
|
final Context ctx = this;
|
||||||
private Context appCtx;
|
private Context appCtx;
|
||||||
private LinearLayout labelsLayout;
|
private LinearLayout labelsLayout;
|
||||||
@ -398,7 +397,6 @@ public class IssueDetailActivity extends BaseActivity {
|
|||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
tinyDb.putString("issueState", singleIssue.getState());
|
tinyDb.putString("issueState", singleIssue.getState());
|
||||||
tinyDb.putString("issueTitle", singleIssue.getTitle());
|
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)
|
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);
|
.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.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
@ -12,6 +13,7 @@ import android.widget.Button;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
|
import android.widget.ScrollView;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -20,12 +22,11 @@ import com.tooltip.Tooltip;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
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.AppUtil;
|
||||||
import org.mian.gitnex.helpers.NetworkObserver;
|
import org.mian.gitnex.helpers.NetworkObserver;
|
||||||
import org.mian.gitnex.helpers.PathsHelper;
|
import org.mian.gitnex.helpers.PathsHelper;
|
||||||
|
import org.mian.gitnex.helpers.SnackBar;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
|
||||||
import org.mian.gitnex.helpers.UrlHelper;
|
import org.mian.gitnex.helpers.UrlHelper;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.models.GiteaVersion;
|
import org.mian.gitnex.models.GiteaVersion;
|
||||||
@ -60,6 +61,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
private TextView otpInfo;
|
private TextView otpInfo;
|
||||||
private RadioGroup loginMethod;
|
private RadioGroup loginMethod;
|
||||||
private String device_id = "token";
|
private String device_id = "token";
|
||||||
|
private ScrollView layoutView;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId() {
|
protected int getLayoutResourceId() {
|
||||||
@ -86,6 +88,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
protocolSpinner = findViewById(R.id.httpsSpinner);
|
protocolSpinner = findViewById(R.id.httpsSpinner);
|
||||||
loginMethod = findViewById(R.id.loginMethod);
|
loginMethod = findViewById(R.id.loginMethod);
|
||||||
loginTokenCode = findViewById(R.id.loginTokenCode);
|
loginTokenCode = findViewById(R.id.loginTokenCode);
|
||||||
|
layoutView = findViewById(R.id.loginForm);
|
||||||
|
|
||||||
((TextView) findViewById(R.id.appVersion)).setText(AppUtil.getAppVersion(appCtx));
|
((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) {
|
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||||
|
|
||||||
if(protocolSpinner.getSelectedItem() == Protocol.HTTP) {
|
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(
|
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)
|
.setBackgroundColor(getResources().getColor(R.color.tooltipBackground)).setCancelable(true).setDismissOnClick(true).setPadding(30)
|
||||||
.setCornerRadius(R.dimen.tooltipCornor).setGravity(Gravity.BOTTOM).show());
|
.setCornerRadius(R.dimen.tooltipCornor).setGravity(Gravity.BOTTOM).show());
|
||||||
|
|
||||||
@ -134,12 +137,13 @@ public class LoginActivity extends BaseActivity {
|
|||||||
if(isAvailable) {
|
if(isAvailable) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
SnackBar.success(ctx, layoutView, getResources().getString(R.string.netConnectionIsBack));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
loginButton.setText(getResources().getString(R.string.btnLogin));
|
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("")) {
|
if(instanceUrlET.getText().toString().equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.emptyFieldURL));
|
SnackBar.warning(ctx, layoutView, getResources().getString(R.string.emptyFieldURL));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -190,7 +194,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(otpCode.length() != 0 && otpCode.length() != 6) {
|
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();
|
enableProcessButton();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -205,7 +209,15 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(loginUid.equals("")) {
|
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();
|
enableProcessButton();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -213,7 +225,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(loginPass.equals("")) {
|
if(loginPass.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.emptyFieldPassword));
|
SnackBar.warning(ctx, layoutView, getResources().getString(R.string.emptyFieldPassword));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -229,7 +241,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(loginToken.equals("")) {
|
if(loginToken.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.loginTokenError));
|
SnackBar.warning(ctx, layoutView, getResources().getString(R.string.loginTokenError));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -243,7 +255,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
|
|
||||||
Log.e("onFailure-login", e.toString());
|
Log.e("onFailure-login", e.toString());
|
||||||
Toasty.error(ctx, getResources().getString(R.string.malformedUrl));
|
SnackBar.error(ctx, layoutView, getResources().getString(R.string.malformedUrl));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -285,7 +297,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.versionUnknown));
|
SnackBar.error(ctx, layoutView, getResources().getString(R.string.versionUnknown));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -317,7 +329,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
else {
|
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);
|
login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -346,7 +358,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
public void onFailure(@NonNull Call<GiteaVersion> callVersion, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<GiteaVersion> callVersion, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure-versionCheck", t.toString());
|
Log.e("onFailure-versionCheck", t.toString());
|
||||||
Toasty.error(ctx, getResources().getString(R.string.errorOnLogin));
|
SnackBar.error(ctx, layoutView, getResources().getString(R.string.errorOnLogin));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -376,18 +388,9 @@ public class LoginActivity extends BaseActivity {
|
|||||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
||||||
int checkAccount = userAccountsApi.getCount(accountName);
|
int checkAccount = userAccountsApi.getCount(accountName);
|
||||||
long accountId;
|
|
||||||
|
|
||||||
if(checkAccount == 0) {
|
if(checkAccount == 0) {
|
||||||
|
userAccountsApi.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), loginToken, "");
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
@ -396,12 +399,12 @@ public class LoginActivity extends BaseActivity {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 401:
|
case 401:
|
||||||
Toasty.error(ctx, getResources().getString(R.string.unauthorizedApiError));
|
SnackBar.error(ctx, layoutView, getResources().getString(R.string.unauthorizedApiError));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
SnackBar.error(ctx, layoutView, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -412,7 +415,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
SnackBar.error(ctx, layoutView, getResources().getString(R.string.genericError));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -472,7 +475,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
SnackBar.error(ctx, layoutView, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -482,7 +485,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
public void onFailure(@NonNull Call<Void> delcall, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<Void> delcall, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure-login", t.toString());
|
Log.e("onFailure-login", t.toString());
|
||||||
Toasty.error(ctx, getResources().getString(R.string.malformedJson));
|
SnackBar.error(ctx, layoutView, getResources().getString(R.string.malformedJson));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -495,7 +498,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
SnackBar.error(ctx, layoutView, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -505,7 +508,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
public void onFailure(@NonNull Call<List<UserTokens>> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<List<UserTokens>> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure-login", t.toString());
|
Log.e("onFailure-login", t.toString());
|
||||||
Toasty.error(ctx, getResources().getString(R.string.malformedJson));
|
SnackBar.error(ctx, layoutView, getResources().getString(R.string.malformedJson));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -566,18 +569,10 @@ public class LoginActivity extends BaseActivity {
|
|||||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
||||||
int checkAccount = userAccountsApi.getCount(accountName);
|
int checkAccount = userAccountsApi.getCount(accountName);
|
||||||
long accountId;
|
|
||||||
|
|
||||||
if(checkAccount == 0) {
|
if(checkAccount == 0) {
|
||||||
|
userAccountsApi
|
||||||
accountId = userAccountsApi.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), newToken.getSha1(), "");
|
.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), newToken.getSha1(), "");
|
||||||
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
userAccountsApi.updateTokenByAccountName(accountName, newToken.getSha1());
|
|
||||||
UserAccount data = userAccountsApi.getAccountData(accountName);
|
|
||||||
tinyDB.putInt("currentActiveAccountId", data.getAccountId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||||
@ -585,12 +580,12 @@ public class LoginActivity extends BaseActivity {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 401:
|
case 401:
|
||||||
Toasty.error(ctx, getResources().getString(R.string.unauthorizedApiError));
|
SnackBar.error(ctx, layoutView, getResources().getString(R.string.unauthorizedApiError));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
SnackBar.error(ctx, layoutView, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -601,7 +596,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
SnackBar.error(ctx, layoutView, getResources().getString(R.string.genericError));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -610,7 +605,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
else if(responseCreate.code() == 500) {
|
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();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -659,14 +654,26 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
private void disableProcessButton() {
|
private void disableProcessButton() {
|
||||||
|
|
||||||
|
GradientDrawable shape = new GradientDrawable();
|
||||||
|
shape.setCornerRadius(8);
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
|
||||||
loginButton.setText(R.string.processingText);
|
loginButton.setText(R.string.processingText);
|
||||||
|
loginButton.setBackground(shape);
|
||||||
loginButton.setEnabled(false);
|
loginButton.setEnabled(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableProcessButton() {
|
private void enableProcessButton() {
|
||||||
|
|
||||||
|
GradientDrawable shape = new GradientDrawable();
|
||||||
|
shape.setCornerRadius(8);
|
||||||
|
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||||
|
|
||||||
loginButton.setText(R.string.btnLogin);
|
loginButton.setText(R.string.btnLogin);
|
||||||
|
loginButton.setBackground(shape);
|
||||||
loginButton.setEnabled(true);
|
loginButton.setEnabled(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,16 +18,13 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.core.view.GravityCompat;
|
import androidx.core.view.GravityCompat;
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import com.google.android.material.navigation.NavigationView;
|
import com.google.android.material.navigation.NavigationView;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.adapters.UserAccountsNavAdapter;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
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.helpers.Version;
|
||||||
import org.mian.gitnex.models.GiteaVersion;
|
import org.mian.gitnex.models.GiteaVersion;
|
||||||
import org.mian.gitnex.models.UserInfo;
|
import org.mian.gitnex.models.UserInfo;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import eightbitlab.com.blurview.BlurView;
|
import eightbitlab.com.blurview.BlurView;
|
||||||
import eightbitlab.com.blurview.RenderScriptBlur;
|
import eightbitlab.com.blurview.RenderScriptBlur;
|
||||||
@ -128,9 +123,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getInt("currentActiveAccountId") <= 0) {
|
String accountName = loginUid + "@" + instanceUrl;
|
||||||
AlertDialogs.forceLogoutDialog(ctx, getResources().getString(R.string.forceLogoutDialogHeader), getResources().getString(R.string.forceLogoutDialogDescription), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getAccountData(accountName);
|
||||||
}
|
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||||
@ -204,13 +198,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
@Override
|
@Override
|
||||||
public void onDrawerOpened(@NonNull View drawerView) {
|
public void onDrawerOpened(@NonNull View drawerView) {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
|
|
||||||
|
|
||||||
if(tinyDb.getBoolean("noConnection")) {
|
if(tinyDb.getBoolean("noConnection")) {
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
tinyDb.putBoolean("noConnection", false);
|
tinyDb.putBoolean("noConnection", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,29 +214,14 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
userAvatarBackground = hView.findViewById(R.id.userAvatarBackground);
|
userAvatarBackground = hView.findViewById(R.id.userAvatarBackground);
|
||||||
navHeaderFrame = hView.findViewById(R.id.navHeaderFrame);
|
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);
|
userEmail.setTypeface(myTypeface);
|
||||||
userFullName.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("")) {
|
if(!userEmailNav.equals("")) {
|
||||||
userEmail.setText(userEmailNav);
|
userEmail.setText(userEmailNav);
|
||||||
}
|
}
|
||||||
@ -298,12 +272,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
drawer.closeDrawers();
|
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
|
@Override
|
||||||
public void onDrawerClosed(@NonNull View drawerView) {}
|
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();
|
toggle.syncState();
|
||||||
toolbar.setNavigationIcon(R.drawable.ic_menu);
|
toolbar.setNavigationIcon(R.drawable.ic_menu);
|
||||||
|
|
||||||
@ -338,14 +319,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
|
|
||||||
if(savedInstanceState == null) {
|
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")) {
|
switch(tinyDb.getInt("homeScreenId")) {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
@ -384,12 +357,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
navigationView.setCheckedItem(R.id.nav_comments_draft);
|
navigationView.setCheckedItem(R.id.nav_comments_draft);
|
||||||
break;
|
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:
|
default:
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyRepositoriesFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyRepositoriesFragment()).commit();
|
||||||
@ -402,7 +369,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
if(!tinyDb.getBoolean("noConnection")) {
|
if(!tinyDb.getBoolean("noConnection")) {
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
}
|
}
|
||||||
|
|
||||||
tinyDb.putBoolean("noConnection", true);
|
tinyDb.putBoolean("noConnection", true);
|
||||||
@ -454,18 +421,12 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
|
|
||||||
if(frag != null) {
|
if(frag != null) {
|
||||||
|
|
||||||
new AlertDialog.Builder(ctx)
|
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) -> {
|
||||||
.setTitle(R.string.deleteAllDrafts)
|
|
||||||
.setIcon(R.drawable.ic_delete)
|
|
||||||
.setCancelable(false)
|
|
||||||
.setMessage(R.string.deleteAllDraftsDialogMessage)
|
|
||||||
.setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
|
||||||
|
|
||||||
frag.deleteAllDrafts(currentActiveAccountId);
|
frag.deleteAllDrafts(currentActiveAccountId);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
})
|
}).setNegativeButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss()).show();
|
||||||
.setNeutralButton(R.string.cancelButton, null).show();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
|
|
||||||
@ -690,7 +665,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
String toastError = getResources().getString(R.string.genericApiStatusError) + response.code();
|
String toastError = getResources().getString(R.string.genericApiStatusError) + response.code();
|
||||||
Toasty.error(ctx, toastError);
|
Toasty.info(ctx, toastError);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,10 +126,12 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
viewBinding.mergeButton.setOnClickListener(mergePullRequest);
|
viewBinding.mergeButton.setOnClickListener(mergePullRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -219,7 +221,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -264,7 +266,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
|
|
||||||
deleteBranchFunction(repoOwner, repoName);
|
deleteBranchFunction(repoOwner, repoName);
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
Toasty.info(ctx, getString(R.string.mergePRSuccessMsg));
|
||||||
tinyDb.putBoolean("prMerged", true);
|
tinyDb.putBoolean("prMerged", true);
|
||||||
tinyDb.putBoolean("resumePullRequests", true);
|
tinyDb.putBoolean("resumePullRequests", true);
|
||||||
finish();
|
finish();
|
||||||
@ -279,7 +281,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
|
|
||||||
deleteBranchFunction(repoOwner, repoName);
|
deleteBranchFunction(repoOwner, repoName);
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
Toasty.info(ctx, getString(R.string.mergePRSuccessMsg));
|
||||||
tinyDb.putBoolean("prMerged", true);
|
tinyDb.putBoolean("prMerged", true);
|
||||||
tinyDb.putBoolean("resumePullRequests", true);
|
tinyDb.putBoolean("resumePullRequests", true);
|
||||||
finish();
|
finish();
|
||||||
@ -289,7 +291,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
Toasty.info(ctx, getString(R.string.mergePRSuccessMsg));
|
||||||
tinyDb.putBoolean("prMerged", true);
|
tinyDb.putBoolean("prMerged", true);
|
||||||
tinyDb.putBoolean("resumePullRequests", true);
|
tinyDb.putBoolean("resumePullRequests", true);
|
||||||
finish();
|
finish();
|
||||||
@ -306,13 +308,13 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
else if(response.code() == 404) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, getString(R.string.mergePR404ErrorMsg));
|
Toasty.info(ctx, getString(R.string.mergePR404ErrorMsg));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
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() {
|
private void disableProcessButton() {
|
||||||
|
|
||||||
viewBinding.mergeButton.setEnabled(false);
|
viewBinding.mergeButton.setEnabled(false);
|
||||||
|
viewBinding.mergeButton.setBackground(getResources().getDrawable(R.drawable.shape_buttons_disabled));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableProcessButton() {
|
private void enableProcessButton() {
|
||||||
|
|
||||||
viewBinding.mergeButton.setEnabled(true);
|
viewBinding.mergeButton.setEnabled(true);
|
||||||
|
viewBinding.mergeButton.setBackground(getResources().getDrawable(R.drawable.shape_buttons));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,7 @@ public class OpenRepoInBrowserActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
URI instanceUrl = new URI(UrlBuilder.fromString(tinyDb.getString("instanceUrl"))
|
URI instanceUrl = new URI(tinyDb.getString("instanceUrlWithProtocol"));
|
||||||
.withPath("/")
|
|
||||||
.toString());
|
|
||||||
|
|
||||||
String browserPath = PathsHelper.join(instanceUrl.getPath(), getIntent().getStringExtra("repoFullNameBrowser"));
|
String browserPath = PathsHelper.join(instanceUrl.getPath(), getIntent().getStringExtra("repoFullNameBrowser"));
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
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.RepositoriesByOrgFragment;
|
||||||
import org.mian.gitnex.fragments.TeamsByOrgFragment;
|
import org.mian.gitnex.fragments.TeamsByOrgFragment;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import io.mikael.urlbuilder.UrlBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -38,7 +34,6 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
|
|
||||||
final Context ctx = this;
|
final Context ctx = this;
|
||||||
private Context appCtx;
|
private Context appCtx;
|
||||||
private TinyDB tinyDb;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
@ -50,7 +45,6 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
appCtx = getApplicationContext();
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = new TinyDB(appCtx);
|
||||||
String orgName = tinyDb.getString("orgName");
|
String orgName = tinyDb.getString("orgName");
|
||||||
@ -111,7 +105,6 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
inflater.inflate(R.menu.repo_dotted_menu, menu);
|
inflater.inflate(R.menu.repo_dotted_menu, menu);
|
||||||
return true;
|
return true;
|
||||||
@ -139,28 +132,19 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
@Override
|
@Override
|
||||||
public void onButtonClicked(String text) {
|
public void onButtonClicked(String text) {
|
||||||
|
|
||||||
|
TinyDB tinyDb = new TinyDB(appCtx);
|
||||||
|
|
||||||
switch (text) {
|
switch (text) {
|
||||||
case "repository":
|
case "repository":
|
||||||
|
|
||||||
tinyDb.putBoolean("organizationAction", true);
|
tinyDb.putBoolean("organizationAction", true);
|
||||||
startActivity(new Intent(OrganizationDetailActivity.this, CreateRepoActivity.class));
|
startActivity(new Intent(OrganizationDetailActivity.this, CreateRepoActivity.class));
|
||||||
break;
|
break;
|
||||||
case "team":
|
case "team":
|
||||||
|
|
||||||
startActivity(new Intent(OrganizationDetailActivity.this, CreateTeamByOrgActivity.class));
|
startActivity(new Intent(OrganizationDetailActivity.this, CreateTeamByOrgActivity.class));
|
||||||
break;
|
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 {
|
public class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||||
@ -173,6 +157,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
@Override
|
@Override
|
||||||
public Fragment getItem(int position) {
|
public Fragment getItem(int position) {
|
||||||
|
|
||||||
|
TinyDB tinyDb = new TinyDB(appCtx);
|
||||||
String orgName;
|
String orgName;
|
||||||
if(getIntent().getStringExtra("orgName") != null || !Objects.equals(getIntent().getStringExtra("orgName"), "")) {
|
if(getIntent().getStringExtra("orgName") != null || !Objects.equals(getIntent().getStringExtra("orgName"), "")) {
|
||||||
orgName = getIntent().getStringExtra("orgName");
|
orgName = getIntent().getStringExtra("orgName");
|
||||||
|
@ -9,7 +9,6 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.GridView;
|
import android.widget.GridView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
@ -31,7 +30,6 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
|||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private TeamMembersByOrgAdapter adapter;
|
private TeamMembersByOrgAdapter adapter;
|
||||||
private GridView mGridView;
|
private GridView mGridView;
|
||||||
private ProgressBar progressBar;
|
|
||||||
|
|
||||||
final Context ctx = this;
|
final Context ctx = this;
|
||||||
private Context appCtx;
|
private Context appCtx;
|
||||||
@ -60,7 +58,6 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
|||||||
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
||||||
noDataMembers = findViewById(R.id.noDataMembers);
|
noDataMembers = findViewById(R.id.noDataMembers);
|
||||||
mGridView = findViewById(R.id.gridView);
|
mGridView = findViewById(R.id.gridView);
|
||||||
progressBar = findViewById(R.id.progressBar);
|
|
||||||
|
|
||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
@ -117,7 +114,6 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
|||||||
noDataMembers.setVisibility(View.VISIBLE);
|
noDataMembers.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Patterns;
|
import android.util.Patterns;
|
||||||
@ -66,9 +67,11 @@ public class ProfileEmailActivity extends BaseActivity {
|
|||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
addEmailButton.setOnClickListener(addEmailListener);
|
addEmailButton.setOnClickListener(addEmailListener);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -91,20 +94,20 @@ public class ProfileEmailActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newUserEmail.equals("")) {
|
if(newUserEmail.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.emailErrorEmpty));
|
Toasty.info(ctx, getString(R.string.emailErrorEmpty));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
|
else if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.emailErrorInvalid));
|
Toasty.info(ctx, getString(R.string.emailErrorInvalid));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -135,7 +138,7 @@ public class ProfileEmailActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.emailAddedText));
|
Toasty.info(ctx, getString(R.string.emailAddedText));
|
||||||
tinyDb.putBoolean("emailsRefresh", true);
|
tinyDb.putBoolean("emailsRefresh", true);
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
finish();
|
finish();
|
||||||
@ -153,25 +156,25 @@ public class ProfileEmailActivity extends BaseActivity {
|
|||||||
else if(response.code() == 403) {
|
else if(response.code() == 403) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 404) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 422) {
|
else if(response.code() == 422) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.emailErrorInUse));
|
Toasty.info(ctx, ctx.getString(R.string.emailErrorInUse));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
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() {
|
private void initCloseListener() {
|
||||||
|
onClickListener = new View.OnClickListener() {
|
||||||
onClickListener = view -> finish();
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableProcessButton() {
|
private void disableProcessButton() {
|
||||||
|
|
||||||
addEmailButton.setEnabled(false);
|
addEmailButton.setEnabled(false);
|
||||||
|
GradientDrawable shape = new GradientDrawable();
|
||||||
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
addEmailButton.setBackground(shape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableProcessButton() {
|
private void enableProcessButton() {
|
||||||
|
|
||||||
addEmailButton.setEnabled(true);
|
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.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
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.Collaborators;
|
||||||
import org.mian.gitnex.models.Issues;
|
import org.mian.gitnex.models.Issues;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -55,7 +55,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
|||||||
private ArrayAdapter<Mention> defaultMentionAdapter;
|
private ArrayAdapter<Mention> defaultMentionAdapter;
|
||||||
private Button replyButton;
|
private Button replyButton;
|
||||||
private String TAG = StaticGlobalVariables.replyToIssueActivity;
|
private String TAG = StaticGlobalVariables.replyToIssueActivity;
|
||||||
private long draftIdOnCreate;
|
private long draftId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
@ -98,15 +98,6 @@ public class ReplyToIssueActivity extends BaseActivity {
|
|||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
if(getIntent().getStringExtra("draftId") != null) {
|
|
||||||
|
|
||||||
draftIdOnCreate = Long.parseLong(Objects.requireNonNull(getIntent().getStringExtra("draftId")));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
draftIdOnCreate = returnDraftId();
|
|
||||||
}
|
|
||||||
|
|
||||||
replyButton = findViewById(R.id.replyButton);
|
replyButton = findViewById(R.id.replyButton);
|
||||||
|
|
||||||
if(getIntent().getStringExtra("commentBody") != null) {
|
if(getIntent().getStringExtra("commentBody") != null) {
|
||||||
@ -125,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");
|
final String commentId = getIntent().getStringExtra("commentId");
|
||||||
|
|
||||||
@ -144,7 +135,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
|||||||
|
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
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);
|
draftSaved.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -155,7 +146,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
|||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
assert commentId != null;
|
assert commentId != null;
|
||||||
IssueActions.editIssueComment(ctx, Integer.parseInt(commentId), addComment.getText().toString(), draftIdOnCreate);
|
IssueActions.editIssueComment(ctx, Integer.parseInt(commentId), addComment.getText().toString());
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -175,7 +166,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
|||||||
|
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
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);
|
draftSaved.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -195,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());
|
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
|
|
||||||
@ -205,31 +196,17 @@ public class ReplyToIssueActivity extends BaseActivity {
|
|||||||
|
|
||||||
DraftsApi draftsApi = new DraftsApi(appCtx);
|
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 {
|
else {
|
||||||
|
DraftsApi.updateDraftByIssueIdAsyncTask(draftText, issueNumber, repositoryId);
|
||||||
DraftsApi.updateDraft(draftText, (int) draftIdOnCreate, commentId); //updateDraftByIssueIdAsyncTask(draftText, issueNumber, repositoryId, commentId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private long returnDraftId() {
|
|
||||||
|
|
||||||
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, "", StaticGlobalVariables.draftTypeComment, "");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadCollaboratorsList() {
|
public void loadCollaboratorsList() {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||||
@ -295,14 +272,14 @@ public class ReplyToIssueActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newReplyDT.equals("")) {
|
if(newReplyDT.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.commentEmptyError));
|
Toasty.info(ctx, getString(R.string.commentEmptyError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -341,7 +318,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.commentSuccess));
|
Toasty.info(ctx, getString(R.string.commentSuccess));
|
||||||
tinyDb.putBoolean("commentPosted", true);
|
tinyDb.putBoolean("commentPosted", true);
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
tinyDb.putBoolean("resumePullRequests", true);
|
tinyDb.putBoolean("resumePullRequests", true);
|
||||||
@ -349,8 +326,12 @@ public class ReplyToIssueActivity extends BaseActivity {
|
|||||||
// delete draft comment
|
// delete draft comment
|
||||||
if(tinyDb.getBoolean("draftsCommentsDeletionEnabled")) {
|
if(tinyDb.getBoolean("draftsCommentsDeletionEnabled")) {
|
||||||
|
|
||||||
|
int repositoryId = (int) tinyDb.getLong("repositoryId", 0);
|
||||||
|
int issueNumber = Integer.parseInt(tinyDb.getString("issueNumber"));
|
||||||
|
|
||||||
DraftsApi draftsApi = new DraftsApi(appCtx);
|
DraftsApi draftsApi = new DraftsApi(appCtx);
|
||||||
draftsApi.deleteSingleDraft((int) draftIdOnCreate);
|
draftId = draftsApi.getDraftIdAsync(issueNumber, repositoryId);
|
||||||
|
draftsApi.deleteSingleDraft((int) draftId);
|
||||||
}
|
}
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
@ -368,7 +349,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, getString(R.string.commentError));
|
Toasty.info(ctx, getString(R.string.commentError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,11 +397,21 @@ public class ReplyToIssueActivity extends BaseActivity {
|
|||||||
private void disableProcessButton() {
|
private void disableProcessButton() {
|
||||||
|
|
||||||
replyButton.setEnabled(false);
|
replyButton.setEnabled(false);
|
||||||
|
GradientDrawable shape = new GradientDrawable();
|
||||||
|
shape.setCornerRadius(8);
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
replyButton.setBackground(shape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableProcessButton() {
|
private void enableProcessButton() {
|
||||||
|
|
||||||
replyButton.setEnabled(true);
|
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;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -44,7 +42,6 @@ import org.mian.gitnex.fragments.ReleasesFragment;
|
|||||||
import org.mian.gitnex.fragments.RepoInfoFragment;
|
import org.mian.gitnex.fragments.RepoInfoFragment;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.models.Branches;
|
import org.mian.gitnex.models.Branches;
|
||||||
import org.mian.gitnex.models.UserRepositories;
|
import org.mian.gitnex.models.UserRepositories;
|
||||||
@ -84,7 +81,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
private String repositoryOwner;
|
private String repositoryOwner;
|
||||||
private String repositoryName;
|
private String repositoryName;
|
||||||
|
|
||||||
public static ViewPager mViewPager;
|
|
||||||
private int tabsCount;
|
private int tabsCount;
|
||||||
|
|
||||||
@Override
|
@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));
|
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||||
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||||
@ -349,14 +345,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
startActivity(Intent.createChooser(sharingIntent, tinyDB.getString("repoHtmlUrl")));
|
startActivity(Intent.createChooser(sharingIntent, tinyDB.getString("repoHtmlUrl")));
|
||||||
break;
|
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":
|
case "newFile":
|
||||||
startActivity(new Intent(RepoDetailActivity.this, CreateFileActivity.class));
|
startActivity(new Intent(RepoDetailActivity.this, CreateFileActivity.class));
|
||||||
break;
|
break;
|
||||||
@ -444,7 +432,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
dialogInterface.dismiss();
|
dialogInterface.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
pBuilder.setNeutralButton(R.string.cancelButton, null);
|
|
||||||
|
|
||||||
pBuilder.create().show();
|
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() {
|
private void initCloseListener() {
|
||||||
|
onClickListener = new View.OnClickListener() {
|
||||||
onClickListener = view -> finish();
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -93,8 +93,12 @@ public class RepoWatchersActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
onClickListener = new View.OnClickListener() {
|
||||||
onClickListener = view -> finish();
|
@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.R;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -29,13 +28,12 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||||||
private static int codeBlockSelectedChoice = 0;
|
private static int codeBlockSelectedChoice = 0;
|
||||||
|
|
||||||
private static String[] homeScreenList = {"My Repositories", "Starred Repositories", "Organizations", "Repositories", "Profile", "Explore", "Drafts"};
|
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 int homeScreenSelectedChoice = 0;
|
||||||
|
|
||||||
private static String[] customFontList = {"Roboto", "Manrope", "Source Code Pro"};
|
private static String[] customFontList = {"Roboto", "Manrope", "Source Code Pro"};
|
||||||
private static int customFontSelectedChoice = 0;
|
private static int customFontSelectedChoice = 0;
|
||||||
|
|
||||||
private static String[] themeList = {"Dark", "Light", "Auto (Light / Dark)", "Retro", "Auto (Retro / Dark)"};
|
private static String[] themeList = {"Dark", "Light", "Auto (Day/Night)"};
|
||||||
private static int themeSelectedChoice = 0;
|
private static int themeSelectedChoice = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -71,11 +69,6 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
|
||||||
|
|
||||||
homeScreenList = homeScreenListNew;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!tinyDb.getString("timeStr").isEmpty()) {
|
if(!tinyDb.getString("timeStr").isEmpty()) {
|
||||||
tvDateTimeSelected.setText(tinyDb.getString("timeStr"));
|
tvDateTimeSelected.setText(tinyDb.getString("timeStr"));
|
||||||
}
|
}
|
||||||
@ -128,11 +121,11 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||||||
|
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
tinyDb.putBoolean("enableCounterBadges", true);
|
tinyDb.putBoolean("enableCounterBadges", true);
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tinyDb.putBoolean("enableCounterBadges", false);
|
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.recreate();
|
||||||
this.overridePendingTransition(0, 0);
|
this.overridePendingTransition(0, 0);
|
||||||
dialogInterfaceTheme.dismiss();
|
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.recreate();
|
||||||
this.overridePendingTransition(0, 0);
|
this.overridePendingTransition(0, 0);
|
||||||
dialogInterfaceCustomFont.dismiss();
|
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);
|
tinyDb.putInt("homeScreenId", i);
|
||||||
|
|
||||||
dialogInterfaceHomeScreen.dismiss();
|
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]) {
|
switch(codeBlockList[i]) {
|
||||||
case "White - Black":
|
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));
|
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
||||||
break;
|
break;
|
||||||
case "Grey - Black":
|
case "Grey - Black":
|
||||||
@ -263,12 +256,12 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
||||||
break;
|
break;
|
||||||
case "White - Grey":
|
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));
|
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.colorAccent));
|
||||||
break;
|
break;
|
||||||
case "Dark - White":
|
case "Dark - White":
|
||||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorPrimary));
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorLightGreen));
|
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorLightGreen));
|
||||||
@ -277,7 +270,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dialogInterfaceCodeBlock.dismiss();
|
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();
|
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() {
|
private void initCloseListener() {
|
||||||
onClickListener = view -> finish();
|
onClickListener = view -> {
|
||||||
|
finish();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -51,11 +51,11 @@ public class SettingsDraftsActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(isChecked) {
|
if(isChecked) {
|
||||||
tinyDb.putBoolean("draftsCommentsDeletionEnabled", true);
|
tinyDb.putBoolean("draftsCommentsDeletionEnabled", true);
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tinyDb.putBoolean("draftsCommentsDeletionEnabled", false);
|
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);
|
tinyDb.putInt("fileviewerSourceCodeThemeId", i);
|
||||||
|
|
||||||
dialogInterfaceTheme.dismiss();
|
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) {
|
if(isChecked) {
|
||||||
tinyDb.putBoolean("enablePdfMode", true);
|
tinyDb.putBoolean("enablePdfMode", true);
|
||||||
tinyDb.putString("enablePdfModeInit", "yes");
|
tinyDb.putString("enablePdfModeInit", "yes");
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tinyDb.putBoolean("enablePdfMode", false);
|
tinyDb.putBoolean("enablePdfMode", false);
|
||||||
tinyDb.putString("enablePdfModeInit", "yes");
|
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) {
|
if(isChecked) {
|
||||||
tinyDb.putBoolean("crashReportingEnabled", true);
|
tinyDb.putBoolean("crashReportingEnabled", true);
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tinyDb.putBoolean("crashReportingEnabled", false);
|
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() {
|
private void initCloseListener() {
|
||||||
onClickListener = view -> finish();
|
onClickListener = view -> {
|
||||||
|
finish();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||||||
tinyDb.putInt("cacheSizeImagesId", i);
|
tinyDb.putInt("cacheSizeImagesId", i);
|
||||||
|
|
||||||
dialogInterfaceTheme.dismiss();
|
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);
|
tinyDb.putInt("cacheSizeId", i);
|
||||||
|
|
||||||
dialogInterfaceTheme.dismiss();
|
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);
|
NotificationsMaster.hireWorker(ctx);
|
||||||
|
|
||||||
pollingDelaySelected.setText(String.format(getString(R.string.pollingDelaySelectedText), numberPicker.getValue()));
|
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.setView(numberPicker);
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
|
|
||||||
|
@ -143,11 +143,11 @@ public class SettingsTranslationActivity extends BaseActivity {
|
|||||||
this.recreate();
|
this.recreate();
|
||||||
this.overridePendingTransition(0, 0);
|
this.overridePendingTransition(0, 0);
|
||||||
dialogInterface.dismiss();
|
dialogInterface.dismiss();
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.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();
|
AlertDialog lDialog = lBuilder.create();
|
||||||
lDialog.show();
|
lDialog.show();
|
||||||
@ -157,7 +157,9 @@ public class SettingsTranslationActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
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);
|
holder.userRole.setVisibility(View.VISIBLE);
|
||||||
TextDrawable drawable = TextDrawable.builder()
|
TextDrawable drawable = TextDrawable.builder()
|
||||||
.beginConfig()
|
.beginConfig()
|
||||||
.textColor(mCtx.getResources().getColor(R.color.colorWhite))
|
.textColor(mCtx.getResources().getColor(R.color.white))
|
||||||
.fontSize(44)
|
.fontSize(44)
|
||||||
.width(180)
|
.width(180)
|
||||||
.height(60)
|
.height(60)
|
||||||
|
@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -39,8 +38,6 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
private TextView issueType;
|
private TextView issueType;
|
||||||
private TextView repoOwner;
|
private TextView repoOwner;
|
||||||
private TextView repoName;
|
private TextView repoName;
|
||||||
private TextView commentId;
|
|
||||||
private ImageView editCommentStatus;
|
|
||||||
|
|
||||||
private DraftsViewHolder(View itemView) {
|
private DraftsViewHolder(View itemView) {
|
||||||
|
|
||||||
@ -54,9 +51,7 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
issueType = itemView.findViewById(R.id.issueType);
|
issueType = itemView.findViewById(R.id.issueType);
|
||||||
repoOwner = itemView.findViewById(R.id.repoOwner);
|
repoOwner = itemView.findViewById(R.id.repoOwner);
|
||||||
repoName = itemView.findViewById(R.id.repoName);
|
repoName = itemView.findViewById(R.id.repoName);
|
||||||
commentId = itemView.findViewById(R.id.commentId);
|
|
||||||
ImageView deleteDraft = itemView.findViewById(R.id.deleteDraft);
|
ImageView deleteDraft = itemView.findViewById(R.id.deleteDraft);
|
||||||
editCommentStatus = itemView.findViewById(R.id.editCommentStatus);
|
|
||||||
|
|
||||||
deleteDraft.setOnClickListener(itemDelete -> {
|
deleteDraft.setOnClickListener(itemDelete -> {
|
||||||
|
|
||||||
@ -74,12 +69,6 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
intent.putExtra("issueNumber", issueNumber.getText().toString());
|
intent.putExtra("issueNumber", issueNumber.getText().toString());
|
||||||
intent.putExtra("repositoryId", repoId.getText().toString());
|
intent.putExtra("repositoryId", repoId.getText().toString());
|
||||||
intent.putExtra("draftTitle", repoInfo.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 tinyDb = new TinyDB(mCtx);
|
||||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||||
@ -104,7 +93,7 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
draftsList.remove(position);
|
draftsList.remove(position);
|
||||||
notifyItemRemoved(position);
|
notifyItemRemoved(position);
|
||||||
notifyItemRangeChanged(position, draftsList.size());
|
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.repoOwner.setText(currentItem.getRepositoryOwner());
|
||||||
holder.repoName.setText(currentItem.getRepositoryName());
|
holder.repoName.setText(currentItem.getRepositoryName());
|
||||||
holder.draftText.setText(currentItem.getDraftText());
|
holder.draftText.setText(currentItem.getDraftText());
|
||||||
holder.commentId.setText(currentItem.getCommentId());
|
|
||||||
|
|
||||||
String issueNumber = "<font color='" + mCtx.getResources().getColor(R.color.lightGray) + "'>" + mCtx.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
|
String issueNumber = "<font color='" + mCtx.getResources().getColor(R.color.lightGray) + "'>" + mCtx.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
|
||||||
Spanned headTitle = Html.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName());
|
holder.repoInfo.setText(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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package org.mian.gitnex.adapters;
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
@ -21,7 +19,6 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
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.UserRepositories;
|
||||||
import org.mian.gitnex.models.WatchInfo;
|
import org.mian.gitnex.models.WatchInfo;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -44,6 +40,7 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepositoriesAdapter.ReposSearchViewHolder> {
|
public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepositoriesAdapter.ReposSearchViewHolder> {
|
||||||
|
|
||||||
|
|
||||||
private List<UserRepositories> searchedReposList;
|
private List<UserRepositories> searchedReposList;
|
||||||
private Context mCtx;
|
private Context mCtx;
|
||||||
|
|
||||||
@ -67,7 +64,6 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
private TextView repoType;
|
private TextView repoType;
|
||||||
private LinearLayout archiveRepo;
|
private LinearLayout archiveRepo;
|
||||||
private TextView repoBranch;
|
private TextView repoBranch;
|
||||||
private TextView htmlUrl;
|
|
||||||
|
|
||||||
private ReposSearchViewHolder(View itemView) {
|
private ReposSearchViewHolder(View itemView) {
|
||||||
|
|
||||||
@ -86,7 +82,6 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
repoType = itemView.findViewById(R.id.repoType);
|
repoType = itemView.findViewById(R.id.repoType);
|
||||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
@ -153,7 +148,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
|
|
||||||
if(response.code() != 404) {
|
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) {
|
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
tinyDb.putBoolean("repoWatch", false);
|
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 repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
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);
|
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||||
|
|
||||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
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.setContentView(view);
|
||||||
dialog.show();
|
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 -> {
|
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||||
|
|
||||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
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);
|
UserRepositories currentItem = searchedReposList.get(position);
|
||||||
holder.repoDescription.setVisibility(View.GONE);
|
holder.repoDescription.setVisibility(View.GONE);
|
||||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
int color = generator.getColor(currentItem.getName());
|
int color = generator.getColor(currentItem.getName());
|
||||||
@ -292,7 +264,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
holder.repoType.setText(R.string.strPrivate);
|
holder.repoType.setText(R.string.strPrivate);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.repoPrivatePublic.setVisibility(View.GONE);
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_unlock);
|
||||||
holder.repoType.setText(R.string.strPublic);
|
holder.repoType.setText(R.string.strPublic);
|
||||||
}
|
}
|
||||||
holder.repoStars.setText(currentItem.getStars_count());
|
holder.repoStars.setText(currentItem.getStars_count());
|
||||||
|
@ -37,8 +37,6 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
|||||||
class FilesViewHolder extends RecyclerView.ViewHolder {
|
class FilesViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private ImageView fileTypeImage;
|
private ImageView fileTypeImage;
|
||||||
private ImageView dirTypeImage;
|
|
||||||
private ImageView unknownTypeImage;
|
|
||||||
private TextView fileName;
|
private TextView fileName;
|
||||||
private TextView fileType;
|
private TextView fileType;
|
||||||
private TextView fileInfo;
|
private TextView fileInfo;
|
||||||
@ -48,8 +46,6 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
|||||||
super(itemView);
|
super(itemView);
|
||||||
fileName = itemView.findViewById(R.id.fileName);
|
fileName = itemView.findViewById(R.id.fileName);
|
||||||
fileTypeImage = itemView.findViewById(R.id.fileImage);
|
fileTypeImage = itemView.findViewById(R.id.fileImage);
|
||||||
dirTypeImage = itemView.findViewById(R.id.dirImage);
|
|
||||||
unknownTypeImage = itemView.findViewById(R.id.unknownImage);
|
|
||||||
fileType = itemView.findViewById(R.id.fileType);
|
fileType = itemView.findViewById(R.id.fileType);
|
||||||
fileInfo = itemView.findViewById(R.id.fileInfo);
|
fileInfo = itemView.findViewById(R.id.fileInfo);
|
||||||
|
|
||||||
@ -66,7 +62,7 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
|||||||
filesListener.onClickDir(fileName.getText().toString());
|
filesListener.onClickDir(fileName.getText().toString());
|
||||||
}
|
}
|
||||||
else {
|
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());
|
holder.fileName.setText(currentItem.getName());
|
||||||
|
|
||||||
if(currentItem.getType().equals("file")) {
|
if(currentItem.getType().equals("file")) {
|
||||||
holder.fileTypeImage.setVisibility(View.VISIBLE);
|
holder.fileTypeImage.setImageDrawable(mCtx.getResources().getDrawable(R.drawable.ic_file));
|
||||||
holder.dirTypeImage.setVisibility(View.GONE);
|
|
||||||
holder.unknownTypeImage.setVisibility(View.GONE);
|
|
||||||
holder.fileInfo.setVisibility(View.VISIBLE);
|
holder.fileInfo.setVisibility(View.VISIBLE);
|
||||||
holder.fileInfo.setText(AppUtil.formatFileSizeInDetail(currentItem.getSize()));
|
holder.fileInfo.setText(AppUtil.formatFileSizeInDetail(currentItem.getSize()));
|
||||||
}
|
}
|
||||||
else if(currentItem.getType().equals("dir")) {
|
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.fileInfo.setVisibility(View.GONE);
|
||||||
|
holder.fileTypeImage.setImageDrawable(mCtx.getResources().getDrawable(R.drawable.ic_directory));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.unknownTypeImage.setVisibility(View.VISIBLE);
|
holder.fileTypeImage.setImageDrawable(mCtx.getResources().getDrawable(R.drawable.ic_question));
|
||||||
holder.dirTypeImage.setVisibility(View.GONE);
|
|
||||||
holder.fileTypeImage.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,6 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
TextView commentMenuQuote = view.findViewById(R.id.commentMenuQuote);
|
TextView commentMenuQuote = view.findViewById(R.id.commentMenuQuote);
|
||||||
TextView commentMenuCopy = view.findViewById(R.id.commentMenuCopy);
|
TextView commentMenuCopy = view.findViewById(R.id.commentMenuCopy);
|
||||||
TextView commentMenuDelete = view.findViewById(R.id.commentMenuDelete);
|
TextView commentMenuDelete = view.findViewById(R.id.commentMenuDelete);
|
||||||
TextView issueCommentCopyUrl = view.findViewById(R.id.issueCommentCopyUrl);
|
|
||||||
|
|
||||||
if(!loginUid.contentEquals(commenterUsername.getText())) {
|
if(!loginUid.contentEquals(commenterUsername.getText())) {
|
||||||
commentMenuEdit.setVisibility(View.GONE);
|
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 -> {
|
commentMenuQuote.setOnClickListener(v1 -> {
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
@ -206,7 +189,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
|
|
||||||
dialog.dismiss();
|
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) {
|
if(response.code() == 204) {
|
||||||
|
|
||||||
updateAdapter(position);
|
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) {
|
else if(response.code() == 401) {
|
||||||
@ -272,17 +255,17 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
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) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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;
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
@ -23,7 +21,6 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
@ -37,7 +34,6 @@ import org.mian.gitnex.models.UserRepositories;
|
|||||||
import org.mian.gitnex.models.WatchInfo;
|
import org.mian.gitnex.models.WatchInfo;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -65,7 +61,6 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
private CheckBox isRepoAdmin;
|
private CheckBox isRepoAdmin;
|
||||||
private LinearLayout archiveRepo;
|
private LinearLayout archiveRepo;
|
||||||
private TextView repoBranch;
|
private TextView repoBranch;
|
||||||
private TextView htmlUrl;
|
|
||||||
|
|
||||||
private MyReposViewHolder(View itemView) {
|
private MyReposViewHolder(View itemView) {
|
||||||
|
|
||||||
@ -83,7 +78,6 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
@ -151,7 +145,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
|
|
||||||
if(response.code() != 404) {
|
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) {
|
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
tinyDb.putBoolean("repoWatch", false);
|
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 repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
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);
|
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||||
|
|
||||||
bottomSheetHeader.setText(String.format("%s / %s", repoFullName.getText().toString().split("/")[0], repoFullName.getText().toString().split("/")[1]));
|
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.setContentView(view);
|
||||||
dialog.show();
|
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 -> {
|
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||||
|
|
||||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
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);
|
UserRepositories currentItem = reposList.get(position);
|
||||||
holder.repoDescription.setVisibility(View.GONE);
|
holder.repoDescription.setVisibility(View.GONE);
|
||||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
int color = generator.getColor(currentItem.getName());
|
int color = generator.getColor(currentItem.getName());
|
||||||
@ -297,7 +268,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
holder.repoType.setText(R.string.strPrivate);
|
holder.repoType.setText(R.string.strPrivate);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.repoPrivatePublic.setVisibility(View.GONE);
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_unlock);
|
||||||
holder.repoType.setText(R.string.strPublic);
|
holder.repoType.setText(R.string.strPublic);
|
||||||
}
|
}
|
||||||
holder.repoStars.setText(currentItem.getStars_count());
|
holder.repoStars.setText(currentItem.getStars_count());
|
||||||
|
@ -44,9 +44,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
|
|||||||
private LinearLayout frame;
|
private LinearLayout frame;
|
||||||
private TextView subject;
|
private TextView subject;
|
||||||
private TextView repository;
|
private TextView repository;
|
||||||
private ImageView typePr;
|
private ImageView type;
|
||||||
private ImageView typeIssue;
|
|
||||||
private ImageView typeUnknown;
|
|
||||||
private ImageView pinned;
|
private ImageView pinned;
|
||||||
private ImageView more;
|
private ImageView more;
|
||||||
|
|
||||||
@ -57,9 +55,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
|
|||||||
frame = itemView.findViewById(R.id.frame);
|
frame = itemView.findViewById(R.id.frame);
|
||||||
subject = itemView.findViewById(R.id.subject);
|
subject = itemView.findViewById(R.id.subject);
|
||||||
repository = itemView.findViewById(R.id.repository);
|
repository = itemView.findViewById(R.id.repository);
|
||||||
typePr = itemView.findViewById(R.id.typePr);
|
type = itemView.findViewById(R.id.type);
|
||||||
typeIssue = itemView.findViewById(R.id.typeIssue);
|
|
||||||
typeUnknown = itemView.findViewById(R.id.typeUnknown);
|
|
||||||
pinned = itemView.findViewById(R.id.pinned);
|
pinned = itemView.findViewById(R.id.pinned);
|
||||||
more = itemView.findViewById(R.id.more);
|
more = itemView.findViewById(R.id.more);
|
||||||
|
|
||||||
@ -97,21 +93,15 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
|
|||||||
switch(notificationThread.getSubject().getType()) {
|
switch(notificationThread.getSubject().getType()) {
|
||||||
|
|
||||||
case "Pull":
|
case "Pull":
|
||||||
holder.typePr.setVisibility(View.VISIBLE);
|
holder.type.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_pull_request, null));
|
||||||
holder.typeIssue.setVisibility(View.GONE);
|
|
||||||
holder.typeUnknown.setVisibility(View.GONE);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Issue":
|
case "Issue":
|
||||||
holder.typePr.setVisibility(View.GONE);
|
holder.type.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_issue, null));
|
||||||
holder.typeIssue.setVisibility(View.VISIBLE);
|
|
||||||
holder.typeUnknown.setVisibility(View.GONE);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
holder.typePr.setVisibility(View.GONE);
|
holder.type.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_question, null));
|
||||||
holder.typeIssue.setVisibility(View.GONE);
|
|
||||||
holder.typeUnknown.setVisibility(View.VISIBLE);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public class ProfileEmailsAdapter extends RecyclerView.Adapter<ProfileEmailsAdap
|
|||||||
if(currentItem.getPrimary()) {
|
if(currentItem.getPrimary()) {
|
||||||
TextDrawable drawable = TextDrawable.builder()
|
TextDrawable drawable = TextDrawable.builder()
|
||||||
.beginConfig()
|
.beginConfig()
|
||||||
.textColor(mCtx.getResources().getColor(R.color.colorWhite))
|
.textColor(mCtx.getResources().getColor(R.color.white))
|
||||||
.fontSize(36)
|
.fontSize(36)
|
||||||
.width(220)
|
.width(220)
|
||||||
.height(60)
|
.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;
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
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.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
@ -37,7 +34,6 @@ import org.mian.gitnex.models.UserRepositories;
|
|||||||
import org.mian.gitnex.models.WatchInfo;
|
import org.mian.gitnex.models.WatchInfo;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -65,7 +61,6 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
private TextView repoType;
|
private TextView repoType;
|
||||||
private LinearLayout archiveRepo;
|
private LinearLayout archiveRepo;
|
||||||
private TextView repoBranch;
|
private TextView repoBranch;
|
||||||
private TextView htmlUrl;
|
|
||||||
|
|
||||||
private ReposViewHolder(View itemView) {
|
private ReposViewHolder(View itemView) {
|
||||||
|
|
||||||
@ -83,7 +78,6 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
repoType = itemView.findViewById(R.id.repoType);
|
repoType = itemView.findViewById(R.id.repoType);
|
||||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
@ -152,7 +146,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
|
|
||||||
if(response.code() != 404) {
|
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) {
|
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
tinyDb.putBoolean("repoWatch", false);
|
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 repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
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);
|
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||||
|
|
||||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
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.setContentView(view);
|
||||||
dialog.show();
|
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 -> {
|
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||||
|
|
||||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
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);
|
UserRepositories currentItem = reposList.get(position);
|
||||||
holder.repoDescription.setVisibility(View.GONE);
|
holder.repoDescription.setVisibility(View.GONE);
|
||||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
int color = generator.getColor(currentItem.getName());
|
int color = generator.getColor(currentItem.getName());
|
||||||
@ -298,7 +269,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
holder.repoType.setText(R.string.strPrivate);
|
holder.repoType.setText(R.string.strPrivate);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.repoPrivatePublic.setVisibility(View.GONE);
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_unlock);
|
||||||
holder.repoType.setText(R.string.strPublic);
|
holder.repoType.setText(R.string.strPublic);
|
||||||
}
|
}
|
||||||
holder.repoStars.setText(currentItem.getStars_count());
|
holder.repoStars.setText(currentItem.getStars_count());
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package org.mian.gitnex.adapters;
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
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.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
@ -37,7 +34,6 @@ import org.mian.gitnex.models.UserRepositories;
|
|||||||
import org.mian.gitnex.models.WatchInfo;
|
import org.mian.gitnex.models.WatchInfo;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -65,7 +61,6 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
private TextView repoType;
|
private TextView repoType;
|
||||||
private LinearLayout archiveRepo;
|
private LinearLayout archiveRepo;
|
||||||
private TextView repoBranch;
|
private TextView repoBranch;
|
||||||
private TextView htmlUrl;
|
|
||||||
|
|
||||||
private OrgReposViewHolder(View itemView) {
|
private OrgReposViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@ -82,7 +77,6 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
repoType = itemView.findViewById(R.id.repoType);
|
repoType = itemView.findViewById(R.id.repoType);
|
||||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
@ -147,7 +141,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
|
|
||||||
if(response.code() != 404) {
|
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) {
|
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
tinyDb.putBoolean("repoWatch", false);
|
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 repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
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);
|
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||||
|
|
||||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
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.setContentView(view);
|
||||||
dialog.show();
|
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 -> {
|
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||||
|
|
||||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
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 intent = new Intent(context, RepoStargazersActivity.class);
|
||||||
intent.putExtra("repoFullNameForStars", fullName.getText());
|
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);
|
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
||||||
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
|
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);
|
UserRepositories currentItem = reposList.get(position);
|
||||||
holder.repoDescription.setVisibility(View.GONE);
|
holder.repoDescription.setVisibility(View.GONE);
|
||||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
int color = generator.getColor(currentItem.getName());
|
int color = generator.getColor(currentItem.getName());
|
||||||
@ -298,7 +269,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
holder.repoType.setText(R.string.strPrivate);
|
holder.repoType.setText(R.string.strPrivate);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.repoPrivatePublic.setVisibility(View.GONE);
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_unlock);
|
||||||
holder.repoType.setText(R.string.strPublic);
|
holder.repoType.setText(R.string.strPublic);
|
||||||
}
|
}
|
||||||
holder.repoStars.setText(currentItem.getStars_count());
|
holder.repoStars.setText(currentItem.getStars_count());
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package org.mian.gitnex.adapters;
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
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.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
@ -37,7 +34,6 @@ import org.mian.gitnex.models.UserRepositories;
|
|||||||
import org.mian.gitnex.models.WatchInfo;
|
import org.mian.gitnex.models.WatchInfo;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -65,7 +61,6 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
private TextView repoType;
|
private TextView repoType;
|
||||||
private LinearLayout archiveRepo;
|
private LinearLayout archiveRepo;
|
||||||
private TextView repoBranch;
|
private TextView repoBranch;
|
||||||
private TextView htmlUrl;
|
|
||||||
|
|
||||||
private StarredReposViewHolder(View itemView) {
|
private StarredReposViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@ -82,7 +77,6 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
repoType = itemView.findViewById(R.id.repoType);
|
repoType = itemView.findViewById(R.id.repoType);
|
||||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
@ -182,8 +176,6 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
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);
|
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||||
|
|
||||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
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.setContentView(view);
|
||||||
dialog.show();
|
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 -> {
|
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||||
|
|
||||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
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);
|
UserRepositories currentItem = reposList.get(position);
|
||||||
holder.repoDescription.setVisibility(View.GONE);
|
holder.repoDescription.setVisibility(View.GONE);
|
||||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
int color = generator.getColor(currentItem.getName());
|
int color = generator.getColor(currentItem.getName());
|
||||||
@ -301,7 +272,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
holder.repoType.setText(R.string.strPrivate);
|
holder.repoType.setText(R.string.strPrivate);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.repoPrivatePublic.setVisibility(View.GONE);
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_unlock);
|
||||||
holder.repoType.setText(R.string.strPublic);
|
holder.repoType.setText(R.string.strPublic);
|
||||||
}
|
}
|
||||||
holder.repoStars.setText(currentItem.getStars_count());
|
holder.repoStars.setText(currentItem.getStars_count());
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.mian.gitnex.adapters;
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -9,11 +8,9 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
|
||||||
import org.mian.gitnex.database.models.UserAccount;
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
@ -31,15 +28,13 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||||||
private Context mCtx;
|
private Context mCtx;
|
||||||
private TinyDB tinyDB;
|
private TinyDB tinyDB;
|
||||||
|
|
||||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
static class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private TextView accountUrl;
|
private TextView accountUrl;
|
||||||
private TextView userId;
|
private TextView userId;
|
||||||
private ImageView activeAccount;
|
private ImageView activeAccount;
|
||||||
private ImageView deleteAccount;
|
private ImageView deleteAccount;
|
||||||
private ImageView repoAvatar;
|
private ImageView repoAvatar;
|
||||||
private TextView accountId;
|
|
||||||
private TextView accountName;
|
|
||||||
|
|
||||||
private UserAccountsViewHolder(View itemView) {
|
private UserAccountsViewHolder(View itemView) {
|
||||||
|
|
||||||
@ -50,46 +45,14 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||||||
activeAccount = itemView.findViewById(R.id.activeAccount);
|
activeAccount = itemView.findViewById(R.id.activeAccount);
|
||||||
deleteAccount = itemView.findViewById(R.id.deleteAccount);
|
deleteAccount = itemView.findViewById(R.id.deleteAccount);
|
||||||
repoAvatar = itemView.findViewById(R.id.repoAvatar);
|
repoAvatar = itemView.findViewById(R.id.repoAvatar);
|
||||||
accountId = itemView.findViewById(R.id.accountId);
|
|
||||||
accountName = itemView.findViewById(R.id.accountName);
|
|
||||||
|
|
||||||
deleteAccount.setOnClickListener(itemDelete -> {
|
deleteAccount.setOnClickListener(itemDelete -> {
|
||||||
|
// use later to delete an account
|
||||||
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();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
itemView.setOnClickListener(itemEdit -> {
|
itemView.setOnClickListener(itemEdit -> {
|
||||||
|
// use later to switch account
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -103,12 +66,12 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||||||
this.userAccountsList = userAccountsListMain;
|
this.userAccountsList = userAccountsListMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLayoutByPosition(int position) {
|
private void deleteAccount(int position) {
|
||||||
|
|
||||||
userAccountsList.remove(position);
|
userAccountsList.remove(position);
|
||||||
notifyItemRemoved(position);
|
notifyItemRemoved(position);
|
||||||
notifyItemRangeChanged(position, userAccountsList.size());
|
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("/")
|
.withPath("/")
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
holder.accountId.setText(String.valueOf(currentItem.getAccountId()));
|
|
||||||
holder.accountName.setText(currentItem.getAccountName());
|
|
||||||
holder.userId.setText(String.format("@%s", currentItem.getUserName()));
|
holder.userId.setText(String.format("@%s", currentItem.getUserName()));
|
||||||
holder.accountUrl.setText(url);
|
holder.accountUrl.setText(url);
|
||||||
|
|
||||||
@ -142,7 +103,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||||||
holder.activeAccount.setVisibility(View.VISIBLE);
|
holder.activeAccount.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
else {
|
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();
|
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 draft = new Draft();
|
||||||
draft.setDraftRepositoryId(repositoryId);
|
draft.setDraftRepositoryId(repositoryId);
|
||||||
@ -35,7 +35,6 @@ public class DraftsApi {
|
|||||||
draft.setIssueId(issueId);
|
draft.setIssueId(issueId);
|
||||||
draft.setDraftText(draftText);
|
draft.setDraftText(draftText);
|
||||||
draft.setDraftType(draftType);
|
draft.setDraftType(draftType);
|
||||||
draft.setCommentId(draftType);
|
|
||||||
|
|
||||||
return insertDraftAsyncTask(draft);
|
return insertDraftAsyncTask(draft);
|
||||||
}
|
}
|
||||||
@ -72,11 +71,11 @@ public class DraftsApi {
|
|||||||
return draftId;
|
return draftId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer checkDraft(int issueId, int draftRepositoryId, String commentId) {
|
public Integer checkDraft(int issueId, int draftRepositoryId) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Thread thread = new Thread(() -> checkDraftFlag = draftsDao.checkDraftDao(issueId, draftRepositoryId, commentId));
|
Thread thread = new Thread(() -> checkDraftFlag = draftsDao.checkDraftDao(issueId, draftRepositoryId));
|
||||||
thread.start();
|
thread.start();
|
||||||
thread.join();
|
thread.join();
|
||||||
}
|
}
|
||||||
@ -113,14 +112,14 @@ public class DraftsApi {
|
|||||||
new Thread(() -> draftsDao.deleteAllDrafts(accountId)).start();
|
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 UserAccountsDao userAccountsDao;
|
||||||
private static UserAccount userAccount;
|
private static UserAccount userAccount;
|
||||||
private static Integer checkAccount;
|
private static Integer checkAccount;
|
||||||
private static long accountId;
|
|
||||||
|
|
||||||
public UserAccountsApi(Context context) {
|
public UserAccountsApi(Context context) {
|
||||||
|
|
||||||
@ -27,7 +26,7 @@ public class UserAccountsApi {
|
|||||||
userAccountsDao = db.userAccountsDao();
|
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 userAccount = new UserAccount();
|
||||||
userAccount.setAccountName(accountName);
|
userAccount.setAccountName(accountName);
|
||||||
@ -36,23 +35,12 @@ public class UserAccountsApi {
|
|||||||
userAccount.setToken(token);
|
userAccount.setToken(token);
|
||||||
userAccount.setServerVersion(serverVersion);
|
userAccount.setServerVersion(serverVersion);
|
||||||
|
|
||||||
return insertNewAccountAsync(userAccount);
|
insertNewAccountAsync(userAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long insertNewAccountAsync(final UserAccount userAccount) {
|
private static void insertNewAccountAsync(final UserAccount userAccount) {
|
||||||
|
|
||||||
try {
|
new Thread(() -> userAccountsDao.newAccount(userAccount)).start();
|
||||||
|
|
||||||
Thread thread = new Thread(() -> accountId = userAccountsDao.newAccount(userAccount));
|
|
||||||
thread.start();
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
catch(InterruptedException e) {
|
|
||||||
|
|
||||||
Log.e(StaticGlobalVariables.userAccountsRepository, e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return accountId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateServerVersion(final String serverVersion, final int accountId) {
|
public static void updateServerVersion(final String serverVersion, final int accountId) {
|
||||||
@ -60,16 +48,11 @@ public class UserAccountsApi {
|
|||||||
new Thread(() -> userAccountsDao.updateServerVersion(serverVersion, accountId)).start();
|
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();
|
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) {
|
public UserAccount getAccountData(String accountName) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -107,7 +90,7 @@ public class UserAccountsApi {
|
|||||||
return userAccountsDao.fetchAllAccounts();
|
return userAccountsDao.fetchAllAccounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAccount(final int accountId) {
|
public static void deleteAccount(final int accountId) {
|
||||||
|
|
||||||
new Thread(() -> userAccountsDao.deleteAccount(accountId)).start();
|
new Thread(() -> userAccountsDao.deleteAccount(accountId)).start();
|
||||||
}
|
}
|
||||||
|
@ -35,14 +35,14 @@ public interface DraftsDao {
|
|||||||
@Query("SELECT * FROM Drafts WHERE issueId = :issueId")
|
@Query("SELECT * FROM Drafts WHERE issueId = :issueId")
|
||||||
LiveData<Draft> fetchDraftByIssueId(int issueId);
|
LiveData<Draft> fetchDraftByIssueId(int issueId);
|
||||||
|
|
||||||
@Query("SELECT count(draftId) FROM Drafts WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId AND commentId = :commentId")
|
@Query("SELECT count(draftId) FROM Drafts WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId")
|
||||||
Integer checkDraftDao(int issueId, int draftRepositoryId, String commentId);
|
Integer checkDraftDao(int issueId, int draftRepositoryId);
|
||||||
|
|
||||||
@Query("UPDATE Drafts SET draftText = :draftText, commentId = :commentId WHERE draftId = :draftId")
|
@Query("UPDATE Drafts SET draftText= :draftText WHERE draftId = :draftId")
|
||||||
void updateDraft(String draftText, int draftId, String commentId);
|
void updateDraft(String draftText, int draftId);
|
||||||
|
|
||||||
@Query("UPDATE Drafts SET draftText = :draftText WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId AND commentId = :commentId")
|
@Query("UPDATE Drafts SET draftText= :draftText WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId")
|
||||||
void updateDraftByIssueId(String draftText, int issueId, int draftRepositoryId, String commentId);
|
void updateDraftByIssueId(String draftText, int issueId, int draftRepositoryId);
|
||||||
|
|
||||||
@Query("SELECT draftId FROM Drafts WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId")
|
@Query("SELECT draftId FROM Drafts WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId")
|
||||||
Integer getDraftId(int issueId, int draftRepositoryId);
|
Integer getDraftId(int issueId, int draftRepositoryId);
|
||||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
|||||||
public interface UserAccountsDao {
|
public interface UserAccountsDao {
|
||||||
|
|
||||||
@Insert
|
@Insert
|
||||||
long newAccount(UserAccount userAccounts);
|
void newAccount(UserAccount userAccounts);
|
||||||
|
|
||||||
@Query("SELECT * FROM UserAccounts ORDER BY accountId ASC")
|
@Query("SELECT * FROM UserAccounts ORDER BY accountId ASC")
|
||||||
LiveData<List<UserAccount>> fetchAllAccounts();
|
LiveData<List<UserAccount>> fetchAllAccounts();
|
||||||
@ -38,9 +38,6 @@ public interface UserAccountsDao {
|
|||||||
@Query("UPDATE UserAccounts SET token = :token WHERE accountId = :accountId")
|
@Query("UPDATE UserAccounts SET token = :token WHERE accountId = :accountId")
|
||||||
void updateAccountToken(int accountId, String token);
|
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")
|
@Query("UPDATE UserAccounts SET instanceUrl = :instanceUrl, token = :token WHERE accountId = :accountId")
|
||||||
void updateHostInfo(String instanceUrl, String token, int 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},
|
@Database(entities = {Draft.class, Repository.class, UserAccount.class},
|
||||||
version = 2, exportSchema = false)
|
version = 1, exportSchema = false)
|
||||||
public abstract class GitnexDatabase extends RoomDatabase {
|
public abstract class GitnexDatabase extends RoomDatabase {
|
||||||
|
|
||||||
private static GitnexDatabase gitnexDatabase;
|
private static GitnexDatabase gitnexDatabase;
|
||||||
@ -30,7 +30,7 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||||||
String DB_NAME = "gitnex";
|
String DB_NAME = "gitnex";
|
||||||
gitnexDatabase = Room.databaseBuilder(context, GitnexDatabase.class, DB_NAME)
|
gitnexDatabase = Room.databaseBuilder(context, GitnexDatabase.class, DB_NAME)
|
||||||
//.fallbackToDestructiveMigration()
|
//.fallbackToDestructiveMigration()
|
||||||
.addMigrations(MIGRATION_1_2)
|
//.addMigrations(MIGRATION_1_2)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
|
||||||
//database.execSQL("DROP TABLE Drafts");
|
//database.execSQL("DROP TABLE Drafts");
|
||||||
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'commentId' TEXT");
|
//database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'draftType' TEXT");
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -24,8 +24,6 @@ public class Draft implements Serializable {
|
|||||||
private String draftText;
|
private String draftText;
|
||||||
@Nullable
|
@Nullable
|
||||||
private String draftType;
|
private String draftType;
|
||||||
@Nullable
|
|
||||||
private String commentId;
|
|
||||||
|
|
||||||
public int getDraftId() {
|
public int getDraftId() {
|
||||||
|
|
||||||
@ -88,15 +86,4 @@ public class Draft implements Serializable {
|
|||||||
this.draftType = draftType;
|
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 int issueId;
|
||||||
private String draftText;
|
private String draftText;
|
||||||
private String draftType;
|
private String draftType;
|
||||||
private String commentId;
|
|
||||||
|
|
||||||
public int getRepositoryId() {
|
public int getRepositoryId() {
|
||||||
|
|
||||||
@ -120,14 +119,4 @@ public class DraftWithRepository {
|
|||||||
this.draftType = draftType;
|
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.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.activities.CreditsActivity;
|
||||||
|
import org.mian.gitnex.activities.SponsorsActivity;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -31,62 +33,83 @@ public class AboutFragment extends Fragment {
|
|||||||
final TextView donationLink;
|
final TextView donationLink;
|
||||||
final TextView donationLinkPatreon;
|
final TextView donationLinkPatreon;
|
||||||
final TextView translateLink;
|
final TextView translateLink;
|
||||||
|
final TextView creditsButton;
|
||||||
|
final TextView sponsorsButton;
|
||||||
final TextView appWebsite;
|
final TextView appWebsite;
|
||||||
final TextView appRepo;
|
final TextView appRepo;
|
||||||
|
|
||||||
appVerBuild = v.findViewById(R.id.appVerBuild);
|
appVerBuild = v.findViewById(R.id.appVerBuild);
|
||||||
TextView viewTextGiteaVersion = v.findViewById(R.id.giteaVersion);
|
TextView viewTextGiteaVersion = v.findViewById(R.id.giteaVersion);
|
||||||
|
creditsButton = v.findViewById(R.id.creditsButton);
|
||||||
donationLink = v.findViewById(R.id.donationLink);
|
donationLink = v.findViewById(R.id.donationLink);
|
||||||
donationLinkPatreon = v.findViewById(R.id.donationLinkPatreon);
|
donationLinkPatreon = v.findViewById(R.id.donationLinkPatreon);
|
||||||
translateLink = v.findViewById(R.id.translateLink);
|
translateLink = v.findViewById(R.id.translateLink);
|
||||||
|
sponsorsButton = v.findViewById(R.id.sponsorsButton);
|
||||||
appWebsite = v.findViewById(R.id.appWebsite);
|
appWebsite = v.findViewById(R.id.appWebsite);
|
||||||
appRepo = v.findViewById(R.id.appRepo);
|
appRepo = v.findViewById(R.id.appRepo);
|
||||||
|
|
||||||
appVerBuild.setText(getString(R.string.appVerBuild, AppUtil.getAppVersion(Objects.requireNonNull(getContext())), AppUtil.getAppBuildNo(getContext())));
|
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 intent = new Intent();
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||||
intent.setData(Uri.parse(getResources().getString(R.string.supportLink)));
|
intent.setData(Uri.parse(getResources().getString(R.string.supportLink)));
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
donationLinkPatreon.setOnClickListener(v12 -> {
|
donationLinkPatreon.setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||||
intent.setData(Uri.parse(getResources().getString(R.string.supportLinkPatreon)));
|
intent.setData(Uri.parse(getResources().getString(R.string.supportLinkPatreon)));
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
translateLink.setOnClickListener(v13 -> {
|
translateLink.setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||||
intent.setData(Uri.parse(getResources().getString(R.string.crowdInLink)));
|
intent.setData(Uri.parse(getResources().getString(R.string.crowdInLink)));
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
appWebsite.setOnClickListener(v14 -> {
|
appWebsite.setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||||
intent.setData(Uri.parse(getResources().getString(R.string.appWebsiteLink)));
|
intent.setData(Uri.parse(getResources().getString(R.string.appWebsiteLink)));
|
||||||
startActivity(intent);
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Intent intent = new Intent();
|
creditsButton.setOnClickListener(new View.OnClickListener() {
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
public void onClick(View v) {
|
||||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
startActivity(new Intent(getContext(), CreditsActivity.class));
|
||||||
intent.setData(Uri.parse(getResources().getString(R.string.appRepoLink)));
|
}
|
||||||
startActivity(intent);
|
});
|
||||||
|
|
||||||
|
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");
|
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);
|
TextView createNewUser = v.findViewById(R.id.createNewUser);
|
||||||
|
|
||||||
createNewUser.setOnClickListener(v1 -> {
|
createNewUser.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
bmListener.onButtonClicked("newUser");
|
public void onClick(View v) {
|
||||||
dismiss();
|
bmListener.onButtonClicked("newUser");
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
@ -45,9 +47,9 @@ public class BottomSheetAdminUsersFragment extends BottomSheetDialogFragment {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
bmListener = (BottomSheetAdminUsersFragment.BottomSheetListener) context;
|
bmListener = (BottomSheetAdminUsersFragment.BottomSheetListener) context;
|
||||||
}
|
} catch (ClassCastException e) {
|
||||||
catch (ClassCastException e) {
|
throw new ClassCastException(context.toString()
|
||||||
throw new ClassCastException(context.toString() + " must implement BottomSheetListener");
|
+ " must implement BottomSheetListener");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,27 +26,15 @@ public class BottomSheetFileViewerFragment extends BottomSheetDialogFragment {
|
|||||||
View v = inflater.inflate(R.layout.bottom_sheet_file_viewer, container, false);
|
View v = inflater.inflate(R.layout.bottom_sheet_file_viewer, container, false);
|
||||||
|
|
||||||
TextView downloadFile = v.findViewById(R.id.downloadFile);
|
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
|
||||||
bmListener.onButtonClicked("downloadFile");
|
public void onClick(View v) {
|
||||||
dismiss();
|
bmListener.onButtonClicked("downloadFile");
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
deleteFile.setOnClickListener(v1 -> {
|
|
||||||
|
|
||||||
bmListener.onButtonClicked("deleteFile");
|
|
||||||
dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
editFile.setOnClickListener(v1 -> {
|
|
||||||
|
|
||||||
bmListener.onButtonClicked("editFile");
|
|
||||||
dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,12 +47,10 @@ public class BottomSheetFileViewerFragment extends BottomSheetDialogFragment {
|
|||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
bmListener = (BottomSheetFileViewerFragment.BottomSheetListener) context;
|
bmListener = (BottomSheetFileViewerFragment.BottomSheetListener) context;
|
||||||
}
|
} catch (ClassCastException e) {
|
||||||
catch (ClassCastException e) {
|
throw new ClassCastException(context.toString()
|
||||||
|
+ " must implement BottomSheetListener");
|
||||||
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 createTeam = v.findViewById(R.id.createTeam);
|
||||||
TextView createRepository = v.findViewById(R.id.createRepository);
|
TextView createRepository = v.findViewById(R.id.createRepository);
|
||||||
TextView copyOrgUrl = v.findViewById(R.id.copyOrgUrl);
|
|
||||||
|
|
||||||
createTeam.setOnClickListener(v1 -> {
|
createTeam.setOnClickListener(v1 -> {
|
||||||
|
|
||||||
@ -41,12 +40,6 @@ public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
|
|||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
copyOrgUrl.setOnClickListener(v1 -> {
|
|
||||||
|
|
||||||
bmListener.onButtonClicked("copyOrgUrl");
|
|
||||||
dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,10 +25,12 @@ public class BottomSheetProfileFragment extends BottomSheetDialogFragment {
|
|||||||
|
|
||||||
TextView addNewEmailAddress = v.findViewById(R.id.addNewEmailAddress);
|
TextView addNewEmailAddress = v.findViewById(R.id.addNewEmailAddress);
|
||||||
|
|
||||||
addNewEmailAddress.setOnClickListener(v1 -> {
|
addNewEmailAddress.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
startActivity(new Intent(getContext(), ProfileEmailActivity.class));
|
public void onClick(View v) {
|
||||||
dismiss();
|
startActivity(new Intent(getContext(), ProfileEmailActivity.class));
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
@ -40,7 +40,6 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
|||||||
TextView watchRepository = v.findViewById(R.id.watchRepository);
|
TextView watchRepository = v.findViewById(R.id.watchRepository);
|
||||||
TextView unWatchRepository = v.findViewById(R.id.unWatchRepository);
|
TextView unWatchRepository = v.findViewById(R.id.unWatchRepository);
|
||||||
TextView shareRepository = v.findViewById(R.id.shareRepository);
|
TextView shareRepository = v.findViewById(R.id.shareRepository);
|
||||||
TextView copyRepoUrl = v.findViewById(R.id.copyRepoUrl);
|
|
||||||
|
|
||||||
createLabel.setOnClickListener(v112 -> {
|
createLabel.setOnClickListener(v112 -> {
|
||||||
|
|
||||||
@ -94,12 +93,6 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
|||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
copyRepoUrl.setOnClickListener(copyUrl -> {
|
|
||||||
|
|
||||||
bmListener.onButtonClicked("copyRepoUrl");
|
|
||||||
dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
newFile.setOnClickListener(v17 -> {
|
newFile.setOnClickListener(v17 -> {
|
||||||
|
|
||||||
bmListener.onButtonClicked("newFile");
|
bmListener.onButtonClicked("newFile");
|
||||||
@ -169,9 +162,9 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
bmListener = (BottomSheetListener) context;
|
bmListener = (BottomSheetListener) context;
|
||||||
}
|
} catch (ClassCastException e) {
|
||||||
catch (ClassCastException e) {
|
throw new ClassCastException(context.toString()
|
||||||
throw new ClassCastException(context.toString() + " must implement BottomSheetListener");
|
+ " must implement BottomSheetListener");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,10 +19,14 @@ import org.mian.gitnex.activities.AddRemoveLabelsActivity;
|
|||||||
import org.mian.gitnex.activities.EditIssueActivity;
|
import org.mian.gitnex.activities.EditIssueActivity;
|
||||||
import org.mian.gitnex.activities.FileDiffActivity;
|
import org.mian.gitnex.activities.FileDiffActivity;
|
||||||
import org.mian.gitnex.activities.MergePullRequestActivity;
|
import org.mian.gitnex.activities.MergePullRequestActivity;
|
||||||
|
import org.mian.gitnex.helpers.PathsHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import io.mikael.urlbuilder.UrlBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -81,64 +85,117 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mergePullRequest.setOnClickListener(v13 -> {
|
mergePullRequest.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
startActivity(new Intent(ctx, MergePullRequestActivity.class));
|
@Override
|
||||||
dismiss();
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
startActivity(new Intent(ctx, MergePullRequestActivity.class));
|
||||||
|
dismiss();
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
openFilesDiff.setOnClickListener(v14 -> {
|
openFilesDiff.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
startActivity(new Intent(ctx, FileDiffActivity.class));
|
@Override
|
||||||
dismiss();
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
startActivity(new Intent(ctx, FileDiffActivity.class));
|
||||||
|
dismiss();
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
editIssue.setOnClickListener(v15 -> {
|
editIssue.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
startActivity(new Intent(ctx, EditIssueActivity.class));
|
@Override
|
||||||
dismiss();
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
startActivity(new Intent(ctx, EditIssueActivity.class));
|
||||||
|
dismiss();
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
editLabels.setOnClickListener(v16 -> {
|
editLabels.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
startActivity(new Intent(ctx, AddRemoveLabelsActivity.class));
|
@Override
|
||||||
dismiss();
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
startActivity(new Intent(ctx, AddRemoveLabelsActivity.class));
|
||||||
|
dismiss();
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addRemoveAssignees.setOnClickListener(v17 -> {
|
addRemoveAssignees.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
startActivity(new Intent(ctx, AddRemoveAssigneesActivity.class));
|
@Override
|
||||||
dismiss();
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
startActivity(new Intent(ctx, AddRemoveAssigneesActivity.class));
|
||||||
|
dismiss();
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
shareIssue.setOnClickListener(v1 -> {
|
shareIssue.setOnClickListener(v1 -> {
|
||||||
|
|
||||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
try {
|
||||||
sharingIntent.setType("text/plain");
|
|
||||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.hash) + tinyDB.getString("issueNumber") + " " + tinyDB.getString("issueTitle"));
|
|
||||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, tinyDB.getString("singleIssueHtmlUrl"));
|
|
||||||
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.hash) + tinyDB.getString("issueNumber") + " " + tinyDB.getString("issueTitle")));
|
|
||||||
|
|
||||||
dismiss();
|
URI instanceUrl = new URI(tinyDB.getString("instanceUrlWithProtocol"));
|
||||||
|
|
||||||
|
String issuePath = PathsHelper.join(instanceUrl.getPath(), tinyDB.getString("repoFullName"), "/issues/", tinyDB.getString("issueNumber"));
|
||||||
|
|
||||||
|
String issueUrl = UrlBuilder.fromUri(instanceUrl)
|
||||||
|
.withPath(issuePath)
|
||||||
|
.toString();
|
||||||
|
|
||||||
|
// share issue
|
||||||
|
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||||
|
sharingIntent.setType("text/plain");
|
||||||
|
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.hash) + tinyDB.getString("issueNumber") + " " + tinyDB.getString("issueTitle"));
|
||||||
|
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, issueUrl);
|
||||||
|
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.hash) + tinyDB.getString("issueNumber") + " " + tinyDB.getString("issueTitle")));
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(URISyntaxException e) {
|
||||||
|
Toasty.error(ctx, getString(R.string.genericError));
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
copyIssueUrl.setOnClickListener(v12 -> {
|
copyIssueUrl.setOnClickListener(v12 -> {
|
||||||
|
|
||||||
// copy to clipboard
|
try {
|
||||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
|
||||||
ClipData clip = ClipData.newPlainText("issueUrl", tinyDB.getString("singleIssueHtmlUrl"));
|
|
||||||
assert clipboard != null;
|
|
||||||
clipboard.setPrimaryClip(clip);
|
|
||||||
|
|
||||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
URI instanceUrl = new URI(tinyDB.getString("instanceUrlWithProtocol"));
|
||||||
|
|
||||||
dismiss();
|
String issuePath = PathsHelper.join(instanceUrl.getPath(), tinyDB.getString("repoFullName"), "/issues/", tinyDB.getString("issueNumber"));
|
||||||
|
|
||||||
|
String issueUrl = UrlBuilder.fromUri(instanceUrl)
|
||||||
|
.withPath(issuePath)
|
||||||
|
.toString();
|
||||||
|
|
||||||
|
// copy to clipboard
|
||||||
|
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
ClipData clip = ClipData.newPlainText("issueUrl", issueUrl);
|
||||||
|
assert clipboard != null;
|
||||||
|
clipboard.setPrimaryClip(clip);
|
||||||
|
|
||||||
|
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(URISyntaxException e) {
|
||||||
|
Toasty.error(ctx, getString(R.string.genericError));
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -122,11 +122,11 @@ public class DraftsFragment extends Fragment {
|
|||||||
DraftsApi.deleteAllDrafts(accountId);
|
DraftsApi.deleteAllDrafts(accountId);
|
||||||
draftsList_.clear();
|
draftsList_.clear();
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
Toasty.success(ctx, getResources().getString(R.string.draftsDeleteSuccess));
|
Toasty.info(ctx, getResources().getString(R.string.draftsDeleteSuccess));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -29,8 +30,9 @@ import retrofit2.Callback;
|
|||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template Author Author M M Arif
|
* + * Template Author M M Arif
|
||||||
* Author 6543
|
* + * Author 6543
|
||||||
|
* +
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ExploreRepositoriesFragment extends Fragment {
|
public class ExploreRepositoriesFragment extends Fragment {
|
||||||
@ -90,19 +92,23 @@ public class ExploreRepositoriesFragment extends Fragment {
|
|||||||
|
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
searchKeyword.setOnEditorActionListener((v1, actionId, event) -> {
|
searchKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
|
|
||||||
if(actionId == EditorInfo.IME_ACTION_SEND) {
|
@Override
|
||||||
if(!searchKeyword.getText().toString().equals("")) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
|
||||||
mRecyclerView.setVisibility(View.GONE);
|
if(actionId == EditorInfo.IME_ACTION_SEND) {
|
||||||
loadSearchReposList(instanceUrl, instanceToken, loginUid, searchKeyword.getText().toString(), repoTypeInclude, sort, order, getContext(), limit);
|
if(!searchKeyword.getText().toString().equals("")) {
|
||||||
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
mRecyclerView.setVisibility(View.GONE);
|
||||||
|
loadSearchReposList(instanceUrl, instanceToken, loginUid, searchKeyword.getText().toString(), repoTypeInclude, sort, order, getContext(), limit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
int limitDefault = 25;
|
int limitDefault = 10;
|
||||||
loadDefaultList(instanceUrl, instanceToken, loginUid, repoTypeInclude, sort, order, getContext(), limitDefault);
|
loadDefaultList(instanceUrl, instanceToken, loginUid, repoTypeInclude, sort, order, getContext(), limitDefault);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
@ -55,7 +55,6 @@ public class IssuesFragment extends Fragment {
|
|||||||
private TextView noDataIssues;
|
private TextView noDataIssues;
|
||||||
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||||
private String requestType = StaticGlobalVariables.issuesRequestType;
|
private String requestType = StaticGlobalVariables.issuesRequestType;
|
||||||
private ProgressBar progressLoadMore;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
@ -84,7 +83,6 @@ public class IssuesFragment extends Fragment {
|
|||||||
recyclerView = v.findViewById(R.id.recyclerView);
|
recyclerView = v.findViewById(R.id.recyclerView);
|
||||||
issuesList = new ArrayList<>();
|
issuesList = new ArrayList<>();
|
||||||
|
|
||||||
progressLoadMore = v.findViewById(R.id.progressLoadMore);
|
|
||||||
mProgressBar = v.findViewById(R.id.progress_bar);
|
mProgressBar = v.findViewById(R.id.progress_bar);
|
||||||
noDataIssues = v.findViewById(R.id.noDataIssues);
|
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) {
|
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);
|
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) {
|
if(response.code() == 200) {
|
||||||
|
|
||||||
|
//remove loading view
|
||||||
|
issuesList.remove(issuesList.size() - 1);
|
||||||
|
|
||||||
List<Issues> result = response.body();
|
List<Issues> result = response.body();
|
||||||
|
|
||||||
assert result != null;
|
assert result != null;
|
||||||
@ -250,13 +253,12 @@ public class IssuesFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.warning(context, getString(R.string.noMoreData));
|
Toasty.info(context, getString(R.string.noMoreData));
|
||||||
adapter.setMoreDataAvailable(false);
|
adapter.setMoreDataAvailable(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
progressLoadMore.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -10,7 +10,6 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.GridView;
|
import android.widget.GridView;
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -40,7 +39,6 @@ public class MembersByOrgFragment extends Fragment {
|
|||||||
private String orgName;
|
private String orgName;
|
||||||
private MembersByOrgAdapter adapter;
|
private MembersByOrgAdapter adapter;
|
||||||
private GridView mGridView;
|
private GridView mGridView;
|
||||||
private ProgressBar progressBar;
|
|
||||||
|
|
||||||
public MembersByOrgFragment() {
|
public MembersByOrgFragment() {
|
||||||
}
|
}
|
||||||
@ -74,7 +72,6 @@ public class MembersByOrgFragment extends Fragment {
|
|||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
noDataMembers = v.findViewById(R.id.noDataMembers);
|
noDataMembers = v.findViewById(R.id.noDataMembers);
|
||||||
|
|
||||||
progressBar = v.findViewById(R.id.progressBar);
|
|
||||||
mGridView = v.findViewById(R.id.gridView);
|
mGridView = v.findViewById(R.id.gridView);
|
||||||
|
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
||||||
@ -99,8 +96,6 @@ public class MembersByOrgFragment extends Fragment {
|
|||||||
mGridView.setAdapter(adapter);
|
mGridView.setAdapter(adapter);
|
||||||
noDataMembers.setVisibility(View.VISIBLE);
|
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) {
|
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);
|
Call<List<Milestones>> call = api.getMilestones(token, repoOwner, repoName, page, resultLimit, milestoneState);
|
||||||
|
|
||||||
@ -249,7 +251,6 @@ public class MilestonesFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
viewBinding.progressLoadMore.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -11,6 +11,7 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -22,7 +23,6 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.CreateRepoActivity;
|
import org.mian.gitnex.activities.CreateRepoActivity;
|
||||||
import org.mian.gitnex.adapters.MyReposListAdapter;
|
import org.mian.gitnex.adapters.MyReposListAdapter;
|
||||||
@ -45,7 +45,7 @@ public class MyRepositoriesFragment extends Fragment {
|
|||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
private MyReposListAdapter adapter;
|
private MyReposListAdapter adapter;
|
||||||
private ExtendedFloatingActionButton createNewRepo;
|
private ImageView createNewRepo;
|
||||||
private TextView noDataMyRepo;
|
private TextView noDataMyRepo;
|
||||||
|
|
||||||
private int pageSize = 1;
|
private int pageSize = 1;
|
||||||
@ -105,10 +105,15 @@ public class MyRepositoriesFragment extends Fragment {
|
|||||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
createNewRepo = v.findViewById(R.id.addNewRepo);
|
createNewRepo = v.findViewById(R.id.addNewRepo);
|
||||||
createNewRepo.setOnClickListener(view -> {
|
createNewRepo.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
Intent intent = new Intent(view.getContext(), CreateRepoActivity.class);
|
@Override
|
||||||
startActivity(intent);
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
Intent intent = new Intent(view.getContext(), CreateRepoActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -130,11 +135,18 @@ public class MyRepositoriesFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> {
|
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
|
@Override
|
||||||
swipeRefresh.setRefreshing(false);
|
public void onRefresh() {
|
||||||
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, getContext(), pageSize, resultLimit);
|
new Handler().postDelayed(new Runnable() {
|
||||||
}, 50));
|
@Override
|
||||||
|
public void run() {
|
||||||
|
swipeRefresh.setRefreshing(false);
|
||||||
|
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, getContext(), pageSize, resultLimit);
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, pageSize, resultLimit);
|
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.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -19,7 +21,6 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.actions.NotificationsActions;
|
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.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.InfiniteScrollListener;
|
import org.mian.gitnex.helpers.InfiniteScrollListener;
|
||||||
|
import org.mian.gitnex.helpers.SnackBar;
|
||||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
|
||||||
import org.mian.gitnex.models.NotificationThread;
|
import org.mian.gitnex.models.NotificationThread;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -51,8 +52,9 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
|||||||
private NotificationsAdapter notificationsAdapter;
|
private NotificationsAdapter notificationsAdapter;
|
||||||
private NotificationsActions notificationsActions;
|
private NotificationsActions notificationsActions;
|
||||||
|
|
||||||
private ExtendedFloatingActionButton markAllAsRead;
|
private ImageView markAllAsRead;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
|
private RelativeLayout mainLayout;
|
||||||
private ProgressBar loadingMoreView;
|
private ProgressBar loadingMoreView;
|
||||||
private TextView noDataNotifications;
|
private TextView noDataNotifications;
|
||||||
private SwipeRefreshLayout pullToRefresh;
|
private SwipeRefreshLayout pullToRefresh;
|
||||||
@ -86,6 +88,7 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
|||||||
pageResultLimit = StaticGlobalVariables.getCurrentResultLimit(context);
|
pageResultLimit = StaticGlobalVariables.getCurrentResultLimit(context);
|
||||||
tinyDB.putString("notificationsFilterState", currentFilterMode);
|
tinyDB.putString("notificationsFilterState", currentFilterMode);
|
||||||
|
|
||||||
|
mainLayout = v.findViewById(R.id.mainLayout);
|
||||||
markAllAsRead = v.findViewById(R.id.markAllAsRead);
|
markAllAsRead = v.findViewById(R.id.markAllAsRead);
|
||||||
noDataNotifications = v.findViewById(R.id.noDataNotifications);
|
noDataNotifications = v.findViewById(R.id.noDataNotifications);
|
||||||
loadingMoreView = v.findViewById(R.id.loadingMoreView);
|
loadingMoreView = v.findViewById(R.id.loadingMoreView);
|
||||||
@ -147,7 +150,7 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
|||||||
|
|
||||||
activity.runOnUiThread(() -> {
|
activity.runOnUiThread(() -> {
|
||||||
|
|
||||||
Toasty.success(context, getString(R.string.markedNotificationsAsRead));
|
SnackBar.info(context, mainLayout, getString(R.string.markedNotificationsAsRead));
|
||||||
loadNotifications(true);
|
loadNotifications(true);
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -155,7 +158,7 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
|||||||
}
|
}
|
||||||
catch(IOException e) {
|
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());
|
Log.e("onError", e.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -21,7 +22,6 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.CreateOrganizationActivity;
|
import org.mian.gitnex.activities.CreateOrganizationActivity;
|
||||||
import org.mian.gitnex.adapters.OrganizationsListAdapter;
|
import org.mian.gitnex.adapters.OrganizationsListAdapter;
|
||||||
@ -42,7 +42,7 @@ public class OrganizationsFragment extends Fragment {
|
|||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
private OrganizationsListAdapter adapter;
|
private OrganizationsListAdapter adapter;
|
||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
private ExtendedFloatingActionButton createNewOrganization;
|
private ImageView createNewOrganization;
|
||||||
private TextView noDataOrg;
|
private TextView noDataOrg;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -67,7 +67,7 @@ public class ProfileFragment extends Fragment {
|
|||||||
if(userLanguageCodes.length >= 2) {
|
if(userLanguageCodes.length >= 2) {
|
||||||
|
|
||||||
Locale locale = new Locale(userLanguageCodes[0], userLanguageCodes[1]);
|
Locale locale = new Locale(userLanguageCodes[0], userLanguageCodes[1]);
|
||||||
userLanguage.setText(locale.getDisplayLanguage());
|
userLanguage.setText(locale.getDisplayCountry());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
@ -55,7 +55,6 @@ public class PullRequestsFragment extends Fragment {
|
|||||||
private int pageSize = StaticGlobalVariables.prPageInit;
|
private int pageSize = StaticGlobalVariables.prPageInit;
|
||||||
private TextView noData;
|
private TextView noData;
|
||||||
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||||
private ProgressBar progressLoadMore;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
@ -84,7 +83,6 @@ public class PullRequestsFragment extends Fragment {
|
|||||||
recyclerView = v.findViewById(R.id.recyclerView);
|
recyclerView = v.findViewById(R.id.recyclerView);
|
||||||
prList = new ArrayList<>();
|
prList = new ArrayList<>();
|
||||||
|
|
||||||
progressLoadMore = v.findViewById(R.id.progressLoadMore);
|
|
||||||
mProgressBar = v.findViewById(R.id.progress_bar);
|
mProgressBar = v.findViewById(R.id.progress_bar);
|
||||||
noData = v.findViewById(R.id.noData);
|
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) {
|
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);
|
Call<List<PullRequests>> call = apiPR.getPullRequests(token, repoOwner, repoName, page, prState, resultLimit);
|
||||||
|
|
||||||
@ -266,7 +266,6 @@ public class PullRequestsFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
progressLoadMore.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.mian.gitnex.fragments;
|
package org.mian.gitnex.fragments;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -20,10 +19,6 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.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.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
@ -148,9 +143,6 @@ public class RepoInfoFragment extends Fragment {
|
|||||||
repoFilenameExpandCollapse = v.findViewById(R.id.repoFilenameExpandCollapse);
|
repoFilenameExpandCollapse = v.findViewById(R.id.repoFilenameExpandCollapse);
|
||||||
fileContentsFrameHeader = v.findViewById(R.id.fileContentsFrameHeader);
|
fileContentsFrameHeader = v.findViewById(R.id.fileContentsFrameHeader);
|
||||||
fileContentsFrame = v.findViewById(R.id.fileContentsFrame);
|
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);
|
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;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +327,7 @@ public class RepoInfoFragment extends Fragment {
|
|||||||
|
|
||||||
alertDialog.setTitle(getResources().getString(R.string.infoMoreInformation));
|
alertDialog.setTitle(getResources().getString(R.string.infoMoreInformation));
|
||||||
alertDialog.setView(view);
|
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();
|
alertDialog.create().show();
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -487,7 +456,7 @@ public class RepoInfoFragment extends Fragment {
|
|||||||
|
|
||||||
} else if (response.code() == 403) {
|
} 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) {
|
} else if (response.code() == 404) {
|
||||||
|
|
||||||
@ -496,7 +465,7 @@ public class RepoInfoFragment extends Fragment {
|
|||||||
|
|
||||||
} else {
|
} 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.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -21,7 +22,6 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.CreateRepoActivity;
|
import org.mian.gitnex.activities.CreateRepoActivity;
|
||||||
import org.mian.gitnex.adapters.ReposListAdapter;
|
import org.mian.gitnex.adapters.ReposListAdapter;
|
||||||
@ -42,7 +42,7 @@ public class RepositoriesFragment extends Fragment {
|
|||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
private ReposListAdapter adapter;
|
private ReposListAdapter adapter;
|
||||||
private ExtendedFloatingActionButton createNewRepo;
|
private ImageView createNewRepo;
|
||||||
private TextView noDataRepo;
|
private TextView noDataRepo;
|
||||||
private int pageSize = 1;
|
private int pageSize = 1;
|
||||||
private int resultLimit = 50;
|
private int resultLimit = 50;
|
||||||
@ -75,10 +75,14 @@ public class RepositoriesFragment extends Fragment {
|
|||||||
|
|
||||||
createNewRepo = v.findViewById(R.id.addNewRepo);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
Intent intent = new Intent(view.getContext(), CreateRepoActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
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
|
||||||
swipeRefresh.setRefreshing(false);
|
public void onRefresh() {
|
||||||
RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext(), pageSize, resultLimit);
|
new Handler().postDelayed(new Runnable() {
|
||||||
}, 50));
|
@Override
|
||||||
|
public void run() {
|
||||||
|
swipeRefresh.setRefreshing(false);
|
||||||
|
RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext(), pageSize, resultLimit);
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), pageSize, resultLimit);
|
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), pageSize, resultLimit);
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -22,7 +23,6 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.CreateRepoActivity;
|
import org.mian.gitnex.activities.CreateRepoActivity;
|
||||||
import org.mian.gitnex.adapters.StarredReposListAdapter;
|
import org.mian.gitnex.adapters.StarredReposListAdapter;
|
||||||
@ -45,7 +45,7 @@ public class StarredRepositoriesFragment extends Fragment {
|
|||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
private StarredReposListAdapter adapter;
|
private StarredReposListAdapter adapter;
|
||||||
private ExtendedFloatingActionButton createNewRepo;
|
private ImageView createNewRepo;
|
||||||
private TextView noData;
|
private TextView noData;
|
||||||
private int pageSize = 1;
|
private int pageSize = 1;
|
||||||
private int resultLimit = 50;
|
private int resultLimit = 50;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.mian.gitnex.fragments;
|
package org.mian.gitnex.fragments;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -12,9 +11,7 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.AddNewAccountActivity;
|
|
||||||
import org.mian.gitnex.adapters.UserAccountsAdapter;
|
import org.mian.gitnex.adapters.UserAccountsAdapter;
|
||||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||||
import org.mian.gitnex.database.models.UserAccount;
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
@ -32,7 +29,6 @@ public class UserAccountsFragment extends Fragment {
|
|||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
private UserAccountsApi userAccountsApi;
|
private UserAccountsApi userAccountsApi;
|
||||||
private List<UserAccount> userAccountsList;
|
private List<UserAccount> userAccountsList;
|
||||||
private ExtendedFloatingActionButton addNewAccount;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
@ -65,13 +61,6 @@ public class UserAccountsFragment extends Fragment {
|
|||||||
|
|
||||||
}, 250));
|
}, 250));
|
||||||
|
|
||||||
addNewAccount = v.findViewById(R.id.addNewAccount);
|
|
||||||
addNewAccount.setOnClickListener(view -> {
|
|
||||||
|
|
||||||
Intent intent = new Intent(view.getContext(), AddNewAccountActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
});
|
|
||||||
|
|
||||||
fetchDataAsync();
|
fetchDataAsync();
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
@ -22,7 +22,7 @@ public class AlertDialogs {
|
|||||||
.setMessage(message)
|
.setMessage(message)
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setIcon(R.drawable.ic_warning)
|
.setIcon(R.drawable.ic_warning)
|
||||||
.setNeutralButton(copyNegativeButton, (dialog, which) -> dialog.dismiss())
|
.setNegativeButton(copyNegativeButton, (dialog, which) -> dialog.dismiss())
|
||||||
.setPositiveButton(copyPositiveButton, (dialog, which) -> {
|
.setPositiveButton(copyPositiveButton, (dialog, which) -> {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = new TinyDB(context);
|
||||||
@ -76,7 +76,7 @@ public class AlertDialogs {
|
|||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
})
|
})
|
||||||
.setNeutralButton(negativeButton, null).show();
|
.setNegativeButton(negativeButton, null).show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class AlertDialogs {
|
|||||||
.setTitle(title + userNameMain)
|
.setTitle(title + userNameMain)
|
||||||
.setMessage(message)
|
.setMessage(message)
|
||||||
.setPositiveButton(positiveButton, (dialog, whichButton) -> CollaboratorActions.deleteCollaborator(context, searchKeyword, userNameMain))
|
.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)
|
.setTitle(title + userNameMain)
|
||||||
.setMessage(message)
|
.setMessage(message)
|
||||||
.setPositiveButton(positiveButton, (dialog, whichButton) -> TeamActions.addTeamMember(context, userNameMain, teamId))
|
.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)
|
.setTitle(title + userNameMain)
|
||||||
.setMessage(message)
|
.setMessage(message)
|
||||||
.setPositiveButton(positiveButton, (dialog, whichButton) -> TeamActions.removeTeamMember(context, userNameMain, teamId))
|
.setPositiveButton(positiveButton, (dialog, whichButton) -> TeamActions.removeTeamMember(context, userNameMain, teamId))
|
||||||
.setNeutralButton(negativeButton, null).show();
|
.setNegativeButton(negativeButton, null).show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ public class ChangeLog {
|
|||||||
|
|
||||||
static final private String TAG = "ChangeLog";
|
static final private String TAG = "ChangeLog";
|
||||||
static final private String CHANGELOG_XML_NODE = "changelog";
|
static final private String CHANGELOG_XML_NODE = "changelog";
|
||||||
|
|
||||||
private Activity changelogActivity;
|
private Activity changelogActivity;
|
||||||
|
|
||||||
public ChangeLog(Activity context) {
|
public ChangeLog(Activity context) {
|
||||||
changelogActivity = context;
|
changelogActivity = context;
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ public class ChangeLog {
|
|||||||
androidx.appcompat.app.AlertDialog.Builder builder = new AlertDialog.Builder(changelogActivity);
|
androidx.appcompat.app.AlertDialog.Builder builder = new AlertDialog.Builder(changelogActivity);
|
||||||
builder.setTitle(R.string.changelogTitle);
|
builder.setTitle(R.string.changelogTitle);
|
||||||
builder.setMessage(Html.fromHtml("<small>" + changelogMessage + "</small>"));
|
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.setCancelable(false);
|
||||||
builder.create();
|
builder.create();
|
||||||
builder.show();
|
builder.show();
|
||||||
|
@ -27,7 +27,7 @@ public class ClickListener implements View.OnClickListener {
|
|||||||
{
|
{
|
||||||
|
|
||||||
LayoutInflater inflater1 = LayoutInflater.from(mCtx);
|
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));
|
(ViewGroup) v.findViewById(R.id.custom_toast_container));
|
||||||
|
|
||||||
TextView text = layout.findViewById(R.id.toastText);
|
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) {
|
public static void info(Context context, String message) {
|
||||||
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(context);
|
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);
|
TextView text = view.findViewById(R.id.toastText);
|
||||||
text.setText(message);
|
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.Commits;
|
||||||
import org.mian.gitnex.models.CreateIssue;
|
import org.mian.gitnex.models.CreateIssue;
|
||||||
import org.mian.gitnex.models.CreateLabel;
|
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.Emails;
|
||||||
import org.mian.gitnex.models.ExploreRepositories;
|
import org.mian.gitnex.models.ExploreRepositories;
|
||||||
import org.mian.gitnex.models.Files;
|
import org.mian.gitnex.models.Files;
|
||||||
@ -41,7 +39,6 @@ import retrofit2.Call;
|
|||||||
import retrofit2.http.Body;
|
import retrofit2.http.Body;
|
||||||
import retrofit2.http.DELETE;
|
import retrofit2.http.DELETE;
|
||||||
import retrofit2.http.GET;
|
import retrofit2.http.GET;
|
||||||
import retrofit2.http.HTTP;
|
|
||||||
import retrofit2.http.Header;
|
import retrofit2.http.Header;
|
||||||
import retrofit2.http.PATCH;
|
import retrofit2.http.PATCH;
|
||||||
import retrofit2.http.POST;
|
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
|
@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);
|
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
|
@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);
|
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
|
@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);
|
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 int id;
|
||||||
private String url;
|
private String url;
|
||||||
private String html_url;
|
|
||||||
private int number;
|
private int number;
|
||||||
private String title;
|
private String title;
|
||||||
private String body;
|
private String body;
|
||||||
@ -32,7 +31,7 @@ public class Issues {
|
|||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class userObject {
|
public class userObject {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String login;
|
private String login;
|
||||||
@ -72,7 +71,7 @@ public class Issues {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class labelsObject {
|
public class labelsObject {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
@ -96,7 +95,7 @@ public class Issues {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class pullRequestObject {
|
public class pullRequestObject {
|
||||||
|
|
||||||
private boolean merged;
|
private boolean merged;
|
||||||
private String merged_at;
|
private String merged_at;
|
||||||
@ -110,7 +109,7 @@ public class Issues {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class milestoneObject {
|
public class milestoneObject {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String title;
|
private String title;
|
||||||
@ -154,7 +153,7 @@ public class Issues {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class assigneesObject {
|
public class assigneesObject {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String login;
|
private String login;
|
||||||
@ -257,14 +256,4 @@ public class Issues {
|
|||||||
return assignees;
|
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;
|
this.new_branch = new_branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class authorObject {
|
public class authorObject {
|
||||||
|
|
||||||
private String email;
|
private String email;
|
||||||
private String name;
|
private String name;
|
||||||
@ -68,7 +68,7 @@ public class NewFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class committerObject {
|
public class committerObject {
|
||||||
|
|
||||||
private String email;
|
private String email;
|
||||||
private String name;
|
private String name;
|
||||||
@ -96,4 +96,4 @@ public class NewFile {
|
|||||||
this.message = message;
|
this.message = message;
|
||||||
this.new_branch = new_branch;
|
this.new_branch = new_branch;
|
||||||
}
|
}
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user