Compare commits
68 Commits
release-2.
...
2.3.2
Author | SHA1 | Date | |
---|---|---|---|
1e7572d0ea | |||
2e6d07860f | |||
01498d6b0d | |||
3e016dc90f | |||
52b65f8bed | |||
e2b607d013 | |||
82977c7a53 | |||
9729ebdc99 | |||
3ed5ddc6e8 | |||
7019268512 | |||
22b88bc4f4 | |||
b2565c7c62 | |||
7d4ffe43dc | |||
3c12c9261d | |||
308bc033fa | |||
4fae271b09 | |||
13a0b55612 | |||
94d4dbf440 | |||
82034273c4 | |||
cf22a5d5fa | |||
fde33dbc3e | |||
85a7fddc49 | |||
25fbc4b017 | |||
fc02b652f5 | |||
a32e11c172 | |||
51dc31ef15 | |||
5b4cb3ff8e | |||
0daf0d1110 | |||
533be20f46 | |||
8b88dca833 | |||
94d6334e52 | |||
79f6a2435b | |||
9f5eceff0e | |||
f9550ad115 | |||
7e8a2722ac | |||
51da8b9c4d | |||
29fb2631cb | |||
126d1d0896 | |||
b6c0e94ee9 | |||
80445952b1 | |||
d61fb8a0c6 | |||
51c88e9f45 | |||
463961800f | |||
04073ac873 | |||
26b93a4280 | |||
71be20b1b9 | |||
9f833259f7 | |||
d184bdca12 | |||
15b320f4bd | |||
fdc1514f5f | |||
67f4283cb9 | |||
fc2b09b91c | |||
eb38df745c | |||
8787f8d9eb | |||
7e3eef90d2 | |||
c4b0b596d3 | |||
2aaf0eb103 | |||
f9d51094e4 | |||
96ab992264 | |||
bc2b609585 | |||
2a05d4e24b | |||
fb9d101283 | |||
ef2f5a9667 | |||
d14ecd9c68 | |||
d29b1901c0 | |||
6d7fcd8430 | |||
b6ca7bf2a4 | |||
67add714b3 |
@ -3,20 +3,33 @@ This part lists all PUBLIC individuals having contributed content to the code.
|
|||||||
|
|
||||||
* M M Arif (mmarif)
|
* M M Arif (mmarif)
|
||||||
* 6543
|
* 6543
|
||||||
|
* Unpublished
|
||||||
|
|
||||||
# Translators
|
# Translators
|
||||||
This part lists all PUBLIC individuals having contributed content to the translation.
|
This part lists all PUBLIC individuals having contributed content to the translation.
|
||||||
*Entries are in alphabetical order*
|
*Entries are in alphabetical order*
|
||||||
|
|
||||||
* 6543
|
* 6543
|
||||||
|
* acrylicpaintboy
|
||||||
|
* Antoine GIRARD (sapk)
|
||||||
|
* BaRaN6161_TURK
|
||||||
* ButterflyOfFire (BoFFire)
|
* ButterflyOfFire (BoFFire)
|
||||||
|
* dadosch
|
||||||
|
* erardiflorian
|
||||||
* IndeedNotJames
|
* IndeedNotJames
|
||||||
|
* jaqra
|
||||||
|
* ljoonal
|
||||||
* Lunny Xiao (xiaolunwen)
|
* Lunny Xiao (xiaolunwen)
|
||||||
|
* lxs
|
||||||
|
* Marcos de Oliveira (markkrj)
|
||||||
* mmarif
|
* mmarif
|
||||||
* Nadezhda Moiseeva (digitalkiller)
|
* Nadezhda Moiseeva (digitalkiller)
|
||||||
|
* Oleg Popenkov (FanHamMer)
|
||||||
* PsychotherapistSam
|
* PsychotherapistSam
|
||||||
* Rodion Borisov (vintproykt)
|
* Rodion Borisov (vintproykt)
|
||||||
|
* s4ne
|
||||||
* valeriezhao1013
|
* valeriezhao1013
|
||||||
|
* Vladislav Glinsky (cl0ne)
|
||||||
* Voyvode
|
* Voyvode
|
||||||
|
|
||||||
**Thank you for all your work** :+1:
|
**Thank you for all your work** :+1:
|
||||||
|
19
README.md
19
README.md
@ -19,7 +19,7 @@ No trackers are used and source code is available here for anyone to audit.
|
|||||||
[<img alt='Download APK' src='https://gitnex.com/img/download-apk.png' height="80"/>](https://gitea.com/gitnex/GitNex/releases)
|
[<img alt='Download APK' src='https://gitnex.com/img/download-apk.png' height="80"/>](https://gitea.com/gitnex/GitNex/releases)
|
||||||
|
|
||||||
## Note about Gitea version
|
## Note about Gitea version
|
||||||
Please make sure that you are on Gitea **1.9.x** stable release or later. Below this may not work as one would expect because of the newly added objects to the API at later versions. Please consider updating your Gitea server.
|
Please make sure that you are on Gitea **1.10.x** stable release or later. Below this may not work as one would expect because of the newly added objects to the API at later versions. Please consider updating your Gitea server.
|
||||||
|
|
||||||
Check the versions [compatibility page](https://gitea.com/gitnex/GitNex/wiki/Compatibility) which lists all the supported versions with compatibility ratio.
|
Check the versions [compatibility page](https://gitea.com/gitnex/GitNex/wiki/Compatibility) which lists all the supported versions with compatibility ratio.
|
||||||
|
|
||||||
@ -29,12 +29,12 @@ 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
|
||||||
- My Repositories
|
- File and directory browser
|
||||||
- Repositories list
|
- Create files
|
||||||
- Organizations list
|
- Explore repositories
|
||||||
- Create repository
|
|
||||||
- Create organization
|
|
||||||
- Issues list
|
- Issues list
|
||||||
|
- Pull requests
|
||||||
|
- Merge pull request
|
||||||
- [MANY MORE](https://gitea.com/gitnex/GitNex/wiki/Features)
|
- [MANY MORE](https://gitea.com/gitnex/GitNex/wiki/Features)
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
@ -83,6 +83,11 @@ Open source libraries
|
|||||||
- Abumoallim/android-multi-select-dialog
|
- Abumoallim/android-multi-select-dialog
|
||||||
- Pes/materialcolorpicker
|
- Pes/materialcolorpicker
|
||||||
- Hendraanggrian/socialview
|
- Hendraanggrian/socialview
|
||||||
- Fython/BreadcrumbsView
|
- HamidrezaAmz/BreadcrumbsView
|
||||||
|
- Chrisbanes/PhotoView
|
||||||
|
- Pddstudio/highlightjs-android
|
||||||
|
- Apache/commons-io
|
||||||
|
- Caverock/androidsvg
|
||||||
|
- Droidsonroids.gif/android-gif-drawable
|
||||||
|
|
||||||
[Follow me on Fediverse - mastodon.social/@mmarif](https://mastodon.social/@mmarif)
|
[Follow me on Fediverse - mastodon.social/@mmarif](https://mastodon.social/@mmarif)
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 29
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "org.mian.gitnex"
|
applicationId "org.mian.gitnex"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 28
|
targetSdkVersion 29
|
||||||
versionCode 72
|
versionCode 82
|
||||||
versionName "2.2.2"
|
versionName "2.3.2"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@ -23,30 +23,29 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
def lifecycle_version = "2.2.0-beta01"
|
def lifecycle_version = "2.2.0-rc02"
|
||||||
final def markwon_version = "4.1.1"
|
final def markwon_version = "4.1.1"
|
||||||
|
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
implementation "androidx.appcompat:appcompat:1.1.0"
|
||||||
implementation 'com.google.android.material:material:1.1.0-beta01'
|
implementation "com.google.android.material:material:1.2.0-alpha02"
|
||||||
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"
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation "junit:junit:4.12"
|
||||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
androidTestImplementation "androidx.test:runner:1.2.0"
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
|
||||||
implementation 'com.github.vihtarb:tooltip:0.2.0'
|
implementation "com.github.vihtarb:tooltip:0.2.0"
|
||||||
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
|
implementation "com.squareup.okhttp3:okhttp:3.12.1"
|
||||||
implementation 'com.google.code.gson:gson:2.8.5'
|
implementation "com.google.code.gson:gson:2.8.5"
|
||||||
implementation 'com.squareup.picasso:picasso:2.71828'
|
implementation "com.squareup.picasso:picasso:2.71828"
|
||||||
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
implementation "com.amulyakhare:com.amulyakhare.textdrawable:1.0.1"
|
||||||
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
|
implementation "com.squareup.retrofit2:retrofit:2.5.0"
|
||||||
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
|
implementation "com.squareup.retrofit2:converter-gson:2.5.0"
|
||||||
implementation 'com.squareup.retrofit2:converter-scalars:2.5.0'
|
implementation "com.squareup.retrofit2:converter-scalars:2.5.0"
|
||||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.1'
|
implementation "com.squareup.okhttp3:logging-interceptor:3.12.1"
|
||||||
implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
|
implementation "org.ocpsoft.prettytime:prettytime:4.0.1.Final"
|
||||||
implementation "com.vdurmont:emoji-java:4.0.0"
|
implementation "com.vdurmont:emoji-java:4.0.0"
|
||||||
implementation "com.pes.materialcolorpicker:library:1.2.5"
|
implementation "com.pes.materialcolorpicker:library:1.2.5"
|
||||||
|
|
||||||
implementation "io.noties.markwon:core:$markwon_version"
|
implementation "io.noties.markwon:core:$markwon_version"
|
||||||
implementation "io.noties.markwon:ext-latex:$markwon_version"
|
implementation "io.noties.markwon:ext-latex:$markwon_version"
|
||||||
implementation "io.noties.markwon:ext-strikethrough:$markwon_version"
|
implementation "io.noties.markwon:ext-strikethrough:$markwon_version"
|
||||||
@ -61,13 +60,13 @@ dependencies {
|
|||||||
implementation "io.noties.markwon:simple-ext:$markwon_version"
|
implementation "io.noties.markwon:simple-ext:$markwon_version"
|
||||||
implementation "io.noties.markwon:syntax-highlight:$markwon_version"
|
implementation "io.noties.markwon:syntax-highlight:$markwon_version"
|
||||||
implementation "com.caverock:androidsvg:1.4"
|
implementation "com.caverock:androidsvg:1.4"
|
||||||
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.14"
|
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.19"
|
||||||
|
|
||||||
implementation "com.hendraanggrian.appcompat:socialview:0.2"
|
implementation "com.hendraanggrian.appcompat:socialview:0.2"
|
||||||
implementation "com.hendraanggrian.appcompat:socialview-commons:0.2"
|
implementation "com.hendraanggrian.appcompat:socialview-commons:0.2"
|
||||||
|
|
||||||
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
|
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
|
||||||
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
|
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
|
||||||
|
|
||||||
implementation "com.github.HamidrezaAmz:BreadcrumbsView:0.2.9"
|
implementation "com.github.HamidrezaAmz:BreadcrumbsView:0.2.9"
|
||||||
|
implementation "commons-io:commons-io:2.6"
|
||||||
|
implementation "com.github.chrisbanes:PhotoView:2.3.0"
|
||||||
|
implementation "com.pddstudio:highlightjs-android:1.5.0"
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.mian.gitnex">
|
package="org.mian.gitnex">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/app_logo"
|
android:icon="@mipmap/app_logo"
|
||||||
@ -10,9 +13,10 @@
|
|||||||
android:roundIcon="@mipmap/app_logo_round"
|
android:roundIcon="@mipmap/app_logo_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
|
<activity android:name=".activities.MergePullRequestActivity"></activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.FileViewActivity"
|
android:name=".activities.FileViewActivity"
|
||||||
android:theme="@style/AppTheme.NoActionBar"></activity>
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.NewFileActivity"
|
android:name=".activities.NewFileActivity"
|
||||||
android:theme="@style/AppTheme.NoActionBar" />
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
@ -66,9 +70,7 @@
|
|||||||
<activity android:name=".activities.NewRepoActivity" />
|
<activity android:name=".activities.NewRepoActivity" />
|
||||||
<activity android:name=".activities.NewOrganizationActivity" />
|
<activity android:name=".activities.NewOrganizationActivity" />
|
||||||
<activity android:name=".activities.OpenRepoInBrowserActivity" />
|
<activity android:name=".activities.OpenRepoInBrowserActivity" />
|
||||||
|
<activity android:name=".activities.FileDiffActivity" />
|
||||||
</application>
|
</application>
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -35,7 +35,7 @@ public class CollaboratorActions {
|
|||||||
Call<Collaborators> call;
|
Call<Collaborators> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, context)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.deleteCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName);
|
.deleteCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName);
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ public class CollaboratorActions {
|
|||||||
Call<Permission> call;
|
Call<Permission> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, context)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.addCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName, permissionString);
|
.addCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName, permissionString);
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class IssueActions {
|
|||||||
Call<IssueComments> call;
|
Call<IssueComments> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, context)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.patchIssueComment(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, commentId, commentBodyJson);
|
.patchIssueComment(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, commentId, commentBodyJson);
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ public class IssueActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, context)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.closeReopenIssue(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueStatJson);
|
.closeReopenIssue(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueStatJson);
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class RepositoryActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, context)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.starRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
.starRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ public class RepositoryActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, context)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.unStarRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
.unStarRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ public class RepositoryActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, context)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.watchRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
.watchRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ public class RepositoryActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, context)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.unWatchRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
.unWatchRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ import org.mian.gitnex.clients.RetrofitClient;
|
|||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.models.UserSearch;
|
import org.mian.gitnex.models.UserSearch;
|
||||||
import org.mian.gitnex.models.UserInfo;
|
import org.mian.gitnex.models.UserInfo;
|
||||||
import org.mian.gitnex.util.AppUtil;
|
|
||||||
import org.mian.gitnex.util.TinyDB;
|
import org.mian.gitnex.util.TinyDB;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -46,8 +46,6 @@ public class AddCollaboratorToRepositoryActivity extends AppCompatActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_add_collaborator_to_repository);
|
setContentView(R.layout.activity_add_collaborator_to_repository);
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
@ -81,7 +79,7 @@ public class AddCollaboratorToRepositoryActivity extends AppCompatActivity {
|
|||||||
public void loadUserSearchList(String instanceUrl, String token, String searchKeyword, final Context context, String loginUid) {
|
public void loadUserSearchList(String instanceUrl, String token, String searchKeyword, final Context context, String loginUid) {
|
||||||
|
|
||||||
Call<UserSearch> call = RetrofitClient
|
Call<UserSearch> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getUserBySearch(Authorization.returnAuthentication(getApplicationContext(), loginUid, token), searchKeyword, 10);
|
.getUserBySearch(Authorization.returnAuthentication(getApplicationContext(), loginUid, token), searchKeyword, 10);
|
||||||
|
|
||||||
@ -101,7 +99,7 @@ public class AddCollaboratorToRepositoryActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<UserSearch> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<UserSearch> call, @NonNull Throwable t) {
|
||||||
Log.i("onFailure", t.getMessage());
|
Log.i("onFailure", t.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -65,7 +65,7 @@ public class AddRemoveAssigneesActivity extends AppCompatActivity {
|
|||||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
|
|
||||||
Call<List<Collaborators>> call = RetrofitClient
|
Call<List<Collaborators>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ public class AddRemoveAssigneesActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
// get current issue assignees
|
// get current issue assignees
|
||||||
Call<Issues> callSingleIssueAssignees = RetrofitClient
|
Call<Issues> callSingleIssueAssignees = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getIssueByIndex(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
.getIssueByIndex(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ public class AddRemoveAssigneesActivity extends AppCompatActivity {
|
|||||||
Call<JsonElement> call3;
|
Call<JsonElement> call3;
|
||||||
|
|
||||||
call3 = RetrofitClient
|
call3 = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.patchIssueAssignee(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, updateAssigneeJson);
|
.patchIssueAssignee(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, updateAssigneeJson);
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class AddRemoveLabelsActivity extends AppCompatActivity {
|
|||||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
|
|
||||||
Call<List<Labels>> call = RetrofitClient
|
Call<List<Labels>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getlabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
.getlabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ public class AddRemoveLabelsActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
// get current issue labels
|
// get current issue labels
|
||||||
Call<List<Labels>> callSingleIssueLabels = RetrofitClient
|
Call<List<Labels>> callSingleIssueLabels = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getIssueLabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
.getIssueLabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ public class AddRemoveLabelsActivity extends AppCompatActivity {
|
|||||||
Labels patchIssueLabels = new Labels(issueLabels);
|
Labels patchIssueLabels = new Labels(issueLabels);
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
Call<JsonElement> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.updateIssueLabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, patchIssueLabels);
|
.updateIssueLabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, patchIssueLabels);
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -217,7 +218,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
|||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
Call<List<Collaborators>> call = RetrofitClient
|
Call<List<Collaborators>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||||
|
|
||||||
@ -248,7 +249,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
||||||
Log.i("onFailure", t.getMessage());
|
Log.i("onFailure", t.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -261,7 +262,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
|||||||
Call<JsonElement> call3;
|
Call<JsonElement> call3;
|
||||||
|
|
||||||
call3 = RetrofitClient
|
call3 = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.createNewIssue(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, createNewIssueJson);
|
.createNewIssue(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, createNewIssueJson);
|
||||||
|
|
||||||
@ -325,7 +326,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
|||||||
|
|
||||||
String msState = "open";
|
String msState = "open";
|
||||||
Call<List<Milestones>> call = RetrofitClient
|
Call<List<Milestones>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getMilestones(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, msState);
|
.getMilestones(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, msState);
|
||||||
|
|
||||||
@ -339,13 +340,13 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
|||||||
|
|
||||||
List<Milestones> milestonesList_ = response.body();
|
List<Milestones> milestonesList_ = response.body();
|
||||||
|
|
||||||
milestonesList.add(new Milestones(0,"No milestone"));
|
milestonesList.add(new Milestones(0,getString(R.string.issueCreatedNoMilestone)));
|
||||||
assert milestonesList_ != null;
|
assert milestonesList_ != null;
|
||||||
if(milestonesList_.size() > 0) {
|
if(milestonesList_.size() > 0) {
|
||||||
for (int i = 0; i < milestonesList_.size(); i++) {
|
for (int i = 0; i < milestonesList_.size(); i++) {
|
||||||
|
|
||||||
//String mStone = getString(R.string.spinnerMilestoneText, milestonesList_.get(i).getTitle(), milestonesList_.get(i).getState());
|
//Don't translate "open" is a enum
|
||||||
if(milestonesList_.get(i).getState().equals(getString(R.string.issueStatusOpen))) {
|
if(milestonesList_.get(i).getState().equals("open")) {
|
||||||
Milestones data = new Milestones(
|
Milestones data = new Milestones(
|
||||||
milestonesList_.get(i).getId(),
|
milestonesList_.get(i).getId(),
|
||||||
milestonesList_.get(i).getTitle()
|
milestonesList_.get(i).getTitle()
|
||||||
@ -379,7 +380,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
|||||||
private void getCollaborators(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
private void getCollaborators(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
||||||
|
|
||||||
Call<List<Collaborators>> call = RetrofitClient
|
Call<List<Collaborators>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||||
|
|
||||||
@ -449,7 +450,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
|||||||
private void getLabels(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
private void getLabels(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
||||||
|
|
||||||
Call<List<Labels>> call = RetrofitClient
|
Call<List<Labels>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getlabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
.getlabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import org.mian.gitnex.models.Labels;
|
|||||||
import org.mian.gitnex.util.AppUtil;
|
import org.mian.gitnex.util.AppUtil;
|
||||||
import org.mian.gitnex.util.TinyDB;
|
import org.mian.gitnex.util.TinyDB;
|
||||||
import org.mian.gitnex.viewmodels.LabelsViewModel;
|
import org.mian.gitnex.viewmodels.LabelsViewModel;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -55,9 +56,9 @@ public class CreateLabelActivity extends AppCompatActivity {
|
|||||||
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");
|
||||||
|
|
||||||
if(getIntent().getStringExtra("labelAction") != null && getIntent().getStringExtra("labelAction").equals("delete")) {
|
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("delete")) {
|
||||||
|
|
||||||
deleteLabel(instanceUrl, instanceToken, repoOwner, repoName, Integer.valueOf(getIntent().getStringExtra("labelId")), loginUid);
|
deleteLabel(instanceUrl, instanceToken, repoOwner, repoName, Integer.valueOf(Objects.requireNonNull(getIntent().getStringExtra("labelId"))), loginUid);
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -92,7 +93,7 @@ public class CreateLabelActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(getIntent().getStringExtra("labelAction") != null && getIntent().getStringExtra("labelAction").equals("edit")) {
|
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("edit")) {
|
||||||
|
|
||||||
labelName.setText(getIntent().getStringExtra("labelTitle"));
|
labelName.setText(getIntent().getStringExtra("labelTitle"));
|
||||||
int labelColor_ = Color.parseColor("#" + getIntent().getStringExtra("labelColor"));
|
int labelColor_ = Color.parseColor("#" + getIntent().getStringExtra("labelColor"));
|
||||||
@ -242,7 +243,7 @@ public class CreateLabelActivity extends AppCompatActivity {
|
|||||||
Call<CreateLabel> call;
|
Call<CreateLabel> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.createLabel(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, createLabelFunc);
|
.createLabel(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, createLabelFunc);
|
||||||
|
|
||||||
@ -296,7 +297,7 @@ public class CreateLabelActivity extends AppCompatActivity {
|
|||||||
Call<CreateLabel> call;
|
Call<CreateLabel> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.patchLabel(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, labelId, createLabelFunc);
|
.patchLabel(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, labelId, createLabelFunc);
|
||||||
|
|
||||||
@ -369,7 +370,7 @@ public class CreateLabelActivity extends AppCompatActivity {
|
|||||||
Call<Labels> call;
|
Call<Labels> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.deleteLabel(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, labelId);
|
.deleteLabel(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, labelId);
|
||||||
|
|
||||||
@ -382,7 +383,7 @@ public class CreateLabelActivity extends AppCompatActivity {
|
|||||||
if(response.code() == 204) {
|
if(response.code() == 204) {
|
||||||
|
|
||||||
Toasty.info(getApplicationContext(), getString(R.string.labelDeleteText));
|
Toasty.info(getApplicationContext(), getString(R.string.labelDeleteText));
|
||||||
LabelsViewModel.loadLabelsList(instanceUrl, instanceToken, repoOwner, repoName);
|
LabelsViewModel.loadLabelsList(instanceUrl, instanceToken, repoOwner, repoName, getApplicationContext());
|
||||||
getIntent().removeExtra("labelAction");
|
getIntent().removeExtra("labelAction");
|
||||||
getIntent().removeExtra("labelId");
|
getIntent().removeExtra("labelId");
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ public class CreateNewUserActivity extends AppCompatActivity {
|
|||||||
Call<UserInfo> call;
|
Call<UserInfo> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.createNewUser(instanceToken, createUser);
|
.createNewUser(instanceToken, createUser);
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ public class CreateReleaseActivity extends AppCompatActivity {
|
|||||||
Call<Releases> call;
|
Call<Releases> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.createNewRelease(token, repoOwner, repoName, createReleaseJson);
|
.createNewRelease(token, repoOwner, repoName, createReleaseJson);
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ public class CreateReleaseActivity extends AppCompatActivity {
|
|||||||
private void getBranches(String instanceUrl, String instanceToken, final String repoOwner, final String repoName) {
|
private void getBranches(String instanceUrl, String instanceToken, final String repoOwner, final String repoName) {
|
||||||
|
|
||||||
Call<List<Branches>> call = RetrofitClient
|
Call<List<Branches>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getBranches(instanceToken, repoOwner, repoName);
|
.getBranches(instanceToken, repoOwner, repoName);
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ public class CreateTeamByOrgActivity extends AppCompatActivity implements View.O
|
|||||||
Call<Teams> call3;
|
Call<Teams> call3;
|
||||||
|
|
||||||
call3 = RetrofitClient
|
call3 = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.createTeamsByOrg(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), orgName, createNewTeamJson);
|
.createTeamsByOrg(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), orgName, createNewTeamJson);
|
||||||
|
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.method.LinkMovementMethod;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
|
||||||
import org.mian.gitnex.R;
|
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
|
* Author M M Arif
|
||||||
@ -22,14 +28,28 @@ public class CreditsActivity extends AppCompatActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_credits);
|
setContentView(R.layout.activity_credits);
|
||||||
|
|
||||||
TextView creditKasun = findViewById(R.id.creditKasun);
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
|
||||||
creditKasun.setMovementMethod(LinkMovementMethod.getInstance());
|
|
||||||
|
|
||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
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(getApplicationContext()));
|
||||||
|
|
||||||
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
||||||
|
DividerItemDecoration.VERTICAL);
|
||||||
|
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
|
CreditsAdapter adapter = new CreditsAdapter(creditsList);
|
||||||
|
mRecyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
@ -100,7 +100,13 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
|||||||
editIssueButton.setOnClickListener(this);
|
editIssueButton.setOnClickListener(this);
|
||||||
|
|
||||||
if(!tinyDb.getString("issueNumber").isEmpty()) {
|
if(!tinyDb.getString("issueNumber").isEmpty()) {
|
||||||
toolbar_title.setText(getString(R.string.editIssueNavHeader, String.valueOf(issueIndex)));
|
|
||||||
|
if(tinyDb.getString("issueType").equals("pr")) {
|
||||||
|
toolbar_title.setText(getString(R.string.editPrNavHeader, String.valueOf(issueIndex)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
toolbar_title.setText(getString(R.string.editIssueNavHeader, String.valueOf(issueIndex)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
@ -122,7 +128,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
|||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
Call<List<Collaborators>> call = RetrofitClient
|
Call<List<Collaborators>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||||
|
|
||||||
@ -153,7 +159,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
||||||
Log.i("onFailure", t.getMessage());
|
Log.i("onFailure", t.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -229,7 +235,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
|||||||
CreateIssue issueData = new CreateIssue(title, description, dueDate, editIssueMilestoneId);
|
CreateIssue issueData = new CreateIssue(title, description, dueDate, editIssueMilestoneId);
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
Call<JsonElement> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.patchIssue(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, issueData);
|
.patchIssue(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, issueData);
|
||||||
|
|
||||||
@ -240,7 +246,13 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
|||||||
|
|
||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
Toasty.info(getApplicationContext(), getString(R.string.editIssueSuccessMessage));
|
if(tinyDb.getString("issueType").equals("pr")) {
|
||||||
|
Toasty.info(getApplicationContext(), getString(R.string.editPrSuccessMessage));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Toasty.info(getApplicationContext(), getString(R.string.editIssueSuccessMessage));
|
||||||
|
}
|
||||||
|
|
||||||
tinyDb.putBoolean("issueEdited", true);
|
tinyDb.putBoolean("issueEdited", true);
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
finish();
|
finish();
|
||||||
@ -307,7 +319,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
|||||||
private void getIssue(final String instanceUrl, final String instanceToken, final String loginUid, final String repoOwner, final String repoName, int issueIndex) {
|
private void getIssue(final String instanceUrl, final String instanceToken, final String loginUid, final String repoOwner, final String repoName, int issueIndex) {
|
||||||
|
|
||||||
Call<Issues> call = RetrofitClient
|
Call<Issues> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getIssueByIndex(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
.getIssueByIndex(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||||
|
|
||||||
@ -331,7 +343,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
|||||||
if(response.body().getId() > 0) {
|
if(response.body().getId() > 0) {
|
||||||
|
|
||||||
Call<List<Milestones>> call_ = RetrofitClient
|
Call<List<Milestones>> call_ = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getMilestones(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, msState);
|
.getMilestones(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, msState);
|
||||||
|
|
||||||
|
@ -0,0 +1,212 @@
|
|||||||
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.adapters.FilesDiffAdapter;
|
||||||
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
import org.mian.gitnex.models.FileDiffView;
|
||||||
|
import org.mian.gitnex.util.AppUtil;
|
||||||
|
import org.mian.gitnex.util.TinyDB;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import okhttp3.ResponseBody;
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author M M Arif
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class FileDiffActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private View.OnClickListener onClickListener;
|
||||||
|
private TextView toolbar_title;
|
||||||
|
private RecyclerView mRecyclerView;
|
||||||
|
private ProgressBar mProgressBar;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_file_diff);
|
||||||
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
|
String[] parts = repoFullName.split("/");
|
||||||
|
final String repoOwner = parts[0];
|
||||||
|
final String repoName = parts[1];
|
||||||
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||||
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
toolbar_title = findViewById(R.id.toolbar_title);
|
||||||
|
mRecyclerView = findViewById(R.id.recyclerView);
|
||||||
|
mProgressBar = findViewById(R.id.progress_bar);
|
||||||
|
|
||||||
|
mRecyclerView.setHasFixedSize(true);
|
||||||
|
mRecyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
|
||||||
|
|
||||||
|
toolbar_title.setText(R.string.processingText);
|
||||||
|
initCloseListener();
|
||||||
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
String fileDiffName = tinyDb.getString("issueNumber")+".diff";
|
||||||
|
|
||||||
|
getFileContents(tinyDb.getString("instanceUrlWithProtocol"), repoOwner, repoName, fileDiffName);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getFileContents(String instanceUrl, String owner, String repo, String filename) {
|
||||||
|
|
||||||
|
Call<ResponseBody> call = RetrofitClient
|
||||||
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
|
.getApiInterface()
|
||||||
|
.getFileDiffContents(owner, repo, filename);
|
||||||
|
|
||||||
|
call.enqueue(new Callback<ResponseBody>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<ResponseBody> call, @NonNull retrofit2.Response<ResponseBody> response) {
|
||||||
|
|
||||||
|
if (response.code() == 200) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
assert response.body() != null;
|
||||||
|
|
||||||
|
AppUtil appUtil = new AppUtil();
|
||||||
|
List<FileDiffView> fileContentsArray = new ArrayList<>();
|
||||||
|
|
||||||
|
String[] lines = response.body().string().split("diff");
|
||||||
|
|
||||||
|
if(lines.length > 0) {
|
||||||
|
|
||||||
|
for (int i = 1; i < lines.length; i++) {
|
||||||
|
|
||||||
|
if(lines[i].contains("@@ -")) {
|
||||||
|
|
||||||
|
String[] level2nd = lines[i].split("@@ -"); // main content part of single diff view
|
||||||
|
|
||||||
|
String[] fileName_ = level2nd[0].split("\\+\\+\\+ b/"); // filename part
|
||||||
|
String fileNameFinal = fileName_[1];
|
||||||
|
|
||||||
|
String[] fileContents_ = level2nd[1].split("@@"); // file info / content part
|
||||||
|
String fileInfoFinal = fileContents_[0];
|
||||||
|
String fileContentsFinal = (fileContents_[1]);
|
||||||
|
|
||||||
|
if(level2nd.length > 2) {
|
||||||
|
for (int j = 2; j < level2nd.length; j++) {
|
||||||
|
fileContentsFinal += (level2nd[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String fileExtension = FilenameUtils.getExtension(fileNameFinal);
|
||||||
|
|
||||||
|
String fileContentsFinalWithBlankLines = fileContentsFinal.replaceAll( ".*@@.*", "" );
|
||||||
|
String fileContentsFinalWithoutBlankLines = fileContentsFinal.replaceAll( ".*@@.*(\r?\n|\r)?", "" );
|
||||||
|
fileContentsFinalWithoutBlankLines = fileContentsFinalWithoutBlankLines.replaceAll( ".*\\ No newline at end of file.*(\r?\n|\r)?", "" );
|
||||||
|
|
||||||
|
fileContentsArray.add(new FileDiffView(fileNameFinal, appUtil.imageExtension(fileExtension), fileInfoFinal, fileContentsFinalWithoutBlankLines));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
String[] getFileName = lines[i].split("--git a/");
|
||||||
|
|
||||||
|
String[] getFileName_ = getFileName[1].split("b/");
|
||||||
|
String getFileNameFinal = getFileName_[0].trim();
|
||||||
|
|
||||||
|
String[] binaryFile = getFileName_[1].split("GIT binary patch");
|
||||||
|
String binaryFileRaw = binaryFile[1].substring(binaryFile[1].indexOf('\n')+1);
|
||||||
|
String binaryFileFinal = binaryFile[1].substring(binaryFileRaw.indexOf('\n')+1);
|
||||||
|
|
||||||
|
String fileExtension = FilenameUtils.getExtension(getFileNameFinal);
|
||||||
|
|
||||||
|
fileContentsArray.add(new FileDiffView(getFileNameFinal, appUtil.imageExtension(fileExtension),"", binaryFileFinal));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int filesCount = fileContentsArray.size();
|
||||||
|
if(filesCount > 1) {
|
||||||
|
toolbar_title.setText(getResources().getString(R.string.fileDiffViewHeader, Integer.toString(filesCount)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
toolbar_title.setText(getResources().getString(R.string.fileDiffViewHeaderSingle, Integer.toString(filesCount)));
|
||||||
|
}
|
||||||
|
|
||||||
|
FilesDiffAdapter adapter = new FilesDiffAdapter(fileContentsArray, getApplicationContext());
|
||||||
|
mRecyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
|
mProgressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(response.code() == 401) {
|
||||||
|
|
||||||
|
AlertDialogs.authorizationTokenRevokedDialog(getApplicationContext(), getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||||
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(response.code() == 403) {
|
||||||
|
|
||||||
|
Toasty.info(getApplicationContext(), getApplicationContext().getString(R.string.authorizeError));
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
|
Toasty.info(getApplicationContext(), getApplicationContext().getString(R.string.apiNotFound));
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
Toasty.info(getApplicationContext(), getString(R.string.labelGeneralError));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {
|
||||||
|
Log.e("onFailure", t.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initCloseListener() {
|
||||||
|
onClickListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
getIntent().removeExtra("singleFileName");
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,8 +1,12 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.method.ScrollingMovementMethod;
|
import android.text.method.ScrollingMovementMethod;
|
||||||
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -11,6 +15,10 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import com.github.chrisbanes.photoview.PhotoView;
|
||||||
|
import com.pddstudio.highlightjs.HighlightJsView;
|
||||||
|
import com.pddstudio.highlightjs.models.Theme;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
@ -18,6 +26,8 @@ import org.mian.gitnex.helpers.Toasty;
|
|||||||
import org.mian.gitnex.models.Files;
|
import org.mian.gitnex.models.Files;
|
||||||
import org.mian.gitnex.util.AppUtil;
|
import org.mian.gitnex.util.AppUtil;
|
||||||
import org.mian.gitnex.util.TinyDB;
|
import org.mian.gitnex.util.TinyDB;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLDecoder;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -29,8 +39,11 @@ public class FileViewActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private TextView singleFileContents;
|
private TextView singleFileContents;
|
||||||
|
private HighlightJsView singleCodeContents;
|
||||||
|
private PhotoView imageView;
|
||||||
final Context ctx = this;
|
final Context ctx = this;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
|
private byte[] imageData;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -49,10 +62,10 @@ public class FileViewActivity extends AppCompatActivity {
|
|||||||
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");
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
|
||||||
|
|
||||||
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);
|
||||||
|
imageView = findViewById(R.id.imageView);
|
||||||
singleFileContents.setVisibility(View.GONE);
|
singleFileContents.setVisibility(View.GONE);
|
||||||
mProgressBar = findViewById(R.id.progress_bar);
|
mProgressBar = findViewById(R.id.progress_bar);
|
||||||
|
|
||||||
@ -60,24 +73,34 @@ public class FileViewActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
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());
|
||||||
toolbar_title.setText(singleFileName);
|
|
||||||
|
|
||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
if(connToInternet) {
|
try {
|
||||||
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName);
|
|
||||||
|
singleFileName = URLDecoder.decode(singleFileName, "UTF-8");
|
||||||
|
singleFileName = singleFileName.replaceAll("//", "/");
|
||||||
|
singleFileName = singleFileName.startsWith("/") ? singleFileName.substring(1) : singleFileName;
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
catch (UnsupportedEncodingException e) {
|
||||||
Toasty.info(getApplicationContext(), getString(R.string.checkNetConnection));
|
|
||||||
|
assert singleFileName != null;
|
||||||
|
Log.i("singleFileName", singleFileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toolbar_title.setText(singleFileName);
|
||||||
|
|
||||||
|
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getSingleFileContents(String instanceUrl, String token, final String owner, String repo, final String filename) {
|
private void getSingleFileContents(String instanceUrl, String token, final String owner, String repo, final String filename) {
|
||||||
|
|
||||||
Call<Files> call = RetrofitClient
|
Call<Files> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getSingleFileContents(token, owner, repo, filename);
|
.getSingleFileContents(token, owner, repo, filename);
|
||||||
|
|
||||||
@ -92,9 +115,42 @@ public class FileViewActivity extends AppCompatActivity {
|
|||||||
assert response.body() != null;
|
assert response.body() != null;
|
||||||
|
|
||||||
if(!response.body().getContent().equals("")) {
|
if(!response.body().getContent().equals("")) {
|
||||||
singleFileContents.setVisibility(View.VISIBLE);
|
|
||||||
|
String fileExtension = FilenameUtils.getExtension(filename);
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mProgressBar.setVisibility(View.GONE);
|
||||||
singleFileContents.setText(appUtil.decodeBase64(response.body().getContent()));
|
|
||||||
|
if(appUtil.imageExtension(fileExtension)) { // file is image
|
||||||
|
|
||||||
|
singleFileContents.setVisibility(View.GONE);
|
||||||
|
singleCodeContents.setVisibility(View.GONE);
|
||||||
|
imageView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
imageData = Base64.decode(response.body().getContent(), Base64.DEFAULT);
|
||||||
|
Drawable imageDrawable = new BitmapDrawable(getResources(), BitmapFactory.decodeByteArray(imageData, 0, imageData.length));
|
||||||
|
imageView.setImageDrawable(imageDrawable);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (appUtil.sourceCodeExtension(fileExtension)) { // file is sourcecode
|
||||||
|
|
||||||
|
imageView.setVisibility(View.GONE);
|
||||||
|
singleFileContents.setVisibility(View.GONE);
|
||||||
|
singleCodeContents.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
singleCodeContents.setTheme(Theme.GRUVBOX_DARK);
|
||||||
|
singleCodeContents.setShowLineNumbers(true);
|
||||||
|
singleCodeContents.setSource(appUtil.decodeBase64(response.body().getContent()));
|
||||||
|
|
||||||
|
}
|
||||||
|
else { // file type not known - plain text view
|
||||||
|
|
||||||
|
imageView.setVisibility(View.GONE);
|
||||||
|
singleCodeContents.setVisibility(View.GONE);
|
||||||
|
singleFileContents.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
singleFileContents.setText(appUtil.decodeBase64(response.body().getContent()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
singleFileContents.setText("");
|
singleFileContents.setText("");
|
||||||
|
@ -152,7 +152,7 @@ public class IssueDetailActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, getApplicationContext());
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
@ -206,7 +206,7 @@ public class IssueDetailActivity extends AppCompatActivity {
|
|||||||
scrollViewComments.post(new Runnable() {
|
scrollViewComments.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, getApplicationContext());
|
||||||
|
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -224,7 +224,7 @@ public class IssueDetailActivity extends AppCompatActivity {
|
|||||||
scrollViewComments.post(new Runnable() {
|
scrollViewComments.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, getApplicationContext());
|
||||||
tinyDb.putBoolean("commentEdited", false);
|
tinyDb.putBoolean("commentEdited", false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -264,7 +264,7 @@ public class IssueDetailActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
IssueCommentsViewModel issueCommentsModel = ViewModelProviders.of(this).get(IssueCommentsViewModel.class);
|
IssueCommentsViewModel issueCommentsModel = ViewModelProviders.of(this).get(IssueCommentsViewModel.class);
|
||||||
|
|
||||||
issueCommentsModel.getIssueCommentList(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), owner, repo, index).observe(this, new Observer<List<IssueComments>>() {
|
issueCommentsModel.getIssueCommentList(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), owner, repo, index, getApplicationContext()).observe(this, new Observer<List<IssueComments>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<IssueComments> issueCommentsMain) {
|
public void onChanged(@Nullable List<IssueComments> issueCommentsMain) {
|
||||||
adapter = new IssueCommentsAdapter(getApplicationContext(), issueCommentsMain);
|
adapter = new IssueCommentsAdapter(getApplicationContext(), issueCommentsMain);
|
||||||
@ -278,7 +278,7 @@ public class IssueDetailActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
Call<Issues> call = RetrofitClient
|
Call<Issues> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getIssueByIndex(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
.getIssueByIndex(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.GradientDrawable;
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -15,21 +15,28 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import com.tooltip.Tooltip;
|
import com.tooltip.Tooltip;
|
||||||
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
import org.mian.gitnex.helpers.VersionCheck;
|
||||||
|
import org.mian.gitnex.models.GiteaVersion;
|
||||||
|
import org.mian.gitnex.models.UserInfo;
|
||||||
import org.mian.gitnex.models.UserTokens;
|
import org.mian.gitnex.models.UserTokens;
|
||||||
import org.mian.gitnex.util.AppUtil;
|
import org.mian.gitnex.util.AppUtil;
|
||||||
import org.mian.gitnex.R;
|
|
||||||
import org.mian.gitnex.util.TinyDB;
|
import org.mian.gitnex.util.TinyDB;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
import okhttp3.Credentials;
|
import okhttp3.Credentials;
|
||||||
import okhttp3.Headers;
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -39,9 +46,13 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
|
public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
|
||||||
|
|
||||||
private Button login_button;
|
private Button loginButton;
|
||||||
private EditText instance_url, login_uid, login_passwd, otpCode;
|
private EditText instanceUrlET, loginUidET, loginPassword, otpCode, loginTokenCode;
|
||||||
private Spinner protocolSpinner;
|
private Spinner protocolSpinner;
|
||||||
|
private TextView otpInfo;
|
||||||
|
private RadioGroup loginMethod;
|
||||||
|
final Context ctx = this;
|
||||||
|
private String device_id = "token";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -52,16 +63,19 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
||||||
|
|
||||||
login_button = findViewById(R.id.login_button);
|
loginButton = findViewById(R.id.login_button);
|
||||||
instance_url = findViewById(R.id.instance_url);
|
instanceUrlET = findViewById(R.id.instance_url);
|
||||||
login_uid = findViewById(R.id.login_uid);
|
loginUidET = findViewById(R.id.login_uid);
|
||||||
login_passwd = findViewById(R.id.login_passwd);
|
loginPassword = findViewById(R.id.login_passwd);
|
||||||
otpCode = findViewById(R.id.otpCode);
|
otpCode = findViewById(R.id.otpCode);
|
||||||
|
otpInfo = findViewById(R.id.otpInfo);
|
||||||
ImageView info_button = findViewById(R.id.info);
|
ImageView info_button = findViewById(R.id.info);
|
||||||
final TextView viewTextGiteaVersion = findViewById(R.id.appVersion);
|
final TextView viewTextAppVersion = findViewById(R.id.appVersion);
|
||||||
protocolSpinner = findViewById(R.id.httpsSpinner);
|
protocolSpinner = findViewById(R.id.httpsSpinner);
|
||||||
|
loginMethod = findViewById(R.id.loginMethod);
|
||||||
|
loginTokenCode = findViewById(R.id.loginTokenCode);
|
||||||
|
|
||||||
viewTextGiteaVersion.setText(AppUtil.getAppVersion(getApplicationContext()));
|
viewTextAppVersion.setText(AppUtil.getAppVersion(getApplicationContext()));
|
||||||
|
|
||||||
Resources res = getResources();
|
Resources res = getResources();
|
||||||
String[] allProtocols = res.getStringArray(R.array.protocolValues);
|
String[] allProtocols = res.getStringArray(R.array.protocolValues);
|
||||||
@ -94,12 +108,31 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loginMethod.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||||
|
if(checkedId == R.id.loginUsernamePassword){
|
||||||
|
loginUidET.setVisibility(View.VISIBLE);
|
||||||
|
loginPassword.setVisibility(View.VISIBLE);
|
||||||
|
otpCode.setVisibility(View.VISIBLE);
|
||||||
|
otpInfo.setVisibility(View.VISIBLE);
|
||||||
|
loginTokenCode.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
loginUidET.setVisibility(View.GONE);
|
||||||
|
loginPassword.setVisibility(View.GONE);
|
||||||
|
otpCode.setVisibility(View.GONE);
|
||||||
|
otpInfo.setVisibility(View.GONE);
|
||||||
|
loginTokenCode.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//login_button.setOnClickListener(this);
|
//login_button.setOnClickListener(this);
|
||||||
if(!tinyDb.getString("instanceUrlRaw").isEmpty()) {
|
if(!tinyDb.getString("instanceUrlRaw").isEmpty()) {
|
||||||
instance_url.setText(tinyDb.getString("instanceUrlRaw"));
|
instanceUrlET.setText(tinyDb.getString("instanceUrlRaw"));
|
||||||
}
|
}
|
||||||
if(!tinyDb.getString("loginUid").isEmpty()) {
|
if(!tinyDb.getString("loginUid").isEmpty()) {
|
||||||
login_uid.setText(tinyDb.getString("loginUid"));
|
loginUidET.setText(tinyDb.getString("loginUid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getBoolean("loggedInMode")) {
|
if(tinyDb.getBoolean("loggedInMode")) {
|
||||||
@ -109,20 +142,23 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
login_button.setOnClickListener(loginListener);
|
loginButton.setOnClickListener(loginListener);
|
||||||
|
|
||||||
|
if(!tinyDb.getString("uniqueAppId").isEmpty()) {
|
||||||
|
device_id = tinyDb.getString("uniqueAppId");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
device_id = UUID.randomUUID().toString();
|
||||||
|
tinyDb.putString("uniqueAppId", device_id);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
switch(v.getId()) {
|
if (v.getId() == R.id.login_button) {
|
||||||
|
login();
|
||||||
case R.id.login_button:
|
|
||||||
login();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -131,7 +167,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
login_button.setText(R.string.processingText);
|
loginButton.setText(R.string.processingText);
|
||||||
login();
|
login();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -159,112 +195,336 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
AppUtil appUtil = new AppUtil();
|
AppUtil appUtil = new AppUtil();
|
||||||
boolean connToInternet = AppUtil.haveNetworkConnection(LoginActivity.this);
|
boolean connToInternet = AppUtil.haveNetworkConnection(LoginActivity.this);
|
||||||
|
|
||||||
String instanceUrl = instance_url.getText().toString().trim();
|
String instanceUrl = instanceUrlET.getText().toString().trim();
|
||||||
String loginUid = login_uid.getText().toString();
|
String loginUid = loginUidET.getText().toString();
|
||||||
String loginPass = login_passwd.getText().toString();
|
String loginPass = loginPassword.getText().toString();
|
||||||
String protocol = protocolSpinner.getSelectedItem().toString();
|
String protocol = protocolSpinner.getSelectedItem().toString();
|
||||||
String loginOTP_ = otpCode.getText().toString().trim();
|
String loginOTP_ = otpCode.getText().toString().trim();
|
||||||
|
int loginMethodType = loginMethod.getCheckedRadioButtonId();
|
||||||
|
String loginToken_ = loginTokenCode.getText().toString().trim();
|
||||||
|
|
||||||
if(instanceUrl.contains("@")) {
|
if(loginMethodType == R.id.loginUsernamePassword) {
|
||||||
|
|
||||||
String[] urlForHttpAuth = instanceUrl.split("@");
|
if(instanceUrl.contains("@")) {
|
||||||
|
|
||||||
tinyDb.putString("basicAuthPassword", loginPass);
|
String[] urlForHttpAuth = instanceUrl.split("@");
|
||||||
tinyDb.putBoolean("basicAuthFlag", true);
|
|
||||||
|
|
||||||
instanceUrl = urlForHttpAuth[1];
|
tinyDb.putString("basicAuthPassword", loginPass);
|
||||||
loginUid = urlForHttpAuth[0];
|
tinyDb.putBoolean("basicAuthFlag", true);
|
||||||
|
|
||||||
}
|
instanceUrl = urlForHttpAuth[1];
|
||||||
|
loginUid = urlForHttpAuth[0];
|
||||||
String instanceHost;
|
|
||||||
if(AppUtil.httpCheck(instanceUrl)) {
|
|
||||||
|
|
||||||
URI uri = null;
|
|
||||||
try {
|
|
||||||
uri = new URI(instanceUrl);
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
assert uri != null;
|
|
||||||
instanceHost = uri.getHost();
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
instanceHost = instanceUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
String instanceUrlWithProtocol;
|
|
||||||
if(protocol.toLowerCase().equals("https")) {
|
|
||||||
instanceUrl = "https://" + instanceHost + "/api/v1/";
|
|
||||||
instanceUrlWithProtocol = "https://" + instanceHost;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
instanceUrl = "http://" + instanceHost + "/api/v1/";
|
|
||||||
instanceUrlWithProtocol = "https://" + instanceHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
tinyDb.putString("instanceUrlRaw", instanceHost);
|
|
||||||
tinyDb.putString("loginUid", loginUid);
|
|
||||||
tinyDb.putString("instanceUrl", instanceUrl);
|
|
||||||
tinyDb.putString("instanceUrlWithProtocol", instanceUrlWithProtocol);
|
|
||||||
|
|
||||||
if(connToInternet) {
|
|
||||||
|
|
||||||
if(instance_url.getText().toString().equals("")) {
|
|
||||||
|
|
||||||
Toasty.info(getApplicationContext(), getString(R.string.emptyFieldURL));
|
|
||||||
enableProcessButton();
|
|
||||||
login_button.setText(R.string.btnLogin);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
if(loginUid.equals("")) {
|
|
||||||
|
|
||||||
Toasty.info(getApplicationContext(), getString(R.string.emptyFieldUsername));
|
|
||||||
enableProcessButton();
|
|
||||||
login_button.setText(R.string.btnLogin);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
if(login_passwd.getText().toString().equals("")) {
|
|
||||||
|
|
||||||
Toasty.info(getApplicationContext(), getString(R.string.emptyFieldPassword));
|
|
||||||
enableProcessButton();
|
|
||||||
login_button.setText(R.string.btnLogin);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int loginOTP = 0;
|
String instanceHost;
|
||||||
if(loginOTP_.length() == 6) {
|
if(AppUtil.httpCheck(instanceUrl)) {
|
||||||
|
|
||||||
if(appUtil.checkIntegers(loginOTP_)) {
|
URI uri = null;
|
||||||
|
try {
|
||||||
loginOTP = Integer.valueOf(loginOTP_);
|
uri = new URI(instanceUrl);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
else {
|
assert uri != null;
|
||||||
|
instanceHost = uri.getHost();
|
||||||
|
|
||||||
Toasty.info(getApplicationContext(), getString(R.string.loginOTPTypeError));
|
}
|
||||||
|
else {
|
||||||
|
instanceHost = instanceUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
String instanceUrlWithProtocol;
|
||||||
|
if(protocol.toLowerCase().equals("https")) {
|
||||||
|
instanceUrl = "https://" + instanceHost + "/api/v1/";
|
||||||
|
instanceUrlWithProtocol = "https://" + instanceHost;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
instanceUrl = "http://" + instanceHost + "/api/v1/";
|
||||||
|
instanceUrlWithProtocol = "https://" + instanceHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
tinyDb.putString("instanceUrlRaw", instanceHost);
|
||||||
|
tinyDb.putString("loginUid", loginUid);
|
||||||
|
tinyDb.putString("instanceUrl", instanceUrl);
|
||||||
|
tinyDb.putString("instanceUrlWithProtocol", instanceUrlWithProtocol);
|
||||||
|
|
||||||
|
if(connToInternet) {
|
||||||
|
|
||||||
|
if(instanceUrlET.getText().toString().equals("")) {
|
||||||
|
|
||||||
|
Toasty.info(getApplicationContext(), getString(R.string.emptyFieldURL));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
login_button.setText(R.string.btnLogin);
|
loginButton.setText(R.string.btnLogin);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
if(loginUid.equals("")) {
|
||||||
|
|
||||||
|
Toasty.info(getApplicationContext(), getString(R.string.emptyFieldUsername));
|
||||||
|
enableProcessButton();
|
||||||
|
loginButton.setText(R.string.btnLogin);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
if(loginPassword.getText().toString().equals("")) {
|
||||||
|
|
||||||
|
Toasty.info(getApplicationContext(), getString(R.string.emptyFieldPassword));
|
||||||
|
enableProcessButton();
|
||||||
|
loginButton.setText(R.string.btnLogin);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
int loginOTP = 0;
|
||||||
|
if(loginOTP_.length() == 6) {
|
||||||
|
|
||||||
letTheUserIn(instanceUrl, loginUid, loginPass, loginOTP);
|
if(appUtil.checkIntegers(loginOTP_)) {
|
||||||
|
|
||||||
|
loginOTP = Integer.valueOf(loginOTP_);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
Toasty.info(getApplicationContext(), getString(R.string.loginOTPTypeError));
|
||||||
|
enableProcessButton();
|
||||||
|
loginButton.setText(R.string.btnLogin);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
versionCheck(instanceUrl, loginUid, loginPass, loginOTP, loginToken_, 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
Toasty.info(getApplicationContext(), getString(R.string.checkNetConnection));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.info(getApplicationContext(), getString(R.string.checkNetConnection));
|
String instanceHost;
|
||||||
|
if(AppUtil.httpCheck(instanceUrl)) {
|
||||||
|
|
||||||
|
URI uri = null;
|
||||||
|
try {
|
||||||
|
uri = new URI(instanceUrl);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
assert uri != null;
|
||||||
|
instanceHost = uri.getHost();
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
instanceHost = instanceUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
String instanceUrlWithProtocol;
|
||||||
|
if(protocol.toLowerCase().equals("https")) {
|
||||||
|
instanceUrl = "https://" + instanceHost + "/api/v1/";
|
||||||
|
instanceUrlWithProtocol = "https://" + instanceHost;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
instanceUrl = "http://" + instanceHost + "/api/v1/";
|
||||||
|
instanceUrlWithProtocol = "https://" + instanceHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
tinyDb.putString("instanceUrlRaw", instanceHost);
|
||||||
|
//tinyDb.putString("loginUid", loginUid);
|
||||||
|
tinyDb.putString("instanceUrl", instanceUrl);
|
||||||
|
tinyDb.putString("instanceUrlWithProtocol", instanceUrlWithProtocol);
|
||||||
|
|
||||||
|
if(connToInternet) {
|
||||||
|
|
||||||
|
if (instanceUrlET.getText().toString().equals("")) {
|
||||||
|
|
||||||
|
Toasty.info(getApplicationContext(), getString(R.string.emptyFieldURL));
|
||||||
|
enableProcessButton();
|
||||||
|
loginButton.setText(R.string.btnLogin);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (loginToken_.equals("")) {
|
||||||
|
|
||||||
|
Toasty.info(getApplicationContext(), getString(R.string.loginTokenError));
|
||||||
|
enableProcessButton();
|
||||||
|
loginButton.setText(R.string.btnLogin);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
versionCheck(instanceUrl, loginUid, loginPass, 123, loginToken_, 2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
Toasty.info(getApplicationContext(), getString(R.string.checkNetConnection));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void versionCheck(final String instanceUrl, final String loginUid, final String loginPass, final int loginOTP, final String loginToken_, final int loginType) {
|
||||||
|
|
||||||
|
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
|
|
||||||
|
Call<GiteaVersion> callVersion = RetrofitClient
|
||||||
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
|
.getApiInterface()
|
||||||
|
.getGiteaVersion();
|
||||||
|
|
||||||
|
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull final Call<GiteaVersion> callVersion, @NonNull retrofit2.Response<GiteaVersion> responseVersion) {
|
||||||
|
|
||||||
|
if (responseVersion.code() == 200) {
|
||||||
|
|
||||||
|
GiteaVersion version = responseVersion.body();
|
||||||
|
assert version != null;
|
||||||
|
|
||||||
|
VersionCheck vt = VersionCheck.check(getString(R.string.versionLow), getString(R.string.versionHigh), version.getVersion());
|
||||||
|
|
||||||
|
switch (vt) {
|
||||||
|
case UNSUPPORTED_NEW:
|
||||||
|
//Toasty.info(getApplicationContext(), getString(R.string.versionUnsupportedNew));
|
||||||
|
case SUPPORTED_LATEST:
|
||||||
|
case SUPPORTED_OLD:
|
||||||
|
case DEVELOPMENT:
|
||||||
|
login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken_);
|
||||||
|
return;
|
||||||
|
case UNSUPPORTED_OLD:
|
||||||
|
|
||||||
|
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx, R.style.confirmDialog);
|
||||||
|
|
||||||
|
alertDialogBuilder
|
||||||
|
.setTitle(getString(R.string.versionAlertDialogHeader))
|
||||||
|
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion()))
|
||||||
|
.setCancelable(true)
|
||||||
|
.setIcon(R.drawable.ic_warning)
|
||||||
|
.setNegativeButton(getString(R.string.cancelButton), new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.dismiss();
|
||||||
|
enableProcessButton();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setPositiveButton(getString(R.string.textContinue), new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|
||||||
|
dialog.dismiss();
|
||||||
|
login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken_);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||||
|
|
||||||
|
alertDialog.show();
|
||||||
|
return;
|
||||||
|
default: // UNKNOWN
|
||||||
|
Toasty.info(getApplicationContext(), getString(R.string.versionUnknow));
|
||||||
|
enableProcessButton();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (responseVersion.code() == 403) {
|
||||||
|
login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void login(int loginType, String instanceUrl, String loginUid, String loginPass, int loginOTP, String loginToken_) {
|
||||||
|
if (loginType == 1) {
|
||||||
|
letTheUserIn(instanceUrl, loginUid, loginPass, loginOTP);
|
||||||
|
}
|
||||||
|
else if (loginType == 2) { // token
|
||||||
|
letTheUserInViaToken(instanceUrl, loginToken_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<GiteaVersion> callVersion, Throwable t) {
|
||||||
|
|
||||||
|
Log.e("onFailure-version", t.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void letTheUserInViaToken(String instanceUrl, final String loginToken_) {
|
||||||
|
|
||||||
|
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
|
|
||||||
|
Call<UserInfo> call = RetrofitClient
|
||||||
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
|
.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();
|
||||||
|
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
|
||||||
|
if (response.code() == 200) {
|
||||||
|
|
||||||
|
tinyDb.putBoolean("loggedInMode", true);
|
||||||
|
assert userDetails != null;
|
||||||
|
tinyDb.putString(userDetails.getLogin() + "-token", loginToken_);
|
||||||
|
tinyDb.putString("loginUid", userDetails.getLogin());
|
||||||
|
|
||||||
|
enableProcessButton();
|
||||||
|
loginButton.setText(R.string.btnLogin);
|
||||||
|
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||||
|
finish();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(response.code() == 401) {
|
||||||
|
|
||||||
|
String toastError = getResources().getString(R.string.unauthorizedApiError);
|
||||||
|
Toasty.info(getApplicationContext(), toastError);
|
||||||
|
|
||||||
|
enableProcessButton();
|
||||||
|
loginButton.setText(R.string.btnLogin);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
String toastError = getResources().getString(R.string.genericApiStatusError) + response.code();
|
||||||
|
Toasty.info(getApplicationContext(), toastError);
|
||||||
|
|
||||||
|
enableProcessButton();
|
||||||
|
loginButton.setText(R.string.btnLogin);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||||
|
Log.e("onFailure", t.toString());
|
||||||
|
Toasty.info(getApplicationContext(), getResources().getString(R.string.genericError));
|
||||||
|
enableProcessButton();
|
||||||
|
loginButton.setText(R.string.btnLogin);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void letTheUserIn(final String instanceUrl, final String loginUid, final String loginPass, final int loginOTP) {
|
private void letTheUserIn(final String instanceUrl, final String loginUid, final String loginPass, final int loginOTP) {
|
||||||
|
|
||||||
final String credential = Credentials.basic(loginUid, loginPass);
|
final String credential = Credentials.basic(loginUid, loginPass);
|
||||||
@ -272,13 +532,13 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
Call<List<UserTokens>> call;
|
Call<List<UserTokens>> call;
|
||||||
if(loginOTP != 0) {
|
if(loginOTP != 0) {
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getUserTokensWithOTP(credential, loginOTP, loginUid);
|
.getUserTokensWithOTP(credential, loginOTP, loginUid);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getUserTokens(credential, loginUid);
|
.getUserTokens(credential, loginUid);
|
||||||
}
|
}
|
||||||
@ -290,7 +550,8 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
|
|
||||||
List<UserTokens> userTokens = response.body();
|
List<UserTokens> userTokens = response.body();
|
||||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
Headers responseHeaders = response.headers();
|
final AppUtil appUtil = new AppUtil();
|
||||||
|
//Headers responseHeaders = response.headers();
|
||||||
|
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
|
|
||||||
@ -300,29 +561,46 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
|
|
||||||
assert userTokens != null;
|
assert userTokens != null;
|
||||||
if (userTokens.size() > 0) {
|
if (userTokens.size() > 0) {
|
||||||
for (int i = 0; i < userTokens.size(); i++) {
|
|
||||||
if (userTokens.get(i).getSha1().equals(tinyDb.getString(loginUid + "-token"))) {
|
if(userTokens.get(0).getToken_last_eight() != null) {
|
||||||
setTokenFlag = true;
|
|
||||||
break;
|
for (int i = 0; i < userTokens.size(); i++) {
|
||||||
|
if (userTokens.get(i).getToken_last_eight().equals(tinyDb.getString(loginUid + "-token-last-eight"))) {
|
||||||
|
setTokenFlag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//Log.i("Tokens: ", userTokens.get(i).getToken_last_eight());
|
||||||
}
|
}
|
||||||
//Log.i("Tokens: ", userTokens.get(i).getSha1());
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
for (int i = 0; i < userTokens.size(); i++) {
|
||||||
|
if (userTokens.get(i).getSha1().equals(tinyDb.getString(loginUid + "-token"))) {
|
||||||
|
setTokenFlag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//Log.i("Tokens: ", userTokens.get(i).getSha1());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getString(loginUid + "-token").isEmpty() || !setTokenFlag) {
|
if(tinyDb.getString(loginUid + "-token").isEmpty() || !setTokenFlag) {
|
||||||
|
|
||||||
UserTokens createUserToken = new UserTokens("gitnex-app-token");
|
UserTokens createUserToken = new UserTokens("gitnex-app-" + device_id);
|
||||||
|
|
||||||
Call<UserTokens> callCreateToken;
|
Call<UserTokens> callCreateToken;
|
||||||
if(loginOTP != 0) {
|
if(loginOTP != 0) {
|
||||||
callCreateToken = RetrofitClient
|
callCreateToken = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.createNewTokenWithOTP(credential, loginOTP, loginUid, createUserToken);
|
.createNewTokenWithOTP(credential, loginOTP, loginUid, createUserToken);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
callCreateToken = RetrofitClient
|
callCreateToken = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.createNewToken(credential, loginUid, createUserToken);
|
.createNewToken(credential, loginUid, createUserToken);
|
||||||
}
|
}
|
||||||
@ -332,7 +610,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<UserTokens> callCreateToken, @NonNull retrofit2.Response<UserTokens> responseCreate) {
|
public void onResponse(@NonNull Call<UserTokens> callCreateToken, @NonNull retrofit2.Response<UserTokens> responseCreate) {
|
||||||
|
|
||||||
if (responseCreate.isSuccessful()) {
|
if(responseCreate.isSuccessful()) {
|
||||||
|
|
||||||
if(responseCreate.code() == 201) {
|
if(responseCreate.code() == 201) {
|
||||||
|
|
||||||
@ -345,6 +623,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
tinyDb.remove("loginPass");
|
tinyDb.remove("loginPass");
|
||||||
tinyDb.putBoolean("loggedInMode", true);
|
tinyDb.putBoolean("loggedInMode", true);
|
||||||
tinyDb.putString(loginUid + "-token", newToken.getSha1());
|
tinyDb.putString(loginUid + "-token", newToken.getSha1());
|
||||||
|
tinyDb.putString(loginUid + "-token-last-eight", appUtil.getLastCharactersOfWord(newToken.getSha1(), 8));
|
||||||
//Log.i("Tokens", "new:" + newToken.getSha1() + " old:" + tinyDb.getString(loginUid + "-token"));
|
//Log.i("Tokens", "new:" + newToken.getSha1() + " old:" + tinyDb.getString(loginUid + "-token"));
|
||||||
|
|
||||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||||
@ -357,10 +636,10 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
}
|
}
|
||||||
else if(responseCreate.code() == 500) {
|
else if(responseCreate.code() == 500) {
|
||||||
|
|
||||||
String toastError = getResources().getString(R.string.genericApiStatusError) + String.valueOf(responseCreate.code());
|
String toastError = getResources().getString(R.string.genericApiStatusError) + responseCreate.code();
|
||||||
Toasty.info(getApplicationContext(), toastError);
|
Toasty.info(getApplicationContext(), toastError);
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
login_button.setText(R.string.btnLogin);
|
loginButton.setText(R.string.btnLogin);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,20 +666,20 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
}
|
}
|
||||||
else if(response.code() == 500) {
|
else if(response.code() == 500) {
|
||||||
|
|
||||||
String toastError = getResources().getString(R.string.genericApiStatusError) + String.valueOf(response.code());
|
String toastError = getResources().getString(R.string.genericApiStatusError) + response.code();
|
||||||
Toasty.info(getApplicationContext(), toastError);
|
Toasty.info(getApplicationContext(), toastError);
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
login_button.setText(R.string.btnLogin);
|
loginButton.setText(R.string.btnLogin);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
String toastError = getResources().getString(R.string.genericApiStatusError) + String.valueOf(response.code());
|
String toastError = getResources().getString(R.string.genericApiStatusError) + response.code();
|
||||||
//Log.i("error message else4", String.valueOf(response.code()));
|
//Log.i("error message else4", String.valueOf(response.code()));
|
||||||
|
|
||||||
Toasty.info(getApplicationContext(), toastError);
|
Toasty.info(getApplicationContext(), toastError);
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
login_button.setText(R.string.btnLogin);
|
loginButton.setText(R.string.btnLogin);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +690,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
Log.e("onFailure-login", t.toString());
|
Log.e("onFailure-login", t.toString());
|
||||||
Toasty.info(getApplicationContext(), getResources().getString(R.string.malformedJson));
|
Toasty.info(getApplicationContext(), getResources().getString(R.string.malformedJson));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
login_button.setText(R.string.btnLogin);
|
loginButton.setText(R.string.btnLogin);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -419,21 +698,21 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
|
|
||||||
private void disableProcessButton() {
|
private void disableProcessButton() {
|
||||||
|
|
||||||
login_button.setEnabled(false);
|
loginButton.setEnabled(false);
|
||||||
GradientDrawable shape = new GradientDrawable();
|
GradientDrawable shape = new GradientDrawable();
|
||||||
shape.setCornerRadius( 8 );
|
shape.setCornerRadius( 8 );
|
||||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
login_button.setBackground(shape);
|
loginButton.setBackground(shape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableProcessButton() {
|
private void enableProcessButton() {
|
||||||
|
|
||||||
login_button.setEnabled(true);
|
loginButton.setEnabled(true);
|
||||||
GradientDrawable shape = new GradientDrawable();
|
GradientDrawable shape = new GradientDrawable();
|
||||||
shape.setCornerRadius( 8 );
|
shape.setCornerRadius( 8 );
|
||||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||||
login_button.setBackground(shape);
|
loginButton.setBackground(shape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import org.mian.gitnex.fragments.StarredRepositoriesFragment;
|
|||||||
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.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
import org.mian.gitnex.models.GiteaVersion;
|
||||||
import org.mian.gitnex.models.UserInfo;
|
import org.mian.gitnex.models.UserInfo;
|
||||||
import org.mian.gitnex.util.AppUtil;
|
import org.mian.gitnex.util.AppUtil;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
@ -124,41 +125,40 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
|||||||
@Override
|
@Override
|
||||||
public void onDrawerOpened(@NonNull View drawerView) {
|
public void onDrawerOpened(@NonNull View drawerView) {
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
if(tinyDb.getBoolean("noConnection")) {
|
||||||
if(!connToInternet) {
|
Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
|
||||||
|
|
||||||
if(!tinyDb.getBoolean("noConnection")) {
|
|
||||||
Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
|
|
||||||
}
|
|
||||||
|
|
||||||
tinyDb.putBoolean("noConnection", true);
|
|
||||||
|
|
||||||
String userEmailNav = tinyDb.getString("userEmail");
|
|
||||||
String userFullNameNav = tinyDb.getString("userFullname");
|
|
||||||
String userAvatarNav = tinyDb.getString("userAvatar");
|
|
||||||
|
|
||||||
userEmail = hView.findViewById(R.id.userEmail);
|
|
||||||
if (!userEmailNav.equals("")) {
|
|
||||||
userEmail.setText(userEmailNav);
|
|
||||||
}
|
|
||||||
|
|
||||||
userFullName = hView.findViewById(R.id.userFullname);
|
|
||||||
if (!userFullNameNav.equals("")) {
|
|
||||||
userFullName.setText(userFullNameNav);
|
|
||||||
}
|
|
||||||
|
|
||||||
userAvatar = hView.findViewById(R.id.userAvatar);
|
|
||||||
if (!userAvatarNav.equals("")) {
|
|
||||||
Picasso.get().load(userAvatarNav).networkPolicy(NetworkPolicy.OFFLINE).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(userAvatar);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
displayUserInfo(instanceUrl, instanceToken, loginUid);
|
|
||||||
tinyDb.putBoolean("noConnection", false);
|
tinyDb.putBoolean("noConnection", false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//tinyDb.putBoolean("noConnection", true);
|
||||||
|
|
||||||
|
String userEmailNav = tinyDb.getString("userEmail");
|
||||||
|
String userFullNameNav = tinyDb.getString("userFullname");
|
||||||
|
String userAvatarNav = tinyDb.getString("userAvatar");
|
||||||
|
|
||||||
|
userEmail = hView.findViewById(R.id.userEmail);
|
||||||
|
if (!userEmailNav.equals("")) {
|
||||||
|
userEmail.setText(userEmailNav);
|
||||||
|
}
|
||||||
|
|
||||||
|
userFullName = hView.findViewById(R.id.userFullname);
|
||||||
|
if (!userFullNameNav.equals("")) {
|
||||||
|
userFullName.setText(userFullNameNav);
|
||||||
|
}
|
||||||
|
|
||||||
|
userAvatar = hView.findViewById(R.id.userAvatar);
|
||||||
|
if (!userAvatarNav.equals("")) {
|
||||||
|
Picasso.get().load(userAvatarNav).networkPolicy(NetworkPolicy.OFFLINE).transform(new RoundedTransformation(8, 0)).resize(160, 160).centerCrop().into(userAvatar);
|
||||||
|
}
|
||||||
|
|
||||||
|
userAvatar.setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
|
||||||
|
new ProfileFragment()).commit();
|
||||||
|
drawer.closeDrawers();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -218,6 +218,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
displayUserInfo(instanceUrl, instanceToken, loginUid);
|
displayUserInfo(instanceUrl, instanceToken, loginUid);
|
||||||
|
giteaVersion(instanceUrl);
|
||||||
tinyDb.putBoolean("noConnection", false);
|
tinyDb.putBoolean("noConnection", false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -312,12 +313,48 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void giteaVersion(final String instanceUrl) {
|
||||||
|
|
||||||
|
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
|
|
||||||
|
Call<GiteaVersion> callVersion = RetrofitClient
|
||||||
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
|
.getApiInterface()
|
||||||
|
.getGiteaVersion();
|
||||||
|
|
||||||
|
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull final Call<GiteaVersion> callVersion, @NonNull retrofit2.Response<GiteaVersion> responseVersion) {
|
||||||
|
|
||||||
|
if (responseVersion.code() == 200) {
|
||||||
|
|
||||||
|
GiteaVersion version = responseVersion.body();
|
||||||
|
assert version != null;
|
||||||
|
|
||||||
|
tinyDb.putString("giteaVersion", version.getVersion());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<GiteaVersion> callVersion, Throwable t) {
|
||||||
|
|
||||||
|
Log.e("onFailure-version", t.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void displayUserInfo(String instanceUrl, String token, String loginUid) {
|
private void displayUserInfo(String instanceUrl, String token, String loginUid) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
|
|
||||||
Call<UserInfo> call = RetrofitClient
|
Call<UserInfo> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getUserInfo(Authorization.returnAuthentication(getApplicationContext(), loginUid, token));
|
.getUserInfo(Authorization.returnAuthentication(getApplicationContext(), loginUid, token));
|
||||||
|
|
||||||
@ -345,7 +382,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
|||||||
tinyDb.putString("userFullname", userDetails.getFullname());
|
tinyDb.putString("userFullname", userDetails.getFullname());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tinyDb.putString("userFullname", "...");
|
tinyDb.putString("userFullname", userDetails.getLogin());
|
||||||
}
|
}
|
||||||
|
|
||||||
tinyDb.putString("userEmail", userDetails.getEmail());
|
tinyDb.putString("userEmail", userDetails.getEmail());
|
||||||
|
@ -0,0 +1,258 @@
|
|||||||
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import com.hendraanggrian.appcompat.socialview.Mention;
|
||||||
|
import com.hendraanggrian.appcompat.widget.MentionArrayAdapter;
|
||||||
|
import com.hendraanggrian.appcompat.widget.SocialAutoCompleteTextView;
|
||||||
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
import org.mian.gitnex.models.Collaborators;
|
||||||
|
import org.mian.gitnex.models.MergePullRequest;
|
||||||
|
import org.mian.gitnex.util.AppUtil;
|
||||||
|
import org.mian.gitnex.util.TinyDB;
|
||||||
|
import java.util.List;
|
||||||
|
import okhttp3.ResponseBody;
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author M M Arif
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class MergePullRequestActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
public ImageView closeActivity;
|
||||||
|
private View.OnClickListener onClickListener;
|
||||||
|
|
||||||
|
final Context ctx = this;
|
||||||
|
|
||||||
|
private SocialAutoCompleteTextView mergePR;
|
||||||
|
private ArrayAdapter<Mention> defaultMentionAdapter;
|
||||||
|
private Button mergeButton;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_merge_pull_request);
|
||||||
|
|
||||||
|
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
||||||
|
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
|
|
||||||
|
mergePR = findViewById(R.id.mergePR);
|
||||||
|
mergePR.setShowSoftInputOnFocus(true);
|
||||||
|
|
||||||
|
defaultMentionAdapter = new MentionArrayAdapter<>(this);
|
||||||
|
loadCollaboratorsList();
|
||||||
|
|
||||||
|
mergePR.setMentionAdapter(defaultMentionAdapter);
|
||||||
|
|
||||||
|
closeActivity = findViewById(R.id.close);
|
||||||
|
TextView toolbar_title = findViewById(R.id.toolbar_title);
|
||||||
|
|
||||||
|
if(!tinyDb.getString("issueTitle").isEmpty()) {
|
||||||
|
toolbar_title.setText(tinyDb.getString("issueTitle"));
|
||||||
|
}
|
||||||
|
|
||||||
|
initCloseListener();
|
||||||
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
|
mergeButton = findViewById(R.id.mergeButton);
|
||||||
|
|
||||||
|
if(!connToInternet) {
|
||||||
|
|
||||||
|
disableProcessButton();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
mergeButton.setOnClickListener(mergePullRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadCollaboratorsList() {
|
||||||
|
|
||||||
|
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
|
|
||||||
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||||
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
|
String[] parts = repoFullName.split("/");
|
||||||
|
final String repoOwner = parts[0];
|
||||||
|
final String repoName = parts[1];
|
||||||
|
|
||||||
|
Call<List<Collaborators>> call = RetrofitClient
|
||||||
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
|
.getApiInterface()
|
||||||
|
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||||
|
|
||||||
|
call.enqueue(new Callback<List<Collaborators>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<List<Collaborators>> call, @NonNull Response<List<Collaborators>> response) {
|
||||||
|
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
|
||||||
|
assert response.body() != null;
|
||||||
|
String fullName = "";
|
||||||
|
for (int i = 0; i < response.body().size(); i++) {
|
||||||
|
if(!response.body().get(i).getFull_name().equals("")) {
|
||||||
|
fullName = response.body().get(i).getFull_name();
|
||||||
|
}
|
||||||
|
defaultMentionAdapter.add(
|
||||||
|
new Mention(response.body().get(i).getUsername(), fullName, response.body().get(i).getAvatar_url()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
Log.i("onResponse", String.valueOf(response.code()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
||||||
|
Log.i("onFailure", t.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initCloseListener() {
|
||||||
|
onClickListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private View.OnClickListener mergePullRequest = new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
processMergePullRequest();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private void processMergePullRequest() {
|
||||||
|
|
||||||
|
String mergePRDT = mergePR.getText().toString();
|
||||||
|
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
||||||
|
|
||||||
|
if(!connToInternet) {
|
||||||
|
|
||||||
|
Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
disableProcessButton();
|
||||||
|
String doWhat = "merge";
|
||||||
|
mergeFunction(doWhat, mergePRDT);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mergeFunction(String doWhat, String mergePRDT) {
|
||||||
|
|
||||||
|
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
|
|
||||||
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||||
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
|
String[] parts = repoFullName.split("/");
|
||||||
|
final String repoOwner = parts[0];
|
||||||
|
final String repoName = parts[1];
|
||||||
|
final int prIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
|
||||||
|
|
||||||
|
MergePullRequest mergePR = new MergePullRequest(doWhat, mergePRDT, null);
|
||||||
|
|
||||||
|
Call<ResponseBody> call = RetrofitClient
|
||||||
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
|
.getApiInterface()
|
||||||
|
.mergePullRequest(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, prIndex, mergePR);
|
||||||
|
|
||||||
|
call.enqueue(new Callback<ResponseBody>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<ResponseBody> call, @NonNull retrofit2.Response<ResponseBody> response) {
|
||||||
|
|
||||||
|
if(response.code() == 200) {
|
||||||
|
|
||||||
|
Toasty.info(getApplicationContext(), getString(R.string.mergePRSuccessMsg));
|
||||||
|
tinyDb.putBoolean("prMerged", true);
|
||||||
|
tinyDb.putBoolean("resumePullRequests", 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(getApplicationContext(), getString(R.string.mergePR404ErrorMsg));
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
enableProcessButton();
|
||||||
|
Toasty.info(getApplicationContext(), getString(R.string.genericError));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {
|
||||||
|
Log.e("onFailure", t.toString());
|
||||||
|
enableProcessButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void disableProcessButton() {
|
||||||
|
|
||||||
|
mergeButton.setEnabled(false);
|
||||||
|
GradientDrawable shape = new GradientDrawable();
|
||||||
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
|
mergeButton.setBackground(shape);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enableProcessButton() {
|
||||||
|
|
||||||
|
mergeButton.setEnabled(true);
|
||||||
|
GradientDrawable shape = new GradientDrawable();
|
||||||
|
shape.setCornerRadius( 8 );
|
||||||
|
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||||
|
mergeButton.setBackground(shape);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -204,7 +204,7 @@ public class NewFileActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
Call<JsonElement> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.createNewFile(token, repoOwner, repoName, fileName, createNewFileJsonStr);
|
.createNewFile(token, repoOwner, repoName, fileName, createNewFileJsonStr);
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ public class NewFileActivity extends AppCompatActivity {
|
|||||||
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
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getBranches(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
.getBranches(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ public class NewMilestoneActivity extends AppCompatActivity implements View.OnCl
|
|||||||
Call<Milestones> call;
|
Call<Milestones> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.createMilestone(token, repoOwner, repoName, createMilestone);
|
.createMilestone(token, repoOwner, repoName, createMilestone);
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ public class NewOrganizationActivity extends AppCompatActivity {
|
|||||||
UserOrganizations createOrganization = new UserOrganizations(orgName, null, orgDesc, null, null);
|
UserOrganizations createOrganization = new UserOrganizations(orgName, null, orgDesc, null, null);
|
||||||
|
|
||||||
Call<UserOrganizations> call = RetrofitClient
|
Call<UserOrganizations> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.createNewOrganization(token, createOrganization);
|
.createNewOrganization(token, createOrganization);
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ public class NewRepoActivity extends AppCompatActivity {
|
|||||||
if(repoOwner.equals(loginUid)) {
|
if(repoOwner.equals(loginUid)) {
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.createNewUserRepository(token, createRepository);
|
.createNewUserRepository(token, createRepository);
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ public class NewRepoActivity extends AppCompatActivity {
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.createNewUserOrgRepository(token, repoOwner, createRepository);
|
.createNewUserOrgRepository(token, repoOwner, createRepository);
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ public class NewRepoActivity extends AppCompatActivity {
|
|||||||
private void getOrgs(String instanceUrl, String instanceToken, final String userLogin) {
|
private void getOrgs(String instanceUrl, String instanceToken, final String userLogin) {
|
||||||
|
|
||||||
Call<List<OrgOwner>> call = RetrofitClient
|
Call<List<OrgOwner>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getOrgOwners(instanceToken);
|
.getOrgOwners(instanceToken);
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class OrgTeamMembersActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
TeamMembersByOrgViewModel teamMembersModel = new ViewModelProvider(this).get(TeamMembersByOrgViewModel.class);
|
TeamMembersByOrgViewModel teamMembersModel = new ViewModelProvider(this).get(TeamMembersByOrgViewModel.class);
|
||||||
|
|
||||||
teamMembersModel.getMembersByOrgList(instanceUrl, instanceToken, teamId).observe(this, new Observer<List<UserInfo>>() {
|
teamMembersModel.getMembersByOrgList(instanceUrl, instanceToken, teamId, getApplicationContext()).observe(this, new Observer<List<UserInfo>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<UserInfo> teamMembersListMain) {
|
public void onChanged(@Nullable List<UserInfo> teamMembersListMain) {
|
||||||
adapter = new TeamMembersByOrgAdapter(getApplicationContext(), teamMembersListMain);
|
adapter = new TeamMembersByOrgAdapter(getApplicationContext(), teamMembersListMain);
|
||||||
|
@ -114,7 +114,7 @@ public class ProfileEmailActivity extends AppCompatActivity {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.addNewEmail(token, addEmailFunc);
|
.addNewEmail(token, addEmailFunc);
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ public class ReplyToIssueActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
replyButton.setOnClickListener(new View.OnClickListener() {
|
replyButton.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
disableProcessButton();
|
||||||
IssueActions.editIssueComment(ctx, Integer.valueOf(commentId), addComment.getText().toString());
|
IssueActions.editIssueComment(ctx, Integer.valueOf(commentId), addComment.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +118,7 @@ public class ReplyToIssueActivity extends AppCompatActivity {
|
|||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
Call<List<Collaborators>> call = RetrofitClient
|
Call<List<Collaborators>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||||
|
|
||||||
@ -211,7 +212,7 @@ public class ReplyToIssueActivity extends AppCompatActivity {
|
|||||||
Issues issueComment = new Issues(newReplyDT);
|
Issues issueComment = new Issues(newReplyDT);
|
||||||
|
|
||||||
Call<Issues> call = RetrofitClient
|
Call<Issues> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.replyCommentToIssue(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, issueComment);
|
.replyCommentToIssue(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, issueComment);
|
||||||
|
|
||||||
@ -225,6 +226,7 @@ public class ReplyToIssueActivity extends AppCompatActivity {
|
|||||||
Toasty.info(getApplicationContext(), getString(R.string.commentSuccess));
|
Toasty.info(getApplicationContext(), getString(R.string.commentSuccess));
|
||||||
tinyDb.putBoolean("commentPosted", true);
|
tinyDb.putBoolean("commentPosted", true);
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
|
tinyDb.putBoolean("resumePullRequests", true);
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import org.mian.gitnex.fragments.FilesFragment;
|
|||||||
import org.mian.gitnex.fragments.IssuesFragment;
|
import org.mian.gitnex.fragments.IssuesFragment;
|
||||||
import org.mian.gitnex.fragments.LabelsFragment;
|
import org.mian.gitnex.fragments.LabelsFragment;
|
||||||
import org.mian.gitnex.fragments.MilestonesFragment;
|
import org.mian.gitnex.fragments.MilestonesFragment;
|
||||||
|
import org.mian.gitnex.fragments.PullRequestsFragment;
|
||||||
import org.mian.gitnex.fragments.ReleasesFragment;
|
import org.mian.gitnex.fragments.ReleasesFragment;
|
||||||
import org.mian.gitnex.fragments.RepoBottomSheetFragment;
|
import org.mian.gitnex.fragments.RepoBottomSheetFragment;
|
||||||
import org.mian.gitnex.fragments.RepoInfoFragment;
|
import org.mian.gitnex.fragments.RepoInfoFragment;
|
||||||
@ -213,15 +214,18 @@ public class RepoDetailActivity extends AppCompatActivity implements RepoBottomS
|
|||||||
case 3: // closed issues
|
case 3: // closed issues
|
||||||
fragment = new ClosedIssuesFragment();
|
fragment = new ClosedIssuesFragment();
|
||||||
break;
|
break;
|
||||||
case 4: // milestones
|
case 4: // pull requests
|
||||||
|
fragment = new PullRequestsFragment();
|
||||||
|
break;
|
||||||
|
case 5: // milestones
|
||||||
return MilestonesFragment.newInstance(repoOwner, repoName);
|
return MilestonesFragment.newInstance(repoOwner, repoName);
|
||||||
case 5: // labels
|
case 6: // labels
|
||||||
return LabelsFragment.newInstance(repoOwner, repoName);
|
return LabelsFragment.newInstance(repoOwner, repoName);
|
||||||
case 6: // branches
|
case 7: // branches
|
||||||
return BranchesFragment.newInstance(repoOwner, repoName);
|
return BranchesFragment.newInstance(repoOwner, repoName);
|
||||||
case 7: // releases
|
case 8: // releases
|
||||||
return ReleasesFragment.newInstance(repoOwner, repoName);
|
return ReleasesFragment.newInstance(repoOwner, repoName);
|
||||||
case 8: // collaborators
|
case 9: // collaborators
|
||||||
return CollaboratorsFragment.newInstance(repoOwner, repoName);
|
return CollaboratorsFragment.newInstance(repoOwner, repoName);
|
||||||
}
|
}
|
||||||
return fragment;
|
return fragment;
|
||||||
@ -229,7 +233,7 @@ public class RepoDetailActivity extends AppCompatActivity implements RepoBottomS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return 9;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -237,7 +241,7 @@ public class RepoDetailActivity extends AppCompatActivity implements RepoBottomS
|
|||||||
private void getRepoInfo(String instanceUrl, String token, final String owner, String repo) {
|
private void getRepoInfo(String instanceUrl, String token, final String owner, String repo) {
|
||||||
|
|
||||||
Call<UserRepositories> call = RetrofitClient
|
Call<UserRepositories> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getUserRepository(token, owner, repo);
|
.getUserRepository(token, owner, repo);
|
||||||
|
|
||||||
@ -277,7 +281,7 @@ public class RepoDetailActivity extends AppCompatActivity implements RepoBottomS
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.checkRepoStarStatus(instanceToken, owner, repo);
|
.checkRepoStarStatus(instanceToken, owner, repo);
|
||||||
|
|
||||||
@ -304,7 +308,7 @@ public class RepoDetailActivity extends AppCompatActivity implements RepoBottomS
|
|||||||
Call<WatchRepository> call;
|
Call<WatchRepository> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.checkRepoWatchStatus(instanceToken, owner, repo);
|
.checkRepoWatchStatus(instanceToken, owner, repo);
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public class RepoStargazersActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
RepoStargazersViewModel repoStargazersModel = new ViewModelProvider(this).get(RepoStargazersViewModel.class);
|
RepoStargazersViewModel repoStargazersModel = new ViewModelProvider(this).get(RepoStargazersViewModel.class);
|
||||||
|
|
||||||
repoStargazersModel.getRepoStargazers(instanceUrl, instanceToken, repoOwner, repoName).observe(this, new Observer<List<UserInfo>>() {
|
repoStargazersModel.getRepoStargazers(instanceUrl, instanceToken, repoOwner, repoName, getApplicationContext()).observe(this, new Observer<List<UserInfo>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<UserInfo> stargazersListMain) {
|
public void onChanged(@Nullable List<UserInfo> stargazersListMain) {
|
||||||
adapter = new RepoStargazersAdapter(getApplicationContext(), stargazersListMain);
|
adapter = new RepoStargazersAdapter(getApplicationContext(), stargazersListMain);
|
||||||
|
@ -64,7 +64,7 @@ public class RepoWatchersActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
RepoWatchersViewModel repoWatchersModel = new ViewModelProvider(this).get(RepoWatchersViewModel.class);
|
RepoWatchersViewModel repoWatchersModel = new ViewModelProvider(this).get(RepoWatchersViewModel.class);
|
||||||
|
|
||||||
repoWatchersModel.getRepoWatchers(instanceUrl, instanceToken, repoOwner, repoName).observe(this, new Observer<List<UserInfo>>() {
|
repoWatchersModel.getRepoWatchers(instanceUrl, instanceToken, repoOwner, repoName, getApplicationContext()).observe(this, new Observer<List<UserInfo>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<UserInfo> watchersListMain) {
|
public void onChanged(@Nullable List<UserInfo> watchersListMain) {
|
||||||
adapter = new RepoWatchersAdapter(getApplicationContext(), watchersListMain);
|
adapter = new RepoWatchersAdapter(getApplicationContext(), watchersListMain);
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.method.LinkMovementMethod;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
|
||||||
import org.mian.gitnex.R;
|
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
|
* Author M M Arif
|
||||||
@ -22,12 +28,27 @@ public class SponsorsActivity extends AppCompatActivity {
|
|||||||
setContentView(R.layout.activity_sponsors);
|
setContentView(R.layout.activity_sponsors);
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
TextView liberaPaySponsorsThomas = findViewById(R.id.liberaPaySponsorsThomas);
|
|
||||||
|
|
||||||
liberaPaySponsorsThomas.setMovementMethod(LinkMovementMethod.getInstance());
|
|
||||||
|
|
||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
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(getApplicationContext()));
|
||||||
|
|
||||||
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
||||||
|
DividerItemDecoration.VERTICAL);
|
||||||
|
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
|
SponsorsAdapter adapter = new SponsorsAdapter(sponsorsList);
|
||||||
|
mRecyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
@ -11,6 +11,7 @@ import android.widget.Filter;
|
|||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
@ -109,7 +110,7 @@ public class ClosedIssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
private TextView issueTitle;
|
private TextView issueTitle;
|
||||||
private TextView issueCreatedTime;
|
private TextView issueCreatedTime;
|
||||||
private TextView issueCommentsCount;
|
private TextView issueCommentsCount;
|
||||||
private ImageView issueType;
|
private RelativeLayout relativeLayoutFrame;
|
||||||
|
|
||||||
IssuesHolder(View itemView) {
|
IssuesHolder(View itemView) {
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ public class ClosedIssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount);
|
issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount);
|
||||||
LinearLayout frameCommentsCount = itemView.findViewById(R.id.frameCommentsCount);
|
LinearLayout frameCommentsCount = itemView.findViewById(R.id.frameCommentsCount);
|
||||||
issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime);
|
issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime);
|
||||||
issueType = itemView.findViewById(R.id.issueType);
|
relativeLayoutFrame = itemView.findViewById(R.id.relativeLayoutFrame);
|
||||||
|
|
||||||
issueTitle.setOnClickListener(new View.OnClickListener() {
|
issueTitle.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -135,6 +136,7 @@ public class ClosedIssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = new TinyDB(context);
|
||||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||||
|
tinyDb.putString("issueType", "issue");
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -151,6 +153,7 @@ public class ClosedIssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = new TinyDB(context);
|
||||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||||
|
tinyDb.putString("issueType", "issue");
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -165,6 +168,13 @@ public class ClosedIssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
|
/*if(issuesModel.getPull_request() != null) {
|
||||||
|
if (issuesModel.getPull_request().isMerged()) {
|
||||||
|
relativeLayoutFrame.setVisibility(View.GONE);
|
||||||
|
relativeLayoutFrame.setLayoutParams(new RecyclerView.LayoutParams(0, 0));
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
if (!issuesModel.getUser().getFull_name().equals("")) {
|
if (!issuesModel.getUser().getFull_name().equals("")) {
|
||||||
issueAssigneeAvatar.setOnClickListener(new ClickListener(context.getResources().getString(R.string.issueCreator) + issuesModel.getUser().getFull_name(), context));
|
issueAssigneeAvatar.setOnClickListener(new ClickListener(context.getResources().getString(R.string.issueCreator) + issuesModel.getUser().getFull_name(), context));
|
||||||
} else {
|
} else {
|
||||||
@ -177,14 +187,6 @@ public class ClosedIssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
Picasso.get().load(issuesModel.getUser().getAvatar_url()).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(issueAssigneeAvatar);
|
Picasso.get().load(issuesModel.getUser().getAvatar_url()).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(issueAssigneeAvatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (issuesModel.getPull_request() == null) {
|
|
||||||
issueType.setImageResource(R.drawable.ic_issues);
|
|
||||||
issueType.setOnClickListener(new ClickListener(context.getResources().getString(R.string.issueTypeIssue), context));
|
|
||||||
} else {
|
|
||||||
issueType.setImageResource(R.drawable.ic_merge);
|
|
||||||
issueType.setOnClickListener(new ClickListener(context.getResources().getString(R.string.issueTypePullRequest), context));
|
|
||||||
}
|
|
||||||
|
|
||||||
String issueNumber_ = "<font color='" + context.getResources().getColor(R.color.lightGray) + "'>" + context.getResources().getString(R.string.hash) + issuesModel.getNumber() + "</font>";
|
String issueNumber_ = "<font color='" + context.getResources().getColor(R.color.lightGray) + "'>" + context.getResources().getString(R.string.hash) + issuesModel.getNumber() + "</font>";
|
||||||
issueTitle.setText(Html.fromHtml(issueNumber_ + " " + issuesModel.getTitle()));
|
issueTitle.setText(Html.fromHtml(issueNumber_ + " " + issuesModel.getTitle()));
|
||||||
|
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
|
import android.text.SpannableStringBuilder;
|
||||||
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import org.mian.gitnex.R;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author M M Arif
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CreditsAdapter extends RecyclerView.Adapter<CreditsAdapter.CreditsViewHolder> {
|
||||||
|
|
||||||
|
private List<CharSequence> creditsList;
|
||||||
|
|
||||||
|
static class CreditsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
private TextView creditText;
|
||||||
|
|
||||||
|
private CreditsViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
creditText = itemView.findViewById(R.id.creditText);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreditsAdapter(List<CharSequence> creditsListMain) {
|
||||||
|
this.creditsList = creditsListMain;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public CreditsAdapter.CreditsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.credits, parent, false);
|
||||||
|
return new CreditsAdapter.CreditsViewHolder(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull CreditsAdapter.CreditsViewHolder holder, int position) {
|
||||||
|
|
||||||
|
SpannableStringBuilder strBuilder = new SpannableStringBuilder(creditsList.get(position));
|
||||||
|
holder.creditText.setText((strBuilder));
|
||||||
|
holder.creditText.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return creditsList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
138
app/src/main/java/org/mian/gitnex/adapters/FilesDiffAdapter.java
Normal file
138
app/src/main/java/org/mian/gitnex/adapters/FilesDiffAdapter.java
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.HorizontalScrollView;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.models.FileDiffView;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author M M Arif
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class FilesDiffAdapter extends RecyclerView.Adapter<FilesDiffAdapter.FilesDiffViewHolder> {
|
||||||
|
|
||||||
|
private List<FileDiffView> dataList;
|
||||||
|
private Context ctx;
|
||||||
|
|
||||||
|
static class FilesDiffViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
private TextView fileContents;
|
||||||
|
private TextView fileName;
|
||||||
|
private TextView fileInfo;
|
||||||
|
private ImageView fileImage;
|
||||||
|
private HorizontalScrollView fileContentsView;
|
||||||
|
private LinearLayout allLines;
|
||||||
|
|
||||||
|
private FilesDiffViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
fileContents = itemView.findViewById(R.id.fileContents);
|
||||||
|
fileName = itemView.findViewById(R.id.fileName);
|
||||||
|
fileInfo = itemView.findViewById(R.id.fileInfo);
|
||||||
|
fileImage = itemView.findViewById(R.id.fileImage);
|
||||||
|
fileContentsView = itemView.findViewById(R.id.fileContentsView);
|
||||||
|
allLines = itemView.findViewById(R.id.allLinesLayout);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilesDiffAdapter(List<FileDiffView> dataListMain, Context ctx) {
|
||||||
|
this.dataList = dataListMain;
|
||||||
|
this.ctx = ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public FilesDiffAdapter.FilesDiffViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.files_diffs_list, parent, false);
|
||||||
|
return new FilesDiffAdapter.FilesDiffViewHolder(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull FilesDiffViewHolder holder, int position) {
|
||||||
|
|
||||||
|
FileDiffView data = dataList.get(position);
|
||||||
|
|
||||||
|
if(data.isFileType()) {
|
||||||
|
|
||||||
|
holder.fileName.setText(data.getFileName());
|
||||||
|
|
||||||
|
holder.fileInfo.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
//byte[] imageData = Base64.decode(data.getFileContents(), Base64.DEFAULT);
|
||||||
|
//Drawable imageDrawable = new BitmapDrawable(ctx.getResources(), BitmapFactory.decodeByteArray(imageData, 0, imageData.length));
|
||||||
|
//holder.fileImage.setImageDrawable(imageDrawable);
|
||||||
|
holder.fileContentsView.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
String[] splitData = data.getFileContents().split("\\R");
|
||||||
|
|
||||||
|
for (String eachSplit : splitData) {
|
||||||
|
|
||||||
|
TextView textLine = new TextView(ctx);
|
||||||
|
textLine.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
|
|
||||||
|
if (eachSplit.startsWith("+")) {
|
||||||
|
|
||||||
|
textLine.setText(eachSplit);
|
||||||
|
holder.allLines.addView(textLine);
|
||||||
|
|
||||||
|
textLine.setTextColor(ctx.getResources().getColor(R.color.colorPrimary));
|
||||||
|
textLine.setPadding(5, 5, 5, 5);
|
||||||
|
textLine.setBackgroundColor(ctx.getResources().getColor(R.color.diffAddedColor));
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (eachSplit.startsWith("-")) {
|
||||||
|
|
||||||
|
textLine.setText(eachSplit);
|
||||||
|
holder.allLines.addView(textLine);
|
||||||
|
|
||||||
|
textLine.setTextColor(ctx.getResources().getColor(R.color.colorPrimary));
|
||||||
|
textLine.setPadding(5, 5, 5, 5);
|
||||||
|
textLine.setBackgroundColor(ctx.getResources().getColor(R.color.diffRemovedColor));
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
if(eachSplit.length() > 0) {
|
||||||
|
textLine.setText(eachSplit);
|
||||||
|
holder.allLines.addView(textLine);
|
||||||
|
|
||||||
|
textLine.setTextColor(ctx.getResources().getColor(R.color.colorPrimary));
|
||||||
|
textLine.setPadding(5, 5, 5, 5);
|
||||||
|
textLine.setBackgroundColor(ctx.getResources().getColor(R.color.white));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.fileName.setText(data.getFileName());
|
||||||
|
if(!data.getFileInfo().equals("")) {
|
||||||
|
holder.fileInfo.setText(ctx.getResources().getString(R.string.fileDiffInfoChanges, data.getFileInfo()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
holder.fileInfo.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return dataList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -11,6 +11,7 @@ import android.widget.Filter;
|
|||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
@ -109,7 +110,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
private TextView issueTitle;
|
private TextView issueTitle;
|
||||||
private TextView issueCreatedTime;
|
private TextView issueCreatedTime;
|
||||||
private TextView issueCommentsCount;
|
private TextView issueCommentsCount;
|
||||||
private ImageView issueType;
|
private RelativeLayout relativeLayoutFrame;
|
||||||
|
|
||||||
IssuesHolder(View itemView) {
|
IssuesHolder(View itemView) {
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount);
|
issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount);
|
||||||
LinearLayout frameCommentsCount = itemView.findViewById(R.id.frameCommentsCount);
|
LinearLayout frameCommentsCount = itemView.findViewById(R.id.frameCommentsCount);
|
||||||
issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime);
|
issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime);
|
||||||
issueType = itemView.findViewById(R.id.issueType);
|
relativeLayoutFrame = itemView.findViewById(R.id.relativeLayoutFrame);
|
||||||
|
|
||||||
issueTitle.setOnClickListener(new View.OnClickListener() {
|
issueTitle.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -135,6 +136,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = new TinyDB(context);
|
||||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||||
|
tinyDb.putString("issueType", "issue");
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -151,6 +153,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = new TinyDB(context);
|
||||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||||
|
tinyDb.putString("issueType", "issue");
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -165,6 +168,13 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
|
/*if(issuesModel.getPull_request() != null) {
|
||||||
|
if (!issuesModel.getPull_request().isMerged()) {
|
||||||
|
relativeLayoutFrame.setVisibility(View.GONE);
|
||||||
|
relativeLayoutFrame.setLayoutParams(new RecyclerView.LayoutParams(0, 0));
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
if (!issuesModel.getUser().getFull_name().equals("")) {
|
if (!issuesModel.getUser().getFull_name().equals("")) {
|
||||||
issueAssigneeAvatar.setOnClickListener(new ClickListener(context.getResources().getString(R.string.issueCreator) + issuesModel.getUser().getFull_name(), context));
|
issueAssigneeAvatar.setOnClickListener(new ClickListener(context.getResources().getString(R.string.issueCreator) + issuesModel.getUser().getFull_name(), context));
|
||||||
} else {
|
} else {
|
||||||
@ -177,14 +187,6 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
Picasso.get().load(issuesModel.getUser().getAvatar_url()).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(issueAssigneeAvatar);
|
Picasso.get().load(issuesModel.getUser().getAvatar_url()).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(issueAssigneeAvatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (issuesModel.getPull_request() == null) {
|
|
||||||
issueType.setImageResource(R.drawable.ic_issues);
|
|
||||||
issueType.setOnClickListener(new ClickListener(context.getResources().getString(R.string.issueTypeIssue), context));
|
|
||||||
} else {
|
|
||||||
issueType.setImageResource(R.drawable.ic_merge);
|
|
||||||
issueType.setOnClickListener(new ClickListener(context.getResources().getString(R.string.issueTypePullRequest), context));
|
|
||||||
}
|
|
||||||
|
|
||||||
String issueNumber_ = "<font color='" + context.getResources().getColor(R.color.lightGray) + "'>" + context.getResources().getString(R.string.hash) + issuesModel.getNumber() + "</font>";
|
String issueNumber_ = "<font color='" + context.getResources().getColor(R.color.lightGray) + "'>" + context.getResources().getString(R.string.hash) + issuesModel.getNumber() + "</font>";
|
||||||
issueTitle.setText(Html.fromHtml(issueNumber_ + " " + issuesModel.getTitle()));
|
issueTitle.setText(Html.fromHtml(issueNumber_ + " " + issuesModel.getTitle()));
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
private TextView repoStarsMy;
|
private TextView repoStarsMy;
|
||||||
private TextView repoForksMy;
|
private TextView repoForksMy;
|
||||||
private TextView repoOpenIssuesCountMy;
|
private TextView repoOpenIssuesCountMy;
|
||||||
|
private TextView repoType;
|
||||||
|
|
||||||
private MyReposViewHolder(View itemView) {
|
private MyReposViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@ -62,6 +63,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
repoForksMy = itemView.findViewById(R.id.repoForksMy);
|
repoForksMy = itemView.findViewById(R.id.repoForksMy);
|
||||||
repoOpenIssuesCountMy = itemView.findViewById(R.id.repoOpenIssuesCountMy);
|
repoOpenIssuesCountMy = itemView.findViewById(R.id.repoOpenIssuesCountMy);
|
||||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||||
|
repoType = itemView.findViewById(R.id.repoType);
|
||||||
|
|
||||||
itemView.setOnClickListener(new View.OnClickListener() {
|
itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -74,6 +76,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = new TinyDB(context);
|
||||||
tinyDb.putString("repoFullName", fullNameMy.getText().toString());
|
tinyDb.putString("repoFullName", fullNameMy.getText().toString());
|
||||||
|
tinyDb.putString("repoType", repoType.getText().toString());
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
@ -198,9 +201,11 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
holder.fullNameMy.setText(currentItem.getFullname());
|
holder.fullNameMy.setText(currentItem.getFullname());
|
||||||
if(currentItem.getPrivateFlag()) {
|
if(currentItem.getPrivateFlag()) {
|
||||||
holder.repoPrivatePublicMy.setImageResource(R.drawable.ic_lock_bold);
|
holder.repoPrivatePublicMy.setImageResource(R.drawable.ic_lock_bold);
|
||||||
|
holder.repoType.setText(R.string.strPrivate);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.repoPrivatePublicMy.setImageResource(R.drawable.ic_public);
|
holder.repoPrivatePublicMy.setImageResource(R.drawable.ic_public);
|
||||||
|
holder.repoType.setText(R.string.strPublic);
|
||||||
}
|
}
|
||||||
holder.repoStarsMy.setText(currentItem.getStars_count());
|
holder.repoStarsMy.setText(currentItem.getStars_count());
|
||||||
holder.repoForksMy.setText(currentItem.getForks_count());
|
holder.repoForksMy.setText(currentItem.getForks_count());
|
||||||
|
@ -0,0 +1,279 @@
|
|||||||
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.text.Html;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Filter;
|
||||||
|
import android.widget.Filterable;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import com.squareup.picasso.Picasso;
|
||||||
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||||
|
import org.mian.gitnex.helpers.ClickListener;
|
||||||
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
|
import org.mian.gitnex.models.PullRequests;
|
||||||
|
import org.mian.gitnex.util.TinyDB;
|
||||||
|
import org.ocpsoft.prettytime.PrettyTime;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author M M Arif
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Filterable {
|
||||||
|
|
||||||
|
private Context context;
|
||||||
|
private final int TYPE_LOAD = 0;
|
||||||
|
private List<PullRequests> prList;
|
||||||
|
private List<PullRequests> prListFull;
|
||||||
|
private PullRequestsAdapter.OnLoadMoreListener loadMoreListener;
|
||||||
|
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||||
|
|
||||||
|
public PullRequestsAdapter(Context context, List<PullRequests> prListMain) {
|
||||||
|
|
||||||
|
this.context = context;
|
||||||
|
this.prList = prListMain;
|
||||||
|
prListFull = new ArrayList<>(prList);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
|
|
||||||
|
if(viewType == TYPE_LOAD){
|
||||||
|
return new PullRequestsAdapter.PullRequestsHolder(inflater.inflate(R.layout.repo_pr_list, parent,false));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return new PullRequestsAdapter.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) {
|
||||||
|
|
||||||
|
((PullRequestsAdapter.PullRequestsHolder)holder).bindData(prList.get(position));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int position) {
|
||||||
|
|
||||||
|
if(prList.get(position).getTitle() != null) {
|
||||||
|
return TYPE_LOAD;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
|
||||||
|
return prList.size();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class PullRequestsHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
private TextView prNumber;
|
||||||
|
private ImageView assigneeAvatar;
|
||||||
|
private TextView prTitle;
|
||||||
|
private TextView prCreatedTime;
|
||||||
|
private TextView prCommentsCount;
|
||||||
|
|
||||||
|
PullRequestsHolder(View itemView) {
|
||||||
|
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
prNumber = itemView.findViewById(R.id.prNumber);
|
||||||
|
assigneeAvatar = itemView.findViewById(R.id.assigneeAvatar);
|
||||||
|
prTitle = itemView.findViewById(R.id.prTitle);
|
||||||
|
prCommentsCount = itemView.findViewById(R.id.prCommentsCount);
|
||||||
|
LinearLayout frameCommentsCount = itemView.findViewById(R.id.frameCommentsCount);
|
||||||
|
prCreatedTime = itemView.findViewById(R.id.prCreatedTime);
|
||||||
|
|
||||||
|
prTitle.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
Context context = v.getContext();
|
||||||
|
|
||||||
|
Intent intent = new Intent(context, IssueDetailActivity.class);
|
||||||
|
intent.putExtra("issueNumber", prNumber.getText());
|
||||||
|
|
||||||
|
TinyDB tinyDb = new TinyDB(context);
|
||||||
|
tinyDb.putString("issueNumber", prNumber.getText().toString());
|
||||||
|
tinyDb.putString("issueType", "pr");
|
||||||
|
context.startActivity(intent);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
frameCommentsCount.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
Context context = v.getContext();
|
||||||
|
|
||||||
|
Intent intent = new Intent(context, IssueDetailActivity.class);
|
||||||
|
intent.putExtra("issueNumber", prNumber.getText());
|
||||||
|
|
||||||
|
TinyDB tinyDb = new TinyDB(context);
|
||||||
|
tinyDb.putString("issueNumber", prNumber.getText().toString());
|
||||||
|
tinyDb.putString("issueType", "pr");
|
||||||
|
context.startActivity(intent);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
void bindData(PullRequests prModel){
|
||||||
|
|
||||||
|
final TinyDB tinyDb = new TinyDB(context);
|
||||||
|
final String locale = tinyDb.getString("locale");
|
||||||
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
|
if (!prModel.getUser().getFull_name().equals("")) {
|
||||||
|
assigneeAvatar.setOnClickListener(new ClickListener(context.getResources().getString(R.string.prCreator) + prModel.getUser().getFull_name(), context));
|
||||||
|
} else {
|
||||||
|
assigneeAvatar.setOnClickListener(new ClickListener(context.getResources().getString(R.string.prCreator) + prModel.getUser().getLogin(), context));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prModel.getUser().getAvatar_url() != null) {
|
||||||
|
Picasso.get().load(prModel.getUser().getAvatar_url()).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(assigneeAvatar);
|
||||||
|
} else {
|
||||||
|
Picasso.get().load(prModel.getUser().getAvatar_url()).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(assigneeAvatar);
|
||||||
|
}
|
||||||
|
|
||||||
|
String prNumber_ = "<font color='" + context.getResources().getColor(R.color.lightGray) + "'>" + context.getResources().getString(R.string.hash) + prModel.getNumber() + "</font>";
|
||||||
|
prTitle.setText(Html.fromHtml(prNumber_ + " " + prModel.getTitle()));
|
||||||
|
|
||||||
|
prNumber.setText(String.valueOf(prModel.getNumber()));
|
||||||
|
prCommentsCount.setText(String.valueOf(prModel.getComments()));
|
||||||
|
|
||||||
|
switch (timeFormat) {
|
||||||
|
case "pretty": {
|
||||||
|
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
|
||||||
|
String createdTime = prettyTime.format(prModel.getCreated_at());
|
||||||
|
prCreatedTime.setText(createdTime);
|
||||||
|
prCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(prModel.getCreated_at()), context));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "normal": {
|
||||||
|
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
|
String createdTime = formatter.format(prModel.getCreated_at());
|
||||||
|
prCreatedTime.setText(createdTime);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "normal1": {
|
||||||
|
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
|
String createdTime = formatter.format(prModel.getCreated_at());
|
||||||
|
prCreatedTime.setText(createdTime);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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(PullRequestsAdapter.OnLoadMoreListener loadMoreListener) {
|
||||||
|
|
||||||
|
this.loadMoreListener = loadMoreListener;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Filter getFilter() {
|
||||||
|
return prFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Filter prFilter = new Filter() {
|
||||||
|
@Override
|
||||||
|
protected FilterResults performFiltering(CharSequence constraint) {
|
||||||
|
List<PullRequests> filteredList = new ArrayList<>();
|
||||||
|
|
||||||
|
if (constraint == null || constraint.length() == 0) {
|
||||||
|
filteredList.addAll(prList);
|
||||||
|
} else {
|
||||||
|
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||||
|
|
||||||
|
for (PullRequests item : prList) {
|
||||||
|
if (item.getTitle().toLowerCase().contains(filterPattern) || item.getBody().toLowerCase().contains(filterPattern)) {
|
||||||
|
filteredList.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FilterResults results = new FilterResults();
|
||||||
|
results.values = filteredList;
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||||
|
prList.clear();
|
||||||
|
prList.addAll((List) results.values);
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
@ -50,6 +50,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
private TextView repoStars;
|
private TextView repoStars;
|
||||||
private TextView repoForks;
|
private TextView repoForks;
|
||||||
private TextView repoOpenIssuesCount;
|
private TextView repoOpenIssuesCount;
|
||||||
|
private TextView repoType;
|
||||||
|
|
||||||
private ReposViewHolder(View itemView) {
|
private ReposViewHolder(View itemView) {
|
||||||
|
|
||||||
@ -63,6 +64,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
repoForks = itemView.findViewById(R.id.repoForks);
|
repoForks = itemView.findViewById(R.id.repoForks);
|
||||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||||
|
repoType = itemView.findViewById(R.id.repoType);
|
||||||
|
|
||||||
itemView.setOnClickListener(new View.OnClickListener() {
|
itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -70,12 +72,14 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
TextView repoFullName = v.findViewById(R.id.repoFullName);
|
TextView repoFullName = v.findViewById(R.id.repoFullName);
|
||||||
|
TextView repoType_ = v.findViewById(R.id.repoType);
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = new TinyDB(context);
|
||||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||||
|
tinyDb.putString("repoType", repoType_.getText().toString());
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
@ -200,9 +204,11 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
holder.fullName.setText(currentItem.getFullname());
|
holder.fullName.setText(currentItem.getFullname());
|
||||||
if(currentItem.getPrivateFlag()) {
|
if(currentItem.getPrivateFlag()) {
|
||||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
||||||
|
holder.repoType.setText(R.string.strPrivate);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
||||||
|
holder.repoType.setText(R.string.strPublic);
|
||||||
}
|
}
|
||||||
holder.repoStars.setText(currentItem.getStars_count());
|
holder.repoStars.setText(currentItem.getStars_count());
|
||||||
holder.repoForks.setText(currentItem.getForks_count());
|
holder.repoForks.setText(currentItem.getForks_count());
|
||||||
|
@ -50,6 +50,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
private TextView repoStars;
|
private TextView repoStars;
|
||||||
private TextView repoForks;
|
private TextView repoForks;
|
||||||
private TextView repoOpenIssuesCount;
|
private TextView repoOpenIssuesCount;
|
||||||
|
private TextView repoType;
|
||||||
|
|
||||||
private OrgReposViewHolder(View itemView) {
|
private OrgReposViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@ -62,6 +63,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
repoForks = itemView.findViewById(R.id.repoForks);
|
repoForks = itemView.findViewById(R.id.repoForks);
|
||||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||||
|
repoType = itemView.findViewById(R.id.repoType);
|
||||||
|
|
||||||
itemView.setOnClickListener(new View.OnClickListener() {
|
itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -74,6 +76,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = new TinyDB(context);
|
||||||
tinyDb.putString("repoFullName", fullName.getText().toString());
|
tinyDb.putString("repoFullName", fullName.getText().toString());
|
||||||
|
tinyDb.putString("repoType", repoType.getText().toString());
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
@ -199,9 +202,11 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
holder.fullName.setText(currentItem.getFullname());
|
holder.fullName.setText(currentItem.getFullname());
|
||||||
if(currentItem.getPrivateFlag()) {
|
if(currentItem.getPrivateFlag()) {
|
||||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
||||||
|
holder.repoType.setText(R.string.strPrivate);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
||||||
|
holder.repoType.setText(R.string.strPublic);
|
||||||
}
|
}
|
||||||
holder.repoStars.setText(currentItem.getStars_count());
|
holder.repoStars.setText(currentItem.getStars_count());
|
||||||
holder.repoForks.setText(currentItem.getForks_count());
|
holder.repoForks.setText(currentItem.getForks_count());
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
|
import android.text.SpannableStringBuilder;
|
||||||
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import org.mian.gitnex.R;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author M M Arif
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SponsorsAdapter extends RecyclerView.Adapter<SponsorsAdapter.SponsorsViewHolder> {
|
||||||
|
|
||||||
|
private List<CharSequence> sponsorsList;
|
||||||
|
|
||||||
|
static class SponsorsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
private TextView sponsorText;
|
||||||
|
|
||||||
|
private SponsorsViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
sponsorText = itemView.findViewById(R.id.sponsorText);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SponsorsAdapter(List<CharSequence> sponsorsListMain) {
|
||||||
|
this.sponsorsList = sponsorsListMain;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public SponsorsAdapter.SponsorsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.sponsors, parent, false);
|
||||||
|
return new SponsorsAdapter.SponsorsViewHolder(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull SponsorsAdapter.SponsorsViewHolder holder, int position) {
|
||||||
|
|
||||||
|
SpannableStringBuilder strBuilder = new SpannableStringBuilder(sponsorsList.get(position));
|
||||||
|
holder.sponsorText.setText((strBuilder));
|
||||||
|
holder.sponsorText.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return sponsorsList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -50,6 +50,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
private TextView repoStars;
|
private TextView repoStars;
|
||||||
private TextView repoForks;
|
private TextView repoForks;
|
||||||
private TextView repoOpenIssuesCount;
|
private TextView repoOpenIssuesCount;
|
||||||
|
private TextView repoType;
|
||||||
|
|
||||||
private StarredReposViewHolder(View itemView) {
|
private StarredReposViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@ -62,6 +63,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
repoForks = itemView.findViewById(R.id.repoForks);
|
repoForks = itemView.findViewById(R.id.repoForks);
|
||||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||||
|
repoType = itemView.findViewById(R.id.repoType);
|
||||||
|
|
||||||
itemView.setOnClickListener(new View.OnClickListener() {
|
itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -74,6 +76,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = new TinyDB(context);
|
||||||
tinyDb.putString("repoFullName", fullName.getText().toString());
|
tinyDb.putString("repoFullName", fullName.getText().toString());
|
||||||
|
tinyDb.putString("repoType", repoType.getText().toString());
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
@ -199,9 +202,11 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
holder.fullName.setText(currentItem.getFullname());
|
holder.fullName.setText(currentItem.getFullname());
|
||||||
if(currentItem.getPrivateFlag()) {
|
if(currentItem.getPrivateFlag()) {
|
||||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
||||||
|
holder.repoType.setText(R.string.strPrivate);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
||||||
|
holder.repoType.setText(R.string.strPublic);
|
||||||
}
|
}
|
||||||
holder.repoStars.setText(currentItem.getStars_count());
|
holder.repoStars.setText(currentItem.getStars_count());
|
||||||
holder.repoForks.setText(currentItem.getForks_count());
|
holder.repoForks.setText(currentItem.getForks_count());
|
||||||
|
@ -156,7 +156,7 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
|||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
Call<Collaborators> call = RetrofitClient
|
Call<Collaborators> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, mCtx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.checkRepoCollaborator(Authorization.returnAuthentication(mCtx, loginUid, instanceToken), repoOwner, repoName, currentItem.getUsername());
|
.checkRepoCollaborator(Authorization.returnAuthentication(mCtx, loginUid, instanceToken), repoOwner, repoName, currentItem.getUsername());
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<Collaborators> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<Collaborators> call, @NonNull Throwable t) {
|
||||||
Log.i("onFailure", t.getMessage());
|
Log.i("onFailure", t.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
package org.mian.gitnex.clients;
|
package org.mian.gitnex.clients;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import org.mian.gitnex.util.AppUtil;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import okhttp3.Cache;
|
||||||
|
import okhttp3.Interceptor;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
import okhttp3.logging.HttpLoggingInterceptor;
|
import okhttp3.logging.HttpLoggingInterceptor;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
@ -11,21 +20,40 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||||||
|
|
||||||
public class IssuesService {
|
public class IssuesService {
|
||||||
|
|
||||||
public static <S> S createService(Class<S> serviceClass, String instanceURL) {
|
public static <S> S createService(Class<S> serviceClass, String instanceURL, Context ctx) {
|
||||||
|
|
||||||
|
final boolean connToInternet = AppUtil.haveNetworkConnection(ctx);
|
||||||
|
File httpCacheDirectory = new File(ctx.getCacheDir(), "responses");
|
||||||
|
int cacheSize = 50 * 1024 * 1024; // 50MB
|
||||||
|
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
||||||
|
|
||||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||||
|
|
||||||
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
||||||
|
.cache(cache)
|
||||||
httpClient.addInterceptor(logging);
|
//.addInterceptor(logging)
|
||||||
|
.addInterceptor(new Interceptor() {
|
||||||
Retrofit retrofit = new Retrofit.Builder()
|
@NonNull
|
||||||
.baseUrl(instanceURL)
|
@Override public Response intercept(@NonNull Chain chain) throws IOException {
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
Request request = chain.request();
|
||||||
//.client(httpClient.build())
|
if (connToInternet) {
|
||||||
|
request = request.newBuilder().header("Cache-Control", "public, max-age=" + 60).build();
|
||||||
|
} else {
|
||||||
|
request = request.newBuilder().header("Cache-Control", "public, only-if-cached, max-stale=" + 60 * 60 * 24 * 30).build();
|
||||||
|
}
|
||||||
|
return chain.proceed(request);
|
||||||
|
}
|
||||||
|
})
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
Retrofit.Builder builder = new Retrofit.Builder()
|
||||||
|
.baseUrl(instanceURL)
|
||||||
|
.client(okHttpClient)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create());
|
||||||
|
|
||||||
|
Retrofit retrofit = builder.build();
|
||||||
|
|
||||||
return retrofit.create(serviceClass);
|
return retrofit.create(serviceClass);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package org.mian.gitnex.clients;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import org.mian.gitnex.util.AppUtil;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import okhttp3.Cache;
|
||||||
|
import okhttp3.Interceptor;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
import okhttp3.logging.HttpLoggingInterceptor;
|
||||||
|
import retrofit2.Retrofit;
|
||||||
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author M M Arif
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class PullRequestsService {
|
||||||
|
|
||||||
|
public static <S> S createService(Class<S> serviceClass, String instanceURL, Context ctx) {
|
||||||
|
|
||||||
|
final boolean connToInternet = AppUtil.haveNetworkConnection(ctx);
|
||||||
|
File httpCacheDirectory = new File(ctx.getCacheDir(), "responses");
|
||||||
|
int cacheSize = 50 * 1024 * 1024; // 50MB
|
||||||
|
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
||||||
|
|
||||||
|
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||||
|
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||||
|
|
||||||
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
||||||
|
.cache(cache)
|
||||||
|
//.addInterceptor(logging)
|
||||||
|
.addInterceptor(new Interceptor() {
|
||||||
|
@NonNull
|
||||||
|
@Override public Response intercept(@NonNull Chain chain) throws IOException {
|
||||||
|
Request request = chain.request();
|
||||||
|
if (connToInternet) {
|
||||||
|
request = request.newBuilder().header("Cache-Control", "public, max-age=" + 60).build();
|
||||||
|
} else {
|
||||||
|
request = request.newBuilder().header("Cache-Control", "public, only-if-cached, max-stale=" + 60 * 60 * 24 * 30).build();
|
||||||
|
}
|
||||||
|
return chain.proceed(request);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Retrofit.Builder builder = new Retrofit.Builder()
|
||||||
|
.baseUrl(instanceURL)
|
||||||
|
.client(okHttpClient)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create());
|
||||||
|
|
||||||
|
Retrofit retrofit = builder.build();
|
||||||
|
|
||||||
|
return retrofit.create(serviceClass);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,16 @@
|
|||||||
package org.mian.gitnex.clients;
|
package org.mian.gitnex.clients;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import org.mian.gitnex.interfaces.ApiInterface;
|
import org.mian.gitnex.interfaces.ApiInterface;
|
||||||
|
import org.mian.gitnex.util.AppUtil;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import okhttp3.Cache;
|
||||||
|
import okhttp3.Interceptor;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
import okhttp3.logging.HttpLoggingInterceptor;
|
import okhttp3.logging.HttpLoggingInterceptor;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
@ -15,26 +24,45 @@ public class RetrofitClient {
|
|||||||
|
|
||||||
private Retrofit retrofit;
|
private Retrofit retrofit;
|
||||||
|
|
||||||
private RetrofitClient(String instanceUrl) {
|
private RetrofitClient(String instanceUrl, Context ctx) {
|
||||||
|
|
||||||
|
final boolean connToInternet = AppUtil.haveNetworkConnection(ctx);
|
||||||
|
int cacheSize = 50 * 1024 * 1024; // 50MB
|
||||||
|
File httpCacheDirectory = new File(ctx.getCacheDir(), "responses");
|
||||||
|
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
||||||
|
|
||||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||||
|
|
||||||
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
||||||
|
.cache(cache)
|
||||||
httpClient.addInterceptor(logging);
|
//.addInterceptor(logging)
|
||||||
|
.addInterceptor(new Interceptor() {
|
||||||
retrofit = new Retrofit.Builder()
|
@NonNull
|
||||||
.baseUrl(instanceUrl)
|
@Override public Response intercept(@NonNull Chain chain) throws IOException {
|
||||||
.addConverterFactory(ScalarsConverterFactory.create())
|
Request request = chain.request();
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
if (connToInternet) {
|
||||||
//.client(httpClient.build())
|
request = request.newBuilder().header("Cache-Control", "public, max-age=" + 60).build();
|
||||||
|
} else {
|
||||||
|
request = request.newBuilder().header("Cache-Control", "public, only-if-cached, max-stale=" + 60 * 60 * 24 * 30).build();
|
||||||
|
}
|
||||||
|
return chain.proceed(request);
|
||||||
|
}
|
||||||
|
})
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
Retrofit.Builder builder = new Retrofit.Builder()
|
||||||
|
.baseUrl(instanceUrl)
|
||||||
|
.client(okHttpClient)
|
||||||
|
.addConverterFactory(ScalarsConverterFactory.create())
|
||||||
|
.addConverterFactory(GsonConverterFactory.create());
|
||||||
|
|
||||||
|
retrofit = builder.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized RetrofitClient getInstance(String instanceUrl) {
|
public static synchronized RetrofitClient getInstance(String instanceUrl, Context ctx) {
|
||||||
return new RetrofitClient(instanceUrl);
|
return new RetrofitClient(instanceUrl, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiInterface getApiInterface() {
|
public ApiInterface getApiInterface() {
|
||||||
|
@ -6,27 +6,17 @@ import android.os.Bundle;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.CreditsActivity;
|
import org.mian.gitnex.activities.CreditsActivity;
|
||||||
import org.mian.gitnex.activities.MainActivity;
|
import org.mian.gitnex.activities.MainActivity;
|
||||||
import org.mian.gitnex.activities.SponsorsActivity;
|
import org.mian.gitnex.activities.SponsorsActivity;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
|
||||||
import org.mian.gitnex.models.GiteaVersion;
|
|
||||||
import org.mian.gitnex.util.AppUtil;
|
import org.mian.gitnex.util.AppUtil;
|
||||||
import org.mian.gitnex.util.TinyDB;
|
import org.mian.gitnex.util.TinyDB;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import retrofit2.Response;
|
|
||||||
import retrofit2.Call;
|
|
||||||
import retrofit2.Callback;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -34,17 +24,12 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class AboutFragment extends Fragment {
|
public class AboutFragment extends Fragment {
|
||||||
|
|
||||||
private TextView viewTextGiteaVersion;
|
|
||||||
private ProgressBar mProgressBar;
|
|
||||||
private LinearLayout pageContent;
|
|
||||||
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
|
||||||
View v = inflater.inflate(R.layout.fragment_about, container, false);
|
View v = inflater.inflate(R.layout.fragment_about, container, false);
|
||||||
((MainActivity) Objects.requireNonNull(getActivity())).setActionBarTitle(getResources().getString(R.string.pageTitleAbout));
|
((MainActivity) Objects.requireNonNull(getActivity())).setActionBarTitle(getResources().getString(R.string.pageTitleAbout));
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(getContext());
|
TinyDB tinyDb = new TinyDB(getContext());
|
||||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
|
|
||||||
final TextView appVerBuild;
|
final TextView appVerBuild;
|
||||||
final TextView donationLink;
|
final TextView donationLink;
|
||||||
@ -55,13 +40,8 @@ public class AboutFragment extends Fragment {
|
|||||||
final TextView appWebsite;
|
final TextView appWebsite;
|
||||||
final TextView appRepo;
|
final TextView appRepo;
|
||||||
|
|
||||||
pageContent = v.findViewById(R.id.aboutFrame);
|
|
||||||
pageContent.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
mProgressBar = v.findViewById(R.id.progress_bar);
|
|
||||||
|
|
||||||
appVerBuild = v.findViewById(R.id.appVerBuild);
|
appVerBuild = v.findViewById(R.id.appVerBuild);
|
||||||
viewTextGiteaVersion = v.findViewById(R.id.giteaVersion);
|
TextView viewTextGiteaVersion = v.findViewById(R.id.giteaVersion);
|
||||||
creditsButton = v.findViewById(R.id.creditsButton);
|
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);
|
||||||
@ -134,67 +114,10 @@ public class AboutFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.haveNetworkConnection(getContext());
|
String commit = getResources().getString(R.string.commitPage) + tinyDb.getString("giteaVersion");
|
||||||
|
viewTextGiteaVersion.setText(commit);
|
||||||
if(!connToInternet) {
|
|
||||||
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
pageContent.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
giteaVer(instanceUrl);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void giteaVer(String instanceUrl) {
|
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(getContext());
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
Call<GiteaVersion> call = RetrofitClient
|
|
||||||
.getInstance(instanceUrl)
|
|
||||||
.getApiInterface()
|
|
||||||
.getGiteaVersion(Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
|
||||||
|
|
||||||
call.enqueue(new Callback<GiteaVersion>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResponse(@NonNull Call<GiteaVersion> call, @NonNull Response<GiteaVersion> response) {
|
|
||||||
|
|
||||||
if (response.isSuccessful()) {
|
|
||||||
if (response.code() == 200) {
|
|
||||||
|
|
||||||
GiteaVersion version = response.body();
|
|
||||||
assert version != null;
|
|
||||||
String commit = getResources().getString(R.string.commitPage) + version.getVersion();
|
|
||||||
viewTextGiteaVersion.setText(commit);
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
pageContent.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
String commit = getResources().getString(R.string.commitPage);
|
|
||||||
viewTextGiteaVersion.setText(commit);
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
pageContent.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(@NonNull Call<GiteaVersion> call, @NonNull Throwable t) {
|
|
||||||
Log.e("onFailure", t.toString());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class BranchesFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
BranchesViewModel.loadBranchesList(instanceUrl, instanceToken, repoOwner, repoName);
|
BranchesViewModel.loadBranchesList(instanceUrl, instanceToken, repoOwner, repoName, getContext());
|
||||||
}
|
}
|
||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ public class BranchesFragment extends Fragment {
|
|||||||
|
|
||||||
BranchesViewModel branchesModel = new ViewModelProvider(this).get(BranchesViewModel.class);
|
BranchesViewModel branchesModel = new ViewModelProvider(this).get(BranchesViewModel.class);
|
||||||
|
|
||||||
branchesModel.getBranchesList(instanceUrl, instanceToken, owner, repo).observe(this, new Observer<List<Branches>>() {
|
branchesModel.getBranchesList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Branches>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<Branches> branchesListMain) {
|
public void onChanged(@Nullable List<Branches> branchesListMain) {
|
||||||
adapter = new BranchesAdapter(getContext(), branchesListMain);
|
adapter = new BranchesAdapter(getContext(), branchesListMain);
|
||||||
|
@ -28,7 +28,6 @@ import java.util.Objects;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
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;
|
||||||
@ -120,14 +119,11 @@ public class ClosedIssuesFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerViewClosed.getContext(),
|
|
||||||
DividerItemDecoration.VERTICAL);
|
|
||||||
recyclerViewClosed.setHasFixedSize(true);
|
recyclerViewClosed.setHasFixedSize(true);
|
||||||
recyclerViewClosed.addItemDecoration(dividerItemDecoration);
|
|
||||||
recyclerViewClosed.setLayoutManager(new LinearLayoutManager(context));
|
recyclerViewClosed.setLayoutManager(new LinearLayoutManager(context));
|
||||||
recyclerViewClosed.setAdapter(adapterClosed);
|
recyclerViewClosed.setAdapter(adapterClosed);
|
||||||
|
|
||||||
apiClosed = IssuesService.createService(ApiInterface.class, instanceUrl);
|
apiClosed = IssuesService.createService(ApiInterface.class, instanceUrl, getContext());
|
||||||
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, issueState);
|
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, issueState);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
@ -190,7 +186,7 @@ public class ClosedIssuesFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||||
Log.e(TAG, t.getMessage());
|
Log.e(TAG, t.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -245,7 +241,7 @@ public class ClosedIssuesFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e(TAG, t.getMessage());
|
Log.e(TAG, t.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,11 +259,11 @@ public class ClosedIssuesFragment extends Fragment {
|
|||||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||||
|
|
||||||
if(!connToInternet) {
|
/*if(!connToInternet) {
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ public class CollaboratorsFragment extends Fragment {
|
|||||||
|
|
||||||
CollaboratorsViewModel collaboratorsModel = new ViewModelProvider(this).get(CollaboratorsViewModel.class);
|
CollaboratorsViewModel collaboratorsModel = new ViewModelProvider(this).get(CollaboratorsViewModel.class);
|
||||||
|
|
||||||
collaboratorsModel.getCollaboratorsList(instanceUrl, instanceToken, owner, repo).observe(this, new Observer<List<Collaborators>>() {
|
collaboratorsModel.getCollaboratorsList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Collaborators>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<Collaborators> collaboratorsListMain) {
|
public void onChanged(@Nullable List<Collaborators> collaboratorsListMain) {
|
||||||
adapter = new CollaboratorsAdapter(getContext(), collaboratorsListMain);
|
adapter = new CollaboratorsAdapter(getContext(), collaboratorsListMain);
|
||||||
|
@ -46,9 +46,8 @@ public class ExploreRepositoriesFragment extends Fragment {
|
|||||||
private TextView searchKeyword;
|
private TextView searchKeyword;
|
||||||
private Boolean repoTypeInclude = true;
|
private Boolean repoTypeInclude = true;
|
||||||
private String sort = "updated";
|
private String sort = "updated";
|
||||||
private String order = "asc";
|
private String order = "desc";
|
||||||
|
private int limit = 50;
|
||||||
private ExploreRepositoriesAdapter adapter;
|
|
||||||
|
|
||||||
private OnFragmentInteractionListener mListener;
|
private OnFragmentInteractionListener mListener;
|
||||||
|
|
||||||
@ -93,37 +92,30 @@ public class ExploreRepositoriesFragment extends Fragment {
|
|||||||
mProgressBar = v.findViewById(R.id.progress_bar);
|
mProgressBar = v.findViewById(R.id.progress_bar);
|
||||||
mRecyclerView = v.findViewById(R.id.recyclerViewReposSearch);
|
mRecyclerView = v.findViewById(R.id.recyclerViewReposSearch);
|
||||||
|
|
||||||
if(connToInternet) {
|
searchKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
|
@Override
|
||||||
searchKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
@Override
|
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
if(!searchKeyword.getText().toString().equals("")) {
|
||||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
if(!searchKeyword.getText().toString().equals("")) {
|
mRecyclerView.setVisibility(View.GONE);
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
loadSearchReposList(instanceUrl, instanceToken, loginUid, searchKeyword.getText().toString(), repoTypeInclude, sort, order, getContext(), limit);
|
||||||
mRecyclerView.setVisibility(View.GONE);
|
|
||||||
loadSearchReposList(instanceUrl, instanceToken, loginUid, searchKeyword.getText().toString(), repoTypeInclude, sort, order, getContext());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
return false;
|
||||||
|
}
|
||||||
}
|
});
|
||||||
else {
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadSearchReposList(String instanceUrl, String instanceToken, String loginUid, String searchKeyword, Boolean repoTypeInclude, String sort, String order, final Context context) {
|
private void loadSearchReposList(String instanceUrl, String instanceToken, String loginUid, String searchKeyword, Boolean repoTypeInclude, String sort, String order, final Context context, int limit) {
|
||||||
|
|
||||||
Call<ExploreRepositories> call = RetrofitClient
|
Call<ExploreRepositories> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), searchKeyword, repoTypeInclude, sort, order);
|
.queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), searchKeyword, repoTypeInclude, sort, order, limit);
|
||||||
|
|
||||||
call.enqueue(new Callback<ExploreRepositories>() {
|
call.enqueue(new Callback<ExploreRepositories>() {
|
||||||
|
|
||||||
@ -141,7 +133,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
||||||
Log.i("onFailure", t.getMessage());
|
Log.i("onFailure", Objects.requireNonNull(t.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -150,7 +142,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
|||||||
|
|
||||||
private void getReposList(List<UserRepositories> dataList, Context context) {
|
private void getReposList(List<UserRepositories> dataList, Context context) {
|
||||||
|
|
||||||
adapter = new ExploreRepositoriesAdapter(dataList, context);
|
ExploreRepositoriesAdapter adapter = new ExploreRepositoriesAdapter(dataList, context);
|
||||||
|
|
||||||
mRecyclerView.setVisibility(View.VISIBLE);
|
mRecyclerView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
@ -140,6 +140,10 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
|||||||
|
|
||||||
fileStructure.setText(breadcrumbBuilder);
|
fileStructure.setText(breadcrumbBuilder);
|
||||||
|
|
||||||
|
String dirName_ = fileStructure.getText().toString();
|
||||||
|
dirName_ = dirName_.startsWith("/") ? dirName_.substring(1) : dirName_;
|
||||||
|
final String finalDirName_ = dirName_;
|
||||||
|
|
||||||
mBreadcrumbsView.addItem(createItem(dirName));
|
mBreadcrumbsView.addItem(createItem(dirName));
|
||||||
mBreadcrumbsView.setCallback(new DefaultBreadcrumbsCallback<BreadcrumbItem>() {
|
mBreadcrumbsView.setCallback(new DefaultBreadcrumbsCallback<BreadcrumbItem>() {
|
||||||
@Override
|
@Override
|
||||||
@ -154,7 +158,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
|||||||
String filterDir = fileStructure.getText().toString();
|
String filterDir = fileStructure.getText().toString();
|
||||||
String result = filterDir.substring(0, filterDir.indexOf(item.getSelectedItem()));
|
String result = filterDir.substring(0, filterDir.indexOf(item.getSelectedItem()));
|
||||||
fileStructure.setText(result + item.getSelectedItem());
|
fileStructure.setText(result + item.getSelectedItem());
|
||||||
fetchDataAsyncSub(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, fileStructure.getText().toString());
|
fetchDataAsyncSub(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, finalDirName_);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +168,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
fetchDataAsyncSub(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, fileStructure.getText().toString());
|
fetchDataAsyncSub(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, finalDirName_);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +196,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
|||||||
|
|
||||||
FilesViewModel filesModel = new ViewModelProvider(this).get(FilesViewModel.class);
|
FilesViewModel filesModel = new ViewModelProvider(this).get(FilesViewModel.class);
|
||||||
|
|
||||||
filesModel.getFilesList(instanceUrl, instanceToken, owner, repo, getContext()).observe(this, new Observer<List<Files>>() {
|
filesModel.getFilesList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Files>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<Files> filesListMain) {
|
public void onChanged(@Nullable List<Files> filesListMain) {
|
||||||
adapter = new FilesAdapter(getContext(), filesListMain, FilesFragment.this);
|
adapter = new FilesAdapter(getContext(), filesListMain, FilesFragment.this);
|
||||||
@ -260,11 +264,11 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
|||||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
//searchView.setQueryHint(getContext().getString(R.string.search));
|
||||||
|
|
||||||
if(!connToInternet) {
|
/*if(!connToInternet) {
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,7 +5,6 @@ import android.os.Bundle;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
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;
|
||||||
@ -119,14 +118,11 @@ public class IssuesFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
|
|
||||||
DividerItemDecoration.VERTICAL);
|
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
recyclerView.addItemDecoration(dividerItemDecoration);
|
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
api = IssuesService.createService(ApiInterface.class, instanceUrl);
|
api = IssuesService.createService(ApiInterface.class, instanceUrl, getContext());
|
||||||
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
@ -189,7 +185,7 @@ public class IssuesFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||||
Log.e(TAG, t.getMessage());
|
Log.e(TAG, t.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -244,7 +240,7 @@ public class IssuesFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e(TAG, t.getMessage());
|
Log.e(TAG, t.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,11 +258,11 @@ public class IssuesFragment extends Fragment {
|
|||||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||||
|
|
||||||
if(!connToInternet) {
|
/*if(!connToInternet) {
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ public class LabelsFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
LabelsViewModel.loadLabelsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
LabelsViewModel.loadLabelsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getContext());
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ public class LabelsFragment extends Fragment {
|
|||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
if(tinyDb.getBoolean("labelsRefresh")) {
|
if(tinyDb.getBoolean("labelsRefresh")) {
|
||||||
LabelsViewModel.loadLabelsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
LabelsViewModel.loadLabelsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getContext());
|
||||||
tinyDb.putBoolean("labelsRefresh", false);
|
tinyDb.putBoolean("labelsRefresh", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ public class LabelsFragment extends Fragment {
|
|||||||
|
|
||||||
LabelsViewModel labelsModel = new ViewModelProvider(this).get(LabelsViewModel.class);
|
LabelsViewModel labelsModel = new ViewModelProvider(this).get(LabelsViewModel.class);
|
||||||
|
|
||||||
labelsModel.getLabelsList(instanceUrl, instanceToken, owner, repo).observe(this, new Observer<List<Labels>>() {
|
labelsModel.getLabelsList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Labels>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<Labels> labelsListMain) {
|
public void onChanged(@Nullable List<Labels> labelsListMain) {
|
||||||
adapter = new LabelsAdapter(getContext(), labelsListMain);
|
adapter = new LabelsAdapter(getContext(), labelsListMain);
|
||||||
|
@ -83,7 +83,7 @@ public class MembersByOrgFragment extends Fragment {
|
|||||||
|
|
||||||
MembersByOrgViewModel membersModel= new ViewModelProvider(this).get(MembersByOrgViewModel.class);
|
MembersByOrgViewModel membersModel= new ViewModelProvider(this).get(MembersByOrgViewModel.class);
|
||||||
|
|
||||||
membersModel.getMembersList(instanceUrl, instanceToken, owner).observe(this, new Observer<List<UserInfo>>() {
|
membersModel.getMembersList(instanceUrl, instanceToken, owner, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserInfo>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<UserInfo> membersListMain) {
|
public void onChanged(@Nullable List<UserInfo> membersListMain) {
|
||||||
adapter = new MembersByOrgAdapter(getContext(), membersListMain);
|
adapter = new MembersByOrgAdapter(getContext(), membersListMain);
|
||||||
@ -112,7 +112,7 @@ public class MembersByOrgFragment extends Fragment {
|
|||||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
return;
|
return;
|
||||||
|
@ -104,7 +104,7 @@ public class MilestonesFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
MilestonesViewModel.loadMilestonesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, msState);
|
MilestonesViewModel.loadMilestonesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, msState, getContext());
|
||||||
}
|
}
|
||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ public class MilestonesFragment extends Fragment {
|
|||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
if(tinyDb.getBoolean("milestoneCreated")) {
|
if(tinyDb.getBoolean("milestoneCreated")) {
|
||||||
MilestonesViewModel.loadMilestonesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, msState);
|
MilestonesViewModel.loadMilestonesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, msState, getContext());
|
||||||
tinyDb.putBoolean("milestoneCreated", false);
|
tinyDb.putBoolean("milestoneCreated", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ public class MilestonesFragment extends Fragment {
|
|||||||
|
|
||||||
MilestonesViewModel msModel = new ViewModelProvider(this).get(MilestonesViewModel.class);
|
MilestonesViewModel msModel = new ViewModelProvider(this).get(MilestonesViewModel.class);
|
||||||
|
|
||||||
msModel.getMilestonesList(instanceUrl, instanceToken, owner, repo, msState).observe(this, new Observer<List<Milestones>>() {
|
msModel.getMilestonesList(instanceUrl, instanceToken, owner, repo, msState, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Milestones>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<Milestones> msListMain) {
|
public void onChanged(@Nullable List<Milestones> msListMain) {
|
||||||
adapter = new MilestonesAdapter(getContext(), msListMain);
|
adapter = new MilestonesAdapter(getContext(), msListMain);
|
||||||
@ -183,11 +183,11 @@ public class MilestonesFragment extends Fragment {
|
|||||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||||
|
|
||||||
if(!connToInternet) {
|
/*if(!connToInternet) {
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -132,27 +132,20 @@ public class MyRepositoriesFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(connToInternet) {
|
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
|
@Override
|
||||||
|
public void onRefresh() {
|
||||||
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
swipeRefresh.setRefreshing(false);
|
||||||
|
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, getContext());
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin);
|
||||||
@Override
|
|
||||||
public void onRefresh() {
|
|
||||||
new Handler().postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
swipeRefresh.setRefreshing(false);
|
|
||||||
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin);
|
|
||||||
}
|
|
||||||
}, 50);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin);
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
|
||||||
@ -167,7 +160,7 @@ public class MyRepositoriesFragment extends Fragment {
|
|||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
final String userLogin = tinyDb.getString("userLogin");
|
final String userLogin = tinyDb.getString("userLogin");
|
||||||
|
|
||||||
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin);
|
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, getContext());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +168,7 @@ public class MyRepositoriesFragment extends Fragment {
|
|||||||
|
|
||||||
MyRepositoriesViewModel myRepoModel = new ViewModelProvider(this).get(MyRepositoriesViewModel.class);
|
MyRepositoriesViewModel myRepoModel = new ViewModelProvider(this).get(MyRepositoriesViewModel.class);
|
||||||
|
|
||||||
myRepoModel.getCurrentUserRepositories(instanceUrl, instanceToken, userLogin).observe(this, new Observer<List<UserRepositories>>() {
|
myRepoModel.getCurrentUserRepositories(instanceUrl, instanceToken, userLogin, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<UserRepositories> myReposListMain) {
|
public void onChanged(@Nullable List<UserRepositories> myReposListMain) {
|
||||||
adapter = new MyReposListAdapter(getContext(), myReposListMain);
|
adapter = new MyReposListAdapter(getContext(), myReposListMain);
|
||||||
@ -205,11 +198,11 @@ public class MyRepositoriesFragment extends Fragment {
|
|||||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||||
|
|
||||||
if(!connToInternet) {
|
/*if(!connToInternet) {
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,7 +88,7 @@ public class OrganizationInfoFragment extends Fragment {
|
|||||||
private void getOrgInfo(String instanceUrl, String token, final String owner) {
|
private void getOrgInfo(String instanceUrl, String token, final String owner) {
|
||||||
|
|
||||||
Call<Organization> call = RetrofitClient
|
Call<Organization> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getOrganization(token, owner);
|
.getOrganization(token, owner);
|
||||||
|
|
||||||
|
@ -101,25 +101,20 @@ public class OrganizationsFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(connToInternet) {
|
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
@Override
|
||||||
@Override
|
public void onRefresh() {
|
||||||
public void onRefresh() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
new Handler().postDelayed(new Runnable() {
|
@Override
|
||||||
@Override
|
public void run() {
|
||||||
public void run() {
|
swipeRefresh.setRefreshing(false);
|
||||||
swipeRefresh.setRefreshing(false);
|
OrganizationListViewModel.loadOrgsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||||
OrganizationListViewModel.loadOrgsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
}
|
||||||
}
|
}, 50);
|
||||||
}, 50);
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||||
}
|
|
||||||
else {
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
|
||||||
@ -134,7 +129,7 @@ public class OrganizationsFragment extends Fragment {
|
|||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
if(tinyDb.getBoolean("orgCreated")) {
|
if(tinyDb.getBoolean("orgCreated")) {
|
||||||
OrganizationListViewModel.loadOrgsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
OrganizationListViewModel.loadOrgsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||||
tinyDb.putBoolean("orgCreated", false);
|
tinyDb.putBoolean("orgCreated", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,7 +138,7 @@ public class OrganizationsFragment extends Fragment {
|
|||||||
|
|
||||||
OrganizationListViewModel orgModel = new ViewModelProvider(this).get(OrganizationListViewModel.class);
|
OrganizationListViewModel orgModel = new ViewModelProvider(this).get(OrganizationListViewModel.class);
|
||||||
|
|
||||||
orgModel.getUserOrgs(instanceUrl, instanceToken).observe(this, new Observer<List<UserOrganizations>>() {
|
orgModel.getUserOrgs(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserOrganizations>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<UserOrganizations> orgsListMain) {
|
public void onChanged(@Nullable List<UserOrganizations> orgsListMain) {
|
||||||
adapter = new OrganizationsListAdapter(getContext(), orgsListMain);
|
adapter = new OrganizationsListAdapter(getContext(), orgsListMain);
|
||||||
@ -173,11 +168,11 @@ public class OrganizationsFragment extends Fragment {
|
|||||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||||
|
|
||||||
if(!connToInternet) {
|
/*if(!connToInternet) {
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -95,7 +95,7 @@ public class ProfileEmailsFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
ProfileEmailsViewModel.loadEmailsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
ProfileEmailsViewModel.loadEmailsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ public class ProfileEmailsFragment extends Fragment {
|
|||||||
|
|
||||||
ProfileEmailsViewModel profileEmailModel = new ViewModelProvider(this).get(ProfileEmailsViewModel.class);
|
ProfileEmailsViewModel profileEmailModel = new ViewModelProvider(this).get(ProfileEmailsViewModel.class);
|
||||||
|
|
||||||
profileEmailModel.getEmailsList(instanceUrl, instanceToken).observe(this, new Observer<List<Emails>>() {
|
profileEmailModel.getEmailsList(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Emails>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<Emails> emailsListMain) {
|
public void onChanged(@Nullable List<Emails> emailsListMain) {
|
||||||
adapter = new ProfileEmailsAdapter(getContext(), emailsListMain);
|
adapter = new ProfileEmailsAdapter(getContext(), emailsListMain);
|
||||||
|
@ -95,7 +95,7 @@ public class ProfileFollowersFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
ProfileFollowersViewModel.loadFollowersList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
ProfileFollowersViewModel.loadFollowersList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ public class ProfileFollowersFragment extends Fragment {
|
|||||||
|
|
||||||
ProfileFollowersViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowersViewModel.class);
|
ProfileFollowersViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowersViewModel.class);
|
||||||
|
|
||||||
pfModel.getFollowersList(instanceUrl, instanceToken).observe(this, new Observer<List<UserInfo>>() {
|
pfModel.getFollowersList(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserInfo>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<UserInfo> pfListMain) {
|
public void onChanged(@Nullable List<UserInfo> pfListMain) {
|
||||||
adapter = new ProfileFollowersAdapter(getContext(), pfListMain);
|
adapter = new ProfileFollowersAdapter(getContext(), pfListMain);
|
||||||
|
@ -95,7 +95,7 @@ public class ProfileFollowingFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
ProfileFollowingViewModel.loadFollowingList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
ProfileFollowingViewModel.loadFollowingList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ public class ProfileFollowingFragment extends Fragment {
|
|||||||
|
|
||||||
ProfileFollowingViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowingViewModel.class);
|
ProfileFollowingViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowingViewModel.class);
|
||||||
|
|
||||||
pfModel.getFollowingList(instanceUrl, instanceToken).observe(this, new Observer<List<UserInfo>>() {
|
pfModel.getFollowingList(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserInfo>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<UserInfo> pfListMain) {
|
public void onChanged(@Nullable List<UserInfo> pfListMain) {
|
||||||
adapter = new ProfileFollowingAdapter(getContext(), pfListMain);
|
adapter = new ProfileFollowingAdapter(getContext(), pfListMain);
|
||||||
|
@ -0,0 +1,293 @@
|
|||||||
|
package org.mian.gitnex.fragments;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.adapters.PullRequestsAdapter;
|
||||||
|
import org.mian.gitnex.clients.PullRequestsService;
|
||||||
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
import org.mian.gitnex.interfaces.ApiInterface;
|
||||||
|
import org.mian.gitnex.models.PullRequests;
|
||||||
|
import org.mian.gitnex.util.AppUtil;
|
||||||
|
import org.mian.gitnex.util.TinyDB;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author M M Arif
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class PullRequestsFragment extends Fragment {
|
||||||
|
|
||||||
|
private ProgressBar mProgressBar;
|
||||||
|
private RecyclerView recyclerView;
|
||||||
|
private List<PullRequests> prList;
|
||||||
|
private PullRequestsAdapter adapter;
|
||||||
|
private ApiInterface apiPR;
|
||||||
|
private String TAG = "PullRequestsListFragment - ";
|
||||||
|
private Context context;
|
||||||
|
private int pageSize = 1;
|
||||||
|
private TextView noData;
|
||||||
|
private String prState = "open";
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
final View v = inflater.inflate(R.layout.fragment_pull_requests, container, false);
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
|
TinyDB tinyDb = new TinyDB(getContext());
|
||||||
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
|
//Log.i("repoFullName", tinyDb.getString("repoFullName"));
|
||||||
|
String[] parts = repoFullName.split("/");
|
||||||
|
final String repoOwner = parts[0];
|
||||||
|
final String repoName = parts[1];
|
||||||
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||||
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
|
final SwipeRefreshLayout swipeRefresh = v.findViewById(R.id.pullToRefresh);
|
||||||
|
|
||||||
|
context = getContext();
|
||||||
|
recyclerView = v.findViewById(R.id.recyclerView);
|
||||||
|
prList = new ArrayList<>();
|
||||||
|
|
||||||
|
mProgressBar = v.findViewById(R.id.progress_bar);
|
||||||
|
noData = v.findViewById(R.id.noData);
|
||||||
|
|
||||||
|
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
|
@Override
|
||||||
|
public void onRefresh() {
|
||||||
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
swipeRefresh.setRefreshing(false);
|
||||||
|
loadInitial(instanceToken, repoOwner, repoName, pageSize, prState);
|
||||||
|
adapter.notifyDataChanged();
|
||||||
|
|
||||||
|
}
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
adapter = new PullRequestsAdapter(getContext(), prList);
|
||||||
|
adapter.setLoadMoreListener(new PullRequestsAdapter.OnLoadMoreListener() {
|
||||||
|
@Override
|
||||||
|
public void onLoadMore() {
|
||||||
|
|
||||||
|
recyclerView.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if(prList.size() == 10 || pageSize == 10) {
|
||||||
|
|
||||||
|
int page = (prList.size() + 10) / 10;
|
||||||
|
loadMore(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, page, prState);
|
||||||
|
|
||||||
|
}
|
||||||
|
/*else {
|
||||||
|
|
||||||
|
Toasty.info(context, getString(R.string.noMoreData));
|
||||||
|
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
|
||||||
|
DividerItemDecoration.VERTICAL);
|
||||||
|
recyclerView.setHasFixedSize(true);
|
||||||
|
recyclerView.addItemDecoration(dividerItemDecoration);
|
||||||
|
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||||
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
|
apiPR = PullRequestsService.createService(ApiInterface.class, instanceUrl, getContext());
|
||||||
|
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, pageSize, prState);
|
||||||
|
|
||||||
|
return v;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
|
||||||
|
super.onResume();
|
||||||
|
TinyDB tinyDb = new TinyDB(getContext());
|
||||||
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
|
String[] parts = repoFullName.split("/");
|
||||||
|
final String repoOwner = parts[0];
|
||||||
|
final String repoName = parts[1];
|
||||||
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
|
if(tinyDb.getBoolean("resumePullRequests")) {
|
||||||
|
|
||||||
|
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, pageSize, prState);
|
||||||
|
tinyDb.putBoolean("resumePullRequests", false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadInitial(String token, String repoOwner, String repoName, int page, String prState) {
|
||||||
|
|
||||||
|
Call<List<PullRequests>> call = apiPR.getPullRequests(token, repoOwner, repoName, page, prState);
|
||||||
|
|
||||||
|
call.enqueue(new Callback<List<PullRequests>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<List<PullRequests>> call, @NonNull Response<List<PullRequests>> response) {
|
||||||
|
|
||||||
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
|
assert response.body() != null;
|
||||||
|
if(response.body().size() > 0) {
|
||||||
|
|
||||||
|
prList.clear();
|
||||||
|
prList.addAll(response.body());
|
||||||
|
adapter.notifyDataChanged();
|
||||||
|
noData.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
prList.clear();
|
||||||
|
adapter.notifyDataChanged();
|
||||||
|
noData.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
mProgressBar.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log.i(TAG, String.valueOf(response.code()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.i("http", String.valueOf(response.code()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<List<PullRequests>> call, @NonNull Throwable t) {
|
||||||
|
Log.e(TAG, t.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadMore(String token, String repoOwner, String repoName, int page, String prState){
|
||||||
|
|
||||||
|
//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);
|
||||||
|
|
||||||
|
call.enqueue(new Callback<List<PullRequests>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<List<PullRequests>> call, @NonNull Response<List<PullRequests>> response) {
|
||||||
|
|
||||||
|
if(response.isSuccessful()){
|
||||||
|
|
||||||
|
//remove loading view
|
||||||
|
prList.remove(prList.size()-1);
|
||||||
|
|
||||||
|
List<PullRequests> result = response.body();
|
||||||
|
|
||||||
|
assert result != null;
|
||||||
|
if(result.size() > 0) {
|
||||||
|
|
||||||
|
pageSize = result.size();
|
||||||
|
prList.addAll(result);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
Toasty.info(context, getString(R.string.noMoreData));
|
||||||
|
adapter.setMoreDataAvailable(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
adapter.notifyDataChanged();
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
Log.e(TAG, String.valueOf(response.code()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<List<PullRequests>> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
|
Log.e(TAG, t.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||||
|
|
||||||
|
boolean connToInternet = AppUtil.haveNetworkConnection(Objects.requireNonNull(getContext()));
|
||||||
|
|
||||||
|
inflater.inflate(R.menu.search_menu, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
|
||||||
|
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||||
|
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||||
|
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
|
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||||
|
|
||||||
|
/*if(!connToInternet) {
|
||||||
|
return;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onQueryTextSubmit(String query) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onQueryTextChange(String newText) {
|
||||||
|
|
||||||
|
adapter.getFilter().filter(newText);
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -95,7 +95,7 @@ public class ReleasesFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
ReleasesViewModel.loadReleasesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
ReleasesViewModel.loadReleasesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getContext());
|
||||||
}
|
}
|
||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ public class ReleasesFragment extends Fragment {
|
|||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
if(tinyDb.getBoolean("updateReleases")) {
|
if(tinyDb.getBoolean("updateReleases")) {
|
||||||
ReleasesViewModel.loadReleasesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
ReleasesViewModel.loadReleasesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getContext());
|
||||||
tinyDb.putBoolean("updateReleases", false);
|
tinyDb.putBoolean("updateReleases", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ public class ReleasesFragment extends Fragment {
|
|||||||
|
|
||||||
ReleasesViewModel releasesModel = new ViewModelProvider(this).get(ReleasesViewModel.class);
|
ReleasesViewModel releasesModel = new ViewModelProvider(this).get(ReleasesViewModel.class);
|
||||||
|
|
||||||
releasesModel.getReleasesList(instanceUrl, instanceToken, owner, repo).observe(this, new Observer<List<Releases>>() {
|
releasesModel.getReleasesList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Releases>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<Releases> releasesListMain) {
|
public void onChanged(@Nullable List<Releases> releasesListMain) {
|
||||||
adapter = new ReleasesAdapter(getContext(), releasesListMain);
|
adapter = new ReleasesAdapter(getContext(), releasesListMain);
|
||||||
|
@ -218,7 +218,7 @@ public class RepoInfoFragment extends Fragment {
|
|||||||
final TinyDB tinyDb = new TinyDB(getContext());
|
final TinyDB tinyDb = new TinyDB(getContext());
|
||||||
|
|
||||||
Call<UserRepositories> call = RetrofitClient
|
Call<UserRepositories> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getUserRepository(token, owner, repo);
|
.getUserRepository(token, owner, repo);
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ public class RepoInfoFragment extends Fragment {
|
|||||||
final TinyDB tinyDb = new TinyDB(getContext());
|
final TinyDB tinyDb = new TinyDB(getContext());
|
||||||
|
|
||||||
Call<String> call = RetrofitClient
|
Call<String> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, getContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getFileContents(token, owner, repo, filename);
|
.getFileContents(token, owner, repo, filename);
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ public class RepositoriesByOrgFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext());
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ public class RepositoriesByOrgFragment extends Fragment {
|
|||||||
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");
|
||||||
|
|
||||||
RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ public class RepositoriesByOrgFragment extends Fragment {
|
|||||||
|
|
||||||
RepositoriesByOrgViewModel orgRepoModel = new ViewModelProvider(this).get(RepositoriesByOrgViewModel.class);
|
RepositoriesByOrgViewModel orgRepoModel = new ViewModelProvider(this).get(RepositoriesByOrgViewModel.class);
|
||||||
|
|
||||||
orgRepoModel.getRepositoriesByOrg(instanceUrl, instanceToken, owner).observe(this, new Observer<List<UserRepositories>>() {
|
orgRepoModel.getRepositoriesByOrg(instanceUrl, instanceToken, owner, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<UserRepositories> orgReposListMain) {
|
public void onChanged(@Nullable List<UserRepositories> orgReposListMain) {
|
||||||
adapter = new RepositoriesByOrgAdapter(getContext(), orgReposListMain);
|
adapter = new RepositoriesByOrgAdapter(getContext(), orgReposListMain);
|
||||||
@ -155,7 +155,7 @@ public class RepositoriesByOrgFragment extends Fragment {
|
|||||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
return;
|
return;
|
||||||
|
@ -102,27 +102,20 @@ public class RepositoriesFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(connToInternet) {
|
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
|
@Override
|
||||||
|
public void onRefresh() {
|
||||||
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
swipeRefresh.setRefreshing(false);
|
||||||
|
RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||||
@Override
|
|
||||||
public void onRefresh() {
|
|
||||||
new Handler().postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
swipeRefresh.setRefreshing(false);
|
|
||||||
RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
|
||||||
}
|
|
||||||
}, 50);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
|
||||||
@ -137,7 +130,7 @@ public class RepositoriesFragment extends Fragment {
|
|||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
if(tinyDb.getBoolean("repoCreated")) {
|
if(tinyDb.getBoolean("repoCreated")) {
|
||||||
RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||||
tinyDb.putBoolean("repoCreated", false);
|
tinyDb.putBoolean("repoCreated", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,7 +139,7 @@ public class RepositoriesFragment extends Fragment {
|
|||||||
|
|
||||||
RepositoriesListViewModel repoModel = new ViewModelProvider(this).get(RepositoriesListViewModel.class);
|
RepositoriesListViewModel repoModel = new ViewModelProvider(this).get(RepositoriesListViewModel.class);
|
||||||
|
|
||||||
repoModel.getUserRepositories(instanceUrl, instanceToken).observe(this, new Observer<List<UserRepositories>>() {
|
repoModel.getUserRepositories(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<UserRepositories> reposListMain) {
|
public void onChanged(@Nullable List<UserRepositories> reposListMain) {
|
||||||
adapter = new ReposListAdapter(getContext(), reposListMain);
|
adapter = new ReposListAdapter(getContext(), reposListMain);
|
||||||
@ -176,11 +169,11 @@ public class RepositoriesFragment extends Fragment {
|
|||||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||||
|
|
||||||
if(!connToInternet) {
|
/*if(!connToInternet) {
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,7 +30,7 @@ public class SettingsFragment extends Fragment {
|
|||||||
|
|
||||||
private Context ctx = null;
|
private Context ctx = null;
|
||||||
|
|
||||||
private static String[] langList = {"Arabic", "Chinese", "English", "Finnish", "French", "German", "Italian", "Persian", "Russian", "Serbian"};
|
private static String[] langList = {"Arabic", "Chinese", "English", "Finnish", "French", "German", "Italian", "Persian", "Portuguese/Brazilian", "Russian", "Serbian", "Turkish", "Ukrainian"};
|
||||||
private static int langSelectedChoice = 0;
|
private static int langSelectedChoice = 0;
|
||||||
|
|
||||||
private static String[] timeList = {"Pretty", "Normal"};
|
private static String[] timeList = {"Pretty", "Normal"};
|
||||||
@ -265,12 +265,21 @@ public class SettingsFragment extends Fragment {
|
|||||||
case "Persian":
|
case "Persian":
|
||||||
tinyDb.putString("locale", "fa");
|
tinyDb.putString("locale", "fa");
|
||||||
break;
|
break;
|
||||||
|
case "Portuguese/Brazilian":
|
||||||
|
tinyDb.putString("locale", "pt");
|
||||||
|
break;
|
||||||
case "Russian":
|
case "Russian":
|
||||||
tinyDb.putString("locale", "ru");
|
tinyDb.putString("locale", "ru");
|
||||||
break;
|
break;
|
||||||
case "Serbian":
|
case "Serbian":
|
||||||
tinyDb.putString("locale", "sr");
|
tinyDb.putString("locale", "sr");
|
||||||
break;
|
break;
|
||||||
|
case "Turkish":
|
||||||
|
tinyDb.putString("locale", "tr");
|
||||||
|
break;
|
||||||
|
case "Ukrainian":
|
||||||
|
tinyDb.putString("locale", "uk");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
tinyDb.putString("locale", "en");
|
tinyDb.putString("locale", "en");
|
||||||
break;
|
break;
|
||||||
|
@ -12,6 +12,8 @@ import org.mian.gitnex.actions.IssueActions;
|
|||||||
import org.mian.gitnex.activities.AddRemoveAssigneesActivity;
|
import org.mian.gitnex.activities.AddRemoveAssigneesActivity;
|
||||||
import org.mian.gitnex.activities.AddRemoveLabelsActivity;
|
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.MergePullRequestActivity;
|
||||||
import org.mian.gitnex.activities.ReplyToIssueActivity;
|
import org.mian.gitnex.activities.ReplyToIssueActivity;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.util.TinyDB;
|
import org.mian.gitnex.util.TinyDB;
|
||||||
@ -42,6 +44,8 @@ public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
|
|||||||
TextView reOpenIssue = v.findViewById(R.id.reOpenIssue);
|
TextView reOpenIssue = v.findViewById(R.id.reOpenIssue);
|
||||||
TextView addRemoveAssignees = v.findViewById(R.id.addRemoveAssignees);
|
TextView addRemoveAssignees = v.findViewById(R.id.addRemoveAssignees);
|
||||||
TextView copyIssueUrl = v.findViewById(R.id.copyIssueUrl);
|
TextView copyIssueUrl = v.findViewById(R.id.copyIssueUrl);
|
||||||
|
TextView openFilesDiff = v.findViewById(R.id.openFilesDiff);
|
||||||
|
TextView mergePullRequest = v.findViewById(R.id.mergePullRequest);
|
||||||
|
|
||||||
replyToIssue.setOnClickListener(new View.OnClickListener() {
|
replyToIssue.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -53,6 +57,52 @@ public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(tinyDB.getString("issueType").equals("pr")) {
|
||||||
|
|
||||||
|
editIssue.setText(R.string.editPrText);
|
||||||
|
copyIssueUrl.setText(R.string.copyPrUrlText);
|
||||||
|
|
||||||
|
if(tinyDB.getBoolean("prMerged")) {
|
||||||
|
mergePullRequest.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mergePullRequest.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tinyDB.getString("repoType").equals("public")) {
|
||||||
|
openFilesDiff.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
openFilesDiff.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
mergePullRequest.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
mergePullRequest.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
startActivity(new Intent(getContext(), MergePullRequestActivity.class));
|
||||||
|
dismiss();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
openFilesDiff.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
startActivity(new Intent(getContext(), FileDiffActivity.class));
|
||||||
|
dismiss();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
editIssue.setOnClickListener(new View.OnClickListener() {
|
editIssue.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@ -90,7 +140,7 @@ public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
|
|||||||
// get url of repo
|
// get url of repo
|
||||||
String repoFullName = tinyDB.getString("repoFullName");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String instanceUrlWithProtocol = "https://" + tinyDB.getString("instanceUrlRaw");
|
String instanceUrlWithProtocol = "https://" + tinyDB.getString("instanceUrlRaw");
|
||||||
if(!tinyDB.getString("instanceUrlWithProtocol").isEmpty()) {
|
if (!tinyDB.getString("instanceUrlWithProtocol").isEmpty()) {
|
||||||
instanceUrlWithProtocol = tinyDB.getString("instanceUrlWithProtocol");
|
instanceUrlWithProtocol = tinyDB.getString("instanceUrlWithProtocol");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,6 +150,7 @@ public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
|
|||||||
// copy to clipboard
|
// copy to clipboard
|
||||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(getContext()).getSystemService(android.content.Context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(getContext()).getSystemService(android.content.Context.CLIPBOARD_SERVICE);
|
||||||
ClipData clip = ClipData.newPlainText("issueUrl", issueUrl);
|
ClipData clip = ClipData.newPlainText("issueUrl", issueUrl);
|
||||||
|
assert clipboard != null;
|
||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
|
|
||||||
dismiss();
|
dismiss();
|
||||||
@ -109,35 +160,44 @@ public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(tinyDB.getString("issueState").equals("open")) { // close issue
|
if(tinyDB.getString("issueType").equals("issue")) {
|
||||||
|
|
||||||
reOpenIssue.setVisibility(View.GONE);
|
if (tinyDB.getString("issueState").equals("open")) { // close issue
|
||||||
|
|
||||||
closeIssue.setOnClickListener(new View.OnClickListener() {
|
reOpenIssue.setVisibility(View.GONE);
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
|
|
||||||
IssueActions.closeReopenIssue(getContext(), Integer.valueOf(tinyDB.getString("issueNumber")), "closed");
|
closeIssue.setOnClickListener(new View.OnClickListener() {
|
||||||
dismiss();
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
}
|
IssueActions.closeReopenIssue(getContext(), Integer.valueOf(tinyDB.getString("issueNumber")), "closed");
|
||||||
});
|
dismiss();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} else if (tinyDB.getString("issueState").equals("closed")) {
|
||||||
|
|
||||||
|
closeIssue.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
reOpenIssue.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
IssueActions.closeReopenIssue(getContext(), Integer.valueOf(tinyDB.getString("issueNumber")), "open");
|
||||||
|
dismiss();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(tinyDB.getString("issueState").equals("closed")) {
|
else {
|
||||||
|
|
||||||
|
reOpenIssue.setVisibility(View.GONE);
|
||||||
closeIssue.setVisibility(View.GONE);
|
closeIssue.setVisibility(View.GONE);
|
||||||
|
|
||||||
reOpenIssue.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
|
|
||||||
IssueActions.closeReopenIssue(getContext(), Integer.valueOf(tinyDB.getString("issueNumber")), "open");
|
|
||||||
dismiss();
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
@ -127,27 +127,20 @@ public class StarredRepositoriesFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(connToInternet) {
|
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
|
@Override
|
||||||
|
public void onRefresh() {
|
||||||
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
swipeRefresh.setRefreshing(false);
|
||||||
|
StarredRepositoriesViewModel.loadStarredReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||||
@Override
|
|
||||||
public void onRefresh() {
|
|
||||||
new Handler().postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
swipeRefresh.setRefreshing(false);
|
|
||||||
StarredRepositoriesViewModel.loadStarredReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
|
||||||
}
|
|
||||||
}, 50);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
@ -160,7 +153,7 @@ public class StarredRepositoriesFragment extends Fragment {
|
|||||||
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");
|
||||||
|
|
||||||
StarredRepositoriesViewModel.loadStarredReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
StarredRepositoriesViewModel.loadStarredReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +161,7 @@ public class StarredRepositoriesFragment extends Fragment {
|
|||||||
|
|
||||||
StarredRepositoriesViewModel starredRepoModel = new ViewModelProvider(this).get(StarredRepositoriesViewModel.class);
|
StarredRepositoriesViewModel starredRepoModel = new ViewModelProvider(this).get(StarredRepositoriesViewModel.class);
|
||||||
|
|
||||||
starredRepoModel.getUserStarredRepositories(instanceUrl, instanceToken).observe(this, new Observer<List<UserRepositories>>() {
|
starredRepoModel.getUserStarredRepositories(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<UserRepositories> starredReposListMain) {
|
public void onChanged(@Nullable List<UserRepositories> starredReposListMain) {
|
||||||
adapter = new StarredReposListAdapter(getContext(), starredReposListMain);
|
adapter = new StarredReposListAdapter(getContext(), starredReposListMain);
|
||||||
@ -198,11 +191,11 @@ public class StarredRepositoriesFragment extends Fragment {
|
|||||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||||
|
|
||||||
if(!connToInternet) {
|
/*if(!connToInternet) {
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -97,7 +97,7 @@ public class TeamsByOrgFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
TeamsByOrgViewModel.loadTeamsByOrgList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
TeamsByOrgViewModel.loadTeamsByOrgList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext());
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ public class TeamsByOrgFragment extends Fragment {
|
|||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
if(tinyDb.getBoolean("resumeTeams")) {
|
if(tinyDb.getBoolean("resumeTeams")) {
|
||||||
TeamsByOrgViewModel.loadTeamsByOrgList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
TeamsByOrgViewModel.loadTeamsByOrgList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext());
|
||||||
tinyDb.putBoolean("resumeTeams", false);
|
tinyDb.putBoolean("resumeTeams", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ public class TeamsByOrgFragment extends Fragment {
|
|||||||
|
|
||||||
TeamsByOrgViewModel teamModel = new ViewModelProvider(this).get(TeamsByOrgViewModel.class);
|
TeamsByOrgViewModel teamModel = new ViewModelProvider(this).get(TeamsByOrgViewModel.class);
|
||||||
|
|
||||||
teamModel.getTeamsByOrg(instanceUrl, instanceToken, owner).observe(this, new Observer<List<Teams>>() {
|
teamModel.getTeamsByOrg(instanceUrl, instanceToken, owner, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Teams>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<Teams> orgTeamsListMain) {
|
public void onChanged(@Nullable List<Teams> orgTeamsListMain) {
|
||||||
adapter = new TeamsByOrgAdapter(getContext(), orgTeamsListMain);
|
adapter = new TeamsByOrgAdapter(getContext(), orgTeamsListMain);
|
||||||
@ -156,11 +156,11 @@ public class TeamsByOrgFragment extends Fragment {
|
|||||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||||
|
|
||||||
if(!connToInternet) {
|
/*if(!connToInternet) {
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||||
@Override
|
@Override
|
||||||
|
135
app/src/main/java/org/mian/gitnex/helpers/VersionCheck.java
Normal file
135
app/src/main/java/org/mian/gitnex/helpers/VersionCheck.java
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
package org.mian.gitnex.helpers;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author 6543
|
||||||
|
*/
|
||||||
|
|
||||||
|
public enum VersionCheck {
|
||||||
|
|
||||||
|
UNKNOWN,
|
||||||
|
SUPPORTED_LATEST,
|
||||||
|
SUPPORTED_OLD,
|
||||||
|
DEVELOPMENT,
|
||||||
|
UNSUPPORTED_OLD,
|
||||||
|
UNSUPPORTED_NEW;
|
||||||
|
|
||||||
|
public static VersionCheck check(String min, String last, String value) {
|
||||||
|
|
||||||
|
final Pattern pattern_stable_release = Pattern.compile("^(\\d)\\.(\\d+)\\.(\\d+)$");
|
||||||
|
final Pattern pattern_dev_release = Pattern.compile("^(\\d).(\\d+).(\\d+)(\\D)(.+)");
|
||||||
|
Matcher match;
|
||||||
|
|
||||||
|
if (!pattern_stable_release.matcher(min).find() || !pattern_stable_release.matcher(last).find()) {
|
||||||
|
throw new IllegalArgumentException("VersionCheck: wrong format for min or last version given");
|
||||||
|
}
|
||||||
|
|
||||||
|
match = pattern_stable_release.matcher(value);
|
||||||
|
if (match.find()) {
|
||||||
|
|
||||||
|
switch (correlate(min, last, match.group())){
|
||||||
|
case 0:
|
||||||
|
return UNSUPPORTED_OLD;
|
||||||
|
case 1:
|
||||||
|
return SUPPORTED_OLD;
|
||||||
|
case 2:
|
||||||
|
return SUPPORTED_LATEST;
|
||||||
|
default:
|
||||||
|
return UNSUPPORTED_NEW;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
match = pattern_dev_release.matcher(value);
|
||||||
|
if (match.find()) {
|
||||||
|
|
||||||
|
match = Pattern.compile("^(\\d)\\.(\\d+)\\.(\\d+)").matcher(value);
|
||||||
|
match.find();
|
||||||
|
|
||||||
|
if (correlate(min, last, match.group())>0) {
|
||||||
|
return DEVELOPMENT;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return UNSUPPORTED_OLD;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return UNKNOWN;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//helper
|
||||||
|
// 0 to less
|
||||||
|
// 1 in range
|
||||||
|
// 2 at the top
|
||||||
|
// 3 above
|
||||||
|
private static int correlate(String min, String last, String value){
|
||||||
|
int min_check = compareVersion(value,min);
|
||||||
|
int max_check = compareVersion(value,last);
|
||||||
|
int range_check = compareVersion(min,last);
|
||||||
|
|
||||||
|
switch (range_check) {
|
||||||
|
case 2:
|
||||||
|
throw new IllegalArgumentException("Minimum Version higher than Last Version");
|
||||||
|
case 1: //min == last
|
||||||
|
switch (min_check) {
|
||||||
|
case 0:
|
||||||
|
return 0;
|
||||||
|
case 1:
|
||||||
|
return 2;
|
||||||
|
default:
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if (max_check >1) return 3;
|
||||||
|
if (max_check == 1) return 2;
|
||||||
|
if (min_check < 1) return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description compare doted formatted Versions
|
||||||
|
* @param A doted formatted Versions
|
||||||
|
* @param B doted formatted Versions
|
||||||
|
* @return 0|1|2
|
||||||
|
* 0 = less
|
||||||
|
* 1 = same
|
||||||
|
* 2 = more
|
||||||
|
*/
|
||||||
|
public static int compareVersion(String A, String B) {
|
||||||
|
//throw new IllegalArgumentException
|
||||||
|
if((!A.matches("[0-9]+(\\.[0-9]+)*")) || (!B.matches("[0-9]+(\\.[0-9]+)*"))) throw new IllegalArgumentException("Invalid version format");
|
||||||
|
|
||||||
|
if (A.contains(".") || B.contains(".")) {
|
||||||
|
// example 2 vs 1.3
|
||||||
|
if (!(A.contains(".") && B.contains("."))) {
|
||||||
|
if (A.contains(".")) {
|
||||||
|
return compareVersion(A,B + ".0");
|
||||||
|
}
|
||||||
|
if (B.contains(".")) {
|
||||||
|
return compareVersion(A + ".0",B);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//normal compare
|
||||||
|
int a = Integer.parseInt(A.substring(0,A.indexOf(".")));
|
||||||
|
int b = Integer.parseInt(B.substring(0,B.indexOf(".")));
|
||||||
|
if (a < b) return 0;
|
||||||
|
if (a == b) return compareVersion(A.substring(A.indexOf(".")+1),B.substring(B.indexOf(".")+1));
|
||||||
|
return 2; //if (a > b)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int a = Integer.parseInt(A);
|
||||||
|
int b = Integer.parseInt(B);
|
||||||
|
if (a < b) return 0;
|
||||||
|
if (a == b) return 1;
|
||||||
|
return 2; //if (a > b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,7 +5,9 @@ import org.mian.gitnex.models.AddEmail;
|
|||||||
import org.mian.gitnex.models.Branches;
|
import org.mian.gitnex.models.Branches;
|
||||||
import org.mian.gitnex.models.ExploreRepositories;
|
import org.mian.gitnex.models.ExploreRepositories;
|
||||||
import org.mian.gitnex.models.Files;
|
import org.mian.gitnex.models.Files;
|
||||||
|
import org.mian.gitnex.models.MergePullRequest;
|
||||||
import org.mian.gitnex.models.NewFile;
|
import org.mian.gitnex.models.NewFile;
|
||||||
|
import org.mian.gitnex.models.PullRequests;
|
||||||
import org.mian.gitnex.models.UpdateIssueAssignee;
|
import org.mian.gitnex.models.UpdateIssueAssignee;
|
||||||
import org.mian.gitnex.models.UpdateIssueState;
|
import org.mian.gitnex.models.UpdateIssueState;
|
||||||
import org.mian.gitnex.models.Collaborators;
|
import org.mian.gitnex.models.Collaborators;
|
||||||
@ -30,6 +32,7 @@ import org.mian.gitnex.models.UserSearch;
|
|||||||
import org.mian.gitnex.models.UserTokens;
|
import org.mian.gitnex.models.UserTokens;
|
||||||
import org.mian.gitnex.models.WatchRepository;
|
import org.mian.gitnex.models.WatchRepository;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import okhttp3.ResponseBody;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.http.Body;
|
import retrofit2.http.Body;
|
||||||
import retrofit2.http.DELETE;
|
import retrofit2.http.DELETE;
|
||||||
@ -48,7 +51,7 @@ import retrofit2.http.Query;
|
|||||||
public interface ApiInterface {
|
public interface ApiInterface {
|
||||||
|
|
||||||
@GET("version") // gitea version API
|
@GET("version") // gitea version API
|
||||||
Call<GiteaVersion> getGiteaVersion(@Header("Authorization") String token);
|
Call<GiteaVersion> getGiteaVersion();
|
||||||
|
|
||||||
@GET("user") // username, full name, email
|
@GET("user") // username, full name, email
|
||||||
Call<UserInfo> getUserInfo(@Header("Authorization") String token);
|
Call<UserInfo> getUserInfo(@Header("Authorization") String token);
|
||||||
@ -216,7 +219,7 @@ public interface ApiInterface {
|
|||||||
Call<List<UserInfo>> getRepoWatchers(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName);
|
Call<List<UserInfo>> getRepoWatchers(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName);
|
||||||
|
|
||||||
@GET("repos/search") // get all the repos which match the query string
|
@GET("repos/search") // get all the repos which match the query string
|
||||||
Call<ExploreRepositories> queryRepos(@Header("Authorization") String token, @Query("q") String searchKeyword, @Query("private") Boolean repoTypeInclude, @Query("sort") String sort, @Query("order") String order);
|
Call<ExploreRepositories> queryRepos(@Header("Authorization") String token, @Query("q") String searchKeyword, @Query("private") Boolean repoTypeInclude, @Query("sort") String sort, @Query("order") String order, @Query("limit") int limit);
|
||||||
|
|
||||||
@POST("repos/{owner}/{repo}/contents/{file}") // create new file
|
@POST("repos/{owner}/{repo}/contents/{file}") // create new file
|
||||||
Call<JsonElement> createNewFile(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("file") String fileName, @Body NewFile jsonStr);
|
Call<JsonElement> createNewFile(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("file") String fileName, @Body NewFile jsonStr);
|
||||||
@ -247,4 +250,13 @@ public interface ApiInterface {
|
|||||||
|
|
||||||
@DELETE("repos/{owner}/{repo}/subscription") // un watch a repository
|
@DELETE("repos/{owner}/{repo}/subscription") // un watch a repository
|
||||||
Call<JsonElement> unWatchRepository(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName);
|
Call<JsonElement> unWatchRepository(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName);
|
||||||
|
|
||||||
|
@GET("repos/{owner}/{repo}/pulls") // get repository pull requests
|
||||||
|
Call<List<PullRequests>> getPullRequests(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page, @Query("state") String state);
|
||||||
|
|
||||||
|
@GET("{owner}/{repo}/pulls/{filename}") // get pull diff file contents
|
||||||
|
Call<ResponseBody> getFileDiffContents(@Path("owner") String owner, @Path("repo") String repo, @Path("filename") String fileName);
|
||||||
|
|
||||||
|
@POST("repos/{owner}/{repo}/pulls/{index}/merge") // merge a pull request
|
||||||
|
Call<ResponseBody> mergePullRequest(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int index, @Body MergePullRequest jsonStr);
|
||||||
}
|
}
|
||||||
|
39
app/src/main/java/org/mian/gitnex/models/FileDiffView.java
Normal file
39
app/src/main/java/org/mian/gitnex/models/FileDiffView.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package org.mian.gitnex.models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author M M Arif
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class FileDiffView {
|
||||||
|
|
||||||
|
private String fileName;
|
||||||
|
private boolean fileType;
|
||||||
|
private String fileInfo;
|
||||||
|
private String fileContents;
|
||||||
|
|
||||||
|
public FileDiffView(String fileName, boolean fileType, String fileInfo, String fileContents)
|
||||||
|
{
|
||||||
|
|
||||||
|
this.fileName = fileName;
|
||||||
|
this.fileType = fileType;
|
||||||
|
this.fileInfo = fileInfo;
|
||||||
|
this.fileContents = fileContents;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFileType() {
|
||||||
|
return fileType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileInfo() {
|
||||||
|
return fileInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileContents() {
|
||||||
|
return fileContents;
|
||||||
|
}
|
||||||
|
}
|
@ -98,10 +98,10 @@ public class Issues {
|
|||||||
|
|
||||||
public class pullRequestObject {
|
public class pullRequestObject {
|
||||||
|
|
||||||
private String merged;
|
private boolean merged;
|
||||||
private String merged_at;
|
private String merged_at;
|
||||||
|
|
||||||
public String getMerged() {
|
public boolean isMerged() {
|
||||||
return merged;
|
return merged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package org.mian.gitnex.models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author M M Arif
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class MergePullRequest {
|
||||||
|
|
||||||
|
private String Do;
|
||||||
|
private String MergeMessageField;
|
||||||
|
private String MergeTitleField;
|
||||||
|
|
||||||
|
public MergePullRequest(String Do, String MergeMessageField, String MergeTitleField) {
|
||||||
|
this.Do = Do;
|
||||||
|
this.MergeMessageField = MergeMessageField;
|
||||||
|
this.MergeTitleField = MergeTitleField;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
823
app/src/main/java/org/mian/gitnex/models/PullRequests.java
Normal file
823
app/src/main/java/org/mian/gitnex/models/PullRequests.java
Normal file
@ -0,0 +1,823 @@
|
|||||||
|
package org.mian.gitnex.models;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author M M Arif
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class PullRequests {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String body;
|
||||||
|
private int comments;
|
||||||
|
private String diff_url;
|
||||||
|
private String html_url;
|
||||||
|
private String merge_base;
|
||||||
|
private String merge_commit_sha;
|
||||||
|
private boolean mergeable;
|
||||||
|
private boolean merged;
|
||||||
|
private int number;
|
||||||
|
private String patch_url;
|
||||||
|
private String state;
|
||||||
|
private String title;
|
||||||
|
private String url;
|
||||||
|
private Date closed_at;
|
||||||
|
private Date created_at;
|
||||||
|
private Date due_date;
|
||||||
|
private Date merged_at;
|
||||||
|
private Date updated_at;
|
||||||
|
|
||||||
|
private userObject user;
|
||||||
|
private List<labelsObject> labels;
|
||||||
|
private List<assigneesObject> assignees;
|
||||||
|
private mergedByObject merged_by;
|
||||||
|
private milestoneObject milestone;
|
||||||
|
private baseObject base;
|
||||||
|
private headObject head;
|
||||||
|
|
||||||
|
public PullRequests(String body) {
|
||||||
|
this.body = body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class headObject {
|
||||||
|
|
||||||
|
private int repo_id;
|
||||||
|
private String label;
|
||||||
|
private String ref;
|
||||||
|
private String sha;
|
||||||
|
|
||||||
|
private repoObject repo;
|
||||||
|
|
||||||
|
public class repoObject {
|
||||||
|
|
||||||
|
private int repo_id;
|
||||||
|
private boolean allow_merge_commits;
|
||||||
|
private boolean allow_rebase;
|
||||||
|
private boolean allow_rebase_explicit;
|
||||||
|
private boolean allow_squash_merge;
|
||||||
|
private boolean archived;
|
||||||
|
private boolean empty;
|
||||||
|
private boolean fork;
|
||||||
|
private boolean has_issues;
|
||||||
|
private boolean has_pull_requests;
|
||||||
|
private boolean has_wiki;
|
||||||
|
private boolean ignore_whitespace_conflicts;
|
||||||
|
@SerializedName("private")
|
||||||
|
private boolean privateFlag;
|
||||||
|
private boolean mirror;
|
||||||
|
private String avatar_url;
|
||||||
|
private String clone_url;
|
||||||
|
private String default_branch;
|
||||||
|
private String description;
|
||||||
|
private String full_name;
|
||||||
|
private String html_url;
|
||||||
|
private String name;
|
||||||
|
private String ssh_url;
|
||||||
|
private String website;
|
||||||
|
private int forks_count;
|
||||||
|
private int id;
|
||||||
|
private int open_issues_count;
|
||||||
|
private int size;
|
||||||
|
private int stars_count;
|
||||||
|
private int watchers_count;
|
||||||
|
private Date created_at;
|
||||||
|
private Date updated_at;
|
||||||
|
|
||||||
|
private ownerObject owner;
|
||||||
|
private permissionsObject permissions;
|
||||||
|
|
||||||
|
public class ownerObject {
|
||||||
|
|
||||||
|
private int repo_id;
|
||||||
|
private boolean is_admin;
|
||||||
|
private String avatar_url;
|
||||||
|
private String email;
|
||||||
|
private String full_name;
|
||||||
|
private String language;
|
||||||
|
private String login;
|
||||||
|
private Date created;
|
||||||
|
|
||||||
|
public int getRepo_id() {
|
||||||
|
return repo_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIs_admin() {
|
||||||
|
return is_admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatar_url() {
|
||||||
|
return avatar_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFull_name() {
|
||||||
|
return full_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLanguage() {
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLogin() {
|
||||||
|
return login;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreated() {
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class permissionsObject {
|
||||||
|
|
||||||
|
private boolean admin;
|
||||||
|
private boolean pull;
|
||||||
|
private boolean push;
|
||||||
|
|
||||||
|
public boolean isAdmin() {
|
||||||
|
return admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPull() {
|
||||||
|
return pull;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPush() {
|
||||||
|
return push;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRepo_id() {
|
||||||
|
return repo_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAllow_merge_commits() {
|
||||||
|
return allow_merge_commits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAllow_rebase() {
|
||||||
|
return allow_rebase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAllow_rebase_explicit() {
|
||||||
|
return allow_rebase_explicit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAllow_squash_merge() {
|
||||||
|
return allow_squash_merge;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isArchived() {
|
||||||
|
return archived;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFork() {
|
||||||
|
return fork;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHas_issues() {
|
||||||
|
return has_issues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHas_pull_requests() {
|
||||||
|
return has_pull_requests;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHas_wiki() {
|
||||||
|
return has_wiki;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIgnore_whitespace_conflicts() {
|
||||||
|
return ignore_whitespace_conflicts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPrivateFlag() {
|
||||||
|
return privateFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMirror() {
|
||||||
|
return mirror;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatar_url() {
|
||||||
|
return avatar_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClone_url() {
|
||||||
|
return clone_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefault_branch() {
|
||||||
|
return default_branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFull_name() {
|
||||||
|
return full_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHtml_url() {
|
||||||
|
return html_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSsh_url() {
|
||||||
|
return ssh_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWebsite() {
|
||||||
|
return website;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getForks_count() {
|
||||||
|
return forks_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOpen_issues_count() {
|
||||||
|
return open_issues_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStars_count() {
|
||||||
|
return stars_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWatchers_count() {
|
||||||
|
return watchers_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreated_at() {
|
||||||
|
return created_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdated_at() {
|
||||||
|
return updated_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ownerObject getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public permissionsObject getPermissions() {
|
||||||
|
return permissions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class baseObject {
|
||||||
|
|
||||||
|
private int repo_id;
|
||||||
|
private String label;
|
||||||
|
private String ref;
|
||||||
|
private String sha;
|
||||||
|
|
||||||
|
private repoObject repo;
|
||||||
|
|
||||||
|
public class repoObject {
|
||||||
|
|
||||||
|
private int repo_id;
|
||||||
|
private boolean allow_merge_commits;
|
||||||
|
private boolean allow_rebase;
|
||||||
|
private boolean allow_rebase_explicit;
|
||||||
|
private boolean allow_squash_merge;
|
||||||
|
private boolean archived;
|
||||||
|
private boolean empty;
|
||||||
|
private boolean fork;
|
||||||
|
private boolean has_issues;
|
||||||
|
private boolean has_pull_requests;
|
||||||
|
private boolean has_wiki;
|
||||||
|
private boolean ignore_whitespace_conflicts;
|
||||||
|
@SerializedName("private")
|
||||||
|
private boolean privateFlag;
|
||||||
|
private boolean mirror;
|
||||||
|
private String avatar_url;
|
||||||
|
private String clone_url;
|
||||||
|
private String default_branch;
|
||||||
|
private String description;
|
||||||
|
private String full_name;
|
||||||
|
private String html_url;
|
||||||
|
private String name;
|
||||||
|
private String ssh_url;
|
||||||
|
private String website;
|
||||||
|
private int forks_count;
|
||||||
|
private int id;
|
||||||
|
private int open_issues_count;
|
||||||
|
private int size;
|
||||||
|
private int stars_count;
|
||||||
|
private int watchers_count;
|
||||||
|
private Date created_at;
|
||||||
|
private Date updated_at;
|
||||||
|
|
||||||
|
private ownerObject owner;
|
||||||
|
private permissionsObject permissions;
|
||||||
|
|
||||||
|
public class ownerObject {
|
||||||
|
|
||||||
|
private int repo_id;
|
||||||
|
private boolean is_admin;
|
||||||
|
private String avatar_url;
|
||||||
|
private String email;
|
||||||
|
private String full_name;
|
||||||
|
private String language;
|
||||||
|
private String login;
|
||||||
|
private Date created;
|
||||||
|
|
||||||
|
public int getRepo_id() {
|
||||||
|
return repo_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIs_admin() {
|
||||||
|
return is_admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatar_url() {
|
||||||
|
return avatar_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFull_name() {
|
||||||
|
return full_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLanguage() {
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLogin() {
|
||||||
|
return login;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreated() {
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class permissionsObject {
|
||||||
|
|
||||||
|
private boolean admin;
|
||||||
|
private boolean pull;
|
||||||
|
private boolean push;
|
||||||
|
|
||||||
|
public boolean isAdmin() {
|
||||||
|
return admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPull() {
|
||||||
|
return pull;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPush() {
|
||||||
|
return push;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRepo_id() {
|
||||||
|
return repo_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAllow_merge_commits() {
|
||||||
|
return allow_merge_commits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAllow_rebase() {
|
||||||
|
return allow_rebase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAllow_rebase_explicit() {
|
||||||
|
return allow_rebase_explicit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAllow_squash_merge() {
|
||||||
|
return allow_squash_merge;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isArchived() {
|
||||||
|
return archived;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFork() {
|
||||||
|
return fork;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHas_issues() {
|
||||||
|
return has_issues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHas_pull_requests() {
|
||||||
|
return has_pull_requests;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHas_wiki() {
|
||||||
|
return has_wiki;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIgnore_whitespace_conflicts() {
|
||||||
|
return ignore_whitespace_conflicts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPrivateFlag() {
|
||||||
|
return privateFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMirror() {
|
||||||
|
return mirror;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatar_url() {
|
||||||
|
return avatar_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClone_url() {
|
||||||
|
return clone_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefault_branch() {
|
||||||
|
return default_branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFull_name() {
|
||||||
|
return full_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHtml_url() {
|
||||||
|
return html_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSsh_url() {
|
||||||
|
return ssh_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWebsite() {
|
||||||
|
return website;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getForks_count() {
|
||||||
|
return forks_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOpen_issues_count() {
|
||||||
|
return open_issues_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStars_count() {
|
||||||
|
return stars_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWatchers_count() {
|
||||||
|
return watchers_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreated_at() {
|
||||||
|
return created_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdated_at() {
|
||||||
|
return updated_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ownerObject getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public permissionsObject getPermissions() {
|
||||||
|
return permissions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class userObject {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String login;
|
||||||
|
private String full_name;
|
||||||
|
private String email;
|
||||||
|
private String avatar_url;
|
||||||
|
private String language;
|
||||||
|
private boolean is_admin;
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLogin() {
|
||||||
|
return login;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFull_name() {
|
||||||
|
return full_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatar_url() {
|
||||||
|
return avatar_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLanguage() {
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIs_admin() {
|
||||||
|
return is_admin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class labelsObject {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
private String color;
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class assigneesObject {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String login;
|
||||||
|
private String full_name;
|
||||||
|
private String email;
|
||||||
|
private String avatar_url;
|
||||||
|
private String language;
|
||||||
|
private boolean is_admin;
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLogin() {
|
||||||
|
return login;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFull_name() {
|
||||||
|
return full_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatar_url() {
|
||||||
|
return avatar_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLanguage() {
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIs_admin() {
|
||||||
|
return is_admin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class mergedByObject {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String login;
|
||||||
|
private String full_name;
|
||||||
|
private String email;
|
||||||
|
private String avatar_url;
|
||||||
|
private String language;
|
||||||
|
private boolean is_admin;
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLogin() {
|
||||||
|
return login;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFull_name() {
|
||||||
|
return full_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatar_url() {
|
||||||
|
return avatar_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLanguage() {
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIs_admin() {
|
||||||
|
return is_admin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class milestoneObject {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String title;
|
||||||
|
private String description;
|
||||||
|
private String state;
|
||||||
|
private String open_issues;
|
||||||
|
private String closed_issues;
|
||||||
|
private String closed_at;
|
||||||
|
private String due_on;
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOpen_issues() {
|
||||||
|
return open_issues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClosed_issues() {
|
||||||
|
return closed_issues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClosed_at() {
|
||||||
|
return closed_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDue_on() {
|
||||||
|
return due_on;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBody() {
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getComments() {
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDiff_url() {
|
||||||
|
return diff_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHtml_url() {
|
||||||
|
return html_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMerge_base() {
|
||||||
|
return merge_base;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMerge_commit_sha() {
|
||||||
|
return merge_commit_sha;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMergeable() {
|
||||||
|
return mergeable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMerged() {
|
||||||
|
return merged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumber() {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPatch_url() {
|
||||||
|
return patch_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getClosed_at() {
|
||||||
|
return closed_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreated_at() {
|
||||||
|
return created_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDue_date() {
|
||||||
|
return due_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getMerged_at() {
|
||||||
|
return merged_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdated_at() {
|
||||||
|
return updated_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public userObject getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<labelsObject> getLabels() {
|
||||||
|
return labels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<assigneesObject> getAssignees() {
|
||||||
|
return assignees;
|
||||||
|
}
|
||||||
|
|
||||||
|
public mergedByObject getMerged_by() {
|
||||||
|
return merged_by;
|
||||||
|
}
|
||||||
|
|
||||||
|
public milestoneObject getMilestone() {
|
||||||
|
return milestone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public baseObject getBase() {
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
|
public headObject getHead() {
|
||||||
|
return head;
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ public class UserTokens {
|
|||||||
private int id;
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
private String sha1;
|
private String sha1;
|
||||||
|
private String token_last_eight;
|
||||||
|
|
||||||
public UserTokens(String name) {
|
public UserTokens(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -29,4 +30,8 @@ public class UserTokens {
|
|||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getToken_last_eight() {
|
||||||
|
return token_last_eight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import java.net.HttpURLConnection;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -145,16 +146,16 @@ public class AppUtil {
|
|||||||
|
|
||||||
String sMonth;
|
String sMonth;
|
||||||
if (Integer.parseInt(month) < 10) {
|
if (Integer.parseInt(month) < 10) {
|
||||||
sMonth = "0"+String.valueOf(month);
|
sMonth = "0"+ month;
|
||||||
} else {
|
} else {
|
||||||
sMonth = String.valueOf(month);
|
sMonth = month;
|
||||||
}
|
}
|
||||||
|
|
||||||
String sDay;
|
String sDay;
|
||||||
if (Integer.parseInt(day) < 10) {
|
if (Integer.parseInt(day) < 10) {
|
||||||
sDay = "0"+String.valueOf(day);
|
sDay = "0"+ day;
|
||||||
} else {
|
} else {
|
||||||
sDay = String.valueOf(day);
|
sDay = day;
|
||||||
}
|
}
|
||||||
|
|
||||||
return year + "-" + sMonth + "-" + sDay;
|
return year + "-" + sMonth + "-" + sDay;
|
||||||
@ -170,14 +171,14 @@ public class AppUtil {
|
|||||||
|
|
||||||
String sMin;
|
String sMin;
|
||||||
if ((mMinute) < 10) {
|
if ((mMinute) < 10) {
|
||||||
sMin = "0"+String.valueOf(mMinute);
|
sMin = "0"+ mMinute;
|
||||||
} else {
|
} else {
|
||||||
sMin = String.valueOf(mMinute);
|
sMin = String.valueOf(mMinute);
|
||||||
}
|
}
|
||||||
|
|
||||||
String sSec;
|
String sSec;
|
||||||
if ((mSeconds) < 10) {
|
if ((mSeconds) < 10) {
|
||||||
sSec = "0"+String.valueOf(mSeconds);
|
sSec = "0"+ mSeconds;
|
||||||
} else {
|
} else {
|
||||||
sSec = String.valueOf(mSeconds);
|
sSec = String.valueOf(mSeconds);
|
||||||
}
|
}
|
||||||
@ -210,4 +211,30 @@ public class AppUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean sourceCodeExtension(String ext) {
|
||||||
|
|
||||||
|
String[] extValues = new String[] {"md", "json", "java", "go", "php", "c", "cc", "cpp", "cxx", "cyc", "m",
|
||||||
|
"cs", "bash", "sh", "bsh", "cv", "python", "perl", "pm", "rb", "ruby", "javascript",
|
||||||
|
"coffee", "rc", "rs", "rust", "basic", "clj", "css", "dart", "lisp", "erl", "hs", "lsp", "rkt",
|
||||||
|
"ss", "llvm", "ll", "lua", "matlab", "pascal", "r", "scala", "sql", "latex", "tex", "vb", "vbs",
|
||||||
|
"vhd", "tcl", "wiki.meta", "yaml", "yml", "markdown", "xml", "proto", "regex", "py", "pl", "js",
|
||||||
|
"html", "htm", "volt", "ini", "htaccess", "conf", "gitignore", "gradle", "txt", "properties", "bat"};
|
||||||
|
|
||||||
|
return Arrays.asList(extValues).contains(ext);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean imageExtension(String ext) {
|
||||||
|
|
||||||
|
String[] extValues = new String[] {"jpg", "jpeg", "gif", "png", "ico"};
|
||||||
|
|
||||||
|
return Arrays.asList(extValues).contains(ext);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastCharactersOfWord( String str, int count ) {
|
||||||
|
|
||||||
|
return str.substring(str.length() - count);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class AdminGetUsersViewModel extends ViewModel {
|
|||||||
public static void loadUsersList(final Context ctx, String instanceUrl, String token) {
|
public static void loadUsersList(final Context ctx, String instanceUrl, String token) {
|
||||||
|
|
||||||
Call<List<UserInfo>> call = RetrofitClient
|
Call<List<UserInfo>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.adminGetUsers(token);
|
.adminGetUsers(token);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.models.Branches;
|
import org.mian.gitnex.models.Branches;
|
||||||
@ -20,18 +21,18 @@ public class BranchesViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<Branches>> branchesList;
|
private static MutableLiveData<List<Branches>> branchesList;
|
||||||
|
|
||||||
public LiveData<List<Branches>> getBranchesList(String instanceUrl, String token, String owner, String repo) {
|
public LiveData<List<Branches>> getBranchesList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||||
|
|
||||||
branchesList = new MutableLiveData<>();
|
branchesList = new MutableLiveData<>();
|
||||||
loadBranchesList(instanceUrl, token, owner, repo);
|
loadBranchesList(instanceUrl, token, owner, repo, ctx);
|
||||||
|
|
||||||
return branchesList;
|
return branchesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadBranchesList(String instanceUrl, String token, String owner, String repo) {
|
public static void loadBranchesList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||||
|
|
||||||
Call<List<Branches>> call = RetrofitClient
|
Call<List<Branches>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getBranches(token, owner, repo);
|
.getBranches(token, owner, repo);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.models.Collaborators;
|
import org.mian.gitnex.models.Collaborators;
|
||||||
@ -20,18 +21,18 @@ public class CollaboratorsViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<Collaborators>> collaboratorsList;
|
private static MutableLiveData<List<Collaborators>> collaboratorsList;
|
||||||
|
|
||||||
public LiveData<List<Collaborators>> getCollaboratorsList(String instanceUrl, String token, String owner, String repo) {
|
public LiveData<List<Collaborators>> getCollaboratorsList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||||
|
|
||||||
collaboratorsList = new MutableLiveData<>();
|
collaboratorsList = new MutableLiveData<>();
|
||||||
loadCollaboratorsListList(instanceUrl, token, owner, repo);
|
loadCollaboratorsListList(instanceUrl, token, owner, repo, ctx);
|
||||||
|
|
||||||
return collaboratorsList;
|
return collaboratorsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadCollaboratorsListList(String instanceUrl, String token, String owner, String repo) {
|
private static void loadCollaboratorsListList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||||
|
|
||||||
Call<List<Collaborators>> call = RetrofitClient
|
Call<List<Collaborators>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getCollaborators(token, owner, repo);
|
.getCollaborators(token, owner, repo);
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class FilesViewModel extends ViewModel {
|
|||||||
private static void loadFilesList(String instanceUrl, String token, String owner, String repo, final Context ctx) {
|
private static void loadFilesList(String instanceUrl, String token, String owner, String repo, final Context ctx) {
|
||||||
|
|
||||||
Call<List<Files>> call = RetrofitClient
|
Call<List<Files>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getFiles(token, owner, repo);
|
.getFiles(token, owner, repo);
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ public class FilesViewModel extends ViewModel {
|
|||||||
private static void loadFilesList2(String instanceUrl, String token, String owner, String repo, String filesDir, final Context ctx) {
|
private static void loadFilesList2(String instanceUrl, String token, String owner, String repo, String filesDir, final Context ctx) {
|
||||||
|
|
||||||
Call<List<Files>> call = RetrofitClient
|
Call<List<Files>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getDirFiles(token, owner, repo, filesDir);
|
.getDirFiles(token, owner, repo, filesDir);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.models.IssueComments;
|
import org.mian.gitnex.models.IssueComments;
|
||||||
@ -20,18 +21,18 @@ public class IssueCommentsViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<IssueComments>> issueComments;
|
private static MutableLiveData<List<IssueComments>> issueComments;
|
||||||
|
|
||||||
public LiveData<List<IssueComments>> getIssueCommentList(String instanceUrl, String token, String owner, String repo, int index) {
|
public LiveData<List<IssueComments>> getIssueCommentList(String instanceUrl, String token, String owner, String repo, int index, Context ctx) {
|
||||||
|
|
||||||
issueComments = new MutableLiveData<>();
|
issueComments = new MutableLiveData<>();
|
||||||
loadIssueComments(instanceUrl, token, owner, repo, index);
|
loadIssueComments(instanceUrl, token, owner, repo, index, ctx);
|
||||||
|
|
||||||
return issueComments;
|
return issueComments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadIssueComments(String instanceUrl, String token, String owner, String repo, int index) {
|
public static void loadIssueComments(String instanceUrl, String token, String owner, String repo, int index, Context ctx) {
|
||||||
|
|
||||||
Call<List<IssueComments>> call = RetrofitClient
|
Call<List<IssueComments>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getIssueComments(token, owner, repo, index);
|
.getIssueComments(token, owner, repo, index);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.models.Labels;
|
import org.mian.gitnex.models.Labels;
|
||||||
@ -20,18 +21,18 @@ public class LabelsViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<Labels>> labelsList;
|
private static MutableLiveData<List<Labels>> labelsList;
|
||||||
|
|
||||||
public LiveData<List<Labels>> getLabelsList(String instanceUrl, String token, String owner, String repo) {
|
public LiveData<List<Labels>> getLabelsList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||||
|
|
||||||
labelsList = new MutableLiveData<>();
|
labelsList = new MutableLiveData<>();
|
||||||
loadLabelsList(instanceUrl, token, owner, repo);
|
loadLabelsList(instanceUrl, token, owner, repo, ctx);
|
||||||
|
|
||||||
return labelsList;
|
return labelsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadLabelsList(String instanceUrl, String token, String owner, String repo) {
|
public static void loadLabelsList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||||
|
|
||||||
Call<List<Labels>> call = RetrofitClient
|
Call<List<Labels>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getlabels(token, owner, repo);
|
.getlabels(token, owner, repo);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.models.UserInfo;
|
import org.mian.gitnex.models.UserInfo;
|
||||||
@ -20,18 +21,18 @@ public class MembersByOrgViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<UserInfo>> membersList;
|
private static MutableLiveData<List<UserInfo>> membersList;
|
||||||
|
|
||||||
public LiveData<List<UserInfo>> getMembersList(String instanceUrl, String token, String owner) {
|
public LiveData<List<UserInfo>> getMembersList(String instanceUrl, String token, String owner, Context ctx) {
|
||||||
|
|
||||||
membersList = new MutableLiveData<>();
|
membersList = new MutableLiveData<>();
|
||||||
loadMembersList(instanceUrl, token, owner);
|
loadMembersList(instanceUrl, token, owner, ctx);
|
||||||
|
|
||||||
return membersList;
|
return membersList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadMembersList(String instanceUrl, String token, String owner) {
|
private static void loadMembersList(String instanceUrl, String token, String owner, Context ctx) {
|
||||||
|
|
||||||
Call<List<UserInfo>> call = RetrofitClient
|
Call<List<UserInfo>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getMembersByOrg(token, owner);
|
.getMembersByOrg(token, owner);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.models.Milestones;
|
import org.mian.gitnex.models.Milestones;
|
||||||
@ -20,18 +21,18 @@ public class MilestonesViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<Milestones>> milestonesList;
|
private static MutableLiveData<List<Milestones>> milestonesList;
|
||||||
|
|
||||||
public LiveData<List<Milestones>> getMilestonesList(String instanceUrl, String token, String owner, String repo, String msState) {
|
public LiveData<List<Milestones>> getMilestonesList(String instanceUrl, String token, String owner, String repo, String msState, Context ctx) {
|
||||||
|
|
||||||
milestonesList = new MutableLiveData<>();
|
milestonesList = new MutableLiveData<>();
|
||||||
loadMilestonesList(instanceUrl, token, owner, repo, msState);
|
loadMilestonesList(instanceUrl, token, owner, repo, msState, ctx);
|
||||||
|
|
||||||
return milestonesList;
|
return milestonesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadMilestonesList(String instanceUrl, String token, String owner, String repo, String msState) {
|
public static void loadMilestonesList(String instanceUrl, String token, String owner, String repo, String msState, Context ctx) {
|
||||||
|
|
||||||
Call<List<Milestones>> call = RetrofitClient
|
Call<List<Milestones>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getMilestones(token, owner, repo, msState);
|
.getMilestones(token, owner, repo, msState);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.models.UserRepositories;
|
import org.mian.gitnex.models.UserRepositories;
|
||||||
@ -20,20 +21,20 @@ public class MyRepositoriesViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<UserRepositories>> myReposList;
|
private static MutableLiveData<List<UserRepositories>> myReposList;
|
||||||
|
|
||||||
public LiveData<List<UserRepositories>> getCurrentUserRepositories(String instanceUrl, String token, String username) {
|
public LiveData<List<UserRepositories>> getCurrentUserRepositories(String instanceUrl, String token, String username, Context ctx) {
|
||||||
|
|
||||||
//if (myReposList == null) {
|
//if (myReposList == null) {
|
||||||
myReposList = new MutableLiveData<>();
|
myReposList = new MutableLiveData<>();
|
||||||
loadMyReposList(instanceUrl, token, username);
|
loadMyReposList(instanceUrl, token, username, ctx);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return myReposList;
|
return myReposList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadMyReposList(String instanceUrl, String token, String username) {
|
public static void loadMyReposList(String instanceUrl, String token, String username, Context ctx) {
|
||||||
|
|
||||||
Call<List<UserRepositories>> call = RetrofitClient
|
Call<List<UserRepositories>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getCurrentUserRepositories(token, username);
|
.getCurrentUserRepositories(token, username);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.models.UserOrganizations;
|
import org.mian.gitnex.models.UserOrganizations;
|
||||||
@ -20,20 +21,20 @@ public class OrganizationListViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<UserOrganizations>> orgsList;
|
private static MutableLiveData<List<UserOrganizations>> orgsList;
|
||||||
|
|
||||||
public LiveData<List<UserOrganizations>> getUserOrgs(String instanceUrl, String token) {
|
public LiveData<List<UserOrganizations>> getUserOrgs(String instanceUrl, String token, Context ctx) {
|
||||||
|
|
||||||
//if (orgsList == null) {
|
//if (orgsList == null) {
|
||||||
orgsList = new MutableLiveData<>();
|
orgsList = new MutableLiveData<>();
|
||||||
loadOrgsList(instanceUrl, token);
|
loadOrgsList(instanceUrl, token, ctx);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return orgsList;
|
return orgsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadOrgsList(String instanceUrl, String token) {
|
public static void loadOrgsList(String instanceUrl, String token, Context ctx) {
|
||||||
|
|
||||||
Call<List<UserOrganizations>> call = RetrofitClient
|
Call<List<UserOrganizations>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getUserOrgs(token);
|
.getUserOrgs(token);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.models.Emails;
|
import org.mian.gitnex.models.Emails;
|
||||||
@ -20,18 +21,18 @@ public class ProfileEmailsViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<Emails>> emailsList;
|
private static MutableLiveData<List<Emails>> emailsList;
|
||||||
|
|
||||||
public LiveData<List<Emails>> getEmailsList(String instanceUrl, String token) {
|
public LiveData<List<Emails>> getEmailsList(String instanceUrl, String token, Context ctx) {
|
||||||
|
|
||||||
emailsList = new MutableLiveData<>();
|
emailsList = new MutableLiveData<>();
|
||||||
loadEmailsList(instanceUrl, token);
|
loadEmailsList(instanceUrl, token, ctx);
|
||||||
|
|
||||||
return emailsList;
|
return emailsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadEmailsList(String instanceUrl, String token) {
|
public static void loadEmailsList(String instanceUrl, String token, Context ctx) {
|
||||||
|
|
||||||
Call<List<Emails>> call = RetrofitClient
|
Call<List<Emails>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getUserEmails(token);
|
.getUserEmails(token);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.models.UserInfo;
|
import org.mian.gitnex.models.UserInfo;
|
||||||
@ -20,18 +21,18 @@ public class ProfileFollowersViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<UserInfo>> followersList;
|
private static MutableLiveData<List<UserInfo>> followersList;
|
||||||
|
|
||||||
public LiveData<List<UserInfo>> getFollowersList(String instanceUrl, String token) {
|
public LiveData<List<UserInfo>> getFollowersList(String instanceUrl, String token, Context ctx) {
|
||||||
|
|
||||||
followersList = new MutableLiveData<>();
|
followersList = new MutableLiveData<>();
|
||||||
loadFollowersList(instanceUrl, token);
|
loadFollowersList(instanceUrl, token, ctx);
|
||||||
|
|
||||||
return followersList;
|
return followersList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadFollowersList(String instanceUrl, String token) {
|
public static void loadFollowersList(String instanceUrl, String token, Context ctx) {
|
||||||
|
|
||||||
Call<List<UserInfo>> call = RetrofitClient
|
Call<List<UserInfo>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getFollowers(token);
|
.getFollowers(token);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.models.UserInfo;
|
import org.mian.gitnex.models.UserInfo;
|
||||||
@ -20,18 +21,18 @@ public class ProfileFollowingViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<UserInfo>> followingList;
|
private static MutableLiveData<List<UserInfo>> followingList;
|
||||||
|
|
||||||
public LiveData<List<UserInfo>> getFollowingList(String instanceUrl, String token) {
|
public LiveData<List<UserInfo>> getFollowingList(String instanceUrl, String token, Context ctx) {
|
||||||
|
|
||||||
followingList = new MutableLiveData<>();
|
followingList = new MutableLiveData<>();
|
||||||
loadFollowingList(instanceUrl, token);
|
loadFollowingList(instanceUrl, token, ctx);
|
||||||
|
|
||||||
return followingList;
|
return followingList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadFollowingList(String instanceUrl, String token) {
|
public static void loadFollowingList(String instanceUrl, String token, Context ctx) {
|
||||||
|
|
||||||
Call<List<UserInfo>> call = RetrofitClient
|
Call<List<UserInfo>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getFollowing(token);
|
.getFollowing(token);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.models.Releases;
|
import org.mian.gitnex.models.Releases;
|
||||||
@ -20,18 +21,18 @@ public class ReleasesViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<Releases>> releasesList;
|
private static MutableLiveData<List<Releases>> releasesList;
|
||||||
|
|
||||||
public LiveData<List<Releases>> getReleasesList(String instanceUrl, String token, String owner, String repo) {
|
public LiveData<List<Releases>> getReleasesList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||||
|
|
||||||
releasesList = new MutableLiveData<>();
|
releasesList = new MutableLiveData<>();
|
||||||
loadReleasesList(instanceUrl, token, owner, repo);
|
loadReleasesList(instanceUrl, token, owner, repo, ctx);
|
||||||
|
|
||||||
return releasesList;
|
return releasesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadReleasesList(String instanceUrl, String token, String owner, String repo) {
|
public static void loadReleasesList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||||
|
|
||||||
Call<List<Releases>> call = RetrofitClient
|
Call<List<Releases>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getReleases(token, owner, repo);
|
.getReleases(token, owner, repo);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
@ -20,18 +21,18 @@ public class RepoStargazersViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<UserInfo>> stargazersList;
|
private static MutableLiveData<List<UserInfo>> stargazersList;
|
||||||
|
|
||||||
public LiveData<List<UserInfo>> getRepoStargazers(String instanceUrl, String token, String repoOwner, String repoName) {
|
public LiveData<List<UserInfo>> getRepoStargazers(String instanceUrl, String token, String repoOwner, String repoName, Context ctx) {
|
||||||
|
|
||||||
stargazersList = new MutableLiveData<>();
|
stargazersList = new MutableLiveData<>();
|
||||||
loadRepoStargazers(instanceUrl, token, repoOwner, repoName);
|
loadRepoStargazers(instanceUrl, token, repoOwner, repoName, ctx);
|
||||||
|
|
||||||
return stargazersList;
|
return stargazersList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadRepoStargazers(String instanceUrl, String token, String repoOwner, String repoName) {
|
private static void loadRepoStargazers(String instanceUrl, String token, String repoOwner, String repoName, Context ctx) {
|
||||||
|
|
||||||
Call<List<UserInfo>> call = RetrofitClient
|
Call<List<UserInfo>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getRepoStargazers(token, repoOwner, repoName);
|
.getRepoStargazers(token, repoOwner, repoName);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
@ -20,18 +21,18 @@ public class RepoWatchersViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<UserInfo>> watchersList;
|
private static MutableLiveData<List<UserInfo>> watchersList;
|
||||||
|
|
||||||
public LiveData<List<UserInfo>> getRepoWatchers(String instanceUrl, String token, String repoOwner, String repoName) {
|
public LiveData<List<UserInfo>> getRepoWatchers(String instanceUrl, String token, String repoOwner, String repoName, Context ctx) {
|
||||||
|
|
||||||
watchersList = new MutableLiveData<>();
|
watchersList = new MutableLiveData<>();
|
||||||
loadRepoWatchers(instanceUrl, token, repoOwner, repoName);
|
loadRepoWatchers(instanceUrl, token, repoOwner, repoName, ctx);
|
||||||
|
|
||||||
return watchersList;
|
return watchersList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadRepoWatchers(String instanceUrl, String token, String repoOwner, String repoName) {
|
private static void loadRepoWatchers(String instanceUrl, String token, String repoOwner, String repoName, Context ctx) {
|
||||||
|
|
||||||
Call<List<UserInfo>> call = RetrofitClient
|
Call<List<UserInfo>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getRepoWatchers(token, repoOwner, repoName);
|
.getRepoWatchers(token, repoOwner, repoName);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.models.UserRepositories;
|
import org.mian.gitnex.models.UserRepositories;
|
||||||
@ -20,18 +21,18 @@ public class RepositoriesByOrgViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<UserRepositories>> orgReposList;
|
private static MutableLiveData<List<UserRepositories>> orgReposList;
|
||||||
|
|
||||||
public LiveData<List<UserRepositories>> getRepositoriesByOrg(String instanceUrl, String token, String orgName) {
|
public LiveData<List<UserRepositories>> getRepositoriesByOrg(String instanceUrl, String token, String orgName, Context ctx) {
|
||||||
|
|
||||||
orgReposList = new MutableLiveData<>();
|
orgReposList = new MutableLiveData<>();
|
||||||
loadOrgRepos(instanceUrl, token, orgName);
|
loadOrgRepos(instanceUrl, token, orgName, ctx);
|
||||||
|
|
||||||
return orgReposList;
|
return orgReposList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadOrgRepos(String instanceUrl, String token, String orgName) {
|
public static void loadOrgRepos(String instanceUrl, String token, String orgName, Context ctx) {
|
||||||
|
|
||||||
Call<List<UserRepositories>> call = RetrofitClient
|
Call<List<UserRepositories>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getReposByOrg(token, orgName);
|
.getReposByOrg(token, orgName);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.models.UserRepositories;
|
import org.mian.gitnex.models.UserRepositories;
|
||||||
@ -20,20 +21,20 @@ public class RepositoriesListViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<UserRepositories>> reposList;
|
private static MutableLiveData<List<UserRepositories>> reposList;
|
||||||
|
|
||||||
public LiveData<List<UserRepositories>> getUserRepositories(String instanceUrl, String token) {
|
public LiveData<List<UserRepositories>> getUserRepositories(String instanceUrl, String token, Context ctx) {
|
||||||
|
|
||||||
//if (reposList == null) {
|
//if (reposList == null) {
|
||||||
reposList = new MutableLiveData<>();
|
reposList = new MutableLiveData<>();
|
||||||
loadReposList(instanceUrl, token);
|
loadReposList(instanceUrl, token, ctx);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return reposList;
|
return reposList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadReposList(String instanceUrl, String token) {
|
public static void loadReposList(String instanceUrl, String token, Context ctx) {
|
||||||
|
|
||||||
Call<List<UserRepositories>> call = RetrofitClient
|
Call<List<UserRepositories>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getUserRepositories(token);
|
.getUserRepositories(token);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.models.UserRepositories;
|
import org.mian.gitnex.models.UserRepositories;
|
||||||
@ -20,18 +21,18 @@ public class StarredRepositoriesViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static MutableLiveData<List<UserRepositories>> reposList;
|
private static MutableLiveData<List<UserRepositories>> reposList;
|
||||||
|
|
||||||
public LiveData<List<UserRepositories>> getUserStarredRepositories(String instanceUrl, String token) {
|
public LiveData<List<UserRepositories>> getUserStarredRepositories(String instanceUrl, String token, Context ctx) {
|
||||||
|
|
||||||
reposList = new MutableLiveData<>();
|
reposList = new MutableLiveData<>();
|
||||||
loadStarredReposList(instanceUrl, token);
|
loadStarredReposList(instanceUrl, token, ctx);
|
||||||
|
|
||||||
return reposList;
|
return reposList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadStarredReposList(String instanceUrl, String token) {
|
public static void loadStarredReposList(String instanceUrl, String token, Context ctx) {
|
||||||
|
|
||||||
Call<List<UserRepositories>> call = RetrofitClient
|
Call<List<UserRepositories>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl, ctx)
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getUserStarredRepos(token);
|
.getUserStarredRepos(token);
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user