Compare commits
6 Commits
release-2.
...
2.2.2
Author | SHA1 | Date | |
---|---|---|---|
5999b8ed4a | |||
2cba285076 | |||
24a552f0a9 | |||
d9a7fa4e44 | |||
9950d4ea65 | |||
98054b89cc |
@ -3,33 +3,20 @@ This part lists all PUBLIC individuals having contributed content to the code.
|
||||
|
||||
* M M Arif (mmarif)
|
||||
* 6543
|
||||
* Unpublished
|
||||
|
||||
# Translators
|
||||
This part lists all PUBLIC individuals having contributed content to the translation.
|
||||
*Entries are in alphabetical order*
|
||||
|
||||
* 6543
|
||||
* acrylicpaintboy
|
||||
* Antoine GIRARD (sapk)
|
||||
* BaRaN6161_TURK
|
||||
* ButterflyOfFire (BoFFire)
|
||||
* dadosch
|
||||
* erardiflorian
|
||||
* IndeedNotJames
|
||||
* jaqra
|
||||
* ljoonal
|
||||
* Lunny Xiao (xiaolunwen)
|
||||
* lxs
|
||||
* Marcos de Oliveira (markkrj)
|
||||
* mmarif
|
||||
* Nadezhda Moiseeva (digitalkiller)
|
||||
* Oleg Popenkov (FanHamMer)
|
||||
* PsychotherapistSam
|
||||
* Rodion Borisov (vintproykt)
|
||||
* s4ne
|
||||
* valeriezhao1013
|
||||
* Vladislav Glinsky (cl0ne)
|
||||
* Voyvode
|
||||
|
||||
**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)
|
||||
|
||||
## Note about Gitea version
|
||||
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.
|
||||
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.
|
||||
|
||||
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`.
|
||||
|
||||
## Features
|
||||
- File and directory browser
|
||||
- Create files
|
||||
- Explore repositories
|
||||
- My Repositories
|
||||
- Repositories list
|
||||
- Organizations list
|
||||
- Create repository
|
||||
- Create organization
|
||||
- Issues list
|
||||
- Pull requests
|
||||
- Merge pull request
|
||||
- [MANY MORE](https://gitea.com/gitnex/GitNex/wiki/Features)
|
||||
|
||||
## Contributing
|
||||
@ -83,11 +83,6 @@ Open source libraries
|
||||
- Abumoallim/android-multi-select-dialog
|
||||
- Pes/materialcolorpicker
|
||||
- Hendraanggrian/socialview
|
||||
- HamidrezaAmz/BreadcrumbsView
|
||||
- Chrisbanes/PhotoView
|
||||
- Pddstudio/highlightjs-android
|
||||
- Apache/commons-io
|
||||
- Caverock/androidsvg
|
||||
- Droidsonroids.gif/android-gif-drawable
|
||||
- Fython/BreadcrumbsView
|
||||
|
||||
[Follow me on Fediverse - mastodon.social/@mmarif](https://mastodon.social/@mmarif)
|
||||
|
@ -1,13 +1,13 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
compileSdkVersion 28
|
||||
defaultConfig {
|
||||
applicationId "org.mian.gitnex"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 29
|
||||
versionCode 82
|
||||
versionName "2.3.2"
|
||||
targetSdkVersion 28
|
||||
versionCode 72
|
||||
versionName "2.2.2"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
@ -23,29 +23,30 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def lifecycle_version = "2.2.0-rc02"
|
||||
def lifecycle_version = "2.2.0-beta01"
|
||||
final def markwon_version = "4.1.1"
|
||||
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation "androidx.appcompat:appcompat:1.1.0"
|
||||
implementation "com.google.android.material:material:1.2.0-alpha02"
|
||||
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
|
||||
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
||||
testImplementation "junit:junit:4.12"
|
||||
androidTestImplementation "androidx.test:runner:1.2.0"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
|
||||
implementation "com.github.vihtarb:tooltip:0.2.0"
|
||||
implementation "com.squareup.okhttp3:okhttp:3.12.1"
|
||||
implementation "com.google.code.gson:gson:2.8.5"
|
||||
implementation "com.squareup.picasso:picasso:2.71828"
|
||||
implementation "com.amulyakhare:com.amulyakhare.textdrawable:1.0.1"
|
||||
implementation "com.squareup.retrofit2:retrofit:2.5.0"
|
||||
implementation "com.squareup.retrofit2:converter-gson:2.5.0"
|
||||
implementation "com.squareup.retrofit2:converter-scalars:2.5.0"
|
||||
implementation "com.squareup.okhttp3:logging-interceptor:3.12.1"
|
||||
implementation "org.ocpsoft.prettytime:prettytime:4.0.1.Final"
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'com.google.android.material:material:1.1.0-beta01'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
implementation 'com.github.vihtarb:tooltip:0.2.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation 'com.squareup.picasso:picasso:2.71828'
|
||||
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
|
||||
implementation 'com.squareup.retrofit2:converter-scalars:2.5.0'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.1'
|
||||
implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
|
||||
implementation "com.vdurmont:emoji-java:4.0.0"
|
||||
implementation "com.pes.materialcolorpicker:library:1.2.5"
|
||||
|
||||
implementation "io.noties.markwon:core:$markwon_version"
|
||||
implementation "io.noties.markwon:ext-latex:$markwon_version"
|
||||
implementation "io.noties.markwon:ext-strikethrough:$markwon_version"
|
||||
@ -60,13 +61,13 @@ dependencies {
|
||||
implementation "io.noties.markwon:simple-ext:$markwon_version"
|
||||
implementation "io.noties.markwon:syntax-highlight:$markwon_version"
|
||||
implementation "com.caverock:androidsvg:1.4"
|
||||
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.19"
|
||||
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.14"
|
||||
|
||||
implementation "com.hendraanggrian.appcompat:socialview:0.2"
|
||||
implementation "com.hendraanggrian.appcompat:socialview-commons:0.2"
|
||||
|
||||
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
|
||||
|
||||
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,9 +2,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.mian.gitnex">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/app_logo"
|
||||
@ -13,10 +10,9 @@
|
||||
android:roundIcon="@mipmap/app_logo_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".activities.MergePullRequestActivity"></activity>
|
||||
<activity
|
||||
android:name=".activities.FileViewActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme.NoActionBar"></activity>
|
||||
<activity
|
||||
android:name=".activities.NewFileActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
@ -70,7 +66,9 @@
|
||||
<activity android:name=".activities.NewRepoActivity" />
|
||||
<activity android:name=".activities.NewOrganizationActivity" />
|
||||
<activity android:name=".activities.OpenRepoInBrowserActivity" />
|
||||
<activity android:name=".activities.FileDiffActivity" />
|
||||
</application>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
</manifest>
|
@ -35,7 +35,7 @@ public class CollaboratorActions {
|
||||
Call<Collaborators> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.deleteCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName);
|
||||
|
||||
@ -105,7 +105,7 @@ public class CollaboratorActions {
|
||||
Call<Permission> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.addCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName, permissionString);
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class IssueActions {
|
||||
Call<IssueComments> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.patchIssueComment(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, commentId, commentBodyJson);
|
||||
|
||||
@ -104,7 +104,7 @@ public class IssueActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.closeReopenIssue(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueStatJson);
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class RepositoryActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.starRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -98,7 +98,7 @@ public class RepositoryActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.unStarRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -163,7 +163,7 @@ public class RepositoryActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.watchRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -228,7 +228,7 @@ public class RepositoryActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, context)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.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.models.UserSearch;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -46,6 +46,8 @@ public class AddCollaboratorToRepositoryActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_add_collaborator_to_repository);
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
@ -79,7 +81,7 @@ public class AddCollaboratorToRepositoryActivity extends AppCompatActivity {
|
||||
public void loadUserSearchList(String instanceUrl, String token, String searchKeyword, final Context context, String loginUid) {
|
||||
|
||||
Call<UserSearch> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getUserBySearch(Authorization.returnAuthentication(getApplicationContext(), loginUid, token), searchKeyword, 10);
|
||||
|
||||
@ -99,7 +101,7 @@ public class AddCollaboratorToRepositoryActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserSearch> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
Log.i("onFailure", t.getMessage());
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -65,7 +65,7 @@ public class AddRemoveAssigneesActivity extends AppCompatActivity {
|
||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -90,7 +90,7 @@ public class AddRemoveAssigneesActivity extends AppCompatActivity {
|
||||
|
||||
// get current issue assignees
|
||||
Call<Issues> callSingleIssueAssignees = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getIssueByIndex(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
|
||||
@ -239,7 +239,7 @@ public class AddRemoveAssigneesActivity extends AppCompatActivity {
|
||||
Call<JsonElement> call3;
|
||||
|
||||
call3 = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.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());
|
||||
|
||||
Call<List<Labels>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getlabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -87,7 +87,7 @@ public class AddRemoveLabelsActivity extends AppCompatActivity {
|
||||
|
||||
// get current issue labels
|
||||
Call<List<Labels>> callSingleIssueLabels = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getIssueLabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
|
||||
@ -249,7 +249,7 @@ public class AddRemoveLabelsActivity extends AppCompatActivity {
|
||||
Labels patchIssueLabels = new Labels(issueLabels);
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.updateIssueLabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, patchIssueLabels);
|
||||
|
||||
|
@ -40,7 +40,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -218,7 +217,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
||||
final String repoName = parts[1];
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -249,7 +248,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
Log.i("onFailure", t.getMessage());
|
||||
}
|
||||
|
||||
});
|
||||
@ -262,7 +261,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
||||
Call<JsonElement> call3;
|
||||
|
||||
call3 = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.createNewIssue(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, createNewIssueJson);
|
||||
|
||||
@ -326,7 +325,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
||||
|
||||
String msState = "open";
|
||||
Call<List<Milestones>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getMilestones(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, msState);
|
||||
|
||||
@ -340,13 +339,13 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
||||
|
||||
List<Milestones> milestonesList_ = response.body();
|
||||
|
||||
milestonesList.add(new Milestones(0,getString(R.string.issueCreatedNoMilestone)));
|
||||
milestonesList.add(new Milestones(0,"No milestone"));
|
||||
assert milestonesList_ != null;
|
||||
if(milestonesList_.size() > 0) {
|
||||
for (int i = 0; i < milestonesList_.size(); i++) {
|
||||
|
||||
//Don't translate "open" is a enum
|
||||
if(milestonesList_.get(i).getState().equals("open")) {
|
||||
//String mStone = getString(R.string.spinnerMilestoneText, milestonesList_.get(i).getTitle(), milestonesList_.get(i).getState());
|
||||
if(milestonesList_.get(i).getState().equals(getString(R.string.issueStatusOpen))) {
|
||||
Milestones data = new Milestones(
|
||||
milestonesList_.get(i).getId(),
|
||||
milestonesList_.get(i).getTitle()
|
||||
@ -380,7 +379,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
||||
private void getCollaborators(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -450,7 +449,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
||||
private void getLabels(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
||||
|
||||
Call<List<Labels>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getlabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
|
@ -28,7 +28,6 @@ import org.mian.gitnex.models.Labels;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.LabelsViewModel;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -56,9 +55,9 @@ public class CreateLabelActivity extends AppCompatActivity {
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("delete")) {
|
||||
if(getIntent().getStringExtra("labelAction") != null && getIntent().getStringExtra("labelAction").equals("delete")) {
|
||||
|
||||
deleteLabel(instanceUrl, instanceToken, repoOwner, repoName, Integer.valueOf(Objects.requireNonNull(getIntent().getStringExtra("labelId"))), loginUid);
|
||||
deleteLabel(instanceUrl, instanceToken, repoOwner, repoName, Integer.valueOf(getIntent().getStringExtra("labelId")), loginUid);
|
||||
finish();
|
||||
return;
|
||||
|
||||
@ -93,7 +92,7 @@ public class CreateLabelActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("edit")) {
|
||||
if(getIntent().getStringExtra("labelAction") != null && getIntent().getStringExtra("labelAction").equals("edit")) {
|
||||
|
||||
labelName.setText(getIntent().getStringExtra("labelTitle"));
|
||||
int labelColor_ = Color.parseColor("#" + getIntent().getStringExtra("labelColor"));
|
||||
@ -243,7 +242,7 @@ public class CreateLabelActivity extends AppCompatActivity {
|
||||
Call<CreateLabel> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.createLabel(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, createLabelFunc);
|
||||
|
||||
@ -297,7 +296,7 @@ public class CreateLabelActivity extends AppCompatActivity {
|
||||
Call<CreateLabel> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.patchLabel(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, labelId, createLabelFunc);
|
||||
|
||||
@ -370,7 +369,7 @@ public class CreateLabelActivity extends AppCompatActivity {
|
||||
Call<Labels> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.deleteLabel(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, labelId);
|
||||
|
||||
@ -383,7 +382,7 @@ public class CreateLabelActivity extends AppCompatActivity {
|
||||
if(response.code() == 204) {
|
||||
|
||||
Toasty.info(getApplicationContext(), getString(R.string.labelDeleteText));
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, instanceToken, repoOwner, repoName, getApplicationContext());
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, instanceToken, repoOwner, repoName);
|
||||
getIntent().removeExtra("labelAction");
|
||||
getIntent().removeExtra("labelId");
|
||||
|
||||
|
@ -127,7 +127,7 @@ public class CreateNewUserActivity extends AppCompatActivity {
|
||||
Call<UserInfo> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.createNewUser(instanceToken, createUser);
|
||||
|
||||
|
@ -164,7 +164,7 @@ public class CreateReleaseActivity extends AppCompatActivity {
|
||||
Call<Releases> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.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) {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getBranches(instanceToken, repoOwner, repoName);
|
||||
|
||||
|
@ -308,7 +308,7 @@ public class CreateTeamByOrgActivity extends AppCompatActivity implements View.O
|
||||
Call<Teams> call3;
|
||||
|
||||
call3 = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.createTeamsByOrg(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), orgName, createNewTeamJson);
|
||||
|
||||
|
@ -1,18 +1,12 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
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.text.method.LinkMovementMethod;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
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
|
||||
@ -28,28 +22,14 @@ public class CreditsActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_credits);
|
||||
|
||||
TextView creditKasun = findViewById(R.id.creditKasun);
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
creditKasun.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
Resources res = getResources();
|
||||
CharSequence[] creditsInfo = res.getTextArray(R.array.creditsInfo);
|
||||
|
||||
List<CharSequence> creditsList = new ArrayList<>(Arrays.asList(creditsInfo));
|
||||
|
||||
RecyclerView mRecyclerView = findViewById(R.id.recyclerView);
|
||||
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
CreditsAdapter adapter = new CreditsAdapter(creditsList);
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
@ -100,13 +100,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
||||
editIssueButton.setOnClickListener(this);
|
||||
|
||||
if(!tinyDb.getString("issueNumber").isEmpty()) {
|
||||
|
||||
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)));
|
||||
}
|
||||
toolbar_title.setText(getString(R.string.editIssueNavHeader, String.valueOf(issueIndex)));
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
@ -128,7 +122,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
||||
final String repoName = parts[1];
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -159,7 +153,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
Log.i("onFailure", t.getMessage());
|
||||
}
|
||||
|
||||
});
|
||||
@ -235,7 +229,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
||||
CreateIssue issueData = new CreateIssue(title, description, dueDate, editIssueMilestoneId);
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.patchIssue(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, issueData);
|
||||
|
||||
@ -246,13 +240,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
if(tinyDb.getString("issueType").equals("pr")) {
|
||||
Toasty.info(getApplicationContext(), getString(R.string.editPrSuccessMessage));
|
||||
}
|
||||
else {
|
||||
Toasty.info(getApplicationContext(), getString(R.string.editIssueSuccessMessage));
|
||||
}
|
||||
|
||||
Toasty.info(getApplicationContext(), getString(R.string.editIssueSuccessMessage));
|
||||
tinyDb.putBoolean("issueEdited", true);
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
finish();
|
||||
@ -319,7 +307,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) {
|
||||
|
||||
Call<Issues> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getIssueByIndex(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
|
||||
@ -343,7 +331,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
||||
if(response.body().getId() > 0) {
|
||||
|
||||
Call<List<Milestones>> call_ = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getMilestones(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, msState);
|
||||
|
||||
|
@ -1,212 +0,0 @@
|
||||
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,12 +1,8 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@ -15,10 +11,6 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
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.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
@ -26,8 +18,6 @@ import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Files;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -39,11 +29,8 @@ public class FileViewActivity extends AppCompatActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView singleFileContents;
|
||||
private HighlightJsView singleCodeContents;
|
||||
private PhotoView imageView;
|
||||
final Context ctx = this;
|
||||
private ProgressBar mProgressBar;
|
||||
private byte[] imageData;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -62,10 +49,10 @@ public class FileViewActivity extends AppCompatActivity {
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
singleFileContents = findViewById(R.id.singleFileContents);
|
||||
singleCodeContents = findViewById(R.id.singleCodeContents);
|
||||
imageView = findViewById(R.id.imageView);
|
||||
singleFileContents.setVisibility(View.GONE);
|
||||
mProgressBar = findViewById(R.id.progress_bar);
|
||||
|
||||
@ -73,34 +60,24 @@ public class FileViewActivity extends AppCompatActivity {
|
||||
|
||||
TextView toolbar_title = findViewById(R.id.toolbar_title);
|
||||
toolbar_title.setMovementMethod(new ScrollingMovementMethod());
|
||||
toolbar_title.setText(singleFileName);
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
try {
|
||||
|
||||
singleFileName = URLDecoder.decode(singleFileName, "UTF-8");
|
||||
singleFileName = singleFileName.replaceAll("//", "/");
|
||||
singleFileName = singleFileName.startsWith("/") ? singleFileName.substring(1) : singleFileName;
|
||||
|
||||
if(connToInternet) {
|
||||
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName);
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
|
||||
assert singleFileName != null;
|
||||
Log.i("singleFileName", singleFileName);
|
||||
|
||||
else {
|
||||
Toasty.info(getApplicationContext(), getString(R.string.checkNetConnection));
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
Call<Files> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getSingleFileContents(token, owner, repo, filename);
|
||||
|
||||
@ -115,42 +92,9 @@ public class FileViewActivity extends AppCompatActivity {
|
||||
assert response.body() != null;
|
||||
|
||||
if(!response.body().getContent().equals("")) {
|
||||
|
||||
String fileExtension = FilenameUtils.getExtension(filename);
|
||||
singleFileContents.setVisibility(View.VISIBLE);
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
|
||||
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()));
|
||||
|
||||
}
|
||||
|
||||
singleFileContents.setText(appUtil.decodeBase64(response.body().getContent()));
|
||||
}
|
||||
else {
|
||||
singleFileContents.setText("");
|
||||
|
@ -152,7 +152,7 @@ public class IssueDetailActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, getApplicationContext());
|
||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
@ -206,7 +206,7 @@ public class IssueDetailActivity extends AppCompatActivity {
|
||||
scrollViewComments.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, getApplicationContext());
|
||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
@ -224,7 +224,7 @@ public class IssueDetailActivity extends AppCompatActivity {
|
||||
scrollViewComments.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, getApplicationContext());
|
||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
tinyDb.putBoolean("commentEdited", false);
|
||||
}
|
||||
});
|
||||
@ -264,7 +264,7 @@ public class IssueDetailActivity extends AppCompatActivity {
|
||||
|
||||
IssueCommentsViewModel issueCommentsModel = ViewModelProviders.of(this).get(IssueCommentsViewModel.class);
|
||||
|
||||
issueCommentsModel.getIssueCommentList(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), owner, repo, index, getApplicationContext()).observe(this, new Observer<List<IssueComments>>() {
|
||||
issueCommentsModel.getIssueCommentList(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), owner, repo, index).observe(this, new Observer<List<IssueComments>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<IssueComments> issueCommentsMain) {
|
||||
adapter = new IssueCommentsAdapter(getApplicationContext(), issueCommentsMain);
|
||||
@ -278,7 +278,7 @@ public class IssueDetailActivity extends AppCompatActivity {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
Call<Issues> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getIssueByIndex(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
@ -15,28 +15,21 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.tooltip.Tooltip;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
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.util.AppUtil;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import okhttp3.Credentials;
|
||||
import okhttp3.Headers;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -46,13 +39,9 @@ import retrofit2.Callback;
|
||||
|
||||
public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
private Button loginButton;
|
||||
private EditText instanceUrlET, loginUidET, loginPassword, otpCode, loginTokenCode;
|
||||
private Button login_button;
|
||||
private EditText instance_url, login_uid, login_passwd, otpCode;
|
||||
private Spinner protocolSpinner;
|
||||
private TextView otpInfo;
|
||||
private RadioGroup loginMethod;
|
||||
final Context ctx = this;
|
||||
private String device_id = "token";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -63,19 +52,16 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
||||
|
||||
loginButton = findViewById(R.id.login_button);
|
||||
instanceUrlET = findViewById(R.id.instance_url);
|
||||
loginUidET = findViewById(R.id.login_uid);
|
||||
loginPassword = findViewById(R.id.login_passwd);
|
||||
login_button = findViewById(R.id.login_button);
|
||||
instance_url = findViewById(R.id.instance_url);
|
||||
login_uid = findViewById(R.id.login_uid);
|
||||
login_passwd = findViewById(R.id.login_passwd);
|
||||
otpCode = findViewById(R.id.otpCode);
|
||||
otpInfo = findViewById(R.id.otpInfo);
|
||||
ImageView info_button = findViewById(R.id.info);
|
||||
final TextView viewTextAppVersion = findViewById(R.id.appVersion);
|
||||
final TextView viewTextGiteaVersion = findViewById(R.id.appVersion);
|
||||
protocolSpinner = findViewById(R.id.httpsSpinner);
|
||||
loginMethod = findViewById(R.id.loginMethod);
|
||||
loginTokenCode = findViewById(R.id.loginTokenCode);
|
||||
|
||||
viewTextAppVersion.setText(AppUtil.getAppVersion(getApplicationContext()));
|
||||
viewTextGiteaVersion.setText(AppUtil.getAppVersion(getApplicationContext()));
|
||||
|
||||
Resources res = getResources();
|
||||
String[] allProtocols = res.getStringArray(R.array.protocolValues);
|
||||
@ -108,31 +94,12 @@ 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);
|
||||
if(!tinyDb.getString("instanceUrlRaw").isEmpty()) {
|
||||
instanceUrlET.setText(tinyDb.getString("instanceUrlRaw"));
|
||||
instance_url.setText(tinyDb.getString("instanceUrlRaw"));
|
||||
}
|
||||
if(!tinyDb.getString("loginUid").isEmpty()) {
|
||||
loginUidET.setText(tinyDb.getString("loginUid"));
|
||||
login_uid.setText(tinyDb.getString("loginUid"));
|
||||
}
|
||||
|
||||
if(tinyDb.getBoolean("loggedInMode")) {
|
||||
@ -142,23 +109,20 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
|
||||
}
|
||||
|
||||
loginButton.setOnClickListener(loginListener);
|
||||
|
||||
if(!tinyDb.getString("uniqueAppId").isEmpty()) {
|
||||
device_id = tinyDb.getString("uniqueAppId");
|
||||
}
|
||||
else {
|
||||
device_id = UUID.randomUUID().toString();
|
||||
tinyDb.putString("uniqueAppId", device_id);
|
||||
}
|
||||
login_button.setOnClickListener(loginListener);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (v.getId() == R.id.login_button) {
|
||||
login();
|
||||
switch(v.getId()) {
|
||||
|
||||
case R.id.login_button:
|
||||
login();
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -167,7 +131,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
public void onClick(View v) {
|
||||
|
||||
disableProcessButton();
|
||||
loginButton.setText(R.string.processingText);
|
||||
login_button.setText(R.string.processingText);
|
||||
login();
|
||||
|
||||
}
|
||||
@ -195,336 +159,112 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
AppUtil appUtil = new AppUtil();
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(LoginActivity.this);
|
||||
|
||||
String instanceUrl = instanceUrlET.getText().toString().trim();
|
||||
String loginUid = loginUidET.getText().toString();
|
||||
String loginPass = loginPassword.getText().toString();
|
||||
String instanceUrl = instance_url.getText().toString().trim();
|
||||
String loginUid = login_uid.getText().toString();
|
||||
String loginPass = login_passwd.getText().toString();
|
||||
String protocol = protocolSpinner.getSelectedItem().toString();
|
||||
String loginOTP_ = otpCode.getText().toString().trim();
|
||||
int loginMethodType = loginMethod.getCheckedRadioButtonId();
|
||||
String loginToken_ = loginTokenCode.getText().toString().trim();
|
||||
|
||||
if(loginMethodType == R.id.loginUsernamePassword) {
|
||||
if(instanceUrl.contains("@")) {
|
||||
|
||||
if(instanceUrl.contains("@")) {
|
||||
String[] urlForHttpAuth = instanceUrl.split("@");
|
||||
|
||||
String[] urlForHttpAuth = instanceUrl.split("@");
|
||||
tinyDb.putString("basicAuthPassword", loginPass);
|
||||
tinyDb.putBoolean("basicAuthFlag", true);
|
||||
|
||||
tinyDb.putString("basicAuthPassword", loginPass);
|
||||
tinyDb.putBoolean("basicAuthFlag", true);
|
||||
instanceUrl = urlForHttpAuth[1];
|
||||
loginUid = urlForHttpAuth[0];
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
String instanceHost;
|
||||
if(AppUtil.httpCheck(instanceUrl)) {
|
||||
int loginOTP = 0;
|
||||
if(loginOTP_.length() == 6) {
|
||||
|
||||
URI uri = null;
|
||||
try {
|
||||
uri = new URI(instanceUrl);
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
if(appUtil.checkIntegers(loginOTP_)) {
|
||||
|
||||
loginOTP = Integer.valueOf(loginOTP_);
|
||||
}
|
||||
assert uri != null;
|
||||
instanceHost = uri.getHost();
|
||||
else {
|
||||
|
||||
}
|
||||
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));
|
||||
Toasty.info(getApplicationContext(), getString(R.string.loginOTPTypeError));
|
||||
enableProcessButton();
|
||||
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);
|
||||
login_button.setText(R.string.btnLogin);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
int loginOTP = 0;
|
||||
if(loginOTP_.length() == 6) {
|
||||
|
||||
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));
|
||||
|
||||
}
|
||||
letTheUserIn(instanceUrl, loginUid, loginPass, loginOTP);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
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));
|
||||
|
||||
}
|
||||
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) {
|
||||
|
||||
final String credential = Credentials.basic(loginUid, loginPass);
|
||||
@ -532,13 +272,13 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
Call<List<UserTokens>> call;
|
||||
if(loginOTP != 0) {
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getUserTokensWithOTP(credential, loginOTP, loginUid);
|
||||
}
|
||||
else {
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getUserTokens(credential, loginUid);
|
||||
}
|
||||
@ -550,8 +290,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
|
||||
List<UserTokens> userTokens = response.body();
|
||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
final AppUtil appUtil = new AppUtil();
|
||||
//Headers responseHeaders = response.headers();
|
||||
Headers responseHeaders = response.headers();
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
@ -561,46 +300,29 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
|
||||
assert userTokens != null;
|
||||
if (userTokens.size() > 0) {
|
||||
|
||||
if(userTokens.get(0).getToken_last_eight() != null) {
|
||||
|
||||
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());
|
||||
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());
|
||||
}
|
||||
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) {
|
||||
|
||||
UserTokens createUserToken = new UserTokens("gitnex-app-" + device_id);
|
||||
UserTokens createUserToken = new UserTokens("gitnex-app-token");
|
||||
|
||||
Call<UserTokens> callCreateToken;
|
||||
if(loginOTP != 0) {
|
||||
callCreateToken = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.createNewTokenWithOTP(credential, loginOTP, loginUid, createUserToken);
|
||||
}
|
||||
else {
|
||||
callCreateToken = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.createNewToken(credential, loginUid, createUserToken);
|
||||
}
|
||||
@ -610,7 +332,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserTokens> callCreateToken, @NonNull retrofit2.Response<UserTokens> responseCreate) {
|
||||
|
||||
if(responseCreate.isSuccessful()) {
|
||||
if (responseCreate.isSuccessful()) {
|
||||
|
||||
if(responseCreate.code() == 201) {
|
||||
|
||||
@ -623,7 +345,6 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
tinyDb.remove("loginPass");
|
||||
tinyDb.putBoolean("loggedInMode", true);
|
||||
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"));
|
||||
|
||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||
@ -636,10 +357,10 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
}
|
||||
else if(responseCreate.code() == 500) {
|
||||
|
||||
String toastError = getResources().getString(R.string.genericApiStatusError) + responseCreate.code();
|
||||
String toastError = getResources().getString(R.string.genericApiStatusError) + String.valueOf(responseCreate.code());
|
||||
Toasty.info(getApplicationContext(), toastError);
|
||||
enableProcessButton();
|
||||
loginButton.setText(R.string.btnLogin);
|
||||
login_button.setText(R.string.btnLogin);
|
||||
|
||||
}
|
||||
|
||||
@ -666,20 +387,20 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
}
|
||||
else if(response.code() == 500) {
|
||||
|
||||
String toastError = getResources().getString(R.string.genericApiStatusError) + response.code();
|
||||
String toastError = getResources().getString(R.string.genericApiStatusError) + String.valueOf(response.code());
|
||||
Toasty.info(getApplicationContext(), toastError);
|
||||
enableProcessButton();
|
||||
loginButton.setText(R.string.btnLogin);
|
||||
login_button.setText(R.string.btnLogin);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
String toastError = getResources().getString(R.string.genericApiStatusError) + response.code();
|
||||
String toastError = getResources().getString(R.string.genericApiStatusError) + String.valueOf(response.code());
|
||||
//Log.i("error message else4", String.valueOf(response.code()));
|
||||
|
||||
Toasty.info(getApplicationContext(), toastError);
|
||||
enableProcessButton();
|
||||
loginButton.setText(R.string.btnLogin);
|
||||
login_button.setText(R.string.btnLogin);
|
||||
|
||||
}
|
||||
|
||||
@ -690,7 +411,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
Log.e("onFailure-login", t.toString());
|
||||
Toasty.info(getApplicationContext(), getResources().getString(R.string.malformedJson));
|
||||
enableProcessButton();
|
||||
loginButton.setText(R.string.btnLogin);
|
||||
login_button.setText(R.string.btnLogin);
|
||||
}
|
||||
});
|
||||
|
||||
@ -698,21 +419,21 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
|
||||
private void disableProcessButton() {
|
||||
|
||||
loginButton.setEnabled(false);
|
||||
login_button.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
loginButton.setBackground(shape);
|
||||
login_button.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
loginButton.setEnabled(true);
|
||||
login_button.setEnabled(true);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||
loginButton.setBackground(shape);
|
||||
login_button.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,6 @@ import org.mian.gitnex.fragments.StarredRepositoriesFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.GiteaVersion;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
@ -125,39 +124,40 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
@Override
|
||||
public void onDrawerOpened(@NonNull View drawerView) {
|
||||
|
||||
if(tinyDb.getBoolean("noConnection")) {
|
||||
Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
|
||||
tinyDb.putBoolean("noConnection", false);
|
||||
}
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
||||
if(!connToInternet) {
|
||||
|
||||
//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();
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -218,7 +218,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
} else {
|
||||
|
||||
displayUserInfo(instanceUrl, instanceToken, loginUid);
|
||||
giteaVersion(instanceUrl);
|
||||
tinyDb.putBoolean("noConnection", false);
|
||||
|
||||
}
|
||||
@ -313,48 +312,12 @@ 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) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
Call<UserInfo> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getUserInfo(Authorization.returnAuthentication(getApplicationContext(), loginUid, token));
|
||||
|
||||
@ -382,7 +345,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
tinyDb.putString("userFullname", userDetails.getFullname());
|
||||
}
|
||||
else {
|
||||
tinyDb.putString("userFullname", userDetails.getLogin());
|
||||
tinyDb.putString("userFullname", "...");
|
||||
}
|
||||
|
||||
tinyDb.putString("userEmail", userDetails.getEmail());
|
||||
|
@ -1,258 +0,0 @@
|
||||
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
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.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) {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getBranches(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class NewMilestoneActivity extends AppCompatActivity implements View.OnCl
|
||||
Call<Milestones> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.createMilestone(token, repoOwner, repoName, createMilestone);
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class NewOrganizationActivity extends AppCompatActivity {
|
||||
UserOrganizations createOrganization = new UserOrganizations(orgName, null, orgDesc, null, null);
|
||||
|
||||
Call<UserOrganizations> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.createNewOrganization(token, createOrganization);
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class NewRepoActivity extends AppCompatActivity {
|
||||
if(repoOwner.equals(loginUid)) {
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.createNewUserRepository(token, createRepository);
|
||||
|
||||
@ -170,7 +170,7 @@ public class NewRepoActivity extends AppCompatActivity {
|
||||
else {
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.createNewUserOrgRepository(token, repoOwner, createRepository);
|
||||
|
||||
@ -225,7 +225,7 @@ public class NewRepoActivity extends AppCompatActivity {
|
||||
private void getOrgs(String instanceUrl, String instanceToken, final String userLogin) {
|
||||
|
||||
Call<List<OrgOwner>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getOrgOwners(instanceToken);
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class OrgTeamMembersActivity extends AppCompatActivity {
|
||||
|
||||
TeamMembersByOrgViewModel teamMembersModel = new ViewModelProvider(this).get(TeamMembersByOrgViewModel.class);
|
||||
|
||||
teamMembersModel.getMembersByOrgList(instanceUrl, instanceToken, teamId, getApplicationContext()).observe(this, new Observer<List<UserInfo>>() {
|
||||
teamMembersModel.getMembersByOrgList(instanceUrl, instanceToken, teamId).observe(this, new Observer<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserInfo> teamMembersListMain) {
|
||||
adapter = new TeamMembersByOrgAdapter(getApplicationContext(), teamMembersListMain);
|
||||
|
@ -114,7 +114,7 @@ public class ProfileEmailActivity extends AppCompatActivity {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.addNewEmail(token, addEmailFunc);
|
||||
|
||||
|
@ -83,7 +83,6 @@ public class ReplyToIssueActivity extends AppCompatActivity {
|
||||
|
||||
replyButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
disableProcessButton();
|
||||
IssueActions.editIssueComment(ctx, Integer.valueOf(commentId), addComment.getText().toString());
|
||||
}
|
||||
|
||||
@ -118,7 +117,7 @@ public class ReplyToIssueActivity extends AppCompatActivity {
|
||||
final String repoName = parts[1];
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -212,7 +211,7 @@ public class ReplyToIssueActivity extends AppCompatActivity {
|
||||
Issues issueComment = new Issues(newReplyDT);
|
||||
|
||||
Call<Issues> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.replyCommentToIssue(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, issueComment);
|
||||
|
||||
@ -226,7 +225,6 @@ public class ReplyToIssueActivity extends AppCompatActivity {
|
||||
Toasty.info(getApplicationContext(), getString(R.string.commentSuccess));
|
||||
tinyDb.putBoolean("commentPosted", true);
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("resumePullRequests", true);
|
||||
finish();
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ import org.mian.gitnex.fragments.FilesFragment;
|
||||
import org.mian.gitnex.fragments.IssuesFragment;
|
||||
import org.mian.gitnex.fragments.LabelsFragment;
|
||||
import org.mian.gitnex.fragments.MilestonesFragment;
|
||||
import org.mian.gitnex.fragments.PullRequestsFragment;
|
||||
import org.mian.gitnex.fragments.ReleasesFragment;
|
||||
import org.mian.gitnex.fragments.RepoBottomSheetFragment;
|
||||
import org.mian.gitnex.fragments.RepoInfoFragment;
|
||||
@ -214,18 +213,15 @@ public class RepoDetailActivity extends AppCompatActivity implements RepoBottomS
|
||||
case 3: // closed issues
|
||||
fragment = new ClosedIssuesFragment();
|
||||
break;
|
||||
case 4: // pull requests
|
||||
fragment = new PullRequestsFragment();
|
||||
break;
|
||||
case 5: // milestones
|
||||
case 4: // milestones
|
||||
return MilestonesFragment.newInstance(repoOwner, repoName);
|
||||
case 6: // labels
|
||||
case 5: // labels
|
||||
return LabelsFragment.newInstance(repoOwner, repoName);
|
||||
case 7: // branches
|
||||
case 6: // branches
|
||||
return BranchesFragment.newInstance(repoOwner, repoName);
|
||||
case 8: // releases
|
||||
case 7: // releases
|
||||
return ReleasesFragment.newInstance(repoOwner, repoName);
|
||||
case 9: // collaborators
|
||||
case 8: // collaborators
|
||||
return CollaboratorsFragment.newInstance(repoOwner, repoName);
|
||||
}
|
||||
return fragment;
|
||||
@ -233,7 +229,7 @@ public class RepoDetailActivity extends AppCompatActivity implements RepoBottomS
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 10;
|
||||
return 9;
|
||||
}
|
||||
|
||||
}
|
||||
@ -241,7 +237,7 @@ public class RepoDetailActivity extends AppCompatActivity implements RepoBottomS
|
||||
private void getRepoInfo(String instanceUrl, String token, final String owner, String repo) {
|
||||
|
||||
Call<UserRepositories> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getUserRepository(token, owner, repo);
|
||||
|
||||
@ -281,7 +277,7 @@ public class RepoDetailActivity extends AppCompatActivity implements RepoBottomS
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.checkRepoStarStatus(instanceToken, owner, repo);
|
||||
|
||||
@ -308,7 +304,7 @@ public class RepoDetailActivity extends AppCompatActivity implements RepoBottomS
|
||||
Call<WatchRepository> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.checkRepoWatchStatus(instanceToken, owner, repo);
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class RepoStargazersActivity extends AppCompatActivity {
|
||||
|
||||
RepoStargazersViewModel repoStargazersModel = new ViewModelProvider(this).get(RepoStargazersViewModel.class);
|
||||
|
||||
repoStargazersModel.getRepoStargazers(instanceUrl, instanceToken, repoOwner, repoName, getApplicationContext()).observe(this, new Observer<List<UserInfo>>() {
|
||||
repoStargazersModel.getRepoStargazers(instanceUrl, instanceToken, repoOwner, repoName).observe(this, new Observer<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserInfo> stargazersListMain) {
|
||||
adapter = new RepoStargazersAdapter(getApplicationContext(), stargazersListMain);
|
||||
|
@ -64,7 +64,7 @@ public class RepoWatchersActivity extends AppCompatActivity {
|
||||
|
||||
RepoWatchersViewModel repoWatchersModel = new ViewModelProvider(this).get(RepoWatchersViewModel.class);
|
||||
|
||||
repoWatchersModel.getRepoWatchers(instanceUrl, instanceToken, repoOwner, repoName, getApplicationContext()).observe(this, new Observer<List<UserInfo>>() {
|
||||
repoWatchersModel.getRepoWatchers(instanceUrl, instanceToken, repoOwner, repoName).observe(this, new Observer<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserInfo> watchersListMain) {
|
||||
adapter = new RepoWatchersAdapter(getApplicationContext(), watchersListMain);
|
||||
|
@ -1,18 +1,12 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
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.text.method.LinkMovementMethod;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
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
|
||||
@ -28,27 +22,12 @@ public class SponsorsActivity extends AppCompatActivity {
|
||||
setContentView(R.layout.activity_sponsors);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
TextView liberaPaySponsorsThomas = findViewById(R.id.liberaPaySponsorsThomas);
|
||||
|
||||
liberaPaySponsorsThomas.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
Resources res = getResources();
|
||||
CharSequence[] sponsorsInfo = res.getTextArray(R.array.sponsorsInfo);
|
||||
|
||||
List<CharSequence> sponsorsList = new ArrayList<>(Arrays.asList(sponsorsInfo));
|
||||
|
||||
RecyclerView mRecyclerView = findViewById(R.id.recyclerView);
|
||||
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
SponsorsAdapter adapter = new SponsorsAdapter(sponsorsList);
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
@ -11,7 +11,6 @@ import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import org.mian.gitnex.R;
|
||||
@ -110,7 +109,7 @@ public class ClosedIssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
private TextView issueTitle;
|
||||
private TextView issueCreatedTime;
|
||||
private TextView issueCommentsCount;
|
||||
private RelativeLayout relativeLayoutFrame;
|
||||
private ImageView issueType;
|
||||
|
||||
IssuesHolder(View itemView) {
|
||||
|
||||
@ -122,7 +121,7 @@ public class ClosedIssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount);
|
||||
LinearLayout frameCommentsCount = itemView.findViewById(R.id.frameCommentsCount);
|
||||
issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime);
|
||||
relativeLayoutFrame = itemView.findViewById(R.id.relativeLayoutFrame);
|
||||
issueType = itemView.findViewById(R.id.issueType);
|
||||
|
||||
issueTitle.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -136,7 +135,6 @@ public class ClosedIssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||
tinyDb.putString("issueType", "issue");
|
||||
context.startActivity(intent);
|
||||
|
||||
}
|
||||
@ -153,7 +151,6 @@ public class ClosedIssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||
tinyDb.putString("issueType", "issue");
|
||||
context.startActivity(intent);
|
||||
|
||||
}
|
||||
@ -168,13 +165,6 @@ public class ClosedIssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
final String locale = tinyDb.getString("locale");
|
||||
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("")) {
|
||||
issueAssigneeAvatar.setOnClickListener(new ClickListener(context.getResources().getString(R.string.issueCreator) + issuesModel.getUser().getFull_name(), context));
|
||||
} else {
|
||||
@ -187,6 +177,14 @@ 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);
|
||||
}
|
||||
|
||||
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>";
|
||||
issueTitle.setText(Html.fromHtml(issueNumber_ + " " + issuesModel.getTitle()));
|
||||
|
||||
|
@ -1,59 +0,0 @@
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
@ -1,138 +0,0 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.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,7 +11,6 @@ import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import org.mian.gitnex.R;
|
||||
@ -110,7 +109,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
private TextView issueTitle;
|
||||
private TextView issueCreatedTime;
|
||||
private TextView issueCommentsCount;
|
||||
private RelativeLayout relativeLayoutFrame;
|
||||
private ImageView issueType;
|
||||
|
||||
IssuesHolder(View itemView) {
|
||||
|
||||
@ -122,7 +121,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount);
|
||||
LinearLayout frameCommentsCount = itemView.findViewById(R.id.frameCommentsCount);
|
||||
issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime);
|
||||
relativeLayoutFrame = itemView.findViewById(R.id.relativeLayoutFrame);
|
||||
issueType = itemView.findViewById(R.id.issueType);
|
||||
|
||||
issueTitle.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -136,7 +135,6 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||
tinyDb.putString("issueType", "issue");
|
||||
context.startActivity(intent);
|
||||
|
||||
}
|
||||
@ -153,7 +151,6 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||
tinyDb.putString("issueType", "issue");
|
||||
context.startActivity(intent);
|
||||
|
||||
}
|
||||
@ -168,13 +165,6 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
final String locale = tinyDb.getString("locale");
|
||||
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("")) {
|
||||
issueAssigneeAvatar.setOnClickListener(new ClickListener(context.getResources().getString(R.string.issueCreator) + issuesModel.getUser().getFull_name(), context));
|
||||
} else {
|
||||
@ -187,6 +177,14 @@ 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);
|
||||
}
|
||||
|
||||
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>";
|
||||
issueTitle.setText(Html.fromHtml(issueNumber_ + " " + issuesModel.getTitle()));
|
||||
|
||||
|
@ -50,7 +50,6 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
private TextView repoStarsMy;
|
||||
private TextView repoForksMy;
|
||||
private TextView repoOpenIssuesCountMy;
|
||||
private TextView repoType;
|
||||
|
||||
private MyReposViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@ -63,7 +62,6 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
repoForksMy = itemView.findViewById(R.id.repoForksMy);
|
||||
repoOpenIssuesCountMy = itemView.findViewById(R.id.repoOpenIssuesCountMy);
|
||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -76,7 +74,6 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putString("repoFullName", fullNameMy.getText().toString());
|
||||
tinyDb.putString("repoType", repoType.getText().toString());
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
context.startActivity(intent);
|
||||
|
||||
@ -201,11 +198,9 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
holder.fullNameMy.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
holder.repoPrivatePublicMy.setImageResource(R.drawable.ic_lock_bold);
|
||||
holder.repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
holder.repoPrivatePublicMy.setImageResource(R.drawable.ic_public);
|
||||
holder.repoType.setText(R.string.strPublic);
|
||||
}
|
||||
holder.repoStarsMy.setText(currentItem.getStars_count());
|
||||
holder.repoForksMy.setText(currentItem.getForks_count());
|
||||
|
@ -1,279 +0,0 @@
|
||||
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,7 +50,6 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
private TextView repoStars;
|
||||
private TextView repoForks;
|
||||
private TextView repoOpenIssuesCount;
|
||||
private TextView repoType;
|
||||
|
||||
private ReposViewHolder(View itemView) {
|
||||
|
||||
@ -64,7 +63,6 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
repoForks = itemView.findViewById(R.id.repoForks);
|
||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -72,14 +70,12 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
|
||||
Context context = v.getContext();
|
||||
TextView repoFullName = v.findViewById(R.id.repoFullName);
|
||||
TextView repoType_ = v.findViewById(R.id.repoType);
|
||||
|
||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||
tinyDb.putString("repoType", repoType_.getText().toString());
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
context.startActivity(intent);
|
||||
|
||||
@ -204,11 +200,9 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
holder.fullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
||||
holder.repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
||||
holder.repoType.setText(R.string.strPublic);
|
||||
}
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
holder.repoForks.setText(currentItem.getForks_count());
|
||||
|
@ -50,7 +50,6 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
private TextView repoStars;
|
||||
private TextView repoForks;
|
||||
private TextView repoOpenIssuesCount;
|
||||
private TextView repoType;
|
||||
|
||||
private OrgReposViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@ -63,7 +62,6 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
repoForks = itemView.findViewById(R.id.repoForks);
|
||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -76,7 +74,6 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putString("repoFullName", fullName.getText().toString());
|
||||
tinyDb.putString("repoType", repoType.getText().toString());
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
context.startActivity(intent);
|
||||
|
||||
@ -202,11 +199,9 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
holder.fullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
||||
holder.repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
||||
holder.repoType.setText(R.string.strPublic);
|
||||
}
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
holder.repoForks.setText(currentItem.getForks_count());
|
||||
|
@ -1,59 +0,0 @@
|
||||
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,7 +50,6 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
private TextView repoStars;
|
||||
private TextView repoForks;
|
||||
private TextView repoOpenIssuesCount;
|
||||
private TextView repoType;
|
||||
|
||||
private StarredReposViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@ -63,7 +62,6 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
repoForks = itemView.findViewById(R.id.repoForks);
|
||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -76,7 +74,6 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putString("repoFullName", fullName.getText().toString());
|
||||
tinyDb.putString("repoType", repoType.getText().toString());
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
context.startActivity(intent);
|
||||
|
||||
@ -202,11 +199,9 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
holder.fullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
||||
holder.repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
||||
holder.repoType.setText(R.string.strPublic);
|
||||
}
|
||||
holder.repoStars.setText(currentItem.getStars_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");
|
||||
|
||||
Call<Collaborators> call = RetrofitClient
|
||||
.getInstance(instanceUrl, mCtx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.checkRepoCollaborator(Authorization.returnAuthentication(mCtx, loginUid, instanceToken), repoOwner, repoName, currentItem.getUsername());
|
||||
|
||||
@ -191,7 +191,7 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Collaborators> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
Log.i("onFailure", t.getMessage());
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -1,15 +1,6 @@
|
||||
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;
|
||||
@ -20,39 +11,20 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class IssuesService {
|
||||
|
||||
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);
|
||||
public static <S> S createService(Class<S> serviceClass, String instanceURL) {
|
||||
|
||||
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();
|
||||
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
|
||||
|
||||
Retrofit.Builder builder = new Retrofit.Builder()
|
||||
httpClient.addInterceptor(logging);
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(instanceURL)
|
||||
.client(okHttpClient)
|
||||
.addConverterFactory(GsonConverterFactory.create());
|
||||
|
||||
Retrofit retrofit = builder.build();
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
//.client(httpClient.build())
|
||||
.build();
|
||||
|
||||
return retrofit.create(serviceClass);
|
||||
|
||||
|
@ -1,61 +0,0 @@
|
||||
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,16 +1,7 @@
|
||||
package org.mian.gitnex.clients;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
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.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
@ -24,45 +15,26 @@ public class RetrofitClient {
|
||||
|
||||
private Retrofit retrofit;
|
||||
|
||||
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);
|
||||
private RetrofitClient(String instanceUrl) {
|
||||
|
||||
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();
|
||||
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
|
||||
|
||||
Retrofit.Builder builder = new Retrofit.Builder()
|
||||
httpClient.addInterceptor(logging);
|
||||
|
||||
retrofit = new Retrofit.Builder()
|
||||
.baseUrl(instanceUrl)
|
||||
.client(okHttpClient)
|
||||
.addConverterFactory(ScalarsConverterFactory.create())
|
||||
.addConverterFactory(GsonConverterFactory.create());
|
||||
|
||||
retrofit = builder.build();
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
//.client(httpClient.build())
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
public static synchronized RetrofitClient getInstance(String instanceUrl, Context ctx) {
|
||||
return new RetrofitClient(instanceUrl, ctx);
|
||||
public static synchronized RetrofitClient getInstance(String instanceUrl) {
|
||||
return new RetrofitClient(instanceUrl);
|
||||
}
|
||||
|
||||
public ApiInterface getApiInterface() {
|
||||
|
@ -6,17 +6,27 @@ import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CreditsActivity;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
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.TinyDB;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -24,12 +34,17 @@ import java.util.Objects;
|
||||
|
||||
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) {
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_about, container, false);
|
||||
((MainActivity) Objects.requireNonNull(getActivity())).setActionBarTitle(getResources().getString(R.string.pageTitleAbout));
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
|
||||
final TextView appVerBuild;
|
||||
final TextView donationLink;
|
||||
@ -40,8 +55,13 @@ public class AboutFragment extends Fragment {
|
||||
final TextView appWebsite;
|
||||
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);
|
||||
TextView viewTextGiteaVersion = v.findViewById(R.id.giteaVersion);
|
||||
viewTextGiteaVersion = v.findViewById(R.id.giteaVersion);
|
||||
creditsButton = v.findViewById(R.id.creditsButton);
|
||||
donationLink = v.findViewById(R.id.donationLink);
|
||||
donationLinkPatreon = v.findViewById(R.id.donationLinkPatreon);
|
||||
@ -114,10 +134,67 @@ public class AboutFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
String commit = getResources().getString(R.string.commitPage) + tinyDb.getString("giteaVersion");
|
||||
viewTextGiteaVersion.setText(commit);
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(getContext());
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
pageContent.setVisibility(View.VISIBLE);
|
||||
|
||||
} else {
|
||||
|
||||
giteaVer(instanceUrl);
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
BranchesViewModel.loadBranchesList(instanceUrl, instanceToken, repoOwner, repoName, getContext());
|
||||
BranchesViewModel.loadBranchesList(instanceUrl, instanceToken, repoOwner, repoName);
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
@ -127,7 +127,7 @@ public class BranchesFragment extends Fragment {
|
||||
|
||||
BranchesViewModel branchesModel = new ViewModelProvider(this).get(BranchesViewModel.class);
|
||||
|
||||
branchesModel.getBranchesList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Branches>>() {
|
||||
branchesModel.getBranchesList(instanceUrl, instanceToken, owner, repo).observe(this, new Observer<List<Branches>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Branches> branchesListMain) {
|
||||
adapter = new BranchesAdapter(getContext(), branchesListMain);
|
||||
|
@ -28,6 +28,7 @@ import java.util.Objects;
|
||||
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;
|
||||
@ -119,11 +120,14 @@ public class ClosedIssuesFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerViewClosed.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
recyclerViewClosed.setHasFixedSize(true);
|
||||
recyclerViewClosed.addItemDecoration(dividerItemDecoration);
|
||||
recyclerViewClosed.setLayoutManager(new LinearLayoutManager(context));
|
||||
recyclerViewClosed.setAdapter(adapterClosed);
|
||||
|
||||
apiClosed = IssuesService.createService(ApiInterface.class, instanceUrl, getContext());
|
||||
apiClosed = IssuesService.createService(ApiInterface.class, instanceUrl);
|
||||
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, issueState);
|
||||
|
||||
return v;
|
||||
@ -186,7 +190,7 @@ public class ClosedIssuesFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.toString());
|
||||
Log.e(TAG, t.getMessage());
|
||||
}
|
||||
|
||||
});
|
||||
@ -241,7 +245,7 @@ public class ClosedIssuesFragment extends Fragment {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e(TAG, t.toString());
|
||||
Log.e(TAG, t.getMessage());
|
||||
|
||||
}
|
||||
|
||||
@ -259,11 +263,11 @@ public class ClosedIssuesFragment extends Fragment {
|
||||
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));
|
||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
/*if(!connToInternet) {
|
||||
if(!connToInternet) {
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
collaboratorsModel.getCollaboratorsList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Collaborators>>() {
|
||||
collaboratorsModel.getCollaboratorsList(instanceUrl, instanceToken, owner, repo).observe(this, new Observer<List<Collaborators>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Collaborators> collaboratorsListMain) {
|
||||
adapter = new CollaboratorsAdapter(getContext(), collaboratorsListMain);
|
||||
|
@ -46,8 +46,9 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
private TextView searchKeyword;
|
||||
private Boolean repoTypeInclude = true;
|
||||
private String sort = "updated";
|
||||
private String order = "desc";
|
||||
private int limit = 50;
|
||||
private String order = "asc";
|
||||
|
||||
private ExploreRepositoriesAdapter adapter;
|
||||
|
||||
private OnFragmentInteractionListener mListener;
|
||||
|
||||
@ -92,30 +93,37 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
mProgressBar = v.findViewById(R.id.progress_bar);
|
||||
mRecyclerView = v.findViewById(R.id.recyclerViewReposSearch);
|
||||
|
||||
searchKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
if(!searchKeyword.getText().toString().equals("")) {
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
mRecyclerView.setVisibility(View.GONE);
|
||||
loadSearchReposList(instanceUrl, instanceToken, loginUid, searchKeyword.getText().toString(), repoTypeInclude, sort, order, getContext(), limit);
|
||||
if(connToInternet) {
|
||||
|
||||
searchKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
if(!searchKeyword.getText().toString().equals("")) {
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
private void loadSearchReposList(String instanceUrl, String instanceToken, String loginUid, String searchKeyword, Boolean repoTypeInclude, String sort, String order, final Context context, int limit) {
|
||||
private void loadSearchReposList(String instanceUrl, String instanceToken, String loginUid, String searchKeyword, Boolean repoTypeInclude, String sort, String order, final Context context) {
|
||||
|
||||
Call<ExploreRepositories> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), searchKeyword, repoTypeInclude, sort, order, limit);
|
||||
.queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), searchKeyword, repoTypeInclude, sort, order);
|
||||
|
||||
call.enqueue(new Callback<ExploreRepositories>() {
|
||||
|
||||
@ -133,7 +141,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", Objects.requireNonNull(t.getMessage()));
|
||||
Log.i("onFailure", t.getMessage());
|
||||
}
|
||||
|
||||
});
|
||||
@ -142,7 +150,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
private void getReposList(List<UserRepositories> dataList, Context context) {
|
||||
|
||||
ExploreRepositoriesAdapter adapter = new ExploreRepositoriesAdapter(dataList, context);
|
||||
adapter = new ExploreRepositoriesAdapter(dataList, context);
|
||||
|
||||
mRecyclerView.setVisibility(View.VISIBLE);
|
||||
|
||||
|
@ -140,10 +140,6 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
|
||||
fileStructure.setText(breadcrumbBuilder);
|
||||
|
||||
String dirName_ = fileStructure.getText().toString();
|
||||
dirName_ = dirName_.startsWith("/") ? dirName_.substring(1) : dirName_;
|
||||
final String finalDirName_ = dirName_;
|
||||
|
||||
mBreadcrumbsView.addItem(createItem(dirName));
|
||||
mBreadcrumbsView.setCallback(new DefaultBreadcrumbsCallback<BreadcrumbItem>() {
|
||||
@Override
|
||||
@ -158,7 +154,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
String filterDir = fileStructure.getText().toString();
|
||||
String result = filterDir.substring(0, filterDir.indexOf(item.getSelectedItem()));
|
||||
fileStructure.setText(result + item.getSelectedItem());
|
||||
fetchDataAsyncSub(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, finalDirName_);
|
||||
fetchDataAsyncSub(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, fileStructure.getText().toString());
|
||||
|
||||
}
|
||||
|
||||
@ -168,7 +164,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
}
|
||||
});
|
||||
|
||||
fetchDataAsyncSub(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, finalDirName_);
|
||||
fetchDataAsyncSub(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, fileStructure.getText().toString());
|
||||
|
||||
}
|
||||
|
||||
@ -196,7 +192,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
|
||||
FilesViewModel filesModel = new ViewModelProvider(this).get(FilesViewModel.class);
|
||||
|
||||
filesModel.getFilesList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Files>>() {
|
||||
filesModel.getFilesList(instanceUrl, instanceToken, owner, repo, getContext()).observe(this, new Observer<List<Files>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Files> filesListMain) {
|
||||
adapter = new FilesAdapter(getContext(), filesListMain, FilesFragment.this);
|
||||
@ -264,11 +260,11 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
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.search));
|
||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
/*if(!connToInternet) {
|
||||
if(!connToInternet) {
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -5,6 +5,7 @@ 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;
|
||||
@ -118,11 +119,14 @@ public class IssuesFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
recyclerView.addItemDecoration(dividerItemDecoration);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
api = IssuesService.createService(ApiInterface.class, instanceUrl, getContext());
|
||||
api = IssuesService.createService(ApiInterface.class, instanceUrl);
|
||||
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
return v;
|
||||
@ -185,7 +189,7 @@ public class IssuesFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.toString());
|
||||
Log.e(TAG, t.getMessage());
|
||||
}
|
||||
|
||||
});
|
||||
@ -240,7 +244,7 @@ public class IssuesFragment extends Fragment {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e(TAG, t.toString());
|
||||
Log.e(TAG, t.getMessage());
|
||||
|
||||
}
|
||||
|
||||
@ -258,11 +262,11 @@ public class IssuesFragment extends Fragment {
|
||||
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));
|
||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
/*if(!connToInternet) {
|
||||
if(!connToInternet) {
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class LabelsFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getContext());
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
@ -119,7 +119,7 @@ public class LabelsFragment extends Fragment {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("labelsRefresh")) {
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getContext());
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
tinyDb.putBoolean("labelsRefresh", false);
|
||||
}
|
||||
}
|
||||
@ -144,7 +144,7 @@ public class LabelsFragment extends Fragment {
|
||||
|
||||
LabelsViewModel labelsModel = new ViewModelProvider(this).get(LabelsViewModel.class);
|
||||
|
||||
labelsModel.getLabelsList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Labels>>() {
|
||||
labelsModel.getLabelsList(instanceUrl, instanceToken, owner, repo).observe(this, new Observer<List<Labels>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Labels> labelsListMain) {
|
||||
adapter = new LabelsAdapter(getContext(), labelsListMain);
|
||||
|
@ -83,7 +83,7 @@ public class MembersByOrgFragment extends Fragment {
|
||||
|
||||
MembersByOrgViewModel membersModel= new ViewModelProvider(this).get(MembersByOrgViewModel.class);
|
||||
|
||||
membersModel.getMembersList(instanceUrl, instanceToken, owner, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserInfo>>() {
|
||||
membersModel.getMembersList(instanceUrl, instanceToken, owner).observe(this, new Observer<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserInfo> membersListMain) {
|
||||
adapter = new MembersByOrgAdapter(getContext(), membersListMain);
|
||||
@ -112,7 +112,7 @@ public class MembersByOrgFragment extends Fragment {
|
||||
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));
|
||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
if(!connToInternet) {
|
||||
return;
|
||||
|
@ -104,7 +104,7 @@ public class MilestonesFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
MilestonesViewModel.loadMilestonesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, msState, getContext());
|
||||
MilestonesViewModel.loadMilestonesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, msState);
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
@ -128,7 +128,7 @@ public class MilestonesFragment extends Fragment {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("milestoneCreated")) {
|
||||
MilestonesViewModel.loadMilestonesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, msState, getContext());
|
||||
MilestonesViewModel.loadMilestonesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, msState);
|
||||
tinyDb.putBoolean("milestoneCreated", false);
|
||||
}
|
||||
}
|
||||
@ -153,7 +153,7 @@ public class MilestonesFragment extends Fragment {
|
||||
|
||||
MilestonesViewModel msModel = new ViewModelProvider(this).get(MilestonesViewModel.class);
|
||||
|
||||
msModel.getMilestonesList(instanceUrl, instanceToken, owner, repo, msState, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Milestones>>() {
|
||||
msModel.getMilestonesList(instanceUrl, instanceToken, owner, repo, msState).observe(this, new Observer<List<Milestones>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Milestones> msListMain) {
|
||||
adapter = new MilestonesAdapter(getContext(), msListMain);
|
||||
@ -183,11 +183,11 @@ public class MilestonesFragment extends Fragment {
|
||||
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));
|
||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
/*if(!connToInternet) {
|
||||
if(!connToInternet) {
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -132,20 +132,27 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
if(connToInternet) {
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin);
|
||||
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);
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin);
|
||||
|
||||
}
|
||||
else {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
return v;
|
||||
|
||||
@ -160,7 +167,7 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final String userLogin = tinyDb.getString("userLogin");
|
||||
|
||||
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, getContext());
|
||||
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin);
|
||||
|
||||
}
|
||||
|
||||
@ -168,7 +175,7 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
|
||||
MyRepositoriesViewModel myRepoModel = new ViewModelProvider(this).get(MyRepositoriesViewModel.class);
|
||||
|
||||
myRepoModel.getCurrentUserRepositories(instanceUrl, instanceToken, userLogin, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
|
||||
myRepoModel.getCurrentUserRepositories(instanceUrl, instanceToken, userLogin).observe(this, new Observer<List<UserRepositories>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserRepositories> myReposListMain) {
|
||||
adapter = new MyReposListAdapter(getContext(), myReposListMain);
|
||||
@ -198,11 +205,11 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
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));
|
||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
/*if(!connToInternet) {
|
||||
if(!connToInternet) {
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -88,7 +88,7 @@ public class OrganizationInfoFragment extends Fragment {
|
||||
private void getOrgInfo(String instanceUrl, String token, final String owner) {
|
||||
|
||||
Call<Organization> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getOrganization(token, owner);
|
||||
|
||||
|
@ -101,20 +101,25 @@ public class OrganizationsFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
OrganizationListViewModel.loadOrgsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
if(connToInternet) {
|
||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
OrganizationListViewModel.loadOrgsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
}
|
||||
else {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
return v;
|
||||
|
||||
@ -129,7 +134,7 @@ public class OrganizationsFragment extends Fragment {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("orgCreated")) {
|
||||
OrganizationListViewModel.loadOrgsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
OrganizationListViewModel.loadOrgsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
tinyDb.putBoolean("orgCreated", false);
|
||||
}
|
||||
}
|
||||
@ -138,7 +143,7 @@ public class OrganizationsFragment extends Fragment {
|
||||
|
||||
OrganizationListViewModel orgModel = new ViewModelProvider(this).get(OrganizationListViewModel.class);
|
||||
|
||||
orgModel.getUserOrgs(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserOrganizations>>() {
|
||||
orgModel.getUserOrgs(instanceUrl, instanceToken).observe(this, new Observer<List<UserOrganizations>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserOrganizations> orgsListMain) {
|
||||
adapter = new OrganizationsListAdapter(getContext(), orgsListMain);
|
||||
@ -168,11 +173,11 @@ public class OrganizationsFragment extends Fragment {
|
||||
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));
|
||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
/*if(!connToInternet) {
|
||||
if(!connToInternet) {
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -95,7 +95,7 @@ public class ProfileEmailsFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
ProfileEmailsViewModel.loadEmailsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
ProfileEmailsViewModel.loadEmailsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
@ -111,7 +111,7 @@ public class ProfileEmailsFragment extends Fragment {
|
||||
|
||||
ProfileEmailsViewModel profileEmailModel = new ViewModelProvider(this).get(ProfileEmailsViewModel.class);
|
||||
|
||||
profileEmailModel.getEmailsList(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Emails>>() {
|
||||
profileEmailModel.getEmailsList(instanceUrl, instanceToken).observe(this, new Observer<List<Emails>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Emails> emailsListMain) {
|
||||
adapter = new ProfileEmailsAdapter(getContext(), emailsListMain);
|
||||
|
@ -95,7 +95,7 @@ public class ProfileFollowersFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
ProfileFollowersViewModel.loadFollowersList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
ProfileFollowersViewModel.loadFollowersList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
@ -110,7 +110,7 @@ public class ProfileFollowersFragment extends Fragment {
|
||||
|
||||
ProfileFollowersViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowersViewModel.class);
|
||||
|
||||
pfModel.getFollowersList(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserInfo>>() {
|
||||
pfModel.getFollowersList(instanceUrl, instanceToken).observe(this, new Observer<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserInfo> pfListMain) {
|
||||
adapter = new ProfileFollowersAdapter(getContext(), pfListMain);
|
||||
|
@ -95,7 +95,7 @@ public class ProfileFollowingFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
ProfileFollowingViewModel.loadFollowingList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
ProfileFollowingViewModel.loadFollowingList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
@ -110,7 +110,7 @@ public class ProfileFollowingFragment extends Fragment {
|
||||
|
||||
ProfileFollowingViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowingViewModel.class);
|
||||
|
||||
pfModel.getFollowingList(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserInfo>>() {
|
||||
pfModel.getFollowingList(instanceUrl, instanceToken).observe(this, new Observer<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserInfo> pfListMain) {
|
||||
adapter = new ProfileFollowingAdapter(getContext(), pfListMain);
|
||||
|
@ -1,293 +0,0 @@
|
||||
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
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
ReleasesViewModel.loadReleasesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getContext());
|
||||
ReleasesViewModel.loadReleasesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
@ -117,7 +117,7 @@ public class ReleasesFragment extends Fragment {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("updateReleases")) {
|
||||
ReleasesViewModel.loadReleasesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getContext());
|
||||
ReleasesViewModel.loadReleasesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
tinyDb.putBoolean("updateReleases", false);
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ public class ReleasesFragment extends Fragment {
|
||||
|
||||
ReleasesViewModel releasesModel = new ViewModelProvider(this).get(ReleasesViewModel.class);
|
||||
|
||||
releasesModel.getReleasesList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Releases>>() {
|
||||
releasesModel.getReleasesList(instanceUrl, instanceToken, owner, repo).observe(this, new Observer<List<Releases>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Releases> releasesListMain) {
|
||||
adapter = new ReleasesAdapter(getContext(), releasesListMain);
|
||||
|
@ -218,7 +218,7 @@ public class RepoInfoFragment extends Fragment {
|
||||
final TinyDB tinyDb = new TinyDB(getContext());
|
||||
|
||||
Call<UserRepositories> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getUserRepository(token, owner, repo);
|
||||
|
||||
@ -303,7 +303,7 @@ public class RepoInfoFragment extends Fragment {
|
||||
final TinyDB tinyDb = new TinyDB(getContext());
|
||||
|
||||
Call<String> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getContext())
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getFileContents(token, owner, repo, filename);
|
||||
|
||||
|
@ -97,7 +97,7 @@ public class RepositoriesByOrgFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext());
|
||||
RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
@ -117,7 +117,7 @@ public class RepositoriesByOrgFragment extends Fragment {
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext());
|
||||
RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
||||
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ public class RepositoriesByOrgFragment extends Fragment {
|
||||
|
||||
RepositoriesByOrgViewModel orgRepoModel = new ViewModelProvider(this).get(RepositoriesByOrgViewModel.class);
|
||||
|
||||
orgRepoModel.getRepositoriesByOrg(instanceUrl, instanceToken, owner, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
|
||||
orgRepoModel.getRepositoriesByOrg(instanceUrl, instanceToken, owner).observe(this, new Observer<List<UserRepositories>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserRepositories> orgReposListMain) {
|
||||
adapter = new RepositoriesByOrgAdapter(getContext(), orgReposListMain);
|
||||
@ -155,7 +155,7 @@ public class RepositoriesByOrgFragment extends Fragment {
|
||||
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));
|
||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
if(!connToInternet) {
|
||||
return;
|
||||
|
@ -102,20 +102,27 @@ public class RepositoriesFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
if(connToInternet) {
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
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));
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
|
||||
}
|
||||
else {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
return v;
|
||||
|
||||
@ -130,7 +137,7 @@ public class RepositoriesFragment extends Fragment {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("repoCreated")) {
|
||||
RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
tinyDb.putBoolean("repoCreated", false);
|
||||
}
|
||||
}
|
||||
@ -139,7 +146,7 @@ public class RepositoriesFragment extends Fragment {
|
||||
|
||||
RepositoriesListViewModel repoModel = new ViewModelProvider(this).get(RepositoriesListViewModel.class);
|
||||
|
||||
repoModel.getUserRepositories(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
|
||||
repoModel.getUserRepositories(instanceUrl, instanceToken).observe(this, new Observer<List<UserRepositories>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserRepositories> reposListMain) {
|
||||
adapter = new ReposListAdapter(getContext(), reposListMain);
|
||||
@ -169,11 +176,11 @@ public class RepositoriesFragment extends Fragment {
|
||||
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));
|
||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
/*if(!connToInternet) {
|
||||
if(!connToInternet) {
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -30,7 +30,7 @@ public class SettingsFragment extends Fragment {
|
||||
|
||||
private Context ctx = null;
|
||||
|
||||
private static String[] langList = {"Arabic", "Chinese", "English", "Finnish", "French", "German", "Italian", "Persian", "Portuguese/Brazilian", "Russian", "Serbian", "Turkish", "Ukrainian"};
|
||||
private static String[] langList = {"Arabic", "Chinese", "English", "Finnish", "French", "German", "Italian", "Persian", "Russian", "Serbian"};
|
||||
private static int langSelectedChoice = 0;
|
||||
|
||||
private static String[] timeList = {"Pretty", "Normal"};
|
||||
@ -265,21 +265,12 @@ public class SettingsFragment extends Fragment {
|
||||
case "Persian":
|
||||
tinyDb.putString("locale", "fa");
|
||||
break;
|
||||
case "Portuguese/Brazilian":
|
||||
tinyDb.putString("locale", "pt");
|
||||
break;
|
||||
case "Russian":
|
||||
tinyDb.putString("locale", "ru");
|
||||
break;
|
||||
case "Serbian":
|
||||
tinyDb.putString("locale", "sr");
|
||||
break;
|
||||
case "Turkish":
|
||||
tinyDb.putString("locale", "tr");
|
||||
break;
|
||||
case "Ukrainian":
|
||||
tinyDb.putString("locale", "uk");
|
||||
break;
|
||||
default:
|
||||
tinyDb.putString("locale", "en");
|
||||
break;
|
||||
|
@ -12,8 +12,6 @@ import org.mian.gitnex.actions.IssueActions;
|
||||
import org.mian.gitnex.activities.AddRemoveAssigneesActivity;
|
||||
import org.mian.gitnex.activities.AddRemoveLabelsActivity;
|
||||
import org.mian.gitnex.activities.EditIssueActivity;
|
||||
import org.mian.gitnex.activities.FileDiffActivity;
|
||||
import org.mian.gitnex.activities.MergePullRequestActivity;
|
||||
import org.mian.gitnex.activities.ReplyToIssueActivity;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
@ -44,8 +42,6 @@ public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
|
||||
TextView reOpenIssue = v.findViewById(R.id.reOpenIssue);
|
||||
TextView addRemoveAssignees = v.findViewById(R.id.addRemoveAssignees);
|
||||
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() {
|
||||
@Override
|
||||
@ -57,52 +53,6 @@ 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() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -140,7 +90,7 @@ public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
|
||||
// get url of repo
|
||||
String repoFullName = tinyDB.getString("repoFullName");
|
||||
String instanceUrlWithProtocol = "https://" + tinyDB.getString("instanceUrlRaw");
|
||||
if (!tinyDB.getString("instanceUrlWithProtocol").isEmpty()) {
|
||||
if(!tinyDB.getString("instanceUrlWithProtocol").isEmpty()) {
|
||||
instanceUrlWithProtocol = tinyDB.getString("instanceUrlWithProtocol");
|
||||
}
|
||||
|
||||
@ -150,7 +100,6 @@ public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
|
||||
// copy to clipboard
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(getContext()).getSystemService(android.content.Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("issueUrl", issueUrl);
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
dismiss();
|
||||
@ -160,44 +109,35 @@ public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
|
||||
}
|
||||
});
|
||||
|
||||
if(tinyDB.getString("issueType").equals("issue")) {
|
||||
|
||||
if (tinyDB.getString("issueState").equals("open")) { // close issue
|
||||
|
||||
reOpenIssue.setVisibility(View.GONE);
|
||||
|
||||
closeIssue.setOnClickListener(new View.OnClickListener() {
|
||||
@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("open")) { // close issue
|
||||
|
||||
reOpenIssue.setVisibility(View.GONE);
|
||||
|
||||
closeIssue.setOnClickListener(new View.OnClickListener() {
|
||||
@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();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return v;
|
||||
|
@ -127,20 +127,27 @@ public class StarredRepositoriesFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
if(connToInternet) {
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
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));
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
|
||||
}
|
||||
else {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
@ -153,7 +160,7 @@ public class StarredRepositoriesFragment extends Fragment {
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
StarredRepositoriesViewModel.loadStarredReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
StarredRepositoriesViewModel.loadStarredReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
|
||||
}
|
||||
|
||||
@ -161,7 +168,7 @@ public class StarredRepositoriesFragment extends Fragment {
|
||||
|
||||
StarredRepositoriesViewModel starredRepoModel = new ViewModelProvider(this).get(StarredRepositoriesViewModel.class);
|
||||
|
||||
starredRepoModel.getUserStarredRepositories(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
|
||||
starredRepoModel.getUserStarredRepositories(instanceUrl, instanceToken).observe(this, new Observer<List<UserRepositories>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserRepositories> starredReposListMain) {
|
||||
adapter = new StarredReposListAdapter(getContext(), starredReposListMain);
|
||||
@ -191,11 +198,11 @@ public class StarredRepositoriesFragment extends Fragment {
|
||||
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));
|
||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
/*if(!connToInternet) {
|
||||
if(!connToInternet) {
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -97,7 +97,7 @@ public class TeamsByOrgFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
TeamsByOrgViewModel.loadTeamsByOrgList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext());
|
||||
TeamsByOrgViewModel.loadTeamsByOrgList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
@ -117,7 +117,7 @@ public class TeamsByOrgFragment extends Fragment {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("resumeTeams")) {
|
||||
TeamsByOrgViewModel.loadTeamsByOrgList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext());
|
||||
TeamsByOrgViewModel.loadTeamsByOrgList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
||||
tinyDb.putBoolean("resumeTeams", false);
|
||||
}
|
||||
}
|
||||
@ -126,7 +126,7 @@ public class TeamsByOrgFragment extends Fragment {
|
||||
|
||||
TeamsByOrgViewModel teamModel = new ViewModelProvider(this).get(TeamsByOrgViewModel.class);
|
||||
|
||||
teamModel.getTeamsByOrg(instanceUrl, instanceToken, owner, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Teams>>() {
|
||||
teamModel.getTeamsByOrg(instanceUrl, instanceToken, owner).observe(this, new Observer<List<Teams>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Teams> orgTeamsListMain) {
|
||||
adapter = new TeamsByOrgAdapter(getContext(), orgTeamsListMain);
|
||||
@ -156,11 +156,11 @@ public class TeamsByOrgFragment extends Fragment {
|
||||
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));
|
||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
/*if(!connToInternet) {
|
||||
if(!connToInternet) {
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -1,135 +0,0 @@
|
||||
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,9 +5,7 @@ import org.mian.gitnex.models.AddEmail;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
import org.mian.gitnex.models.ExploreRepositories;
|
||||
import org.mian.gitnex.models.Files;
|
||||
import org.mian.gitnex.models.MergePullRequest;
|
||||
import org.mian.gitnex.models.NewFile;
|
||||
import org.mian.gitnex.models.PullRequests;
|
||||
import org.mian.gitnex.models.UpdateIssueAssignee;
|
||||
import org.mian.gitnex.models.UpdateIssueState;
|
||||
import org.mian.gitnex.models.Collaborators;
|
||||
@ -32,7 +30,6 @@ import org.mian.gitnex.models.UserSearch;
|
||||
import org.mian.gitnex.models.UserTokens;
|
||||
import org.mian.gitnex.models.WatchRepository;
|
||||
import java.util.List;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.DELETE;
|
||||
@ -51,7 +48,7 @@ import retrofit2.http.Query;
|
||||
public interface ApiInterface {
|
||||
|
||||
@GET("version") // gitea version API
|
||||
Call<GiteaVersion> getGiteaVersion();
|
||||
Call<GiteaVersion> getGiteaVersion(@Header("Authorization") String token);
|
||||
|
||||
@GET("user") // username, full name, email
|
||||
Call<UserInfo> getUserInfo(@Header("Authorization") String token);
|
||||
@ -219,7 +216,7 @@ public interface ApiInterface {
|
||||
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
|
||||
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);
|
||||
Call<ExploreRepositories> queryRepos(@Header("Authorization") String token, @Query("q") String searchKeyword, @Query("private") Boolean repoTypeInclude, @Query("sort") String sort, @Query("order") String order);
|
||||
|
||||
@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);
|
||||
@ -250,13 +247,4 @@ public interface ApiInterface {
|
||||
|
||||
@DELETE("repos/{owner}/{repo}/subscription") // un watch a repository
|
||||
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);
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
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 {
|
||||
|
||||
private boolean merged;
|
||||
private String merged;
|
||||
private String merged_at;
|
||||
|
||||
public boolean isMerged() {
|
||||
public String getMerged() {
|
||||
return merged;
|
||||
}
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -1,823 +0,0 @@
|
||||
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,7 +9,6 @@ public class UserTokens {
|
||||
private int id;
|
||||
private String name;
|
||||
private String sha1;
|
||||
private String token_last_eight;
|
||||
|
||||
public UserTokens(String name) {
|
||||
this.name = name;
|
||||
@ -30,8 +29,4 @@ public class UserTokens {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getToken_last_eight() {
|
||||
return token_last_eight;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
@ -146,16 +145,16 @@ public class AppUtil {
|
||||
|
||||
String sMonth;
|
||||
if (Integer.parseInt(month) < 10) {
|
||||
sMonth = "0"+ month;
|
||||
sMonth = "0"+String.valueOf(month);
|
||||
} else {
|
||||
sMonth = month;
|
||||
sMonth = String.valueOf(month);
|
||||
}
|
||||
|
||||
String sDay;
|
||||
if (Integer.parseInt(day) < 10) {
|
||||
sDay = "0"+ day;
|
||||
sDay = "0"+String.valueOf(day);
|
||||
} else {
|
||||
sDay = day;
|
||||
sDay = String.valueOf(day);
|
||||
}
|
||||
|
||||
return year + "-" + sMonth + "-" + sDay;
|
||||
@ -171,14 +170,14 @@ public class AppUtil {
|
||||
|
||||
String sMin;
|
||||
if ((mMinute) < 10) {
|
||||
sMin = "0"+ mMinute;
|
||||
sMin = "0"+String.valueOf(mMinute);
|
||||
} else {
|
||||
sMin = String.valueOf(mMinute);
|
||||
}
|
||||
|
||||
String sSec;
|
||||
if ((mSeconds) < 10) {
|
||||
sSec = "0"+ mSeconds;
|
||||
sSec = "0"+String.valueOf(mSeconds);
|
||||
} else {
|
||||
sSec = String.valueOf(mSeconds);
|
||||
}
|
||||
@ -211,30 +210,4 @@ 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) {
|
||||
|
||||
Call<List<UserInfo>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.adminGetUsers(token);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
@ -21,18 +20,18 @@ public class BranchesViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<Branches>> branchesList;
|
||||
|
||||
public LiveData<List<Branches>> getBranchesList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||
public LiveData<List<Branches>> getBranchesList(String instanceUrl, String token, String owner, String repo) {
|
||||
|
||||
branchesList = new MutableLiveData<>();
|
||||
loadBranchesList(instanceUrl, token, owner, repo, ctx);
|
||||
loadBranchesList(instanceUrl, token, owner, repo);
|
||||
|
||||
return branchesList;
|
||||
}
|
||||
|
||||
public static void loadBranchesList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||
public static void loadBranchesList(String instanceUrl, String token, String owner, String repo) {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getBranches(token, owner, repo);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.Collaborators;
|
||||
@ -21,18 +20,18 @@ public class CollaboratorsViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<Collaborators>> collaboratorsList;
|
||||
|
||||
public LiveData<List<Collaborators>> getCollaboratorsList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||
public LiveData<List<Collaborators>> getCollaboratorsList(String instanceUrl, String token, String owner, String repo) {
|
||||
|
||||
collaboratorsList = new MutableLiveData<>();
|
||||
loadCollaboratorsListList(instanceUrl, token, owner, repo, ctx);
|
||||
loadCollaboratorsListList(instanceUrl, token, owner, repo);
|
||||
|
||||
return collaboratorsList;
|
||||
}
|
||||
|
||||
private static void loadCollaboratorsListList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||
private static void loadCollaboratorsListList(String instanceUrl, String token, String owner, String repo) {
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.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) {
|
||||
|
||||
Call<List<Files>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.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) {
|
||||
|
||||
Call<List<Files>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getDirFiles(token, owner, repo, filesDir);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.IssueComments;
|
||||
@ -21,18 +20,18 @@ public class IssueCommentsViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<IssueComments>> issueComments;
|
||||
|
||||
public LiveData<List<IssueComments>> getIssueCommentList(String instanceUrl, String token, String owner, String repo, int index, Context ctx) {
|
||||
public LiveData<List<IssueComments>> getIssueCommentList(String instanceUrl, String token, String owner, String repo, int index) {
|
||||
|
||||
issueComments = new MutableLiveData<>();
|
||||
loadIssueComments(instanceUrl, token, owner, repo, index, ctx);
|
||||
loadIssueComments(instanceUrl, token, owner, repo, index);
|
||||
|
||||
return issueComments;
|
||||
}
|
||||
|
||||
public static void loadIssueComments(String instanceUrl, String token, String owner, String repo, int index, Context ctx) {
|
||||
public static void loadIssueComments(String instanceUrl, String token, String owner, String repo, int index) {
|
||||
|
||||
Call<List<IssueComments>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getIssueComments(token, owner, repo, index);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.Labels;
|
||||
@ -21,18 +20,18 @@ public class LabelsViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<Labels>> labelsList;
|
||||
|
||||
public LiveData<List<Labels>> getLabelsList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||
public LiveData<List<Labels>> getLabelsList(String instanceUrl, String token, String owner, String repo) {
|
||||
|
||||
labelsList = new MutableLiveData<>();
|
||||
loadLabelsList(instanceUrl, token, owner, repo, ctx);
|
||||
loadLabelsList(instanceUrl, token, owner, repo);
|
||||
|
||||
return labelsList;
|
||||
}
|
||||
|
||||
public static void loadLabelsList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||
public static void loadLabelsList(String instanceUrl, String token, String owner, String repo) {
|
||||
|
||||
Call<List<Labels>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getlabels(token, owner, repo);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
@ -21,18 +20,18 @@ public class MembersByOrgViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<UserInfo>> membersList;
|
||||
|
||||
public LiveData<List<UserInfo>> getMembersList(String instanceUrl, String token, String owner, Context ctx) {
|
||||
public LiveData<List<UserInfo>> getMembersList(String instanceUrl, String token, String owner) {
|
||||
|
||||
membersList = new MutableLiveData<>();
|
||||
loadMembersList(instanceUrl, token, owner, ctx);
|
||||
loadMembersList(instanceUrl, token, owner);
|
||||
|
||||
return membersList;
|
||||
}
|
||||
|
||||
private static void loadMembersList(String instanceUrl, String token, String owner, Context ctx) {
|
||||
private static void loadMembersList(String instanceUrl, String token, String owner) {
|
||||
|
||||
Call<List<UserInfo>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getMembersByOrg(token, owner);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.Milestones;
|
||||
@ -21,18 +20,18 @@ public class MilestonesViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<Milestones>> milestonesList;
|
||||
|
||||
public LiveData<List<Milestones>> getMilestonesList(String instanceUrl, String token, String owner, String repo, String msState, Context ctx) {
|
||||
public LiveData<List<Milestones>> getMilestonesList(String instanceUrl, String token, String owner, String repo, String msState) {
|
||||
|
||||
milestonesList = new MutableLiveData<>();
|
||||
loadMilestonesList(instanceUrl, token, owner, repo, msState, ctx);
|
||||
loadMilestonesList(instanceUrl, token, owner, repo, msState);
|
||||
|
||||
return milestonesList;
|
||||
}
|
||||
|
||||
public static void loadMilestonesList(String instanceUrl, String token, String owner, String repo, String msState, Context ctx) {
|
||||
public static void loadMilestonesList(String instanceUrl, String token, String owner, String repo, String msState) {
|
||||
|
||||
Call<List<Milestones>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getMilestones(token, owner, repo, msState);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
@ -21,20 +20,20 @@ public class MyRepositoriesViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<UserRepositories>> myReposList;
|
||||
|
||||
public LiveData<List<UserRepositories>> getCurrentUserRepositories(String instanceUrl, String token, String username, Context ctx) {
|
||||
public LiveData<List<UserRepositories>> getCurrentUserRepositories(String instanceUrl, String token, String username) {
|
||||
|
||||
//if (myReposList == null) {
|
||||
myReposList = new MutableLiveData<>();
|
||||
loadMyReposList(instanceUrl, token, username, ctx);
|
||||
loadMyReposList(instanceUrl, token, username);
|
||||
//}
|
||||
|
||||
return myReposList;
|
||||
}
|
||||
|
||||
public static void loadMyReposList(String instanceUrl, String token, String username, Context ctx) {
|
||||
public static void loadMyReposList(String instanceUrl, String token, String username) {
|
||||
|
||||
Call<List<UserRepositories>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getCurrentUserRepositories(token, username);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.UserOrganizations;
|
||||
@ -21,20 +20,20 @@ public class OrganizationListViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<UserOrganizations>> orgsList;
|
||||
|
||||
public LiveData<List<UserOrganizations>> getUserOrgs(String instanceUrl, String token, Context ctx) {
|
||||
public LiveData<List<UserOrganizations>> getUserOrgs(String instanceUrl, String token) {
|
||||
|
||||
//if (orgsList == null) {
|
||||
orgsList = new MutableLiveData<>();
|
||||
loadOrgsList(instanceUrl, token, ctx);
|
||||
loadOrgsList(instanceUrl, token);
|
||||
//}
|
||||
|
||||
return orgsList;
|
||||
}
|
||||
|
||||
public static void loadOrgsList(String instanceUrl, String token, Context ctx) {
|
||||
public static void loadOrgsList(String instanceUrl, String token) {
|
||||
|
||||
Call<List<UserOrganizations>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getUserOrgs(token);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.Emails;
|
||||
@ -21,18 +20,18 @@ public class ProfileEmailsViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<Emails>> emailsList;
|
||||
|
||||
public LiveData<List<Emails>> getEmailsList(String instanceUrl, String token, Context ctx) {
|
||||
public LiveData<List<Emails>> getEmailsList(String instanceUrl, String token) {
|
||||
|
||||
emailsList = new MutableLiveData<>();
|
||||
loadEmailsList(instanceUrl, token, ctx);
|
||||
loadEmailsList(instanceUrl, token);
|
||||
|
||||
return emailsList;
|
||||
}
|
||||
|
||||
public static void loadEmailsList(String instanceUrl, String token, Context ctx) {
|
||||
public static void loadEmailsList(String instanceUrl, String token) {
|
||||
|
||||
Call<List<Emails>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getUserEmails(token);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
@ -21,18 +20,18 @@ public class ProfileFollowersViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<UserInfo>> followersList;
|
||||
|
||||
public LiveData<List<UserInfo>> getFollowersList(String instanceUrl, String token, Context ctx) {
|
||||
public LiveData<List<UserInfo>> getFollowersList(String instanceUrl, String token) {
|
||||
|
||||
followersList = new MutableLiveData<>();
|
||||
loadFollowersList(instanceUrl, token, ctx);
|
||||
loadFollowersList(instanceUrl, token);
|
||||
|
||||
return followersList;
|
||||
}
|
||||
|
||||
public static void loadFollowersList(String instanceUrl, String token, Context ctx) {
|
||||
public static void loadFollowersList(String instanceUrl, String token) {
|
||||
|
||||
Call<List<UserInfo>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getFollowers(token);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
@ -21,18 +20,18 @@ public class ProfileFollowingViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<UserInfo>> followingList;
|
||||
|
||||
public LiveData<List<UserInfo>> getFollowingList(String instanceUrl, String token, Context ctx) {
|
||||
public LiveData<List<UserInfo>> getFollowingList(String instanceUrl, String token) {
|
||||
|
||||
followingList = new MutableLiveData<>();
|
||||
loadFollowingList(instanceUrl, token, ctx);
|
||||
loadFollowingList(instanceUrl, token);
|
||||
|
||||
return followingList;
|
||||
}
|
||||
|
||||
public static void loadFollowingList(String instanceUrl, String token, Context ctx) {
|
||||
public static void loadFollowingList(String instanceUrl, String token) {
|
||||
|
||||
Call<List<UserInfo>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getFollowing(token);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.Releases;
|
||||
@ -21,18 +20,18 @@ public class ReleasesViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<Releases>> releasesList;
|
||||
|
||||
public LiveData<List<Releases>> getReleasesList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||
public LiveData<List<Releases>> getReleasesList(String instanceUrl, String token, String owner, String repo) {
|
||||
|
||||
releasesList = new MutableLiveData<>();
|
||||
loadReleasesList(instanceUrl, token, owner, repo, ctx);
|
||||
loadReleasesList(instanceUrl, token, owner, repo);
|
||||
|
||||
return releasesList;
|
||||
}
|
||||
|
||||
public static void loadReleasesList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
||||
public static void loadReleasesList(String instanceUrl, String token, String owner, String repo) {
|
||||
|
||||
Call<List<Releases>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getReleases(token, owner, repo);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
@ -21,18 +20,18 @@ public class RepoStargazersViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<UserInfo>> stargazersList;
|
||||
|
||||
public LiveData<List<UserInfo>> getRepoStargazers(String instanceUrl, String token, String repoOwner, String repoName, Context ctx) {
|
||||
public LiveData<List<UserInfo>> getRepoStargazers(String instanceUrl, String token, String repoOwner, String repoName) {
|
||||
|
||||
stargazersList = new MutableLiveData<>();
|
||||
loadRepoStargazers(instanceUrl, token, repoOwner, repoName, ctx);
|
||||
loadRepoStargazers(instanceUrl, token, repoOwner, repoName);
|
||||
|
||||
return stargazersList;
|
||||
}
|
||||
|
||||
private static void loadRepoStargazers(String instanceUrl, String token, String repoOwner, String repoName, Context ctx) {
|
||||
public static void loadRepoStargazers(String instanceUrl, String token, String repoOwner, String repoName) {
|
||||
|
||||
Call<List<UserInfo>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getRepoStargazers(token, repoOwner, repoName);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
@ -21,18 +20,18 @@ public class RepoWatchersViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<UserInfo>> watchersList;
|
||||
|
||||
public LiveData<List<UserInfo>> getRepoWatchers(String instanceUrl, String token, String repoOwner, String repoName, Context ctx) {
|
||||
public LiveData<List<UserInfo>> getRepoWatchers(String instanceUrl, String token, String repoOwner, String repoName) {
|
||||
|
||||
watchersList = new MutableLiveData<>();
|
||||
loadRepoWatchers(instanceUrl, token, repoOwner, repoName, ctx);
|
||||
loadRepoWatchers(instanceUrl, token, repoOwner, repoName);
|
||||
|
||||
return watchersList;
|
||||
}
|
||||
|
||||
private static void loadRepoWatchers(String instanceUrl, String token, String repoOwner, String repoName, Context ctx) {
|
||||
public static void loadRepoWatchers(String instanceUrl, String token, String repoOwner, String repoName) {
|
||||
|
||||
Call<List<UserInfo>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getRepoWatchers(token, repoOwner, repoName);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
@ -21,18 +20,18 @@ public class RepositoriesByOrgViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<UserRepositories>> orgReposList;
|
||||
|
||||
public LiveData<List<UserRepositories>> getRepositoriesByOrg(String instanceUrl, String token, String orgName, Context ctx) {
|
||||
public LiveData<List<UserRepositories>> getRepositoriesByOrg(String instanceUrl, String token, String orgName) {
|
||||
|
||||
orgReposList = new MutableLiveData<>();
|
||||
loadOrgRepos(instanceUrl, token, orgName, ctx);
|
||||
loadOrgRepos(instanceUrl, token, orgName);
|
||||
|
||||
return orgReposList;
|
||||
}
|
||||
|
||||
public static void loadOrgRepos(String instanceUrl, String token, String orgName, Context ctx) {
|
||||
public static void loadOrgRepos(String instanceUrl, String token, String orgName) {
|
||||
|
||||
Call<List<UserRepositories>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getReposByOrg(token, orgName);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
@ -21,20 +20,20 @@ public class RepositoriesListViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<UserRepositories>> reposList;
|
||||
|
||||
public LiveData<List<UserRepositories>> getUserRepositories(String instanceUrl, String token, Context ctx) {
|
||||
public LiveData<List<UserRepositories>> getUserRepositories(String instanceUrl, String token) {
|
||||
|
||||
//if (reposList == null) {
|
||||
reposList = new MutableLiveData<>();
|
||||
loadReposList(instanceUrl, token, ctx);
|
||||
loadReposList(instanceUrl, token);
|
||||
//}
|
||||
|
||||
return reposList;
|
||||
}
|
||||
|
||||
public static void loadReposList(String instanceUrl, String token, Context ctx) {
|
||||
public static void loadReposList(String instanceUrl, String token) {
|
||||
|
||||
Call<List<UserRepositories>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.getUserRepositories(token);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
@ -21,18 +20,18 @@ public class StarredRepositoriesViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<UserRepositories>> reposList;
|
||||
|
||||
public LiveData<List<UserRepositories>> getUserStarredRepositories(String instanceUrl, String token, Context ctx) {
|
||||
public LiveData<List<UserRepositories>> getUserStarredRepositories(String instanceUrl, String token) {
|
||||
|
||||
reposList = new MutableLiveData<>();
|
||||
loadStarredReposList(instanceUrl, token, ctx);
|
||||
loadStarredReposList(instanceUrl, token);
|
||||
|
||||
return reposList;
|
||||
}
|
||||
|
||||
public static void loadStarredReposList(String instanceUrl, String token, Context ctx) {
|
||||
public static void loadStarredReposList(String instanceUrl, String token) {
|
||||
|
||||
Call<List<UserRepositories>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getInstance(instanceUrl)
|
||||
.getApiInterface()
|
||||
.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