mirror of https://codeberg.org/gitnex/GitNex.git
reformat + fix
This commit is contained in:
parent
9c76a6de23
commit
287376b9b7
|
@ -17,6 +17,7 @@ pipeline:
|
|||
- cd /opt
|
||||
- tar xzf /tmp/idea.tar.gz
|
||||
- mv /opt/idea* /opt/idea
|
||||
- cd "$CI_WORKSPACE"
|
||||
- /opt/idea/bin/idea.sh format -s "$(pwd)/.idea/codeStyles/Project.xml" -m "*" -r .
|
||||
- git diff
|
||||
|
||||
|
|
|
@ -8,9 +8,7 @@ import androidx.test.platform.app.InstrumentationRegistry;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author qwerty287
|
||||
|
|
|
@ -24,9 +24,7 @@ public class AssigneesActions {
|
|||
|
||||
public static void getCurrentIssueAssignees(Context ctx, String repoOwner, String repoName, int issueIndex, List<String> currentAssignees) {
|
||||
|
||||
Call<Issue> callSingleIssueLabels = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
Call<Issue> callSingleIssueLabels = RetrofitClient.getApiInterface(ctx).issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
|
||||
callSingleIssueLabels.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -63,11 +61,10 @@ public class AssigneesActions {
|
|||
});
|
||||
}
|
||||
|
||||
public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List<User> assigneesList, MaterialAlertDialogBuilder materialAlertDialogBuilder, AssigneesListAdapter assigneesAdapter, CustomAssigneesSelectionDialogBinding assigneesBinding, ProgressBar progressBar) {
|
||||
public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List<User> assigneesList, MaterialAlertDialogBuilder materialAlertDialogBuilder, AssigneesListAdapter assigneesAdapter,
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding, ProgressBar progressBar) {
|
||||
|
||||
Call<List<User>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoGetAssignees(repoOwner, repoName);
|
||||
Call<List<User>> call = RetrofitClient.getApiInterface(ctx).repoGetAssignees(repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -113,4 +110,5 @@ public class AssigneesActions {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,11 +3,7 @@ package org.mian.gitnex.actions;
|
|||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.v2.models.Comment;
|
||||
import org.gitnex.tea4j.v2.models.CreateIssueCommentOption;
|
||||
import org.gitnex.tea4j.v2.models.EditIssueCommentOption;
|
||||
import org.gitnex.tea4j.v2.models.EditIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
|
|
|
@ -57,7 +57,8 @@ public class LabelsActions {
|
|||
});
|
||||
}
|
||||
|
||||
public static void getRepositoryLabels(Context ctx, String repoOwner, String repoName, List<Label> labelsList, MaterialAlertDialogBuilder materialAlertDialogBuilder, LabelsListAdapter labelsAdapter, CustomLabelsSelectionDialogBinding labelsBinding, ProgressBar progressBar) {
|
||||
public static void getRepositoryLabels(Context ctx, String repoOwner, String repoName, List<Label> labelsList, MaterialAlertDialogBuilder materialAlertDialogBuilder, LabelsListAdapter labelsAdapter,
|
||||
CustomLabelsSelectionDialogBinding labelsBinding, ProgressBar progressBar) {
|
||||
|
||||
Call<List<Label>> call = RetrofitClient.getApiInterface(ctx).issueListLabels(repoOwner, repoName, null, null);
|
||||
|
||||
|
|
|
@ -29,106 +29,104 @@ import retrofit2.Response;
|
|||
public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
|
||||
private ActivityAddCollaboratorToRepositoryBinding activityAddCollaboratorToRepositoryBinding;
|
||||
private View.OnClickListener onClickListener;
|
||||
private RepositoryContext repository;
|
||||
private View.OnClickListener onClickListener;
|
||||
private RepositoryContext repository;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding = ActivityAddCollaboratorToRepositoryBinding.inflate(getLayoutInflater());
|
||||
activityAddCollaboratorToRepositoryBinding = ActivityAddCollaboratorToRepositoryBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityAddCollaboratorToRepositoryBinding.getRoot());
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.requestFocus();
|
||||
assert imm != null;
|
||||
imm.showSoftInput(activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch, InputMethodManager.SHOW_IMPLICIT);
|
||||
activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.requestFocus();
|
||||
assert imm != null;
|
||||
imm.showSoftInput(activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
initCloseListener();
|
||||
activityAddCollaboratorToRepositoryBinding.close.setOnClickListener(onClickListener);
|
||||
initCloseListener();
|
||||
activityAddCollaboratorToRepositoryBinding.close.setOnClickListener(onClickListener);
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.setOnEditorActionListener((v, actionId, event) -> {
|
||||
activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.setOnEditorActionListener((v, actionId, event) -> {
|
||||
|
||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
if(actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
|
||||
if(!Objects.requireNonNull(activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.getText()).toString().equals("")) {
|
||||
if(!Objects.requireNonNull(activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.getText()).toString().equals("")) {
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
loadUserSearchList(activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.getText().toString());
|
||||
}
|
||||
}
|
||||
activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
loadUserSearchList(activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.getText().toString());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
public void loadUserSearchList(String searchKeyword) {
|
||||
public void loadUserSearchList(String searchKeyword) {
|
||||
|
||||
Call<InlineResponse2001> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.userSearch(searchKeyword, null, 1, 10);
|
||||
Call<InlineResponse2001> call = RetrofitClient.getApiInterface(ctx).userSearch(searchKeyword, null, 1, 10);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<InlineResponse2001> call, @NonNull Response<InlineResponse2001> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<InlineResponse2001> call, @NonNull Response<InlineResponse2001> response) {
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.GONE);
|
||||
activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.GONE);
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
assert response.body() != null;
|
||||
getUsersList(response.body().getData(), ctx);
|
||||
}
|
||||
else {
|
||||
assert response.body() != null;
|
||||
getUsersList(response.body().getData(), ctx);
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<InlineResponse2001> call, @NonNull Throwable t) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<InlineResponse2001> call, @NonNull Throwable t) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getUsersList(List<User> dataList, Context context) {
|
||||
private void getUsersList(List<User> dataList, Context context) {
|
||||
|
||||
CollaboratorSearchAdapter adapter = new CollaboratorSearchAdapter(dataList, context, repository);
|
||||
CollaboratorSearchAdapter adapter = new CollaboratorSearchAdapter(dataList, context, repository);
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setHasFixedSize(true);
|
||||
activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.addItemDecoration(dividerItemDecoration);
|
||||
activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setHasFixedSize(true);
|
||||
activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.getContext(), DividerItemDecoration.VERTICAL);
|
||||
activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
if(adapter.getItemCount() > 0) {
|
||||
if(adapter.getItemCount() > 0) {
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setAdapter(adapter);
|
||||
activityAddCollaboratorToRepositoryBinding.noData.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setAdapter(adapter);
|
||||
activityAddCollaboratorToRepositoryBinding.noData.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
activityAddCollaboratorToRepositoryBinding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,11 +17,7 @@ import org.mian.gitnex.database.api.BaseApi;
|
|||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.databinding.ActivityAddNewAccountBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.PathsHelper;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.UrlHelper;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.structs.Protocol;
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
|
@ -58,10 +54,11 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||
viewBinding.instanceUrl.setText(getIntent().getStringExtra("instanceUrl"));
|
||||
viewBinding.loginToken.setText(getIntent().getStringExtra("token"));
|
||||
String scheme = getIntent().getStringExtra("scheme");
|
||||
if(scheme != null && scheme.equals("http")) {
|
||||
if(scheme != null && scheme.equals("http")) {
|
||||
viewBinding.protocolSpinner.setText(Protocol.HTTP.toString());
|
||||
spinnerSelectedValue = Protocol.HTTP.toString();
|
||||
} else { // default is https
|
||||
}
|
||||
else { // default is https
|
||||
viewBinding.protocolSpinner.setText(Protocol.HTTPS.toString());
|
||||
spinnerSelectedValue = Protocol.HTTPS.toString();
|
||||
}
|
||||
|
@ -114,8 +111,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||
|
||||
URI rawInstanceUrl = UrlBuilder.fromString(UrlHelper.fixScheme(instanceUrlET, "http")).toUri();
|
||||
|
||||
URI instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(protocol.toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/"))
|
||||
.toUri();
|
||||
URI instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(protocol.toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/")).toUri();
|
||||
|
||||
versionCheck(instanceUrl.toString(), loginToken);
|
||||
serverPageLimitSettings();
|
||||
|
@ -152,10 +148,8 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||
|
||||
if(giteaVersion.less(getString(R.string.versionLow))) {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion()))
|
||||
.setNeutralButton(getString(R.string.cancelButton), null)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setNeutralButton(getString(R.string.cancelButton), null)
|
||||
.setPositiveButton(getString(R.string.textContinue), (dialog, which) -> {
|
||||
|
||||
dialog.dismiss();
|
||||
|
@ -290,4 +284,5 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,11 +10,7 @@ import com.amrdeveloper.codeview.Code;
|
|||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.databinding.ActivityCodeEditorBinding;
|
||||
import org.mian.gitnex.helpers.codeeditor.CustomCodeViewAdapter;
|
||||
import org.mian.gitnex.helpers.codeeditor.LanguageManager;
|
||||
import org.mian.gitnex.helpers.codeeditor.LanguageName;
|
||||
import org.mian.gitnex.helpers.codeeditor.SourcePositionListener;
|
||||
import org.mian.gitnex.helpers.codeeditor.ThemeName;
|
||||
import org.mian.gitnex.helpers.codeeditor.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -26,10 +22,10 @@ import java.util.Map;
|
|||
|
||||
public class CodeEditorActivity extends BaseActivity {
|
||||
|
||||
private final ThemeName currentTheme = ThemeName.FIVE_COLOR;
|
||||
private ActivityCodeEditorBinding binding;
|
||||
private LanguageManager languageManager;
|
||||
private LanguageName currentLanguage = LanguageName.UNKNOWN;
|
||||
private final ThemeName currentTheme = ThemeName.FIVE_COLOR;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -105,7 +101,7 @@ public class CodeEditorActivity extends BaseActivity {
|
|||
private void configLanguageAutoComplete() {
|
||||
|
||||
boolean useModernAutoCompleteAdapter = true;
|
||||
if (useModernAutoCompleteAdapter) {
|
||||
if(useModernAutoCompleteAdapter) {
|
||||
List<Code> codeList = languageManager.getLanguageCodeList(currentLanguage);
|
||||
|
||||
CustomCodeViewAdapter adapter = new CustomCodeViewAdapter(this, codeList);
|
||||
|
@ -146,4 +142,5 @@ public class CodeEditorActivity extends BaseActivity {
|
|||
binding.sourcePosition.setText(getString(R.string.sourcePosition, line, column));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,12 +15,7 @@ import androidx.activity.result.ActivityResultLauncher;
|
|||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.CreateFileOptions;
|
||||
import org.gitnex.tea4j.v2.models.DeleteFileOptions;
|
||||
import org.gitnex.tea4j.v2.models.FileDeleteResponse;
|
||||
import org.gitnex.tea4j.v2.models.FileResponse;
|
||||
import org.gitnex.tea4j.v2.models.UpdateFileOptions;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateFileBinding;
|
||||
|
@ -41,98 +36,98 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
private ActivityCreateFileBinding binding;
|
||||
|
||||
public static final int FILE_ACTION_CREATE = 0;
|
||||
public static final int FILE_ACTION_DELETE = 1;
|
||||
public static final int FILE_ACTION_EDIT = 2;
|
||||
|
||||
private final List<String> branches = new ArrayList<>();
|
||||
private ActivityCreateFileBinding binding;
|
||||
ActivityResultLauncher<Intent> codeEditorActivityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == Activity.RESULT_OK) {
|
||||
Intent data = result.getData();
|
||||
assert data != null;
|
||||
binding.newFileContent.setText(data.getStringExtra("fileContentFromActivity"));
|
||||
}
|
||||
});
|
||||
private int fileAction = FILE_ACTION_CREATE;
|
||||
|
||||
private String filePath;
|
||||
private String fileSha;
|
||||
|
||||
private final List<String> branches = new ArrayList<>();
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
binding = ActivityCreateFileBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
binding = ActivityCreateFileBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
TextView toolbarTitle = binding.toolbarTitle;
|
||||
TextView toolbarTitle = binding.toolbarTitle;
|
||||
|
||||
binding.newFileName.requestFocus();
|
||||
binding.newFileName.requestFocus();
|
||||
|
||||
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
assert inputMethodManager != null;
|
||||
inputMethodManager.showSoftInput(binding.newFileName, InputMethodManager.SHOW_IMPLICIT);
|
||||
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
assert inputMethodManager != null;
|
||||
inputMethodManager.showSoftInput(binding.newFileName, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
binding.close.setOnClickListener(view -> finish());
|
||||
binding.newFileContent.setOnTouchListener((touchView, motionEvent) -> {
|
||||
binding.close.setOnClickListener(view -> finish());
|
||||
binding.newFileContent.setOnTouchListener((touchView, motionEvent) -> {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 &&
|
||||
(motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", FILE_ACTION_DELETE) == FILE_ACTION_DELETE) {
|
||||
if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", FILE_ACTION_DELETE) == FILE_ACTION_DELETE) {
|
||||
|
||||
fileAction = getIntent().getIntExtra("fileAction", FILE_ACTION_DELETE);
|
||||
filePath = getIntent().getStringExtra("filePath");
|
||||
fileSha = getIntent().getStringExtra("fileSha");
|
||||
fileAction = getIntent().getIntExtra("fileAction", FILE_ACTION_DELETE);
|
||||
filePath = getIntent().getStringExtra("filePath");
|
||||
fileSha = getIntent().getStringExtra("fileSha");
|
||||
|
||||
toolbarTitle.setText(getString(R.string.deleteGenericTitle, filePath));
|
||||
toolbarTitle.setText(getString(R.string.deleteGenericTitle, filePath));
|
||||
|
||||
binding.newFileCreate.setText(R.string.deleteFile);
|
||||
binding.newFileCreate.setText(R.string.deleteFile);
|
||||
|
||||
binding.newFileNameLayout.setVisibility(View.GONE);
|
||||
binding.newFileContentLayout.setVisibility(View.GONE);
|
||||
}
|
||||
binding.newFileNameLayout.setVisibility(View.GONE);
|
||||
binding.newFileContentLayout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", FILE_ACTION_EDIT) == FILE_ACTION_EDIT) {
|
||||
if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", FILE_ACTION_EDIT) == FILE_ACTION_EDIT) {
|
||||
|
||||
fileAction = getIntent().getIntExtra("fileAction", FILE_ACTION_EDIT);
|
||||
filePath = getIntent().getStringExtra("filePath");
|
||||
fileSha = getIntent().getStringExtra("fileSha");
|
||||
fileAction = getIntent().getIntExtra("fileAction", FILE_ACTION_EDIT);
|
||||
filePath = getIntent().getStringExtra("filePath");
|
||||
fileSha = getIntent().getStringExtra("fileSha");
|
||||
|
||||
toolbarTitle.setText(getString(R.string.editFileText, filePath));
|
||||
toolbarTitle.setText(getString(R.string.editFileText, filePath));
|
||||
|
||||
binding.newFileCreate.setText(R.string.editFile);
|
||||
binding.newFileName.setText(filePath);
|
||||
binding.newFileName.setEnabled(false);
|
||||
binding.newFileName.setFocusable(false);
|
||||
binding.newFileCreate.setText(R.string.editFile);
|
||||
binding.newFileName.setText(filePath);
|
||||
binding.newFileName.setEnabled(false);
|
||||
binding.newFileName.setFocusable(false);
|
||||
|
||||
binding.newFileContent.setText(getIntent().getStringExtra("fileContents"));
|
||||
}
|
||||
binding.newFileContent.setText(getIntent().getStringExtra("fileContents"));
|
||||
}
|
||||
|
||||
getBranches(repository.getOwner(), repository.getName());
|
||||
getBranches(repository.getOwner(), repository.getName());
|
||||
|
||||
disableProcessButton();
|
||||
disableProcessButton();
|
||||
|
||||
binding.openCodeEditor.setOnClickListener(v ->
|
||||
launchCodeEditorActivityForResult(Objects.requireNonNull(binding.newFileContent.getText()).toString(), FilenameUtils.getExtension(String.valueOf(binding.newFileName.getText())))
|
||||
);
|
||||
binding.openCodeEditor.setOnClickListener(
|
||||
v -> launchCodeEditorActivityForResult(Objects.requireNonNull(binding.newFileContent.getText()).toString(), FilenameUtils.getExtension(String.valueOf(binding.newFileName.getText()))));
|
||||
|
||||
NetworkStatusObserver networkStatusObserver = NetworkStatusObserver.getInstance(ctx);
|
||||
networkStatusObserver.registerNetworkStatusListener(hasNetworkConnection -> runOnUiThread(() -> binding.newFileCreate.setEnabled(hasNetworkConnection)));
|
||||
NetworkStatusObserver networkStatusObserver = NetworkStatusObserver.getInstance(ctx);
|
||||
networkStatusObserver.registerNetworkStatusListener(hasNetworkConnection -> runOnUiThread(() -> binding.newFileCreate.setEnabled(hasNetworkConnection)));
|
||||
|
||||
binding.newFileCreate.setOnClickListener(v -> processNewFile());
|
||||
}
|
||||
binding.newFileCreate.setOnClickListener(v -> processNewFile());
|
||||
}
|
||||
|
||||
public void launchCodeEditorActivityForResult(String fileContent, String fileExtension) {
|
||||
Intent intent = new Intent(this, CodeEditorActivity.class);
|
||||
|
@ -141,63 +136,54 @@ public class CreateFileActivity extends BaseActivity {
|
|||
codeEditorActivityResultLauncher.launch(intent);
|
||||
}
|
||||
|
||||
ActivityResultLauncher<Intent> codeEditorActivityResultLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == Activity.RESULT_OK) {
|
||||
Intent data = result.getData();
|
||||
assert data != null;
|
||||
binding.newFileContent.setText(data.getStringExtra("fileContentFromActivity"));
|
||||
}
|
||||
});
|
||||
private void processNewFile() {
|
||||
|
||||
private void processNewFile() {
|
||||
String newFileName = binding.newFileName.getText() != null ? binding.newFileName.getText().toString() : "";
|
||||
String newFileContent = binding.newFileContent.getText() != null ? binding.newFileContent.getText().toString() : "";
|
||||
String newFileBranchName = binding.newFileBranches.getText() != null ? binding.newFileBranches.getText().toString() : "";
|
||||
String newFileCommitMessage = binding.newFileCommitMessage.getText() != null ? binding.newFileCommitMessage.getText().toString() : "";
|
||||
|
||||
String newFileName = binding.newFileName.getText() != null ? binding.newFileName.getText().toString() : "";
|
||||
String newFileContent = binding.newFileContent.getText() != null ? binding.newFileContent.getText().toString() : "";
|
||||
String newFileBranchName = binding.newFileBranches.getText() != null ? binding.newFileBranches.getText().toString() : "";
|
||||
String newFileCommitMessage = binding.newFileCommitMessage.getText() != null ? binding.newFileCommitMessage.getText().toString() : "";
|
||||
if(!AppUtil.hasNetworkConnection(appCtx)) {
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!AppUtil.hasNetworkConnection(appCtx)) {
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
if(((newFileName.isEmpty() || newFileContent.isEmpty()) && fileAction != FILE_ACTION_DELETE) || newFileCommitMessage.isEmpty()) {
|
||||
Toasty.error(ctx, getString(R.string.newFileRequiredFields));
|
||||
return;
|
||||
}
|
||||
|
||||
if(((newFileName.isEmpty() || newFileContent.isEmpty()) && fileAction != FILE_ACTION_DELETE) || newFileCommitMessage.isEmpty()) {
|
||||
Toasty.error(ctx, getString(R.string.newFileRequiredFields));
|
||||
return;
|
||||
}
|
||||
if(!AppUtil.checkStringsWithDash(newFileBranchName)) {
|
||||
Toasty.error(ctx, getString(R.string.newFileInvalidBranchName));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!AppUtil.checkStringsWithDash(newFileBranchName)) {
|
||||
Toasty.error(ctx, getString(R.string.newFileInvalidBranchName));
|
||||
return;
|
||||
}
|
||||
if(newFileCommitMessage.length() > 255) {
|
||||
Toasty.warning(ctx, getString(R.string.newFileCommitMessageError));
|
||||
return;
|
||||
}
|
||||
|
||||
if(newFileCommitMessage.length() > 255) {
|
||||
Toasty.warning(ctx, getString(R.string.newFileCommitMessageError));
|
||||
return;
|
||||
}
|
||||
disableProcessButton();
|
||||
|
||||
disableProcessButton();
|
||||
switch(fileAction) {
|
||||
|
||||
switch(fileAction) {
|
||||
case FILE_ACTION_CREATE:
|
||||
createNewFile(repository.getOwner(), repository.getName(), newFileName, AppUtil.encodeBase64(newFileContent), newFileCommitMessage, newFileBranchName);
|
||||
break;
|
||||
|
||||
case FILE_ACTION_CREATE:
|
||||
createNewFile(repository.getOwner(), repository.getName(), newFileName, AppUtil.encodeBase64(newFileContent), newFileCommitMessage, newFileBranchName);
|
||||
break;
|
||||
case FILE_ACTION_DELETE:
|
||||
deleteFile(repository.getOwner(), repository.getName(), filePath, newFileCommitMessage, newFileBranchName, fileSha);
|
||||
break;
|
||||
|
||||
case FILE_ACTION_DELETE:
|
||||
deleteFile(repository.getOwner(), repository.getName(), filePath, newFileCommitMessage, newFileBranchName, fileSha);
|
||||
break;
|
||||
case FILE_ACTION_EDIT:
|
||||
editFile(repository.getOwner(), repository.getName(), filePath, AppUtil.encodeBase64(newFileContent), newFileCommitMessage, newFileBranchName, fileSha);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case FILE_ACTION_EDIT:
|
||||
editFile(repository.getOwner(), repository.getName(), filePath, AppUtil.encodeBase64(newFileContent), newFileCommitMessage, newFileBranchName, fileSha);
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void createNewFile(String repoOwner, String repoName, String fileName, String fileContent, String fileCommitMessage, String branchName) {
|
||||
|
||||
private void createNewFile(String repoOwner, String repoName, String fileName, String fileContent, String fileCommitMessage, String branchName) {
|
||||
|
||||
CreateFileOptions createNewFileJsonStr = new CreateFileOptions();
|
||||
CreateFileOptions createNewFileJsonStr = new CreateFileOptions();
|
||||
createNewFileJsonStr.setContent(fileContent);
|
||||
createNewFileJsonStr.setMessage(fileCommitMessage);
|
||||
|
||||
|
@ -208,56 +194,54 @@ public class CreateFileActivity extends BaseActivity {
|
|||
createNewFileJsonStr.setNewBranch(branchName);
|
||||
}
|
||||
|
||||
Call<FileResponse> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoCreateFile(createNewFileJsonStr, repoOwner, repoName, fileName);
|
||||
Call<FileResponse> call = RetrofitClient.getApiInterface(ctx).repoCreateFile(createNewFileJsonStr, repoOwner, repoName, fileName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<FileResponse> call, @NonNull retrofit2.Response<FileResponse> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<FileResponse> call, @NonNull retrofit2.Response<FileResponse> response) {
|
||||
|
||||
switch(response.code()) {
|
||||
switch(response.code()) {
|
||||
|
||||
case 201:
|
||||
enableProcessButton();
|
||||
Toasty.success(ctx, getString(R.string.newFileSuccessMessage));
|
||||
Intent result = new Intent();
|
||||
result.putExtra("fileModified", true);
|
||||
result.putExtra("fileAction", fileAction);
|
||||
setResult(200, result);
|
||||
finish();
|
||||
break;
|
||||
case 201:
|
||||
enableProcessButton();
|
||||
Toasty.success(ctx, getString(R.string.newFileSuccessMessage));
|
||||
Intent result = new Intent();
|
||||
result.putExtra("fileModified", true);
|
||||
result.putExtra("fileAction", fileAction);
|
||||
setResult(200, result);
|
||||
finish();
|
||||
break;
|
||||
|
||||
case 401:
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
break;
|
||||
case 401:
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
break;
|
||||
|
||||
case 404:
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
||||
break;
|
||||
case 404:
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
||||
break;
|
||||
|
||||
default:
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<FileResponse> call, @NonNull Throwable t) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<FileResponse> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void deleteFile(String repoOwner, String repoName, String fileName, String fileCommitMessage, String branchName, String fileSha) {
|
||||
|
||||
DeleteFileOptions deleteFileJsonStr = new DeleteFileOptions();
|
||||
DeleteFileOptions deleteFileJsonStr = new DeleteFileOptions();
|
||||
deleteFileJsonStr.setMessage(fileCommitMessage);
|
||||
deleteFileJsonStr.setSha(fileSha);
|
||||
|
||||
|
@ -268,9 +252,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||
deleteFileJsonStr.setNewBranch(branchName);
|
||||
}
|
||||
|
||||
Call<FileDeleteResponse> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoDeleteFileWithBody(repoOwner, repoName, fileName, deleteFileJsonStr);
|
||||
Call<FileDeleteResponse> call = RetrofitClient.getApiInterface(ctx).repoDeleteFileWithBody(repoOwner, repoName, fileName, deleteFileJsonStr);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -329,9 +311,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||
editFileJsonStr.setNewBranch(branchName);
|
||||
}
|
||||
|
||||
Call<FileResponse> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoUpdateFile(editFileJsonStr, repoOwner, repoName, fileName);
|
||||
Call<FileResponse> call = RetrofitClient.getApiInterface(ctx).repoUpdateFile(editFileJsonStr, repoOwner, repoName, fileName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -376,46 +356,50 @@ public class CreateFileActivity extends BaseActivity {
|
|||
});
|
||||
}
|
||||
|
||||
private void getBranches(String repoOwner, String repoName) {
|
||||
private void getBranches(String repoOwner, String repoName) {
|
||||
|
||||
Call<List<Branch>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoListBranches(repoOwner, repoName, null, null);
|
||||
Call<List<Branch>> call = RetrofitClient.getApiInterface(ctx).repoListBranches(repoOwner, repoName, null, null);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Branch>> call, @NonNull retrofit2.Response<List<Branch>> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Branch>> call, @NonNull retrofit2.Response<List<Branch>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if(response.code() == 200) {
|
||||
|
||||
assert response.body() != null;
|
||||
for(Branch branch : response.body())
|
||||
branches.add(branch.getName());
|
||||
assert response.body() != null;
|
||||
for(Branch branch : response.body())
|
||||
branches.add(branch.getName());
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreateFileActivity.this, R.layout.list_spinner_items, branches);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreateFileActivity.this, R.layout.list_spinner_items, branches);
|
||||
|
||||
binding.newFileBranches.setAdapter(adapter);
|
||||
binding.newFileBranches.setText(repository.getBranchRef(), false);
|
||||
binding.newFileBranches.setAdapter(adapter);
|
||||
binding.newFileBranches.setText(repository.getBranchRef(), false);
|
||||
|
||||
enableProcessButton();
|
||||
}
|
||||
}
|
||||
enableProcessButton();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Branch>> call, @NonNull Throwable t) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Branch>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void disableProcessButton() { binding.newFileCreate.setEnabled(false); }
|
||||
private void enableProcessButton() { binding.newFileCreate.setEnabled(true); }
|
||||
private void disableProcessButton() {
|
||||
binding.newFileCreate.setEnabled(false);
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
binding.newFileCreate.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,11 +12,7 @@ import android.widget.ArrayAdapter;
|
|||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import org.gitnex.tea4j.v2.models.CreateIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.AssigneesActions;
|
||||
import org.mian.gitnex.actions.LabelsActions;
|
||||
|
@ -32,12 +28,7 @@ import org.mian.gitnex.helpers.AppUtil;
|
|||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
|
@ -47,93 +38,89 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreateIssueActivity extends BaseActivity implements View.OnClickListener, LabelsListAdapter.LabelsListAdapterListener, AssigneesListAdapter.AssigneesListAdapterListener {
|
||||
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
private final LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
private final List<User> assigneesList = new ArrayList<>();
|
||||
private ActivityCreateIssueBinding viewBinding;
|
||||
private View.OnClickListener onClickListener;
|
||||
private int milestoneId;
|
||||
private Date currentDate = null;
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
private AssigneesListAdapter assigneesAdapter;
|
||||
|
||||
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
||||
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
private final LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
private final List<User> assigneesList = new ArrayList<>();
|
||||
private List<String> assigneesListData = new ArrayList<>();
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
viewBinding = ActivityCreateIssueBinding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
viewBinding = ActivityCreateIssueBinding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
int resultLimit = Constants.getCurrentResultLimit(ctx);
|
||||
int resultLimit = Constants.getCurrentResultLimit(ctx);
|
||||
|
||||
viewBinding.newIssueTitle.requestFocus();
|
||||
assert imm != null;
|
||||
imm.showSoftInput(viewBinding.newIssueTitle, InputMethodManager.SHOW_IMPLICIT);
|
||||
viewBinding.newIssueTitle.requestFocus();
|
||||
assert imm != null;
|
||||
imm.showSoftInput(viewBinding.newIssueTitle, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
viewBinding.newIssueDescription.setOnTouchListener((touchView, motionEvent) -> {
|
||||
viewBinding.newIssueDescription.setOnTouchListener((touchView, motionEvent) -> {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
labelsAdapter = new LabelsListAdapter(labelsList, CreateIssueActivity.this, labelsIds);
|
||||
assigneesAdapter = new AssigneesListAdapter(ctx, assigneesList, CreateIssueActivity.this, assigneesListData);
|
||||
labelsAdapter = new LabelsListAdapter(labelsList, CreateIssueActivity.this, labelsIds);
|
||||
assigneesAdapter = new AssigneesListAdapter(ctx, assigneesList, CreateIssueActivity.this, assigneesListData);
|
||||
|
||||
initCloseListener();
|
||||
viewBinding.close.setOnClickListener(onClickListener);
|
||||
initCloseListener();
|
||||
viewBinding.close.setOnClickListener(onClickListener);
|
||||
|
||||
viewBinding.newIssueAssigneesList.setOnClickListener(this);
|
||||
viewBinding.newIssueLabels.setOnClickListener(this);
|
||||
viewBinding.newIssueDueDate.setOnClickListener(this);
|
||||
viewBinding.newIssueAssigneesList.setOnClickListener(this);
|
||||
viewBinding.newIssueLabels.setOnClickListener(this);
|
||||
viewBinding.newIssueDueDate.setOnClickListener(this);
|
||||
|
||||
getMilestones(repository.getOwner(), repository.getName(), resultLimit);
|
||||
getMilestones(repository.getOwner(), repository.getName(), resultLimit);
|
||||
|
||||
disableProcessButton();
|
||||
disableProcessButton();
|
||||
|
||||
viewBinding.newIssueLabels.setOnClickListener(newIssueLabels -> showLabels());
|
||||
viewBinding.newIssueLabels.setOnClickListener(newIssueLabels -> showLabels());
|
||||
|
||||
viewBinding.newIssueAssigneesList.setOnClickListener(newIssueAssigneesList -> showAssignees());
|
||||
viewBinding.newIssueAssigneesList.setOnClickListener(newIssueAssigneesList -> showAssignees());
|
||||
|
||||
if(!connToInternet) {
|
||||
if(!connToInternet) {
|
||||
|
||||
viewBinding.createNewIssueButton.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
viewBinding.createNewIssueButton.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.createNewIssueButton.setOnClickListener(this);
|
||||
}
|
||||
viewBinding.createNewIssueButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
if(!repository.getPermissions().isPush()) {
|
||||
viewBinding.newIssueAssigneesListLayout.setVisibility(View.GONE);
|
||||
viewBinding.newIssueMilestoneSpinnerLayout.setVisibility(View.GONE);
|
||||
viewBinding.newIssueLabelsLayout.setVisibility(View.GONE);
|
||||
viewBinding.newIssueDueDateLayout.setVisibility(View.GONE);
|
||||
}
|
||||
if(!repository.getPermissions().isPush()) {
|
||||
viewBinding.newIssueAssigneesListLayout.setVisibility(View.GONE);
|
||||
viewBinding.newIssueMilestoneSpinnerLayout.setVisibility(View.GONE);
|
||||
viewBinding.newIssueLabelsLayout.setVisibility(View.GONE);
|
||||
viewBinding.newIssueDueDateLayout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assigneesInterface(List<String> data) {
|
||||
|
@ -160,23 +147,20 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding = CustomAssigneesSelectionDialogBinding.inflate(
|
||||
LayoutInflater.from(ctx));
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding = CustomAssigneesSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
View view = assigneesBinding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
|
||||
materialAlertDialogBuilder.setNeutralButton(R.string.close, null);
|
||||
|
||||
AssigneesActions.getRepositoryAssignees(ctx, repository.getOwner(), repository.getName(), assigneesList, materialAlertDialogBuilder, assigneesAdapter,
|
||||
assigneesBinding, viewBinding.progressBar);
|
||||
AssigneesActions.getRepositoryAssignees(ctx, repository.getOwner(), repository.getName(), assigneesList, materialAlertDialogBuilder, assigneesAdapter, assigneesBinding, viewBinding.progressBar);
|
||||
}
|
||||
|
||||
private void showLabels() {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
CustomLabelsSelectionDialogBinding labelsBinding = CustomLabelsSelectionDialogBinding.inflate(
|
||||
LayoutInflater.from(ctx));
|
||||
CustomLabelsSelectionDialogBinding labelsBinding = CustomLabelsSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
View view = labelsBinding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
|
||||
|
@ -185,38 +169,38 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
LabelsActions.getRepositoryLabels(ctx, repository.getOwner(), repository.getName(), labelsList, materialAlertDialogBuilder, labelsAdapter, labelsBinding, viewBinding.progressBar);
|
||||
}
|
||||
|
||||
private void processNewIssue() {
|
||||
private void processNewIssue() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
String newIssueTitleForm = Objects.requireNonNull(viewBinding.newIssueTitle.getText()).toString();
|
||||
String newIssueDescriptionForm = Objects.requireNonNull(viewBinding.newIssueDescription.getText()).toString();
|
||||
String newIssueDueDateForm = Objects.requireNonNull(viewBinding.newIssueDueDate.getText()).toString();
|
||||
String newIssueTitleForm = Objects.requireNonNull(viewBinding.newIssueTitle.getText()).toString();
|
||||
String newIssueDescriptionForm = Objects.requireNonNull(viewBinding.newIssueDescription.getText()).toString();
|
||||
String newIssueDueDateForm = Objects.requireNonNull(viewBinding.newIssueDueDate.getText()).toString();
|
||||
|
||||
if(!connToInternet) {
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if (newIssueTitleForm.equals("")) {
|
||||
if(newIssueTitleForm.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.issueTitleEmpty));
|
||||
return;
|
||||
}
|
||||
Toasty.error(ctx, getString(R.string.issueTitleEmpty));
|
||||
return;
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewIssueFunc(repository.getOwner(), repository.getName(), newIssueDescriptionForm, milestoneId, newIssueTitleForm);
|
||||
}
|
||||
disableProcessButton();
|
||||
createNewIssueFunc(repository.getOwner(), repository.getName(), newIssueDescriptionForm, milestoneId, newIssueTitleForm);
|
||||
}
|
||||
|
||||
private void createNewIssueFunc(String repoOwner, String repoName, String newIssueDescriptionForm, int newIssueMilestoneIdForm, String newIssueTitleForm) {
|
||||
private void createNewIssueFunc(String repoOwner, String repoName, String newIssueDescriptionForm, int newIssueMilestoneIdForm, String newIssueTitleForm) {
|
||||
|
||||
ArrayList<Long> labelIds = new ArrayList<>();
|
||||
for(Integer i : labelsIds) {
|
||||
labelIds.add((long) i);
|
||||
}
|
||||
for(Integer i : labelsIds) {
|
||||
labelIds.add((long) i);
|
||||
}
|
||||
|
||||
CreateIssueOption createNewIssueJson = new CreateIssueOption();
|
||||
CreateIssueOption createNewIssueJson = new CreateIssueOption();
|
||||
createNewIssueJson.setBody(newIssueDescriptionForm);
|
||||
createNewIssueJson.setMilestone((long) newIssueMilestoneIdForm);
|
||||
createNewIssueJson.setDueDate(currentDate);
|
||||
|
@ -224,150 +208,146 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
createNewIssueJson.setAssignees(assigneesListData);
|
||||
createNewIssueJson.setLabels(labelIds);
|
||||
|
||||
Call<Issue> call3 = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueCreateIssue(repoOwner, repoName, createNewIssueJson);
|
||||
Call<Issue> call3 = RetrofitClient.getApiInterface(ctx).issueCreateIssue(repoOwner, repoName, createNewIssueJson);
|
||||
|
||||
call3.enqueue(new Callback<>() {
|
||||
call3.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issue> call, @NonNull retrofit2.Response<Issue> response2) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issue> call, @NonNull retrofit2.Response<Issue> response2) {
|
||||
|
||||
if(response2.code() == 201) {
|
||||
if(response2.code() == 201) {
|
||||
|
||||
IssuesFragment.resumeIssues = true;
|
||||
IssuesFragment.resumeIssues = true;
|
||||
|
||||
Toasty.success(ctx, getString(R.string.issueCreated));
|
||||
enableProcessButton();
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
MainActivity.reloadRepos = true;
|
||||
finish();
|
||||
}
|
||||
else if(response2.code() == 401) {
|
||||
Toasty.success(ctx, getString(R.string.issueCreated));
|
||||
enableProcessButton();
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
MainActivity.reloadRepos = true;
|
||||
finish();
|
||||
}
|
||||
else if(response2.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
enableProcessButton();
|
||||
}
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
enableProcessButton();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
private void getMilestones(String repoOwner, String repoName, int resultLimit) {
|
||||
private void getMilestones(String repoOwner, String repoName, int resultLimit) {
|
||||
|
||||
String msState = "open";
|
||||
Call<List<Milestone>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
String msState = "open";
|
||||
Call<List<Milestone>> call = RetrofitClient.getApiInterface(ctx).issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Milestone>> call, @NonNull retrofit2.Response<List<Milestone>> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Milestone>> call, @NonNull retrofit2.Response<List<Milestone>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if(response.code() == 200) {
|
||||
|
||||
List<Milestone> milestonesList_ = response.body();
|
||||
List<Milestone> milestonesList_ = response.body();
|
||||
|
||||
Milestone ms = new Milestone();
|
||||
ms.setId(0L);
|
||||
ms.setTitle(getString(R.string.issueCreatedNoMilestone));
|
||||
milestonesList.put(ms.getTitle(), ms);
|
||||
assert milestonesList_ != null;
|
||||
Milestone ms = new Milestone();
|
||||
ms.setId(0L);
|
||||
ms.setTitle(getString(R.string.issueCreatedNoMilestone));
|
||||
milestonesList.put(ms.getTitle(), ms);
|
||||
assert milestonesList_ != null;
|
||||
|
||||
if(milestonesList_.size() > 0) {
|
||||
if(milestonesList_.size() > 0) {
|
||||
|
||||
for(Milestone milestone : milestonesList_) {
|
||||
for(Milestone milestone : milestonesList_) {
|
||||
|
||||
//Don't translate "open" is a enum
|
||||
if(milestone.getState().equals("open")) {
|
||||
milestonesList.put(milestone.getTitle(), milestone);
|
||||
}
|
||||
}
|
||||
}
|
||||
//Don't translate "open" is a enum
|
||||
if(milestone.getState().equals("open")) {
|
||||
milestonesList.put(milestone.getTitle(), milestone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreateIssueActivity.this, R.layout.list_spinner_items, new ArrayList<>(milestonesList.keySet()));
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreateIssueActivity.this, R.layout.list_spinner_items, new ArrayList<>(milestonesList.keySet()));
|
||||
|
||||
viewBinding.newIssueMilestoneSpinner.setAdapter(adapter);
|
||||
enableProcessButton();
|
||||
viewBinding.newIssueMilestoneSpinner.setAdapter(adapter);
|
||||
enableProcessButton();
|
||||
|
||||
viewBinding.newIssueMilestoneSpinner.setOnItemClickListener((parent, view, position, id) -> {
|
||||
if(position == 0) {
|
||||
milestoneId = 0;
|
||||
}
|
||||
else if(view instanceof TextView) {
|
||||
milestoneId = Math.toIntExact(Objects.requireNonNull(milestonesList.get(((TextView) view).getText().toString())).getId());
|
||||
}
|
||||
});
|
||||
viewBinding.newIssueMilestoneSpinner.setOnItemClickListener((parent, view, position, id) -> {
|
||||
if(position == 0) {
|
||||
milestoneId = 0;
|
||||
}
|
||||
else if(view instanceof TextView) {
|
||||
milestoneId = Math.toIntExact(Objects.requireNonNull(milestonesList.get(((TextView) view).getText().toString())).getId());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Milestone>> call, @NonNull Throwable t) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Milestone>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (v == viewBinding.newIssueDueDate) {
|
||||
if(v == viewBinding.newIssueDueDate) {
|
||||
|
||||
final Calendar c = Calendar.getInstance();
|
||||
int mYear = c.get(Calendar.YEAR);
|
||||
final int mMonth = c.get(Calendar.MONTH);
|
||||
final int mDay = c.get(Calendar.DAY_OF_MONTH);
|
||||
final Calendar c = Calendar.getInstance();
|
||||
int mYear = c.get(Calendar.YEAR);
|
||||
final int mMonth = c.get(Calendar.MONTH);
|
||||
final int mDay = c.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
|
||||
(view, year, monthOfYear, dayOfMonth) -> {
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this, (view, year, monthOfYear, dayOfMonth) -> {
|
||||
viewBinding.newIssueDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
|
||||
currentDate = new Date(year - 1900, monthOfYear, dayOfMonth);
|
||||
}, mYear, mMonth, mDay);
|
||||
datePickerDialog.show();
|
||||
}
|
||||
else if(v == viewBinding.createNewIssueButton) {
|
||||
}, mYear, mMonth, mDay);
|
||||
datePickerDialog.show();
|
||||
}
|
||||
else if(v == viewBinding.createNewIssueButton) {
|
||||
|
||||
processNewIssue();
|
||||
}
|
||||
}
|
||||
processNewIssue();
|
||||
}
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
private void disableProcessButton() {
|
||||
|
||||
viewBinding.createNewIssueButton.setEnabled(false);
|
||||
}
|
||||
viewBinding.createNewIssueButton.setEnabled(false);
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
private void enableProcessButton() {
|
||||
|
||||
viewBinding.createNewIssueButton.setEnabled(true);
|
||||
}
|
||||
viewBinding.createNewIssueButton.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,333 +35,333 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
public static boolean refreshLabels = false;
|
||||
|
||||
private ActivityCreateLabelBinding activityCreateLabelBinding;
|
||||
private View.OnClickListener onClickListener;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private RepositoryContext repository;
|
||||
private String labelColor = "";
|
||||
private String labelColorDefault = "";
|
||||
private RepositoryContext repository;
|
||||
private String labelColor = "";
|
||||
private final View.OnClickListener createLabelListener = v -> processCreateLabel();
|
||||
private String labelColorDefault = "";
|
||||
private final View.OnClickListener updateLabelListener = v -> processUpdateLabel();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
activityCreateLabelBinding = ActivityCreateLabelBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityCreateLabelBinding.getRoot());
|
||||
activityCreateLabelBinding = ActivityCreateLabelBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityCreateLabelBinding.getRoot());
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
|
||||
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("delete")) {
|
||||
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("delete")) {
|
||||
|
||||
deleteLabel(Integer.parseInt(Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
deleteLabel(Integer.parseInt(Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
activityCreateLabelBinding.labelName.requestFocus();
|
||||
assert imm != null;
|
||||
imm.showSoftInput(activityCreateLabelBinding.labelName, InputMethodManager.SHOW_IMPLICIT);
|
||||
activityCreateLabelBinding.labelName.requestFocus();
|
||||
assert imm != null;
|
||||
imm.showSoftInput(activityCreateLabelBinding.labelName, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
final ColorPicker cp = new ColorPicker(CreateLabelActivity.this, 235, 113, 33);
|
||||
final ColorPicker cp = new ColorPicker(CreateLabelActivity.this, 235, 113, 33);
|
||||
|
||||
initCloseListener();
|
||||
activityCreateLabelBinding.close.setOnClickListener(onClickListener);
|
||||
activityCreateLabelBinding.colorPicker.setOnClickListener(v -> cp.show());
|
||||
initCloseListener();
|
||||
activityCreateLabelBinding.close.setOnClickListener(onClickListener);
|
||||
activityCreateLabelBinding.colorPicker.setOnClickListener(v -> cp.show());
|
||||
|
||||
cp.setCallback(color -> {
|
||||
cp.setCallback(color -> {
|
||||
|
||||
//Log.i("#Hex no alpha", String.format("#%06X", (0xFFFFFF & color)));
|
||||
activityCreateLabelBinding.colorPicker.setBackgroundColor(color);
|
||||
labelColor = String.format("#%06X", (0xFFFFFF & color));
|
||||
cp.dismiss();
|
||||
});
|
||||
//Log.i("#Hex no alpha", String.format("#%06X", (0xFFFFFF & color)));
|
||||
activityCreateLabelBinding.colorPicker.setBackgroundColor(color);
|
||||
labelColor = String.format("#%06X", (0xFFFFFF & color));
|
||||
cp.dismiss();
|
||||
});
|
||||
|
||||
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("edit")) {
|
||||
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("edit")) {
|
||||
|
||||
activityCreateLabelBinding.labelName.setText(getIntent().getStringExtra("labelTitle"));
|
||||
int labelColor_ = Color.parseColor("#" + getIntent().getStringExtra("labelColor"));
|
||||
activityCreateLabelBinding.colorPicker.setBackgroundColor(labelColor_);
|
||||
labelColorDefault = "#" + getIntent().getStringExtra("labelColor");
|
||||
activityCreateLabelBinding.labelName.setText(getIntent().getStringExtra("labelTitle"));
|
||||
int labelColor_ = Color.parseColor("#" + getIntent().getStringExtra("labelColor"));
|
||||
activityCreateLabelBinding.colorPicker.setBackgroundColor(labelColor_);
|
||||
labelColorDefault = "#" + getIntent().getStringExtra("labelColor");
|
||||
|
||||
TextView toolbar_title = activityCreateLabelBinding.toolbarTitle;
|
||||
toolbar_title.setText(getResources().getString(R.string.pageTitleLabelUpdate));
|
||||
activityCreateLabelBinding.createLabelButton.setText(getResources().getString(R.string.newUpdateButtonCopy));
|
||||
TextView toolbar_title = activityCreateLabelBinding.toolbarTitle;
|
||||
toolbar_title.setText(getResources().getString(R.string.pageTitleLabelUpdate));
|
||||
activityCreateLabelBinding.createLabelButton.setText(getResources().getString(R.string.newUpdateButtonCopy));
|
||||
|
||||
activityCreateLabelBinding.createLabelButton.setOnClickListener(updateLabelListener);
|
||||
return;
|
||||
}
|
||||
activityCreateLabelBinding.createLabelButton.setOnClickListener(updateLabelListener);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!connToInternet) {
|
||||
if(!connToInternet) {
|
||||
|
||||
activityCreateLabelBinding.createLabelButton.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
activityCreateLabelBinding.createLabelButton.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
|
||||
activityCreateLabelBinding.createLabelButton.setOnClickListener(createLabelListener);
|
||||
}
|
||||
}
|
||||
activityCreateLabelBinding.createLabelButton.setOnClickListener(createLabelListener);
|
||||
}
|
||||
}
|
||||
|
||||
private final View.OnClickListener createLabelListener = v -> processCreateLabel();
|
||||
private void processUpdateLabel() {
|
||||
|
||||
private final View.OnClickListener updateLabelListener = v -> processUpdateLabel();
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
private void processUpdateLabel() {
|
||||
String updateLabelName = Objects.requireNonNull(activityCreateLabelBinding.labelName.getText()).toString();
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
String updateLabelColor;
|
||||
if(labelColor.isEmpty()) {
|
||||
|
||||
String updateLabelName = Objects.requireNonNull(activityCreateLabelBinding.labelName.getText()).toString();
|
||||
updateLabelColor = labelColorDefault;
|
||||
}
|
||||
else {
|
||||
|
||||
String updateLabelColor;
|
||||
if(labelColor.isEmpty()) {
|
||||
updateLabelColor = labelColor;
|
||||
}
|
||||
|
||||
updateLabelColor = labelColorDefault;
|
||||
}
|
||||
else {
|
||||
if(!connToInternet) {
|
||||
|
||||
updateLabelColor = labelColor;
|
||||
}
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!connToInternet) {
|
||||
if(updateLabelName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
Toasty.error(ctx, getString(R.string.labelEmptyError));
|
||||
return;
|
||||
}
|
||||
|
||||
if(updateLabelName.equals("")) {
|
||||
if(!AppUtil.checkStrings(updateLabelName)) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.labelEmptyError));
|
||||
return;
|
||||
}
|
||||
Toasty.error(ctx, getString(R.string.labelNameError));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!AppUtil.checkStrings(updateLabelName)) {
|
||||
disableProcessButton();
|
||||
patchLabel(repository, updateLabelName, updateLabelColor, Integer.parseInt(Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||
}
|
||||
|
||||
Toasty.error(ctx, getString(R.string.labelNameError));
|
||||
return;
|
||||
}
|
||||
private void processCreateLabel() {
|
||||
|
||||
disableProcessButton();
|
||||
patchLabel(repository, updateLabelName, updateLabelColor, Integer.parseInt(
|
||||
Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||
}
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
private void processCreateLabel() {
|
||||
String newLabelName = Objects.requireNonNull(activityCreateLabelBinding.labelName.getText()).toString();
|
||||
String newLabelColor;
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
if(labelColor.isEmpty()) {
|
||||
|
||||
String newLabelName = Objects.requireNonNull(activityCreateLabelBinding.labelName.getText()).toString();
|
||||
String newLabelColor;
|
||||
newLabelColor = String.format("#%06X", (0xFFFFFF & ContextCompat.getColor(ctx, R.color.releasePre)));
|
||||
}
|
||||
else {
|
||||
|
||||
if(labelColor.isEmpty()) {
|
||||
newLabelColor = labelColor;
|
||||
}
|
||||
|
||||
newLabelColor = String.format("#%06X", (0xFFFFFF & ContextCompat.getColor(ctx, R.color.releasePre)));
|
||||
}
|
||||
else {
|
||||
if(!connToInternet) {
|
||||
|
||||
newLabelColor = labelColor;
|
||||
}
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!connToInternet) {
|
||||
if(newLabelName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
Toasty.error(ctx, getString(R.string.labelEmptyError));
|
||||
return;
|
||||
}
|
||||
|
||||
if(newLabelName.equals("")) {
|
||||
if(!AppUtil.checkStrings(newLabelName)) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.labelEmptyError));
|
||||
return;
|
||||
}
|
||||
Toasty.error(ctx, getString(R.string.labelNameError));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!AppUtil.checkStrings(newLabelName)) {
|
||||
disableProcessButton();
|
||||
createNewLabel(newLabelName, newLabelColor);
|
||||
}
|
||||
|
||||
Toasty.error(ctx, getString(R.string.labelNameError));
|
||||
return;
|
||||
}
|
||||
private void createNewLabel(String newLabelName, String newLabelColor) {
|
||||
|
||||
disableProcessButton();
|
||||
createNewLabel(newLabelName, newLabelColor);
|
||||
}
|
||||
|
||||
private void createNewLabel(String newLabelName, String newLabelColor) {
|
||||
|
||||
CreateLabelOption createLabelFunc = new CreateLabelOption();
|
||||
CreateLabelOption createLabelFunc = new CreateLabelOption();
|
||||
createLabelFunc.setColor(newLabelColor);
|
||||
createLabelFunc.setName(newLabelName);
|
||||
|
||||
Call<Label> call;
|
||||
Call<Label> call;
|
||||
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).orgCreateLabel(getIntent().getStringExtra("orgName"), createLabelFunc);
|
||||
}
|
||||
else if(repository != null) {
|
||||
call = RetrofitClient.getApiInterface(ctx).orgCreateLabel(getIntent().getStringExtra("orgName"), createLabelFunc);
|
||||
}
|
||||
else if(repository != null) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).issueCreateLabel(repository.getOwner(), repository.getName(), createLabelFunc);
|
||||
} else {
|
||||
call = RetrofitClient.getApiInterface(ctx).issueCreateLabel(repository.getOwner(), repository.getName(), createLabelFunc);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Label> call, @NonNull retrofit2.Response<Label> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Label> call, @NonNull retrofit2.Response<Label> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.labelCreated));
|
||||
refreshLabels = true;
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
Toasty.success(ctx, getString(R.string.labelCreated));
|
||||
refreshLabels = true;
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Label> call, @NonNull Throwable t) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Label> call, @NonNull Throwable t) {
|
||||
|
||||
labelColor = "";
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
labelColor = "";
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void patchLabel(RepositoryContext repository, String updateLabelName, String updateLabelColor, int labelId) {
|
||||
private void patchLabel(RepositoryContext repository, String updateLabelName, String updateLabelColor, int labelId) {
|
||||
|
||||
EditLabelOption createLabelFunc = new EditLabelOption();
|
||||
EditLabelOption createLabelFunc = new EditLabelOption();
|
||||
createLabelFunc.setColor(updateLabelColor);
|
||||
createLabelFunc.setName(updateLabelName);
|
||||
|
||||
Call<Label> call;
|
||||
Call<Label> call;
|
||||
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).orgEditLabel(getIntent().getStringExtra("orgName"), (long) labelId, createLabelFunc);
|
||||
}
|
||||
else {
|
||||
call = RetrofitClient.getApiInterface(ctx).orgEditLabel(getIntent().getStringExtra("orgName"), (long) labelId, createLabelFunc);
|
||||
}
|
||||
else {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).issueEditLabel(repository.getOwner(), repository.getName(), (long) labelId, createLabelFunc);
|
||||
}
|
||||
call = RetrofitClient.getApiInterface(ctx).issueEditLabel(repository.getOwner(), repository.getName(), (long) labelId, createLabelFunc);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Label> call, @NonNull retrofit2.Response<Label> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Label> call, @NonNull retrofit2.Response<Label> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if(response.code() == 200) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.labelUpdated));
|
||||
refreshLabels = true;
|
||||
finish();
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
Toasty.success(ctx, getString(R.string.labelUpdated));
|
||||
refreshLabels = true;
|
||||
finish();
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Label> call, @NonNull Throwable t) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Label> call, @NonNull Throwable t) {
|
||||
|
||||
labelColor = "";
|
||||
labelColorDefault = "";
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
labelColor = "";
|
||||
labelColorDefault = "";
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
private void deleteLabel(int labelId) {
|
||||
private void deleteLabel(int labelId) {
|
||||
|
||||
Call<Void> call;
|
||||
Call<Void> call;
|
||||
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).orgDeleteLabel(getIntent().getStringExtra("orgName"), (long) labelId);
|
||||
}
|
||||
else {
|
||||
call = RetrofitClient.getApiInterface(ctx).orgDeleteLabel(getIntent().getStringExtra("orgName"), (long) labelId);
|
||||
}
|
||||
else {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).issueDeleteLabel(repository.getOwner(), repository.getName(), (long) labelId);
|
||||
}
|
||||
call = RetrofitClient.getApiInterface(ctx).issueDeleteLabel(repository.getOwner(), repository.getName(), (long) labelId);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
if(response.code() == 204) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.labelDeleteText));
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
Toasty.success(ctx, getString(R.string.labelDeleteText));
|
||||
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||
|
||||
OrganizationLabelsViewModel.loadOrgLabelsList(getIntent().getStringExtra("orgName"), ctx, null, null);
|
||||
}
|
||||
else {
|
||||
OrganizationLabelsViewModel.loadOrgLabelsList(getIntent().getStringExtra("orgName"), ctx, null, null);
|
||||
}
|
||||
else {
|
||||
|
||||
LabelsViewModel.loadLabelsList(repository.getOwner(), repository.getName(), ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
LabelsViewModel.loadLabelsList(repository.getOwner(), repository.getName(), ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
private void disableProcessButton() {
|
||||
|
||||
activityCreateLabelBinding.createLabelButton.setEnabled(false);
|
||||
}
|
||||
activityCreateLabelBinding.createLabelButton.setEnabled(false);
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
private void enableProcessButton() {
|
||||
|
||||
activityCreateLabelBinding.createLabelButton.setEnabled(true);
|
||||
}
|
||||
activityCreateLabelBinding.createLabelButton.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if(repository == null) return;
|
||||
if(repository == null) {
|
||||
return;
|
||||
}
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,11 +11,7 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.CreatePullRequestOption;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.gitnex.tea4j.v2.models.PullRequest;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.LabelsActions;
|
||||
import org.mian.gitnex.adapters.LabelsListAdapter;
|
||||
|
@ -26,12 +22,7 @@ import org.mian.gitnex.fragments.PullRequestsFragment;
|
|||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
|
@ -41,21 +32,18 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreatePullRequestActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
private ActivityCreatePrBinding viewBinding;
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private final List<String> assignees = new ArrayList<>();
|
||||
private int milestoneId;
|
||||
private Date currentDate = null;
|
||||
|
||||
private RepositoryContext repository;
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
|
||||
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
||||
|
||||
LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
List<String> branchesList = new ArrayList<>();
|
||||
List<Label> labelsList = new ArrayList<>();
|
||||
private View.OnClickListener onClickListener;
|
||||
private ActivityCreatePrBinding viewBinding;
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private int milestoneId;
|
||||
private Date currentDate = null;
|
||||
private RepositoryContext repository;
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
|
@ -76,23 +64,21 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
labelsAdapter = new LabelsListAdapter(labelsList, CreatePullRequestActivity.this, labelsIds);
|
||||
labelsAdapter = new LabelsListAdapter(labelsList, CreatePullRequestActivity.this, labelsIds);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
viewBinding.prDueDate.setOnClickListener(dueDate ->
|
||||
setDueDate()
|
||||
);
|
||||
viewBinding.prDueDate.setOnClickListener(dueDate -> setDueDate());
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
|
@ -119,7 +105,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
|
||||
assignees.add("");
|
||||
|
||||
if (labelsIds.size() == 0) {
|
||||
if(labelsIds.size() == 0) {
|
||||
|
||||
labelsIds.add(0);
|
||||
}
|
||||
|
@ -163,9 +149,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
createPullRequest.setLabels(labelIds);
|
||||
createPullRequest.setDueDate(currentDate);
|
||||
|
||||
Call<PullRequest> transferCall = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoCreatePullRequest(repository.getOwner(), repository.getName(), createPullRequest);
|
||||
Call<PullRequest> transferCall = RetrofitClient.getApiInterface(ctx).repoCreatePullRequest(repository.getOwner(), repository.getName(), createPullRequest);
|
||||
|
||||
transferCall.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -224,8 +208,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
private void showLabels() {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
CustomLabelsSelectionDialogBinding labelsBinding = CustomLabelsSelectionDialogBinding.inflate(
|
||||
LayoutInflater.from(ctx));
|
||||
CustomLabelsSelectionDialogBinding labelsBinding = CustomLabelsSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
View view = labelsBinding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
|
||||
|
@ -235,9 +218,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
|
||||
private void getBranches(String repoOwner, String repoName) {
|
||||
|
||||
Call<List<Branch>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoListBranches(repoOwner, repoName, null, null);
|
||||
Call<List<Branch>> call = RetrofitClient.getApiInterface(ctx).repoListBranches(repoOwner, repoName, null, null);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -277,9 +258,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
private void getMilestones(String repoOwner, String repoName, int resultLimit) {
|
||||
|
||||
String msState = "open";
|
||||
Call<List<Milestone>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
Call<List<Milestone>> call = RetrofitClient.getApiInterface(ctx).issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -336,11 +315,10 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
final int mMonth = c.get(Calendar.MONTH);
|
||||
final int mDay = c.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
|
||||
(view, year, monthOfYear, dayOfMonth) -> {
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this, (view, year, monthOfYear, dayOfMonth) -> {
|
||||
viewBinding.prDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
|
||||
currentDate = new Date(year - 1900, monthOfYear, dayOfMonth);
|
||||
}, mYear, mMonth, mDay);
|
||||
}, mYear, mMonth, mDay);
|
||||
datePickerDialog.show();
|
||||
}
|
||||
|
||||
|
@ -364,4 +342,5 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,18 +8,9 @@ import android.util.Log;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.CreateReleaseOption;
|
||||
import org.gitnex.tea4j.v2.models.CreateTagOption;
|
||||
import org.gitnex.tea4j.v2.models.Release;
|
||||
import org.gitnex.tea4j.v2.models.Tag;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateReleaseBinding;
|
||||
|
|
|
@ -7,12 +7,7 @@ import android.os.Looper;
|
|||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.v2.models.CreateRepoOption;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
|
|
|
@ -33,250 +33,226 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClickListener {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView teamName;
|
||||
private TextView teamDesc;
|
||||
private TextView teamPermission;
|
||||
private TextView teamPermissionDetail;
|
||||
private TextView teamAccessControls;
|
||||
private TextView teamAccessControlsArray;
|
||||
private Button createTeamButton;
|
||||
private final String[] permissionList = {"Read", "Write", "Admin"};
|
||||
public int permissionSelectedChoice = -1;
|
||||
private final String[] permissionList = {"Read", "Write", "Admin"};
|
||||
private final String[] accessControlsList = new String[]{"Code", "Issues", "Pull Request", "Releases", "Wiki", "External Wiki", "External Issues"};
|
||||
private final boolean[] selectedAccessControlsTrueFalse = new boolean[]{false, false, false, false, false, false, false};
|
||||
public int permissionSelectedChoice = -1;
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView teamName;
|
||||
private TextView teamDesc;
|
||||
private TextView teamPermission;
|
||||
private TextView teamPermissionDetail;
|
||||
private TextView teamAccessControls;
|
||||
private TextView teamAccessControlsArray;
|
||||
private Button createTeamButton;
|
||||
private List<String> pushAccessList;
|
||||
|
||||
private final String[] accessControlsList = new String[] {
|
||||
"Code",
|
||||
"Issues",
|
||||
"Pull Request",
|
||||
"Releases",
|
||||
"Wiki",
|
||||
"External Wiki",
|
||||
"External Issues"
|
||||
};
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
private List<String> pushAccessList;
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
private final boolean[] selectedAccessControlsTrueFalse = new boolean[]{
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
};
|
||||
ActivityCreateTeamByOrgBinding activityCreateTeamByOrgBinding = ActivityCreateTeamByOrgBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityCreateTeamByOrgBinding.getRoot());
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
ActivityCreateTeamByOrgBinding activityCreateTeamByOrgBinding = ActivityCreateTeamByOrgBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityCreateTeamByOrgBinding.getRoot());
|
||||
ImageView closeActivity = activityCreateTeamByOrgBinding.close;
|
||||
teamName = activityCreateTeamByOrgBinding.teamName;
|
||||
teamDesc = activityCreateTeamByOrgBinding.teamDesc;
|
||||
teamPermission = activityCreateTeamByOrgBinding.teamPermission;
|
||||
teamPermissionDetail = activityCreateTeamByOrgBinding.teamPermissionDetail;
|
||||
teamAccessControls = activityCreateTeamByOrgBinding.teamAccessControls;
|
||||
teamAccessControlsArray = activityCreateTeamByOrgBinding.teamAccessControlsArray;
|
||||
createTeamButton = activityCreateTeamByOrgBinding.createTeamButton;
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
teamName.requestFocus();
|
||||
assert imm != null;
|
||||
imm.showSoftInput(teamName, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
ImageView closeActivity = activityCreateTeamByOrgBinding.close;
|
||||
teamName = activityCreateTeamByOrgBinding.teamName;
|
||||
teamDesc = activityCreateTeamByOrgBinding.teamDesc;
|
||||
teamPermission = activityCreateTeamByOrgBinding.teamPermission;
|
||||
teamPermissionDetail = activityCreateTeamByOrgBinding.teamPermissionDetail;
|
||||
teamAccessControls = activityCreateTeamByOrgBinding.teamAccessControls;
|
||||
teamAccessControlsArray = activityCreateTeamByOrgBinding.teamAccessControlsArray;
|
||||
createTeamButton = activityCreateTeamByOrgBinding.createTeamButton;
|
||||
|
||||
teamName.requestFocus();
|
||||
assert imm != null;
|
||||
imm.showSoftInput(teamName, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
teamPermission.setOnClickListener(view -> {
|
||||
teamPermission.setOnClickListener(view -> {
|
||||
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilderPerm = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.newTeamPermission)
|
||||
.setCancelable(permissionSelectedChoice != -1)
|
||||
.setSingleChoiceItems(permissionList, permissionSelectedChoice, (dialogInterface, i) -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilderPerm = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.newTeamPermission).setCancelable(permissionSelectedChoice != -1)
|
||||
.setSingleChoiceItems(permissionList, permissionSelectedChoice, (dialogInterface, i) -> {
|
||||
|
||||
permissionSelectedChoice = i;
|
||||
teamPermission.setText(permissionList[i]);
|
||||
permissionSelectedChoice = i;
|
||||
teamPermission.setText(permissionList[i]);
|
||||
|
||||
switch(permissionList[i]) {
|
||||
case "Read":
|
||||
switch(permissionList[i]) {
|
||||
case "Read":
|
||||
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionRead);
|
||||
break;
|
||||
case "Write":
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionRead);
|
||||
break;
|
||||
case "Write":
|
||||
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionWrite);
|
||||
break;
|
||||
case "Admin":
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionWrite);
|
||||
break;
|
||||
case "Admin":
|
||||
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionAdmin);
|
||||
break;
|
||||
default:
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionAdmin);
|
||||
break;
|
||||
default:
|
||||
|
||||
teamPermissionDetail.setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
teamPermissionDetail.setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
|
||||
dialogInterface.dismiss();
|
||||
});
|
||||
dialogInterface.dismiss();
|
||||
});
|
||||
|
||||
materialAlertDialogBuilderPerm.create().show();
|
||||
});
|
||||
materialAlertDialogBuilderPerm.create().show();
|
||||
});
|
||||
|
||||
teamAccessControls.setOnClickListener(v -> {
|
||||
teamAccessControls.setOnClickListener(v -> {
|
||||
|
||||
teamAccessControls.setText("");
|
||||
teamAccessControlsArray.setText("");
|
||||
pushAccessList = Arrays.asList(accessControlsList);
|
||||
teamAccessControls.setText("");
|
||||
teamAccessControlsArray.setText("");
|
||||
pushAccessList = Arrays.asList(accessControlsList);
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setMultiChoiceItems(accessControlsList, selectedAccessControlsTrueFalse, (dialog, which, isChecked) -> {})
|
||||
.setTitle(R.string.newTeamAccessControls)
|
||||
.setPositiveButton(R.string.okButton, (dialog, which) -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setMultiChoiceItems(accessControlsList, selectedAccessControlsTrueFalse, (dialog, which, isChecked) -> {
|
||||
}).setTitle(R.string.newTeamAccessControls).setPositiveButton(R.string.okButton, (dialog, which) -> {
|
||||
|
||||
int selectedVal = 0;
|
||||
while(selectedVal < selectedAccessControlsTrueFalse.length)
|
||||
{
|
||||
boolean value = selectedAccessControlsTrueFalse[selectedVal];
|
||||
int selectedVal = 0;
|
||||
while(selectedVal < selectedAccessControlsTrueFalse.length) {
|
||||
boolean value = selectedAccessControlsTrueFalse[selectedVal];
|
||||
|
||||
String repoCode = "";
|
||||
if(selectedVal == 0) {
|
||||
repoCode = "repo.code";
|
||||
}
|
||||
if(selectedVal == 1) {
|
||||
repoCode = "repo.issues";
|
||||
}
|
||||
if(selectedVal == 2) {
|
||||
repoCode = "repo.pulls";
|
||||
}
|
||||
if(selectedVal == 3) {
|
||||
repoCode = "repo.releases";
|
||||
}
|
||||
if(selectedVal == 4) {
|
||||
repoCode = "repo.wiki";
|
||||
}
|
||||
if(selectedVal == 5) {
|
||||
repoCode = "repo.ext_wiki";
|
||||
}
|
||||
if(selectedVal == 6) {
|
||||
repoCode = "repo.ext_issues";
|
||||
}
|
||||
String repoCode = "";
|
||||
if(selectedVal == 0) {
|
||||
repoCode = "repo.code";
|
||||
}
|
||||
if(selectedVal == 1) {
|
||||
repoCode = "repo.issues";
|
||||
}
|
||||
if(selectedVal == 2) {
|
||||
repoCode = "repo.pulls";
|
||||
}
|
||||
if(selectedVal == 3) {
|
||||
repoCode = "repo.releases";
|
||||
}
|
||||
if(selectedVal == 4) {
|
||||
repoCode = "repo.wiki";
|
||||
}
|
||||
if(selectedVal == 5) {
|
||||
repoCode = "repo.ext_wiki";
|
||||
}
|
||||
if(selectedVal == 6) {
|
||||
repoCode = "repo.ext_issues";
|
||||
}
|
||||
|
||||
if(value){
|
||||
if(value) {
|
||||
|
||||
teamAccessControls.setText(getString(R.string.newTeamPermissionValues, teamAccessControls.getText(), pushAccessList.get(selectedVal)));
|
||||
teamAccessControlsArray.setText(getString(R.string.newTeamPermissionValuesFinal, teamAccessControlsArray.getText(), repoCode));
|
||||
}
|
||||
teamAccessControls.setText(getString(R.string.newTeamPermissionValues, teamAccessControls.getText(), pushAccessList.get(selectedVal)));
|
||||
teamAccessControlsArray.setText(getString(R.string.newTeamPermissionValuesFinal, teamAccessControlsArray.getText(), repoCode));
|
||||
}
|
||||
|
||||
selectedVal++;
|
||||
}
|
||||
selectedVal++;
|
||||
}
|
||||
|
||||
String data = String.valueOf(teamAccessControls.getText());
|
||||
if(!data.equals("")) {
|
||||
String data = String.valueOf(teamAccessControls.getText());
|
||||
if(!data.equals("")) {
|
||||
|
||||
teamAccessControls.setText(data.substring(0, data.length() - 2));
|
||||
}
|
||||
teamAccessControls.setText(data.substring(0, data.length() - 2));
|
||||
}
|
||||
|
||||
String dataArray = String.valueOf(teamAccessControlsArray.getText());
|
||||
String dataArray = String.valueOf(teamAccessControlsArray.getText());
|
||||
|
||||
if(!dataArray.equals("")) {
|
||||
if(!dataArray.equals("")) {
|
||||
|
||||
teamAccessControlsArray.setText(dataArray.substring(0, dataArray.length() - 2));
|
||||
}
|
||||
});
|
||||
teamAccessControlsArray.setText(dataArray.substring(0, dataArray.length() - 2));
|
||||
}
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
|
||||
createTeamButton.setEnabled(false);
|
||||
createTeamButton.setEnabled(false);
|
||||
|
||||
if(!connToInternet) {
|
||||
if(!connToInternet) {
|
||||
|
||||
createTeamButton.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius(8);
|
||||
shape.setColor(ResourcesCompat.getColor(getResources(), R.color.hintColor, null));
|
||||
createTeamButton.setBackground(shape);
|
||||
}
|
||||
else {
|
||||
createTeamButton.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius(8);
|
||||
shape.setColor(ResourcesCompat.getColor(getResources(), R.color.hintColor, null));
|
||||
createTeamButton.setBackground(shape);
|
||||
}
|
||||
else {
|
||||
|
||||
createTeamButton.setEnabled(true);
|
||||
createTeamButton.setOnClickListener(this);
|
||||
}
|
||||
}
|
||||
createTeamButton.setEnabled(true);
|
||||
createTeamButton.setOnClickListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void processCreateTeam() {
|
||||
private void processCreateTeam() {
|
||||
|
||||
final String orgName = getIntent().getStringExtra("orgName");
|
||||
final String orgName = getIntent().getStringExtra("orgName");
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
String newTeamName = teamName.getText().toString();
|
||||
String newTeamDesc = teamDesc.getText().toString();
|
||||
String newTeamPermission = teamPermission.getText().toString().toLowerCase();
|
||||
String newTeamAccessControls = teamAccessControlsArray.getText().toString();
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
String newTeamName = teamName.getText().toString();
|
||||
String newTeamDesc = teamDesc.getText().toString();
|
||||
String newTeamPermission = teamPermission.getText().toString().toLowerCase();
|
||||
String newTeamAccessControls = teamAccessControlsArray.getText().toString();
|
||||
|
||||
if(!connToInternet) {
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
if (newTeamName.equals("")) {
|
||||
if(newTeamName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.teamNameEmpty));
|
||||
return;
|
||||
}
|
||||
Toasty.error(ctx, getString(R.string.teamNameEmpty));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!AppUtil.checkStringsWithAlphaNumericDashDotUnderscore(newTeamName)) {
|
||||
if(!AppUtil.checkStringsWithAlphaNumericDashDotUnderscore(newTeamName)) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.teamNameError));
|
||||
return;
|
||||
}
|
||||
Toasty.warning(ctx, getString(R.string.teamNameError));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!newTeamDesc.equals("")) {
|
||||
if(!newTeamDesc.equals("")) {
|
||||
|
||||
if(!AppUtil.checkStrings(newTeamDesc)) {
|
||||
if(!AppUtil.checkStrings(newTeamDesc)) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.teamDescError));
|
||||
return;
|
||||
}
|
||||
Toasty.warning(ctx, getString(R.string.teamDescError));
|
||||
return;
|
||||
}
|
||||
|
||||
if(newTeamDesc.length() > 100) {
|
||||
if(newTeamDesc.length() > 100) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.teamDescLimit));
|
||||
return;
|
||||
}
|
||||
}
|
||||
Toasty.warning(ctx, getString(R.string.teamDescLimit));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (newTeamPermission.equals("")) {
|
||||
if(newTeamPermission.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.teamPermissionEmpty));
|
||||
return;
|
||||
}
|
||||
Toasty.error(ctx, getString(R.string.teamPermissionEmpty));
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> newTeamAccessControls_ = new ArrayList<>(Arrays.asList(newTeamAccessControls.split(",")));
|
||||
List<String> newTeamAccessControls_ = new ArrayList<>(Arrays.asList(newTeamAccessControls.split(",")));
|
||||
|
||||
for (int i = 0; i < newTeamAccessControls_.size(); i++) {
|
||||
for(int i = 0; i < newTeamAccessControls_.size(); i++) {
|
||||
|
||||
newTeamAccessControls_.set(i, newTeamAccessControls_.get(i).trim());
|
||||
}
|
||||
newTeamAccessControls_.set(i, newTeamAccessControls_.get(i).trim());
|
||||
}
|
||||
|
||||
createNewTeamCall(orgName, newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls_);
|
||||
}
|
||||
createNewTeamCall(orgName, newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls_);
|
||||
}
|
||||
|
||||
private void createNewTeamCall(String orgName, String newTeamName, String newTeamDesc, String newTeamPermission, List<String> newTeamAccessControls) {
|
||||
private void createNewTeamCall(String orgName, String newTeamName, String newTeamDesc, String newTeamPermission, List<String> newTeamAccessControls) {
|
||||
|
||||
CreateTeamOption createNewTeamJson = new CreateTeamOption();
|
||||
CreateTeamOption createNewTeamJson = new CreateTeamOption();
|
||||
createNewTeamJson.setName(newTeamName);
|
||||
createNewTeamJson.setDescription(newTeamDesc);
|
||||
switch(newTeamPermission) {
|
||||
|
@ -292,59 +268,57 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
}
|
||||
createNewTeamJson.setUnits(newTeamAccessControls);
|
||||
|
||||
Call<Team> call3 = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.orgCreateTeam(orgName, createNewTeamJson);
|
||||
Call<Team> call3 = RetrofitClient.getApiInterface(ctx).orgCreateTeam(orgName, createNewTeamJson);
|
||||
|
||||
call3.enqueue(new Callback<Team>() {
|
||||
call3.enqueue(new Callback<Team>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Team> call, @NonNull retrofit2.Response<Team> response2) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Team> call, @NonNull retrofit2.Response<Team> response2) {
|
||||
|
||||
if(response2.isSuccessful()) {
|
||||
if(response2.isSuccessful()) {
|
||||
|
||||
if(response2.code() == 201) {
|
||||
if(response2.code() == 201) {
|
||||
|
||||
TeamsByOrgFragment.resumeTeams = true;
|
||||
TeamsByOrgFragment.resumeTeams = true;
|
||||
|
||||
Toasty.success(ctx, getString(R.string.teamCreated));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
else if(response2.code() == 404) {
|
||||
Toasty.success(ctx, getString(R.string.teamCreated));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
else if(response2.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
||||
}
|
||||
else if(response2.code() == 401) {
|
||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
||||
}
|
||||
else if(response2.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Team> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Team> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if(v == createTeamButton) {
|
||||
if(v == createTeamButton) {
|
||||
|
||||
processCreateTeam();
|
||||
}
|
||||
}
|
||||
processCreateTeam();
|
||||
}
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,11 +9,7 @@ import android.util.Log;
|
|||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.gitnex.tea4j.v2.models.ContentsResponse;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
import org.gitnex.tea4j.v2.models.PullRequest;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
|
@ -95,7 +91,9 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
hostUrlExternal = hostExternal;
|
||||
}
|
||||
|
||||
if (hostUrlExternal == null) hostUrlExternal = "";
|
||||
if(hostUrlExternal == null) {
|
||||
hostUrlExternal = "";
|
||||
}
|
||||
|
||||
if(hostUri.toLowerCase().contains(hostUrlExternal.toLowerCase())) {
|
||||
|
||||
|
@ -131,8 +129,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
finish();
|
||||
}
|
||||
else {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
getUserOrOrg(data.getLastPathSegment()), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> getUserOrOrg(data.getLastPathSegment()), 500);
|
||||
}
|
||||
}
|
||||
else if(data.getPathSegments().size() == 2) {
|
||||
|
@ -159,12 +156,11 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
}
|
||||
else if(!data.getPathSegments().get(0).equals("") & !data.getLastPathSegment().equals("")) { // go to repo
|
||||
String repo = data.getLastPathSegment();
|
||||
if (repo.endsWith(".git")) { // Git clone URL
|
||||
if(repo.endsWith(".git")) { // Git clone URL
|
||||
repo = repo.substring(0, repo.length() - 4);
|
||||
}
|
||||
String finalRepo = repo;
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), finalRepo, "repo"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), finalRepo, "repo"), 500);
|
||||
}
|
||||
else { // no action, show options
|
||||
showNoActionButtons();
|
||||
|
@ -179,15 +175,11 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
issueIntent.putExtra("openedFromLink", "true");
|
||||
|
||||
String[] urlSplitted = data.toString().split("#");
|
||||
if (urlSplitted.length == 2) {
|
||||
if(urlSplitted.length == 2) {
|
||||
issueIntent.putExtra("issueComment", urlSplitted[1]);
|
||||
}
|
||||
|
||||
IssueContext issue = new IssueContext(
|
||||
new RepositoryContext(data.getPathSegments().get(0), data.getPathSegments().get(1), ctx),
|
||||
Integer.parseInt(data.getLastPathSegment()),
|
||||
"Issue"
|
||||
);
|
||||
IssueContext issue = new IssueContext(new RepositoryContext(data.getPathSegments().get(0), data.getPathSegments().get(1), ctx), Integer.parseInt(data.getLastPathSegment()), "Issue");
|
||||
|
||||
issue.getRepository().saveToDB(ctx);
|
||||
|
||||
|
@ -197,12 +189,10 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
finish();
|
||||
}
|
||||
else if(Objects.requireNonNull(data.getLastPathSegment()).contains("issues")) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "issue"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "issue"), 500);
|
||||
}
|
||||
else if(data.getLastPathSegment().equals("new")) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "issueNew"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "issueNew"), 500);
|
||||
}
|
||||
else {
|
||||
ctx.startActivity(mainIntent);
|
||||
|
@ -216,7 +206,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
String[] urlSplitted = data.toString().split("#");
|
||||
if (urlSplitted.length == 2) {
|
||||
if(urlSplitted.length == 2) {
|
||||
issueIntent.putExtra("issueComment", urlSplitted[1]);
|
||||
}
|
||||
|
||||
|
@ -225,8 +215,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
|
||||
}
|
||||
else if(Objects.requireNonNull(data.getLastPathSegment()).contains("pulls")) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "pull"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "pull"), 500);
|
||||
}
|
||||
else if(data.getLastPathSegment().equals("files")) { // pr diff
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
@ -241,36 +230,29 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
else if(data.getPathSegments().get(2).equals("compare")) { // new pull request
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "pullNew"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "pullNew"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("commit")) {
|
||||
repoIntent.putExtra("sha", data.getLastPathSegment());
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "commit"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "commit"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("commits")) { // commits list
|
||||
String branch = data.getLastPathSegment();
|
||||
repoIntent.putExtra("branchName", branch);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "commitsList"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "commitsList"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("milestones") && data.getLastPathSegment().equals("new")) { // new milestone
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestonesNew"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestonesNew"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("milestones")) { // milestones
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("milestone")) { // milestone
|
||||
repoIntent.putExtra("milestoneId", data.getLastPathSegment());
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("releases") && data.getLastPathSegment().equals("new")) { // new release
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "newRelease"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "newRelease"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("releases")) { // releases
|
||||
if(data.getPathSegments().size() == 5) {
|
||||
|
@ -278,49 +260,39 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
repoIntent.putExtra("releaseTagName", data.getLastPathSegment());
|
||||
}
|
||||
}
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1),
|
||||
"releases"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "releases"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("labels")) { // labels
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "labels"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "labels"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("settings")) { // repo settings
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "settings"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "settings"), 500);
|
||||
}
|
||||
else if(data.getLastPathSegment().equals("branches")) { // branches list
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "branchesList"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "branchesList"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().size() == 5 && data.getPathSegments().get(2).equals("src") && data.getPathSegments().get(3).equals("branch")) { // branch
|
||||
repoIntent.putExtra("selectedBranch", data.getLastPathSegment());
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "branch"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "branch"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("src") && data.getPathSegments().get(3).equals("branch")) { // file/dir
|
||||
StringBuilder filePath = new StringBuilder();
|
||||
ArrayList<String> segments = new ArrayList<>(data.getPathSegments());
|
||||
segments.subList(0, 5).clear();
|
||||
for (String item : segments) {
|
||||
for(String item : segments) {
|
||||
filePath.append(item);
|
||||
filePath.append("/");
|
||||
}
|
||||
filePath.deleteCharAt(filePath.toString().length() - 1);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
getFile(data.getPathSegments().get(0),
|
||||
data.getPathSegments().get(1), filePath.toString(), data.getPathSegments().get(4)), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> getFile(data.getPathSegments().get(0), data.getPathSegments().get(1), filePath.toString(), data.getPathSegments().get(4)), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("wiki")) { // wiki
|
||||
|
||||
if(data.getQueryParameter("action") != null && data.getQueryParameter("action").equalsIgnoreCase("_new")) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "wikiNew"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "wikiNew"), 500);
|
||||
}
|
||||
else {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "wiki"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "wiki"), 500);
|
||||
}
|
||||
}
|
||||
else { // no action, show options
|
||||
|
@ -352,9 +324,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
|
||||
Integer port = data.getPort() >= 0 ? data.getPort() : null;
|
||||
|
||||
URI host = UrlBuilder.fromString(UrlHelper.fixScheme(data.getHost(), "https"))
|
||||
.withPort(port)
|
||||
.toUri();
|
||||
URI host = UrlBuilder.fromString(UrlHelper.fixScheme(data.getHost(), "https")).withPort(port).toUri();
|
||||
|
||||
AppUtil.openUrlInBrowser(this, String.valueOf(host));
|
||||
finish();
|
||||
|
@ -371,9 +341,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
|
||||
private void getPullRequest(String repoOwner, String repoName, int index) {
|
||||
|
||||
Call<PullRequest> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoGetPullRequest(repoOwner, repoName, (long) index);
|
||||
Call<PullRequest> call = RetrofitClient.getApiInterface(ctx).repoGetPullRequest(repoOwner, repoName, (long) index);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -417,9 +385,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
|
||||
private void goToRepoSection(String repoOwner, String repoName, String type) {
|
||||
|
||||
Call<Repository> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoGet(repoOwner, repoName);
|
||||
Call<Repository> call = RetrofitClient.getApiInterface(ctx).repoGet(repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -559,7 +525,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
goToRepoSection(owner, repo, "dir");
|
||||
}
|
||||
|
||||
private void showNoActionButtons() {
|
||||
private void showNoActionButtons() {
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
|
||||
switch(tinyDB.getInt("defaultScreenId")) {
|
||||
|
@ -627,4 +593,5 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,12 +11,7 @@ import android.util.Log;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.v2.models.EditIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
|
@ -33,12 +28,7 @@ import org.mian.gitnex.helpers.Toasty;
|
|||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
|
|
|
@ -8,11 +8,7 @@ import android.graphics.Bitmap;
|
|||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.*;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
@ -23,12 +19,7 @@ import org.mian.gitnex.R;
|
|||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityFileViewBinding;
|
||||
import org.mian.gitnex.fragments.BottomSheetFileViewerFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Images;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.notifications.Notifications;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
|
|
|
@ -8,12 +8,7 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.*;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
@ -31,14 +26,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.gitnex.tea4j.v2.models.EditIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.gitnex.tea4j.v2.models.IssueLabelsOption;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.gitnex.tea4j.v2.models.PullRequest;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.gitnex.tea4j.v2.models.WatchInfo;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.AssigneesActions;
|
||||
import org.mian.gitnex.actions.LabelsActions;
|
||||
|
@ -54,29 +42,14 @@ import org.mian.gitnex.databinding.CustomPrInfoDialogBinding;
|
|||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetSingleIssueFragment;
|
||||
import org.mian.gitnex.fragments.IssuesFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.DividerItemDecorator;
|
||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import org.mian.gitnex.viewmodels.IssueCommentsViewModel;
|
||||
import org.mian.gitnex.views.ReactionList;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
@ -87,49 +60,46 @@ import retrofit2.Response;
|
|||
|
||||
public class IssueDetailActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener, AssigneesListAdapter.AssigneesListAdapterListener, BottomSheetListener {
|
||||
|
||||
public static boolean singleIssueUpdate = false;
|
||||
public static boolean commentPosted = false;
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
private final List<User> assigneesList = new ArrayList<>();
|
||||
public boolean commentEdited = false;
|
||||
private IssueCommentsAdapter adapter;
|
||||
|
||||
private String repoOwner;
|
||||
private String repoName;
|
||||
private int issueIndex;
|
||||
private String issueCreator;
|
||||
private IssueContext issue;
|
||||
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
private AssigneesListAdapter assigneesAdapter;
|
||||
|
||||
private List<Integer> currentLabelsIds = new ArrayList<>();
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
private final List<User> assigneesList = new ArrayList<>();
|
||||
private List<String> assigneesListData = new ArrayList<>();
|
||||
private List<String> currentAssignees = new ArrayList<>();
|
||||
|
||||
private ActivityIssueDetailBinding viewBinding;
|
||||
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
||||
|
||||
public static boolean singleIssueUpdate = false;
|
||||
public boolean commentEdited = false;
|
||||
public static boolean commentPosted = false;
|
||||
|
||||
private IssueCommentsViewModel issueCommentsModel;
|
||||
private Runnable showMenu = () -> {
|
||||
};
|
||||
private boolean loadingFinishedIssue = false;
|
||||
private boolean loadingFinishedPr = false;
|
||||
private boolean loadingFinishedRepo = false;
|
||||
public ActivityResultLauncher<Intent> editIssueLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("issueEdited", false)) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
public ActivityResultLauncher<Intent> editIssueLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("issueEdited", false)) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
viewBinding.frameAssignees.removeAllViews();
|
||||
viewBinding.frameLabels.removeAllViews();
|
||||
issue.setIssue(null);
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
|
||||
viewBinding.frameAssignees.removeAllViews();
|
||||
viewBinding.frameLabels.removeAllViews();
|
||||
issue.setIssue(null);
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
|
||||
}, 500);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -174,9 +144,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
viewBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
issueCommentsModel
|
||||
.loadIssueComments(repoOwner, repoName, issueIndex,
|
||||
ctx);
|
||||
issueCommentsModel.loadIssueComments(repoOwner, repoName, issueIndex, ctx);
|
||||
|
||||
}, 500));
|
||||
|
||||
|
@ -212,7 +180,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
}
|
||||
|
||||
@Override
|
||||
public void labelsInterface(List<String> data) { }
|
||||
public void labelsInterface(List<String> data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void labelsIdsInterface(List<Integer> data) {
|
||||
|
@ -230,8 +199,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
assigneesAdapter.updateList(currentAssignees);
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding = CustomAssigneesSelectionDialogBinding.inflate(
|
||||
LayoutInflater.from(ctx));
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding = CustomAssigneesSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
View view = assigneesBinding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
|
||||
|
@ -279,9 +247,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
EditIssueOption updateAssigneeJson = new EditIssueOption().assignees(assigneesListData);
|
||||
|
||||
Call<Issue> call3 = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueEditIssue(repoOwner, repoName, (long) issueIndex, updateAssigneeJson);
|
||||
Call<Issue> call3 = RetrofitClient.getApiInterface(ctx).issueEditIssue(repoOwner, repoName, (long) issueIndex, updateAssigneeJson);
|
||||
|
||||
call3.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -335,9 +301,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
IssueLabelsOption patchIssueLabels = new IssueLabelsOption();
|
||||
patchIssueLabels.setLabels(labelIds);
|
||||
|
||||
Call<List<Label>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueReplaceLabels(repoOwner, repoName, (long) issueIndex, patchIssueLabels);
|
||||
Call<List<Label>> call = RetrofitClient.getApiInterface(ctx).issueReplaceLabels(repoOwner, repoName, (long) issueIndex, patchIssueLabels);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -383,12 +347,10 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
});
|
||||
}
|
||||
|
||||
private Runnable showMenu = () -> {};
|
||||
private boolean loadingFinishedIssue = false;
|
||||
private boolean loadingFinishedPr = false;
|
||||
private boolean loadingFinishedRepo = false;
|
||||
private void updateMenuState() {
|
||||
if(loadingFinishedIssue && loadingFinishedPr && loadingFinishedRepo) showMenu.run();
|
||||
if(loadingFinishedIssue && loadingFinishedPr && loadingFinishedRepo) {
|
||||
showMenu.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -402,7 +364,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
inflater.inflate(R.menu.pr_info_menu, menu);
|
||||
}
|
||||
}
|
||||
showMenu = () -> {}; // reset Runnable
|
||||
showMenu = () -> {
|
||||
}; // reset Runnable
|
||||
};
|
||||
updateMenuState();
|
||||
return true;
|
||||
|
@ -415,8 +378,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
if(id == android.R.id.home) {
|
||||
|
||||
if(issue.hasIssue() && getIntent().getStringExtra("openedFromLink") != null &&
|
||||
getIntent().getStringExtra("openedFromLink").equals("true")) {
|
||||
if(issue.hasIssue() && getIntent().getStringExtra("openedFromLink") != null && getIntent().getStringExtra("openedFromLink").equals("true")) {
|
||||
Intent intent = issue.getRepository().getIntent(ctx, RepoDetailActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
|
@ -466,9 +428,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
viewBinding.scrollViewComments.post(() -> {
|
||||
|
||||
issueCommentsModel
|
||||
.loadIssueComments(repoOwner, repoName, issueIndex,
|
||||
ctx, () -> viewBinding.scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN));
|
||||
issueCommentsModel.loadIssueComments(repoOwner, repoName, issueIndex, ctx, () -> viewBinding.scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN));
|
||||
|
||||
commentPosted = false;
|
||||
});
|
||||
|
@ -478,9 +438,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
viewBinding.scrollViewComments.post(() -> {
|
||||
|
||||
issueCommentsModel
|
||||
.loadIssueComments(repoOwner, repoName, issueIndex,
|
||||
ctx);
|
||||
issueCommentsModel.loadIssueComments(repoOwner, repoName, issueIndex, ctx);
|
||||
commentEdited = false;
|
||||
});
|
||||
}
|
||||
|
@ -501,26 +459,25 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
private void fetchDataAsync(String owner, String repo, int index) {
|
||||
|
||||
issueCommentsModel.getIssueCommentList(owner, repo, index, ctx)
|
||||
.observe(this, issueCommentsMain -> {
|
||||
issueCommentsModel.getIssueCommentList(owner, repo, index, ctx).observe(this, issueCommentsMain -> {
|
||||
|
||||
assert issueCommentsMain != null;
|
||||
assert issueCommentsMain != null;
|
||||
|
||||
if(issueCommentsMain.size() > 0) {
|
||||
if(issueCommentsMain.size() > 0) {
|
||||
|
||||
viewBinding.divider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
viewBinding.divider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("repoOwner", repoOwner);
|
||||
bundle.putString("repoName", repoName);
|
||||
bundle.putInt("issueNumber", issueIndex);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("repoOwner", repoOwner);
|
||||
bundle.putString("repoName", repoName);
|
||||
bundle.putInt("issueNumber", issueIndex);
|
||||
|
||||
adapter = new IssueCommentsAdapter(ctx, bundle, issueCommentsMain, getSupportFragmentManager(), this::onResume, issue);
|
||||
adapter = new IssueCommentsAdapter(ctx, bundle, issueCommentsMain, getSupportFragmentManager(), this::onResume, issue);
|
||||
|
||||
viewBinding.recyclerView.setAdapter(adapter);
|
||||
viewBinding.recyclerView.setAdapter(adapter);
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void getSingleIssue(String repoOwner, String repoName, int issueIndex) {
|
||||
|
@ -531,8 +488,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
return;
|
||||
}
|
||||
|
||||
Call<Issue> call = RetrofitClient.getApiInterface(ctx)
|
||||
.issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
Call<Issue> call = RetrofitClient.getApiInterface(ctx).issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -575,34 +531,33 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
}
|
||||
|
||||
private void getSubscribed() {
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueCheckSubscription(repoOwner, repoName, (long) issueIndex)
|
||||
.enqueue(new Callback<>() {
|
||||
RetrofitClient.getApiInterface(ctx).issueCheckSubscription(repoOwner, repoName, (long) issueIndex).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull Response<WatchInfo> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull Response<WatchInfo> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
assert response.body() != null;
|
||||
issue.setSubscribed(response.body().isSubscribed());
|
||||
}
|
||||
else {
|
||||
issue.setSubscribed(false);
|
||||
}
|
||||
if(response.isSuccessful()) {
|
||||
assert response.body() != null;
|
||||
issue.setSubscribed(response.body().isSubscribed());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
else {
|
||||
issue.setSubscribed(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
issue.setSubscribed(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initWithIssue() {
|
||||
if(!issue.getRepository().hasRepository()) {
|
||||
getRepoInfo();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
loadingFinishedRepo = true;
|
||||
}
|
||||
loadingFinishedIssue = true;
|
||||
|
@ -633,7 +588,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
updateMenuState();
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_issue);
|
||||
ImageViewCompat.setImageTintList(viewBinding.issuePrState, ColorStateList.valueOf(ctx.getResources().getColor(R.color.iconIssuePrClosedColor)));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
loadingFinishedPr = true;
|
||||
updateMenuState();
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_issue);
|
||||
|
@ -645,10 +601,9 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
final String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
issueCreator = issue.getIssue().getUser().getLogin();
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(viewBinding.assigneeAvatar);
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(getResources(), R.color.lightGray, null) + "'>" + appCtx.getResources()
|
||||
.getString(R.string.hash) + issue.getIssue().getNumber() + "</font>";
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop()
|
||||
.into(viewBinding.assigneeAvatar);
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(getResources(), R.color.lightGray, null) + "'>" + appCtx.getResources().getString(R.string.hash) + issue.getIssue().getNumber() + "</font>";
|
||||
viewBinding.issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + EmojiParser.parseToUnicode(issue.getIssue().getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
String cleanIssueDescription = issue.getIssue().getBody().trim();
|
||||
|
||||
|
@ -681,9 +636,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
ImageView assigneesView = new ImageView(ctx);
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getAssignees().get(i).getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(48, 0)).resize(96, 96).centerCrop()
|
||||
.into(assigneesView);
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getAssignees().get(i).getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(48, 0)).resize(96, 96)
|
||||
.centerCrop().into(assigneesView);
|
||||
|
||||
viewBinding.frameAssignees.addView(assigneesView);
|
||||
assigneesView.setLayoutParams(params1);
|
||||
|
@ -721,8 +675,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
viewBinding.assigneesScrollView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
|
||||
if(issue.getIssue().getLabels() != null) {
|
||||
|
@ -743,10 +696,9 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
int height = AppUtil.getPixelsFromDensity(ctx, 20);
|
||||
int textSize = AppUtil.getPixelsFromScaledDensity(ctx, 12);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT)
|
||||
.textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(ctx, 10)))
|
||||
.height(height).endConfig().buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(ctx, 18));
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(ctx, 10))).height(height).endConfig()
|
||||
.buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(ctx, 18));
|
||||
|
||||
labelsView.setImageDrawable(drawable);
|
||||
viewBinding.frameLabels.addView(labelsView);
|
||||
|
@ -765,8 +717,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", locale);
|
||||
String dueDate = formatter.format(issue.getIssue().getDueDate());
|
||||
viewBinding.issueDueDate.setText(dueDate);
|
||||
viewBinding.issueDueDate
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getDueDate()), ctx));
|
||||
viewBinding.issueDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getDueDate()), ctx));
|
||||
}
|
||||
else if(timeFormat.equals("normal1")) {
|
||||
|
||||
|
@ -787,8 +738,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
edited = getString(R.string.colorfulBulletSpan) + getString(R.string.modifiedText);
|
||||
viewBinding.issueModified.setVisibility(View.VISIBLE);
|
||||
viewBinding.issueModified.setText(edited);
|
||||
viewBinding.issueModified
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getUpdatedAt()), ctx));
|
||||
viewBinding.issueModified.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getUpdatedAt()), ctx));
|
||||
}
|
||||
else {
|
||||
|
||||
|
@ -821,8 +771,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
|
||||
viewBinding.issueCreatedTime
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getCreatedAt()), ctx));
|
||||
viewBinding.issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getCreatedAt()), ctx));
|
||||
}
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
|
@ -909,4 +858,5 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,30 +3,17 @@ package org.mian.gitnex.activities;
|
|||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import org.gitnex.tea4j.v2.models.AccessToken;
|
||||
import org.gitnex.tea4j.v2.models.CreateAccessTokenOption;
|
||||
import org.gitnex.tea4j.v2.models.GeneralAPISettings;
|
||||
import org.gitnex.tea4j.v2.models.ServerVersion;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.databinding.ActivityLoginBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.NetworkStatusObserver;
|
||||
import org.mian.gitnex.helpers.PathsHelper;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.UrlHelper;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.structs.Protocol;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -43,15 +30,12 @@ import retrofit2.Callback;
|
|||
|
||||
public class LoginActivity extends BaseActivity {
|
||||
|
||||
private enum LoginType {BASIC, TOKEN}
|
||||
|
||||
private Button loginButton;
|
||||
private EditText instanceUrlET, loginUidET, loginPassword, otpCode, loginTokenCode;
|
||||
private AutoCompleteTextView protocolSpinner;
|
||||
private RadioGroup loginMethod;
|
||||
private String device_id = "token";
|
||||
private String selectedProtocol;
|
||||
|
||||
private URI instanceUrl;
|
||||
private Version giteaVersion;
|
||||
private int maxResponseItems = 50;
|
||||
|
@ -96,7 +80,8 @@ public class LoginActivity extends BaseActivity {
|
|||
if(R.id.loginToken == loginMethod.getCheckedRadioButtonId()) {
|
||||
AppUtil.setMultiVisibility(View.GONE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout), findViewById(R.id.otpCodeLayout));
|
||||
findViewById(R.id.loginTokenCodeLayout).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
AppUtil.setMultiVisibility(View.VISIBLE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout), findViewById(R.id.otpCodeLayout));
|
||||
findViewById(R.id.loginTokenCodeLayout).setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -105,7 +90,8 @@ public class LoginActivity extends BaseActivity {
|
|||
if(checkedId == R.id.loginToken) {
|
||||
AppUtil.setMultiVisibility(View.GONE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout), findViewById(R.id.otpCodeLayout));
|
||||
findViewById(R.id.loginTokenCodeLayout).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
AppUtil.setMultiVisibility(View.VISIBLE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout), findViewById(R.id.otpCodeLayout));
|
||||
findViewById(R.id.loginTokenCodeLayout).setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -114,7 +100,8 @@ public class LoginActivity extends BaseActivity {
|
|||
networkStatusObserver.registerNetworkStatusListener(hasNetworkConnection -> runOnUiThread(() -> {
|
||||
if(hasNetworkConnection) {
|
||||
enableProcessButton();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
disableProcessButton();
|
||||
loginButton.setText(getResources().getString(R.string.btnLogin));
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
|
@ -148,8 +135,7 @@ public class LoginActivity extends BaseActivity {
|
|||
|
||||
URI rawInstanceUrl = UrlBuilder.fromString(UrlHelper.fixScheme(instanceUrlET.getText().toString().replaceAll("[\\uFEFF|#]", "").trim(), "http")).toUri();
|
||||
|
||||
instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(selectedProtocol.toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/"))
|
||||
.toUri();
|
||||
instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(selectedProtocol.toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/")).toUri();
|
||||
|
||||
// cache values to make them available the next time the user wants to log in
|
||||
tinyDB.putString("loginType", loginType.name().toLowerCase());
|
||||
|
@ -234,8 +220,7 @@ public class LoginActivity extends BaseActivity {
|
|||
});
|
||||
}
|
||||
|
||||
private void versionCheck(final String loginUid, final String loginPass, final int loginOTP, final String loginToken,
|
||||
final LoginType loginType) {
|
||||
private void versionCheck(final String loginUid, final String loginPass, final int loginOTP, final String loginToken, final LoginType loginType) {
|
||||
|
||||
Call<ServerVersion> callVersion;
|
||||
|
||||
|
@ -247,10 +232,11 @@ public class LoginActivity extends BaseActivity {
|
|||
|
||||
String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||
|
||||
if (loginOTP != 0) {
|
||||
if(loginOTP != 0) {
|
||||
|
||||
callVersion = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null).getVersion(loginOTP);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
callVersion = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null).getVersion();
|
||||
}
|
||||
|
@ -277,15 +263,12 @@ public class LoginActivity extends BaseActivity {
|
|||
|
||||
if(giteaVersion.less(getString(R.string.versionLow))) {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion()))
|
||||
.setNeutralButton(getString(R.string.cancelButton), (dialog, which) -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setNeutralButton(getString(R.string.cancelButton), (dialog, which) -> {
|
||||
|
||||
dialog.dismiss();
|
||||
enableProcessButton();
|
||||
})
|
||||
.setPositiveButton(getString(R.string.textContinue), (dialog, which) -> {
|
||||
}).setPositiveButton(getString(R.string.textContinue), (dialog, which) -> {
|
||||
|
||||
dialog.dismiss();
|
||||
login(loginType, loginUid, loginPass, loginOTP, loginToken);
|
||||
|
@ -432,8 +415,7 @@ public class LoginActivity extends BaseActivity {
|
|||
Call<Void> delToken;
|
||||
if(loginOTP != 0) {
|
||||
|
||||
delToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null)
|
||||
.userDeleteAccessToken(loginOTP, loginUid, String.valueOf(t.getId()));
|
||||
delToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null).userDeleteAccessToken(loginOTP, loginUid, String.valueOf(t.getId()));
|
||||
}
|
||||
else {
|
||||
|
||||
|
@ -495,13 +477,11 @@ public class LoginActivity extends BaseActivity {
|
|||
|
||||
if(loginOTP != 0) {
|
||||
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null)
|
||||
.userCreateToken(loginOTP, loginUid, createUserToken);
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null).userCreateToken(loginOTP, loginUid, createUserToken);
|
||||
}
|
||||
else {
|
||||
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null)
|
||||
.userCreateToken(loginUid, createUserToken);
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null).userCreateToken(loginUid, createUserToken);
|
||||
}
|
||||
|
||||
callCreateToken.enqueue(new Callback<>() {
|
||||
|
@ -539,9 +519,8 @@ public class LoginActivity extends BaseActivity {
|
|||
|
||||
UserAccount account;
|
||||
if(!userAccountExists) {
|
||||
long accountId = userAccountsApi
|
||||
.createNewAccount(accountName, instanceUrl.toString(), userDetails.getLogin(), newToken.getSha1(),
|
||||
giteaVersion.toString(), maxResponseItems, defaultPagingNumber);
|
||||
long accountId = userAccountsApi.createNewAccount(accountName, instanceUrl.toString(), userDetails.getLogin(), newToken.getSha1(), giteaVersion.toString(), maxResponseItems,
|
||||
defaultPagingNumber);
|
||||
account = userAccountsApi.getAccountById((int) accountId);
|
||||
}
|
||||
else {
|
||||
|
@ -590,7 +569,6 @@ public class LoginActivity extends BaseActivity {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
private void loadDefaults() {
|
||||
|
||||
if(tinyDB.getString("loginType").equals(LoginType.BASIC.name().toLowerCase())) {
|
||||
|
@ -634,4 +612,6 @@ public class LoginActivity extends BaseActivity {
|
|||
loginButton.setEnabled(true);
|
||||
}
|
||||
|
||||
private enum LoginType {BASIC, TOKEN}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,26 +34,8 @@ import org.mian.gitnex.database.api.BaseApi;
|
|||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.databinding.ActivityMainBinding;
|
||||
import org.mian.gitnex.fragments.AdministrationFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetDraftsFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetMyIssuesFilterFragment;
|
||||
import org.mian.gitnex.fragments.DraftsFragment;
|
||||
import org.mian.gitnex.fragments.ExploreFragment;
|
||||
import org.mian.gitnex.fragments.MostVisitedReposFragment;
|
||||
import org.mian.gitnex.fragments.MyIssuesFragment;
|
||||
import org.mian.gitnex.fragments.MyProfileFragment;
|
||||
import org.mian.gitnex.fragments.MyRepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.NotificationsFragment;
|
||||
import org.mian.gitnex.fragments.OrganizationsFragment;
|
||||
import org.mian.gitnex.fragments.RepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.SettingsFragment;
|
||||
import org.mian.gitnex.fragments.StarredRepositoriesFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ChangeLog;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.fragments.*;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import org.mian.gitnex.structs.FragmentRefreshListener;
|
||||
import java.util.ArrayList;
|
||||
|
@ -98,9 +80,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
Handler handler = new Handler();
|
||||
|
||||
// DO NOT MOVE
|
||||
if(mainIntent.hasExtra("switchAccountId") &&
|
||||
AppUtil.switchToAccount(ctx, BaseApi.getInstance(ctx, UserAccountsApi.class)
|
||||
.getAccountById(mainIntent.getIntExtra("switchAccountId", 0)))) {
|
||||
if(mainIntent.hasExtra("switchAccountId") && AppUtil.switchToAccount(ctx, BaseApi.getInstance(ctx, UserAccountsApi.class).getAccountById(mainIntent.getIntExtra("switchAccountId", 0)))) {
|
||||
|
||||
mainIntent.removeExtra("switchAccountId");
|
||||
recreate();
|
||||
|
@ -208,7 +188,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
userEmail.setTypeface(myTypeface);
|
||||
userFullName.setTypeface(myTypeface);
|
||||
|
||||
if (getAccount().getUserInfo() != null) {
|
||||
if(getAccount().getUserInfo() != null) {
|
||||
String userEmailNav = getAccount().getUserInfo().getEmail();
|
||||
String userFullNameNav = getAccount().getFullName();
|
||||
String userAvatarNav = getAccount().getUserInfo().getAvatarUrl();
|
||||
|
@ -225,25 +205,25 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
|
||||
int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 3);
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(userAvatarNav).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(avatarRadius, 0)).resize(160, 160).centerCrop().into(userAvatar);
|
||||
PicassoService.getInstance(ctx).get().load(userAvatarNav).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(avatarRadius, 0)).resize(160, 160).centerCrop()
|
||||
.into(userAvatar);
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(userAvatarNav).transform(new BlurTransformation(ctx))
|
||||
.into(userAvatarBackground, new com.squareup.picasso.Callback() {
|
||||
PicassoService.getInstance(ctx).get().load(userAvatarNav).transform(new BlurTransformation(ctx)).into(userAvatarBackground, new com.squareup.picasso.Callback() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
||||
int textColor = new ColorInverter().getImageViewContrastColor(userAvatarBackground);
|
||||
int textColor = new ColorInverter().getImageViewContrastColor(userAvatarBackground);
|
||||
|
||||
userFullName.setTextColor(textColor);
|
||||
userEmail.setTextColor(textColor);
|
||||
}
|
||||
userFullName.setTextColor(textColor);
|
||||
userEmail.setTextColor(textColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,9 +242,10 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
@Override
|
||||
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
|
||||
|
||||
if (getAccount().getUserInfo() != null) {
|
||||
if(getAccount().getUserInfo() != null) {
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(getAccount().getUserInfo().isIsAdmin());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// hide first
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(false);
|
||||
}
|
||||
|
@ -275,10 +256,12 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerClosed(@NonNull View drawerView) {}
|
||||
public void onDrawerClosed(@NonNull View drawerView) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerStateChanged(int newState) {}
|
||||
public void onDrawerStateChanged(int newState) {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
@ -480,17 +463,13 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
|
||||
if(frag != null) {
|
||||
|
||||
new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.deleteAllDrafts)
|
||||
.setCancelable(false)
|
||||
.setMessage(R.string.deleteAllDraftsDialogMessage)
|
||||
new MaterialAlertDialogBuilder(ctx).setTitle(R.string.deleteAllDrafts).setCancelable(false).setMessage(R.string.deleteAllDraftsDialogMessage)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
|
||||
frag.deleteAllDrafts(currentActiveAccountId);
|
||||
dialog.dismiss();
|
||||
|
||||
})
|
||||
.setNeutralButton(R.string.cancelButton, null).show();
|
||||
}).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
else {
|
||||
|
||||
|
@ -761,6 +740,12 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
}
|
||||
|
||||
// My issues interface
|
||||
public FragmentRefreshListener getFragmentRefreshListener() { return fragmentRefreshListenerMyIssues; }
|
||||
public void setFragmentRefreshListenerMyIssues(FragmentRefreshListener fragmentRefreshListener) { this.fragmentRefreshListenerMyIssues = fragmentRefreshListener; }
|
||||
public FragmentRefreshListener getFragmentRefreshListener() {
|
||||
return fragmentRefreshListenerMyIssues;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListenerMyIssues(FragmentRefreshListener fragmentRefreshListener) {
|
||||
this.fragmentRefreshListenerMyIssues = fragmentRefreshListener;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,11 +3,7 @@ package org.mian.gitnex.activities;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.*;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
@ -20,12 +16,7 @@ import org.gitnex.tea4j.v2.models.OrganizationPermissions;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetOrganizationFragment;
|
||||
import org.mian.gitnex.fragments.MembersByOrgFragment;
|
||||
import org.mian.gitnex.fragments.OrganizationInfoFragment;
|
||||
import org.mian.gitnex.fragments.OrganizationLabelsFragment;
|
||||
import org.mian.gitnex.fragments.RepositoriesByOrgFragment;
|
||||
import org.mian.gitnex.fragments.TeamsByOrgFragment;
|
||||
import org.mian.gitnex.fragments.*;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import java.util.Objects;
|
||||
|
|
|
@ -19,12 +19,7 @@ import com.google.android.material.tabs.TabLayoutMediator;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetUserProfileFragment;
|
||||
import org.mian.gitnex.fragments.profile.DetailFragment;
|
||||
import org.mian.gitnex.fragments.profile.FollowersFragment;
|
||||
import org.mian.gitnex.fragments.profile.FollowingFragment;
|
||||
import org.mian.gitnex.fragments.profile.OrganizationsFragment;
|
||||
import org.mian.gitnex.fragments.profile.RepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.profile.StarredRepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.profile.*;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
|
|
|
@ -6,12 +6,7 @@ import android.content.Intent;
|
|||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
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.*;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
|
@ -26,27 +21,10 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|||
import com.google.android.material.progressindicator.LinearProgressIndicator;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.gitnex.tea4j.v2.models.WatchInfo;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetIssuesFilterFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetMilestonesFilterFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetPullRequestFilterFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetReleasesTagsFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetRepoFragment;
|
||||
import org.mian.gitnex.fragments.CollaboratorsFragment;
|
||||
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.RepoInfoFragment;
|
||||
import org.mian.gitnex.fragments.WikiFragment;
|
||||
import org.mian.gitnex.fragments.*;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
|
@ -65,71 +43,62 @@ import retrofit2.Response;
|
|||
|
||||
public class RepoDetailActivity extends BaseActivity implements BottomSheetListener {
|
||||
|
||||
public static boolean updateRepo = false;
|
||||
private final ActivityResultLauncher<Intent> settingsLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("nameChanged", false)) {
|
||||
recreate();
|
||||
}
|
||||
}
|
||||
});
|
||||
public ViewPager2 viewPager;
|
||||
public RepositoryContext repository;
|
||||
private TextView textViewBadgeIssue;
|
||||
private TextView textViewBadgePull;
|
||||
private TextView textViewBadgeRelease;
|
||||
private Typeface myTypeface;
|
||||
|
||||
private FragmentRefreshListener fragmentRefreshListener;
|
||||
private FragmentRefreshListener fragmentRefreshListenerPr;
|
||||
private FragmentRefreshListener fragmentRefreshListenerMilestone;
|
||||
private final ActivityResultLauncher<Intent> createMilestoneLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 201) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("milestoneCreated", false)) {
|
||||
if(fragmentRefreshListenerMilestone != null) {
|
||||
fragmentRefreshListenerMilestone.onRefresh(repository.getMilestoneState().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
private FragmentRefreshListener fragmentRefreshListenerFiles;
|
||||
private final ActivityResultLauncher<Intent> editFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("fileModified", false)) {
|
||||
if(fragmentRefreshListenerFiles != null) {
|
||||
fragmentRefreshListenerFiles.onRefresh(repository.getBranchRef());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
private FragmentRefreshListener fragmentRefreshListenerFilterIssuesByMilestone;
|
||||
private FragmentRefreshListener fragmentRefreshListenerReleases;
|
||||
|
||||
public ViewPager2 viewPager;
|
||||
|
||||
public RepositoryContext repository;
|
||||
|
||||
public static boolean updateRepo = false;
|
||||
private Dialog progressDialog;
|
||||
|
||||
private Dialog progressDialog; private final ActivityResultLauncher<Intent> createReleaseLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 201) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("updateReleases", false)) {
|
||||
if(fragmentRefreshListenerReleases != null) {
|
||||
fragmentRefreshListenerReleases.onRefresh(null);
|
||||
}
|
||||
repository.removeRepository();
|
||||
getRepoInfo(repository.getOwner(), repository.getName());
|
||||
}
|
||||
}
|
||||
});
|
||||
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
||||
|
||||
private Intent intentWiki;
|
||||
|
||||
private final ActivityResultLauncher<Intent> createReleaseLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 201) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("updateReleases", false)) {
|
||||
if(fragmentRefreshListenerReleases != null) fragmentRefreshListenerReleases.onRefresh(null);
|
||||
repository.removeRepository();
|
||||
getRepoInfo(repository.getOwner(), repository.getName());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private final ActivityResultLauncher<Intent> createMilestoneLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 201) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("milestoneCreated", false)) {
|
||||
if(fragmentRefreshListenerMilestone != null) fragmentRefreshListenerMilestone.onRefresh(repository.getMilestoneState().toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private final ActivityResultLauncher<Intent> editFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("fileModified", false)) {
|
||||
if(fragmentRefreshListenerFiles != null) fragmentRefreshListenerFiles.onRefresh(repository.getBranchRef());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private final ActivityResultLauncher<Intent> settingsLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("nameChanged", false)) {
|
||||
recreate();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
|
@ -204,7 +173,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
finish();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
finish();
|
||||
}
|
||||
return true;
|
||||
|
@ -389,9 +359,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
progressDialog.setContentView(R.layout.custom_progress_loader);
|
||||
progressDialog.show();
|
||||
|
||||
Call<List<Milestone>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueGetMilestonesList(repository.getOwner(), repository.getName(), "open", null, 1, 50);
|
||||
Call<List<Milestone>> call = RetrofitClient.getApiInterface(ctx).issueGetMilestonesList(repository.getOwner(), repository.getName(), "open", null, 1, 50);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -419,17 +387,15 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
}
|
||||
}
|
||||
|
||||
materialAlertDialogBuilder.setTitle(R.string.selectMilestone)
|
||||
.setSingleChoiceItems(milestonesList.toArray(new String[0]), selectedMilestone, (dialogInterface, i) -> {
|
||||
materialAlertDialogBuilder.setTitle(R.string.selectMilestone).setSingleChoiceItems(milestonesList.toArray(new String[0]), selectedMilestone, (dialogInterface, i) -> {
|
||||
|
||||
repository.setIssueMilestoneFilterName(milestonesList.get(i));
|
||||
repository.setIssueMilestoneFilterName(milestonesList.get(i));
|
||||
|
||||
if(getFragmentRefreshListenerFilterIssuesByMilestone() != null) {
|
||||
getFragmentRefreshListenerFilterIssuesByMilestone().onRefresh(milestonesList.get(i));
|
||||
}
|
||||
dialogInterface.dismiss();
|
||||
})
|
||||
.setNeutralButton(R.string.cancelButton, null);
|
||||
if(getFragmentRefreshListenerFilterIssuesByMilestone() != null) {
|
||||
getFragmentRefreshListenerFilterIssuesByMilestone().onRefresh(milestonesList.get(i));
|
||||
}
|
||||
dialogInterface.dismiss();
|
||||
}).setNeutralButton(R.string.cancelButton, null);
|
||||
materialAlertDialogBuilder.create().show();
|
||||
}
|
||||
}
|
||||
|
@ -457,9 +423,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
progressDialog.setContentView(R.layout.custom_progress_loader);
|
||||
progressDialog.show();
|
||||
|
||||
Call<List<Branch>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoListBranches(repository.getOwner(), repository.getName(), null, null);
|
||||
Call<List<Branch>> call = RetrofitClient.getApiInterface(ctx).repoListBranches(repository.getOwner(), repository.getName(), null, null);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -483,17 +447,15 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
}
|
||||
}
|
||||
|
||||
materialAlertDialogBuilder.setTitle(R.string.pageTitleChooseBranch)
|
||||
.setSingleChoiceItems(branchesList.toArray(new String[0]), selectedBranch, (dialogInterface, i) -> {
|
||||
materialAlertDialogBuilder.setTitle(R.string.pageTitleChooseBranch).setSingleChoiceItems(branchesList.toArray(new String[0]), selectedBranch, (dialogInterface, i) -> {
|
||||
|
||||
repository.setBranchRef(branchesList.get(i));
|
||||
repository.setBranchRef(branchesList.get(i));
|
||||
|
||||
if(getFragmentRefreshListenerFiles() != null) {
|
||||
getFragmentRefreshListenerFiles().onRefresh(branchesList.get(i));
|
||||
}
|
||||
dialogInterface.dismiss();
|
||||
})
|
||||
.setNeutralButton(R.string.cancelButton, null);
|
||||
if(getFragmentRefreshListenerFiles() != null) {
|
||||
getFragmentRefreshListenerFiles().onRefresh(branchesList.get(i));
|
||||
}
|
||||
dialogInterface.dismiss();
|
||||
}).setNeutralButton(R.string.cancelButton, null);
|
||||
materialAlertDialogBuilder.create().show();
|
||||
}
|
||||
}
|
||||
|
@ -505,49 +467,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
});
|
||||
}
|
||||
|
||||
public class ViewPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
public ViewPagerAdapter(@NonNull FragmentActivity fa) { super(fa); }
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
|
||||
Fragment fragment = null;
|
||||
|
||||
switch(position) {
|
||||
case 0: // Repository details
|
||||
return RepoInfoFragment.newInstance(repository);
|
||||
case 1: // Files
|
||||
return FilesFragment.newInstance(repository);
|
||||
case 2: // Issues
|
||||
fragment = IssuesFragment.newInstance(repository);
|
||||
break;
|
||||
case 3: // Pull requests
|
||||
fragment = PullRequestsFragment.newInstance(repository);
|
||||
break;
|
||||
case 4: // Releases
|
||||
return ReleasesFragment.newInstance(repository);
|
||||
case 5: // Wiki
|
||||
return WikiFragment.newInstance(repository);
|
||||
case 6: // Milestones
|
||||
fragment = MilestonesFragment.newInstance(repository);
|
||||
break;
|
||||
case 7: // Labels
|
||||
return LabelsFragment.newInstance(repository);
|
||||
case 8: // Collaborators
|
||||
return CollaboratorsFragment.newInstance(repository);
|
||||
}
|
||||
assert fragment != null;
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
|
||||
private void getRepoInfo(final String owner, String repo) {
|
||||
|
||||
LinearProgressIndicator loading = findViewById(R.id.loadingIndicator);
|
||||
|
@ -592,7 +511,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
ImageView repoTypeToolbar = findViewById(R.id.repoTypeToolbar);
|
||||
if(repository.getRepository().isPrivate()) {
|
||||
repoTypeToolbar.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
repoTypeToolbar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
@ -605,7 +525,9 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
|
||||
viewPager.setAdapter(new ViewPagerAdapter(this));
|
||||
|
||||
String[] tabTitles = {ctx.getResources().getString(R.string.tabTextInfo), ctx.getResources().getString(R.string.tabTextFiles), ctx.getResources().getString(R.string.pageTitleIssues), ctx.getResources().getString(R.string.tabPullRequests), ctx.getResources().getString(R.string.tabTextReleases), ctx.getResources().getString(R.string.wiki), ctx.getResources().getString(R.string.tabTextMl), ctx.getResources().getString(R.string.newIssueLabelsTitle), ctx.getResources().getString(R.string.tabTextCollaborators)};
|
||||
String[] tabTitles = {ctx.getResources().getString(R.string.tabTextInfo), ctx.getResources().getString(R.string.tabTextFiles), ctx.getResources().getString(R.string.pageTitleIssues),
|
||||
ctx.getResources().getString(R.string.tabPullRequests), ctx.getResources().getString(R.string.tabTextReleases), ctx.getResources().getString(R.string.wiki),
|
||||
ctx.getResources().getString(R.string.tabTextMl), ctx.getResources().getString(R.string.newIssueLabelsTitle), ctx.getResources().getString(R.string.tabTextCollaborators)};
|
||||
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> tab.setText(tabTitles[position])).attach();
|
||||
|
||||
ViewGroup viewGroup = (ViewGroup) tabLayout.getChildAt(0);
|
||||
|
@ -658,7 +580,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
}
|
||||
TextView openIssueTabView = Objects.requireNonNull(tabOpenIssues.getCustomView()).findViewById(R.id.counterBadgeIssueText);
|
||||
openIssueTabView.setTextColor(textColor);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
textViewBadgeIssue.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
@ -674,7 +597,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
}
|
||||
TextView openPullTabView = Objects.requireNonNull(tabOpenPulls.getCustomView()).findViewById(R.id.counterBadgePullText);
|
||||
openPullTabView.setTextColor(textColor);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
textViewBadgePull.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
@ -690,7 +614,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
}
|
||||
TextView openReleaseTabView = Objects.requireNonNull(tabOpenRelease.getCustomView()).findViewById(R.id.counterBadgeReleaseText);
|
||||
openReleaseTabView.setTextColor(textColor);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
textViewBadgeRelease.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
@ -833,33 +758,105 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
}
|
||||
|
||||
// Issues milestone filter interface
|
||||
public FragmentRefreshListener getFragmentRefreshListenerFilterIssuesByMilestone() { return fragmentRefreshListenerFilterIssuesByMilestone; }
|
||||
public FragmentRefreshListener getFragmentRefreshListenerFilterIssuesByMilestone() {
|
||||
return fragmentRefreshListenerFilterIssuesByMilestone;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListenerFilterIssuesByMilestone(FragmentRefreshListener fragmentRefreshListener) { this.fragmentRefreshListenerFilterIssuesByMilestone = fragmentRefreshListener; }
|
||||
public void setFragmentRefreshListenerFilterIssuesByMilestone(FragmentRefreshListener fragmentRefreshListener) {
|
||||
this.fragmentRefreshListenerFilterIssuesByMilestone = fragmentRefreshListener;
|
||||
}
|
||||
|
||||
// Issues interface
|
||||
public FragmentRefreshListener getFragmentRefreshListener() { return fragmentRefreshListener; }
|
||||
public FragmentRefreshListener getFragmentRefreshListener() {
|
||||
return fragmentRefreshListener;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListener(FragmentRefreshListener fragmentRefreshListener) { this.fragmentRefreshListener = fragmentRefreshListener; }
|
||||
public void setFragmentRefreshListener(FragmentRefreshListener fragmentRefreshListener) {
|
||||
this.fragmentRefreshListener = fragmentRefreshListener;
|
||||
}
|
||||
|
||||
// Pull request interface
|
||||
public FragmentRefreshListener getFragmentRefreshListenerPr() { return fragmentRefreshListenerPr; }
|
||||
public FragmentRefreshListener getFragmentRefreshListenerPr() {
|
||||
return fragmentRefreshListenerPr;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListenerPr(FragmentRefreshListener fragmentRefreshListenerPr) { this.fragmentRefreshListenerPr = fragmentRefreshListenerPr; }
|
||||
public void setFragmentRefreshListenerPr(FragmentRefreshListener fragmentRefreshListenerPr) {
|
||||
this.fragmentRefreshListenerPr = fragmentRefreshListenerPr;
|
||||
}
|
||||
|
||||
// Milestones interface
|
||||
public FragmentRefreshListener getFragmentRefreshListenerMilestone() { return fragmentRefreshListenerMilestone; }
|
||||
public FragmentRefreshListener getFragmentRefreshListenerMilestone() {
|
||||
return fragmentRefreshListenerMilestone;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListenerMilestone(FragmentRefreshListener fragmentRefreshListenerMilestone) { this.fragmentRefreshListenerMilestone = fragmentRefreshListenerMilestone; }
|
||||
public void setFragmentRefreshListenerMilestone(FragmentRefreshListener fragmentRefreshListenerMilestone) {
|
||||
this.fragmentRefreshListenerMilestone = fragmentRefreshListenerMilestone;
|
||||
}
|
||||
|
||||
// Files interface
|
||||
public FragmentRefreshListener getFragmentRefreshListenerFiles() { return fragmentRefreshListenerFiles; }
|
||||
public FragmentRefreshListener getFragmentRefreshListenerFiles() {
|
||||
return fragmentRefreshListenerFiles;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListenerFiles(FragmentRefreshListener fragmentRefreshListenerFiles) { this.fragmentRefreshListenerFiles = fragmentRefreshListenerFiles; }
|
||||
public void setFragmentRefreshListenerFiles(FragmentRefreshListener fragmentRefreshListenerFiles) {
|
||||
this.fragmentRefreshListenerFiles = fragmentRefreshListenerFiles;
|
||||
}
|
||||
|
||||
//Releases interface
|
||||
public FragmentRefreshListener getFragmentRefreshListenerReleases() { return fragmentRefreshListenerReleases; }
|
||||
public FragmentRefreshListener getFragmentRefreshListenerReleases() {
|
||||
return fragmentRefreshListenerReleases;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListenerReleases(FragmentRefreshListener fragmentRefreshListener) {
|
||||
this.fragmentRefreshListenerReleases = fragmentRefreshListener;
|
||||
}
|
||||
|
||||
public class ViewPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
public ViewPagerAdapter(@NonNull FragmentActivity fa) {
|
||||
super(fa);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
|
||||
Fragment fragment = null;
|
||||
|
||||
switch(position) {
|
||||
case 0: // Repository details
|
||||
return RepoInfoFragment.newInstance(repository);
|
||||
case 1: // Files
|
||||
return FilesFragment.newInstance(repository);
|
||||
case 2: // Issues
|
||||
fragment = IssuesFragment.newInstance(repository);
|
||||
break;
|
||||
case 3: // Pull requests
|
||||
fragment = PullRequestsFragment.newInstance(repository);
|
||||
break;
|
||||
case 4: // Releases
|
||||
return ReleasesFragment.newInstance(repository);
|
||||
case 5: // Wiki
|
||||
return WikiFragment.newInstance(repository);
|
||||
case 6: // Milestones
|
||||
fragment = MilestonesFragment.newInstance(repository);
|
||||
break;
|
||||
case 7: // Labels
|
||||
return LabelsFragment.newInstance(repository);
|
||||
case 8: // Collaborators
|
||||
return CollaboratorsFragment.newInstance(repository);
|
||||
}
|
||||
assert fragment != null;
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void setFragmentRefreshListenerReleases(FragmentRefreshListener fragmentRefreshListener) { this.fragmentRefreshListenerReleases = fragmentRefreshListener; }
|
||||
|
||||
}
|
||||
|
|
|
@ -116,9 +116,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
TransferRepoOption repositoryTransfer = new TransferRepoOption();
|
||||
repositoryTransfer.setNewOwner(newOwner);
|
||||
|
||||
Call<Repository> transferCall = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoTransfer(repositoryTransfer, repository.getOwner(), repository.getName());
|
||||
Call<Repository> transferCall = RetrofitClient.getApiInterface(ctx).repoTransfer(repositoryTransfer, repository.getOwner(), repository.getName());
|
||||
|
||||
transferCall.enqueue(new Callback<Repository>() {
|
||||
|
||||
|
@ -128,7 +126,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
transferRepoBinding.transfer.setVisibility(View.GONE);
|
||||
transferRepoBinding.processingRequest.setVisibility(View.VISIBLE);
|
||||
|
||||
if (response.code() == 202) {
|
||||
if(response.code() == 202) {
|
||||
|
||||
dialogRepo.dismiss();
|
||||
Toasty.success(ctx, getString(R.string.repoTransferSuccess));
|
||||
|
@ -138,7 +136,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||
RepositorySettingsActivity.this.startActivity(intent);
|
||||
}
|
||||
else if (response.code() == 404) {
|
||||
else if(response.code() == 404) {
|
||||
|
||||
transferRepoBinding.transfer.setVisibility(View.VISIBLE);
|
||||
transferRepoBinding.processingRequest.setVisibility(View.GONE);
|
||||
|
@ -187,9 +185,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
|
||||
private void deleteRepository() {
|
||||
|
||||
Call<Void> deleteCall = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoDelete(repository.getOwner(), repository.getName());
|
||||
Call<Void> deleteCall = RetrofitClient.getApiInterface(ctx).repoDelete(repository.getOwner(), repository.getName());
|
||||
|
||||
deleteCall.enqueue(new Callback<Void>() {
|
||||
|
||||
|
@ -199,7 +195,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
deleteRepoBinding.delete.setVisibility(View.GONE);
|
||||
deleteRepoBinding.processingRequest.setVisibility(View.VISIBLE);
|
||||
|
||||
if (response.code() == 204) {
|
||||
if(response.code() == 204) {
|
||||
|
||||
dialogRepo.dismiss();
|
||||
Toasty.success(ctx, getString(R.string.repoDeletionSuccess));
|
||||
|
@ -251,7 +247,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
|
||||
propBinding.repoEnableIssues.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
|
||||
if (isChecked) {
|
||||
if(isChecked) {
|
||||
propBinding.repoEnableTimer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
|
@ -275,22 +271,17 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
propBinding.repoEnableSquash.setChecked(repoInfo.isAllowSquashMerge());
|
||||
propBinding.repoEnableForceMerge.setChecked(repoInfo.isAllowRebaseExplicit());
|
||||
|
||||
propBinding.save.setOnClickListener(saveProperties -> saveRepositoryProperties(String.valueOf(propBinding.repoName.getText()),
|
||||
String.valueOf(propBinding.repoWebsite.getText()),
|
||||
String.valueOf(propBinding.repoDescription.getText()),
|
||||
propBinding.repoPrivate.isChecked(), propBinding.repoAsTemplate.isChecked(),
|
||||
propBinding.repoEnableIssues.isChecked(), propBinding.repoEnableWiki.isChecked(),
|
||||
propBinding.repoEnablePr.isChecked(), propBinding.repoEnableTimer.isChecked(),
|
||||
propBinding.repoEnableMerge.isChecked(), propBinding.repoEnableRebase.isChecked(),
|
||||
propBinding.repoEnableSquash.isChecked(), propBinding.repoEnableForceMerge.isChecked()));
|
||||
propBinding.save.setOnClickListener(
|
||||
saveProperties -> saveRepositoryProperties(String.valueOf(propBinding.repoName.getText()), String.valueOf(propBinding.repoWebsite.getText()), String.valueOf(propBinding.repoDescription.getText()),
|
||||
propBinding.repoPrivate.isChecked(), propBinding.repoAsTemplate.isChecked(), propBinding.repoEnableIssues.isChecked(), propBinding.repoEnableWiki.isChecked(), propBinding.repoEnablePr.isChecked(),
|
||||
propBinding.repoEnableTimer.isChecked(), propBinding.repoEnableMerge.isChecked(), propBinding.repoEnableRebase.isChecked(), propBinding.repoEnableSquash.isChecked(),
|
||||
propBinding.repoEnableForceMerge.isChecked()));
|
||||
|
||||
dialogRepo = materialAlertDialogBuilder.show();
|
||||
}
|
||||
|
||||
private void saveRepositoryProperties(String repoName, String repoWebsite, String repoDescription,
|
||||
boolean repoPrivate, boolean repoAsTemplate, boolean repoEnableIssues, boolean repoEnableWiki,
|
||||
boolean repoEnablePr, boolean repoEnableTimer, boolean repoEnableMerge, boolean repoEnableRebase,
|
||||
boolean repoEnableSquash, boolean repoEnableForceMerge) {
|
||||
private void saveRepositoryProperties(String repoName, String repoWebsite, String repoDescription, boolean repoPrivate, boolean repoAsTemplate, boolean repoEnableIssues, boolean repoEnableWiki, boolean repoEnablePr,
|
||||
boolean repoEnableTimer, boolean repoEnableMerge, boolean repoEnableRebase, boolean repoEnableSquash, boolean repoEnableForceMerge) {
|
||||
|
||||
EditRepoOption repoProps = new EditRepoOption();
|
||||
repoProps.setName(repoName);
|
||||
|
@ -307,9 +298,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
repoProps.setAllowSquashMerge(repoEnableSquash);
|
||||
repoProps.setAllowRebaseExplicit(repoEnableForceMerge);
|
||||
|
||||
Call<Repository> propsCall = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoEdit(repository.getOwner(), repository.getName(), repoProps);
|
||||
Call<Repository> propsCall = RetrofitClient.getApiInterface(ctx).repoEdit(repository.getOwner(), repository.getName(), repoProps);
|
||||
|
||||
propsCall.enqueue(new Callback<Repository>() {
|
||||
|
||||
|
@ -319,7 +308,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
propBinding.save.setVisibility(View.GONE);
|
||||
propBinding.processingRequest.setVisibility(View.VISIBLE);
|
||||
|
||||
if (response.code() == 200) {
|
||||
if(response.code() == 200) {
|
||||
|
||||
dialogRepo.dismiss();
|
||||
Toasty.success(ctx, getString(R.string.repoPropertiesSaveSuccess));
|
||||
|
@ -327,8 +316,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
repository.setRepository(response.body());
|
||||
|
||||
if(!repository.getName().equals(repoName)) {
|
||||
Objects.requireNonNull(BaseApi.getInstance(ctx, RepositoriesApi.class))
|
||||
.updateRepositoryOwnerAndName(repository.getOwner(), repoName, repository.getRepositoryId());
|
||||
Objects.requireNonNull(BaseApi.getInstance(ctx, RepositoriesApi.class)).updateRepositoryOwnerAndName(repository.getOwner(), repoName, repository.getRepositoryId());
|
||||
Intent result = new Intent();
|
||||
result.putExtra("nameChanged", true);
|
||||
setResult(200, result);
|
||||
|
|
|
@ -119,8 +119,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
// theme selection dialog
|
||||
themeFrame.setOnClickListener(view -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.themeSelectorDialogTitle)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.themeSelectorDialogTitle)
|
||||
.setSingleChoiceItems(themeList, themeSelectedChoice, (dialogInterfaceTheme, i) -> {
|
||||
|
||||
themeSelectedChoice = i;
|
||||
|
@ -150,9 +149,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
// custom font dialog
|
||||
customFontFrame.setOnClickListener(view -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.settingsCustomFontSelectorDialogTitle)
|
||||
.setCancelable(customFontSelectedChoice != -1)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.settingsCustomFontSelectorDialogTitle).setCancelable(customFontSelectedChoice != -1)
|
||||
.setSingleChoiceItems(customFontList, customFontSelectedChoice, (dialogInterfaceCustomFont, i) -> {
|
||||
|
||||
customFontSelectedChoice = i;
|
||||
|
@ -174,9 +171,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
// time and date dialog
|
||||
timeFrame.setOnClickListener(view -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.settingsTimeSelectorDialogTitle)
|
||||
.setCancelable(timeSelectedChoice != -1)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.settingsTimeSelectorDialogTitle).setCancelable(timeSelectedChoice != -1)
|
||||
.setSingleChoiceItems(timeList, timeSelectedChoice, (dialogInterfaceTime, i) -> {
|
||||
|
||||
timeSelectedChoice = i;
|
||||
|
|
|
@ -98,18 +98,16 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||
|
||||
viewBinding.homeScreenFrame.setOnClickListener(setDefaultHomeScreen -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.settingsHomeScreenSelectorDialogTitle)
|
||||
.setCancelable(homeScreenSelectedChoice != -1)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.settingsHomeScreenSelectorDialogTitle).setCancelable(homeScreenSelectedChoice != -1)
|
||||
.setSingleChoiceItems(homeScreenArray, homeScreenSelectedChoice, (dialogInterfaceHomeScreen, i) -> {
|
||||
|
||||
homeScreenSelectedChoice = i;
|
||||
viewBinding.homeScreenSelected.setText(homeScreenArray[i]);
|
||||
tinyDB.putInt("homeScreenId", i);
|
||||
homeScreenSelectedChoice = i;
|
||||
viewBinding.homeScreenSelected.setText(homeScreenArray[i]);
|
||||
tinyDB.putInt("homeScreenId", i);
|
||||
|
||||
dialogInterfaceHomeScreen.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
});
|
||||
dialogInterfaceHomeScreen.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
|
@ -127,9 +125,7 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||
|
||||
viewBinding.setDefaultLinkHandler.setOnClickListener(setDefaultLinkHandler -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.linkSelectorDialogTitle)
|
||||
.setCancelable(defaultLinkHandlerScreenSelectedChoice != -1)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.linkSelectorDialogTitle).setCancelable(defaultLinkHandlerScreenSelectedChoice != -1)
|
||||
.setSingleChoiceItems(linksArray, defaultLinkHandlerScreenSelectedChoice, (dialogInterfaceHomeScreen, i) -> {
|
||||
|
||||
defaultLinkHandlerScreenSelectedChoice = i;
|
||||
|
|
|
@ -42,12 +42,7 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
viewBinding.enableVibrationMode.setChecked(tinyDB.getBoolean("notificationsEnableVibration", true));
|
||||
|
||||
if(!viewBinding.enableNotificationsMode.isChecked()) {
|
||||
AppUtil.setMultiVisibility(View.GONE,
|
||||
viewBinding.chooseColorFrame,
|
||||
viewBinding.enableLightsFrame,
|
||||
viewBinding.enableVibrationFrame,
|
||||
viewBinding.pollingDelayFrame
|
||||
);
|
||||
AppUtil.setMultiVisibility(View.GONE, viewBinding.chooseColorFrame, viewBinding.enableLightsFrame, viewBinding.enableVibrationFrame, viewBinding.pollingDelayFrame);
|
||||
}
|
||||
|
||||
if(!viewBinding.enableLightsMode.isChecked()) {
|
||||
|
@ -60,27 +55,17 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
|
||||
if(isChecked) {
|
||||
Notifications.startWorker(ctx);
|
||||
AppUtil.setMultiVisibility(View.VISIBLE,
|
||||
viewBinding.chooseColorFrame,
|
||||
viewBinding.enableLightsFrame,
|
||||
viewBinding.enableVibrationFrame,
|
||||
viewBinding.pollingDelayFrame
|
||||
);
|
||||
} else {
|
||||
AppUtil.setMultiVisibility(View.VISIBLE, viewBinding.chooseColorFrame, viewBinding.enableLightsFrame, viewBinding.enableVibrationFrame, viewBinding.pollingDelayFrame);
|
||||
}
|
||||
else {
|
||||
Notifications.stopWorker(ctx);
|
||||
AppUtil.setMultiVisibility(View.GONE,
|
||||
viewBinding.chooseColorFrame,
|
||||
viewBinding.enableLightsFrame,
|
||||
viewBinding.enableVibrationFrame,
|
||||
viewBinding.pollingDelayFrame
|
||||
);
|
||||
AppUtil.setMultiVisibility(View.GONE, viewBinding.chooseColorFrame, viewBinding.enableLightsFrame, viewBinding.enableVibrationFrame, viewBinding.pollingDelayFrame);
|
||||
}
|
||||
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
viewBinding.enableNotificationsFrame.setOnClickListener(
|
||||
v -> viewBinding.enableNotificationsMode.setChecked(!viewBinding.enableNotificationsMode.isChecked()));
|
||||
viewBinding.enableNotificationsFrame.setOnClickListener(v -> viewBinding.enableNotificationsMode.setChecked(!viewBinding.enableNotificationsMode.isChecked()));
|
||||
|
||||
// polling delay
|
||||
viewBinding.pollingDelayFrame.setOnClickListener(v -> {
|
||||
|
@ -91,12 +76,8 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
numberPicker.setValue(tinyDB.getInt("pollingDelayMinutes", Constants.defaultPollingDelay));
|
||||
numberPicker.setWrapSelectorWheel(true);
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.pollingDelayDialogHeaderText)
|
||||
.setMessage(getString(R.string.pollingDelayDialogDescriptionText))
|
||||
.setCancelable(true)
|
||||
.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss())
|
||||
.setPositiveButton(getString(R.string.okButton), (dialog, which) -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.pollingDelayDialogHeaderText).setMessage(getString(R.string.pollingDelayDialogDescriptionText))
|
||||
.setCancelable(true).setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss()).setPositiveButton(getString(R.string.okButton), (dialog, which) -> {
|
||||
|
||||
tinyDB.putInt("pollingDelayMinutes", numberPicker.getValue());
|
||||
|
||||
|
@ -116,7 +97,8 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
|
||||
if(!isChecked) {
|
||||
viewBinding.chooseColorFrame.setVisibility(View.GONE);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
viewBinding.chooseColorFrame.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
@ -150,8 +132,7 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
viewBinding.enableVibrationFrame.setOnClickListener(
|
||||
v -> viewBinding.enableVibrationMode.setChecked(!viewBinding.enableVibrationMode.isChecked()));
|
||||
viewBinding.enableVibrationFrame.setOnClickListener(v -> viewBinding.enableVibrationMode.setChecked(!viewBinding.enableVibrationMode.isChecked()));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -28,13 +28,11 @@ import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTI
|
|||
|
||||
public class SettingsSecurityActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private static String[] cacheSizeDataList;
|
||||
private static int cacheSizeDataSelectedChoice = 0;
|
||||
|
||||
private static String[] cacheSizeImagesList;
|
||||
private static int cacheSizeImagesSelectedChoice = 0;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -86,7 +84,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
BiometricManager biometricManager = BiometricManager.from(ctx);
|
||||
KeyguardManager keyguardManager = (KeyguardManager) ctx.getSystemService(Context.KEYGUARD_SERVICE);
|
||||
|
||||
if (!keyguardManager.isDeviceSecure()) {
|
||||
if(!keyguardManager.isDeviceSecure()) {
|
||||
|
||||
switch(biometricManager.canAuthenticate(BIOMETRIC_STRONG | DEVICE_CREDENTIAL)) {
|
||||
|
||||
|
@ -141,11 +139,8 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
// clear cache
|
||||
clearCacheFrame.setOnClickListener(v1 -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.clearCacheDialogHeader)
|
||||
.setMessage(getResources().getString(R.string.clearCacheDialogMessage))
|
||||
.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss())
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.clearCacheDialogHeader).setMessage(getResources().getString(R.string.clearCacheDialogMessage))
|
||||
.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss()).setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
|
||||
try {
|
||||
|
||||
|
@ -154,7 +149,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch(IOException e) {
|
||||
|
||||
Log.e("SettingsSecurity", e.toString());
|
||||
}
|
||||
|
@ -166,9 +161,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
// cache size images selection dialog
|
||||
cacheSizeImagesFrame.setOnClickListener(view -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.cacheSizeImagesDialogHeader)
|
||||
.setCancelable(cacheSizeImagesSelectedChoice != -1)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.cacheSizeImagesDialogHeader).setCancelable(cacheSizeImagesSelectedChoice != -1)
|
||||
.setSingleChoiceItems(cacheSizeImagesList, cacheSizeImagesSelectedChoice, (dialogInterfaceTheme, i) -> {
|
||||
|
||||
cacheSizeImagesSelectedChoice = i;
|
||||
|
@ -186,9 +179,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
// cache size data selection dialog
|
||||
cacheSizeDataFrame.setOnClickListener(view -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.cacheSizeDataDialogHeader)
|
||||
.setCancelable(cacheSizeDataSelectedChoice != -1)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.cacheSizeDataDialogHeader).setCancelable(cacheSizeDataSelectedChoice != -1)
|
||||
.setSingleChoiceItems(cacheSizeDataList, cacheSizeDataSelectedChoice, (dialogInterfaceTheme, i) -> {
|
||||
|
||||
cacheSizeDataSelectedChoice = i;
|
||||
|
@ -206,11 +197,8 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
// certs deletion
|
||||
certsFrame.setOnClickListener(v1 -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.settingsCertsPopupTitle)
|
||||
.setMessage(getResources().getString(R.string.settingsCertsPopupMessage))
|
||||
.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss())
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.settingsCertsPopupTitle).setMessage(getResources().getString(R.string.settingsCertsPopupMessage))
|
||||
.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss()).setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
|
||||
appCtx.getSharedPreferences(MemorizingTrustManager.KEYSTORE_NAME, Context.MODE_PRIVATE).edit().remove(MemorizingTrustManager.KEYSTORE_KEY).apply();
|
||||
AppUtil.logout(this);
|
||||
|
@ -224,4 +212,5 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,11 +63,8 @@ public class SettingsTranslationActivity extends BaseActivity {
|
|||
// language dialog
|
||||
langFrame.setOnClickListener(view -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.settingsLanguageSelectorDialogTitle)
|
||||
.setCancelable(langSelectedChoice != -1)
|
||||
.setNeutralButton(getString(R.string.cancelButton), null)
|
||||
.setSingleChoiceItems(langs.values().toArray(new String[0]), langSelectedChoice, (dialogInterface, i) -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.settingsLanguageSelectorDialogTitle).setCancelable(langSelectedChoice != -1)
|
||||
.setNeutralButton(getString(R.string.cancelButton), null).setSingleChoiceItems(langs.values().toArray(new String[0]), langSelectedChoice, (dialogInterface, i) -> {
|
||||
|
||||
String selectedLanguage = langs.keySet().toArray(new String[0])[i];
|
||||
tinyDB.putInt("langId", i);
|
||||
|
|
|
@ -105,9 +105,7 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
createWikiPageOptions.setTitle(wikiTitle);
|
||||
createWikiPageOptions.setContentBase64(AppUtil.encodeBase64(wikiContent));
|
||||
|
||||
Call<WikiPage> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoCreateWikiPage(repository.getOwner(), repository.getName(), createWikiPageOptions);
|
||||
Call<WikiPage> call = RetrofitClient.getApiInterface(ctx).repoCreateWikiPage(repository.getOwner(), repository.getName(), createWikiPageOptions);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -155,9 +153,7 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
createWikiPageOptions.setTitle(wikiTitle);
|
||||
createWikiPageOptions.setContentBase64(AppUtil.encodeBase64(wikiContent));
|
||||
|
||||
Call<WikiPage> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoEditWikiPage(repository.getOwner(), repository.getName(), pageName, createWikiPageOptions);
|
||||
Call<WikiPage> call = RetrofitClient.getApiInterface(ctx).repoEditWikiPage(repository.getOwner(), repository.getName(), pageName, createWikiPageOptions);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -201,9 +197,7 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
|
||||
private void getWikiPageContents() {
|
||||
|
||||
Call<WikiPage> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoGetWikiPage(repository.getOwner(), repository.getName(), pageName);
|
||||
Call<WikiPage> call = RetrofitClient.getApiInterface(ctx).repoGetWikiPage(repository.getOwner(), repository.getName(), pageName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -269,35 +263,32 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
|
||||
private void deleteWiki(final String owner, final String repo, final String pageName) {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(String.format(ctx.getString(R.string.deleteGenericTitle), pageName))
|
||||
.setMessage(ctx.getString(R.string.deleteWikiPageMessage, pageName))
|
||||
.setNeutralButton(R.string.cancelButton, null)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient
|
||||
.getApiInterface(ctx).repoDeleteWikiPage(owner, repo, pageName).enqueue(new Callback<>() {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(String.format(ctx.getString(R.string.deleteGenericTitle), pageName))
|
||||
.setMessage(ctx.getString(R.string.deleteWikiPageMessage, pageName)).setNeutralButton(R.string.cancelButton, null)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient.getApiInterface(ctx).repoDeleteWikiPage(owner, repo, pageName).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
Toasty.success(ctx, getString(R.string.wikiPageDeleted));
|
||||
WikiFragment.resumeWiki = true;
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
if(response.isSuccessful()) {
|
||||
Toasty.success(ctx, getString(R.string.wikiPageDeleted));
|
||||
WikiFragment.resumeWiki = true;
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}));
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
}
|
||||
|
@ -362,8 +353,7 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
|
||||
if(action.equalsIgnoreCase("edit") || action.equalsIgnoreCase("add")) {
|
||||
if(renderMd) {
|
||||
Markdown.render(ctx, EmojiParser.parseToUnicode(String.valueOf(
|
||||
Objects.requireNonNull(binding.contentLayout.getEditText()).getText())), binding.markdownPreview, repository);
|
||||
Markdown.render(ctx, EmojiParser.parseToUnicode(String.valueOf(Objects.requireNonNull(binding.contentLayout.getEditText()).getText())), binding.markdownPreview, repository);
|
||||
|
||||
binding.markdownPreview.setVisibility(View.VISIBLE);
|
||||
binding.contentLayout.setVisibility(View.GONE);
|
||||
|
@ -402,4 +392,5 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -140,9 +140,7 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
|
|||
lastRunContent.setText(lastRun);
|
||||
execTimeContent.setText(String.valueOf(cronTasks.getExecTimes()));
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(StringUtils.capitalize(cronTasks.getName().replace("_", " ")))
|
||||
.setView(view)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(StringUtils.capitalize(cronTasks.getName().replace("_", " "))).setView(view)
|
||||
.setPositiveButton(ctx.getString(R.string.close), null);
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
|
|
|
@ -30,11 +30,43 @@ import java.util.List;
|
|||
|
||||
public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Filterable {
|
||||
|
||||
private List<User> usersList;
|
||||
private final List<User> usersListFull;
|
||||
private final Context context;
|
||||
private List<User> usersList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final Filter usersFilter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<User> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(usersListFull);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(User item : usersListFull) {
|
||||
if(item.getEmail().toLowerCase().contains(filterPattern) || item.getFullName().toLowerCase().contains(filterPattern) || item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
usersList.clear();
|
||||
usersList.addAll((List) results.values);
|
||||
notifyDataChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public AdminGetUsersAdapter(List<User> usersListMain, Context ctx) {
|
||||
this.context = ctx;
|
||||
|
@ -69,14 +101,50 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
return usersList.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<User> list) {
|
||||
usersList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return usersFilter;
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
class ReposHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private String userLoginId;
|
||||
private final ImageView userAvatar;
|
||||
private final TextView userFullName;
|
||||
private final TextView userEmail;
|
||||
private final ImageView userRole;
|
||||
private final TextView userName;
|
||||
private String userLoginId;
|
||||
|
||||
ReposHolder(View itemView) {
|
||||
|
||||
|
@ -126,9 +194,8 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
if(users.isIsAdmin()) {
|
||||
|
||||
userRole.setVisibility(View.VISIBLE);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig()
|
||||
.textColor(ResourcesCompat.getColor(context.getResources(), R.color.colorWhite, null)).fontSize(60).width(200).height(80)
|
||||
.endConfig().buildRoundRect(context.getResources().getString(R.string.userRoleAdmin).toLowerCase(), ResourcesCompat.getColor(context.getResources(), R.color.releasePre, null), 8);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().textColor(ResourcesCompat.getColor(context.getResources(), R.color.colorWhite, null)).fontSize(60).width(200).height(80).endConfig()
|
||||
.buildRoundRect(context.getResources().getString(R.string.userRoleAdmin).toLowerCase(), ResourcesCompat.getColor(context.getResources(), R.color.releasePre, null), 8);
|
||||
userRole.setImageDrawable(drawable);
|
||||
}
|
||||
else {
|
||||
|
@ -138,71 +205,7 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
|
||||
PicassoService.getInstance(context).get().load(users.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(userAvatar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
void onLoadMore();
|
||||
void onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<User> list) {
|
||||
usersList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return usersFilter;
|
||||
}
|
||||
|
||||
private final Filter usersFilter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<User> filteredList = new ArrayList<>();
|
||||
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(usersListFull);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for (User item : usersListFull) {
|
||||
if (item.getEmail().toLowerCase().contains(filterPattern) || item.getFullName().toLowerCase().contains(filterPattern) || item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
usersList.clear();
|
||||
usersList.addAll((List) results.values);
|
||||
notifyDataChanged();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -25,37 +25,11 @@ import retrofit2.Callback;
|
|||
|
||||
public class AdminUnadoptedReposAdapter extends RecyclerView.Adapter<AdminUnadoptedReposAdapter.UnadoptedViewHolder> {
|
||||
|
||||
private List<String> repos;
|
||||
private final Runnable updateList;
|
||||
private final Runnable loadMoreListener;
|
||||
private boolean isLoading = false, hasMore = true;
|
||||
private final ActivityAdminCronTasksBinding activityAdminCronTasksBinding;
|
||||
|
||||
class UnadoptedViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private String repoName;
|
||||
private final TextView name;
|
||||
|
||||
private UnadoptedViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
Context ctx = itemView.getContext();
|
||||
|
||||
name = itemView.findViewById(R.id.repo_name);
|
||||
|
||||
itemView.setOnClickListener(taskInfo -> {
|
||||
String[] repoSplit = repoName.split("/");
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(repoName).setMessage(ctx.getString(R.string.unadoptedReposMessage, repoSplit[1], repoSplit[0]))
|
||||
.setNeutralButton(R.string.close, null)
|
||||
.setPositiveButton(R.string.menuDeleteText, ((dialog, which) -> delete(ctx, repoName)))
|
||||
.setNegativeButton(R.string.adoptRepo, ((dialog, which) -> adopt(ctx, repoName, getBindingAdapterPosition())));
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
}
|
||||
}
|
||||
private List<String> repos;
|
||||
private boolean isLoading = false, hasMore = true;
|
||||
|
||||
public AdminUnadoptedReposAdapter(List<String> list, Runnable updateList, Runnable loadMore, ActivityAdminCronTasksBinding activityAdminCronTasksBinding) {
|
||||
this.repos = list;
|
||||
|
@ -95,9 +69,7 @@ public class AdminUnadoptedReposAdapter extends RecyclerView.Adapter<AdminUnadop
|
|||
|
||||
String[] repoSplit = name.split("/");
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.adminDeleteUnadoptedRepository(repoSplit[0], repoSplit[1]);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).adminDeleteUnadoptedRepository(repoSplit[0], repoSplit[1]);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -141,9 +113,7 @@ public class AdminUnadoptedReposAdapter extends RecyclerView.Adapter<AdminUnadop
|
|||
|
||||
String[] repoSplit = name.split("/");
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.adminAdoptRepository(repoSplit[0], repoSplit[1]);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).adminAdoptRepository(repoSplit[0], repoSplit[1]);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -201,4 +171,30 @@ public class AdminUnadoptedReposAdapter extends RecyclerView.Adapter<AdminUnadop
|
|||
this.hasMore = hasMore;
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
class UnadoptedViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView name;
|
||||
private String repoName;
|
||||
|
||||
private UnadoptedViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
Context ctx = itemView.getContext();
|
||||
|
||||
name = itemView.findViewById(R.id.repo_name);
|
||||
|
||||
itemView.setOnClickListener(taskInfo -> {
|
||||
String[] repoSplit = repoName.split("/");
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(repoName).setMessage(ctx.getString(R.string.unadoptedReposMessage, repoSplit[1], repoSplit[0]))
|
||||
.setNeutralButton(R.string.close, null).setPositiveButton(R.string.menuDeleteText, ((dialog, which) -> delete(ctx, repoName)))
|
||||
.setNegativeButton(R.string.adoptRepo, ((dialog, which) -> adopt(ctx, repoName, getBindingAdapterPosition())));
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,150 +37,145 @@ import retrofit2.Response;
|
|||
|
||||
public class CollaboratorSearchAdapter extends RecyclerView.Adapter<CollaboratorSearchAdapter.CollaboratorSearchViewHolder> {
|
||||
|
||||
private final List<User> usersSearchList;
|
||||
private final Context context;
|
||||
private final RepositoryContext repository;
|
||||
private final List<User> usersSearchList;
|
||||
private final Context context;
|
||||
private final RepositoryContext repository;
|
||||
|
||||
public CollaboratorSearchAdapter(List<User> dataList, Context ctx, RepositoryContext repository) {
|
||||
this.context = ctx;
|
||||
this.usersSearchList = dataList;
|
||||
this.repository = repository;
|
||||
}
|
||||
public CollaboratorSearchAdapter(List<User> dataList, Context ctx, RepositoryContext repository) {
|
||||
this.context = ctx;
|
||||
this.usersSearchList = dataList;
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
class CollaboratorSearchViewHolder extends RecyclerView.ViewHolder {
|
||||
@NonNull
|
||||
@Override
|
||||
public CollaboratorSearchViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_collaborators_search, parent, false);
|
||||
return new CollaboratorSearchAdapter.CollaboratorSearchViewHolder(v);
|
||||
}
|
||||
|
||||
private User userInfo;
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final CollaboratorSearchViewHolder holder, int position) {
|
||||
|
||||
private final ImageView userAvatar;
|
||||
private final TextView userFullName;
|
||||
private final TextView userName;
|
||||
private final ImageView addCollaboratorButtonAdd;
|
||||
private final ImageView addCollaboratorButtonRemove;
|
||||
User currentItem = usersSearchList.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
holder.userInfo = currentItem;
|
||||
|
||||
private final String[] permissionList = {"Read", "Write", "Admin"};
|
||||
final private int permissionSelectedChoice = 0;
|
||||
if(!currentItem.getFullName().equals("")) {
|
||||
|
||||
private CollaboratorSearchViewHolder(View itemView) {
|
||||
holder.userFullName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
}
|
||||
else {
|
||||
|
||||
super(itemView);
|
||||
userAvatar = itemView.findViewById(R.id.userAvatar);
|
||||
userFullName = itemView.findViewById(R.id.userFullName);
|
||||
userName = itemView.findViewById(R.id.userName);
|
||||
addCollaboratorButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
|
||||
addCollaboratorButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
|
||||
holder.userFullName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
}
|
||||
|
||||
addCollaboratorButtonAdd.setOnClickListener(v -> {
|
||||
holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context)
|
||||
.setTitle(R.string.newTeamPermission)
|
||||
.setSingleChoiceItems(permissionList, permissionSelectedChoice, null)
|
||||
.setNeutralButton(R.string.cancelButton, null)
|
||||
.setPositiveButton(R.string.addButton, (dialog, which) -> {
|
||||
if(!currentItem.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(holder.userAvatar);
|
||||
}
|
||||
|
||||
ListView lw = ((AlertDialog)dialog).getListView();
|
||||
Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition());
|
||||
if(getItemCount() > 0) {
|
||||
|
||||
CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userInfo.getLogin(), repository);
|
||||
});
|
||||
final String loginUid = ((BaseActivity) context).getAccount().getAccount().getUserName();
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).repoCheckCollaborator(repository.getOwner(), repository.getName(), currentItem.getLogin());
|
||||
|
||||
addCollaboratorButtonRemove.setOnClickListener(v -> AlertDialogs.collaboratorRemoveDialog(context, userInfo.getLogin(), repository));
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
new Handler().postDelayed(() -> {
|
||||
if(!AppUtil.checkGhostUsers(userInfo.getLogin())) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
|
||||
userAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userInfo.getLogin());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
if(response.code() == 204) {
|
||||
if(!currentItem.getLogin().equals(loginUid) && !currentItem.getLogin().equals(repository.getOwner())) {
|
||||
holder.addCollaboratorButtonRemove.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.addCollaboratorButtonRemove.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
if(!currentItem.getLogin().equals(loginUid) && !currentItem.getLogin().equals(repository.getOwner())) {
|
||||
holder.addCollaboratorButtonAdd.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.addCollaboratorButtonAdd.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
holder.addCollaboratorButtonRemove.setVisibility(View.GONE);
|
||||
holder.addCollaboratorButtonAdd.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
userAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userInfo.getLogin(), context.getString(R.string.copyLoginIdToClipBoard, userInfo.getLogin()));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return usersSearchList.size();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public CollaboratorSearchViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_collaborators_search, parent, false);
|
||||
return new CollaboratorSearchAdapter.CollaboratorSearchViewHolder(v);
|
||||
}
|
||||
class CollaboratorSearchViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final CollaboratorSearchViewHolder holder, int position) {
|
||||
private final ImageView userAvatar;
|
||||
private final TextView userFullName;
|
||||
private final TextView userName;
|
||||
private final ImageView addCollaboratorButtonAdd;
|
||||
private final ImageView addCollaboratorButtonRemove;
|
||||
private final String[] permissionList = {"Read", "Write", "Admin"};
|
||||
final private int permissionSelectedChoice = 0;
|
||||
private User userInfo;
|
||||
|
||||
User currentItem = usersSearchList.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
holder.userInfo = currentItem;
|
||||
private CollaboratorSearchViewHolder(View itemView) {
|
||||
|
||||
if (!currentItem.getFullName().equals("")) {
|
||||
super(itemView);
|
||||
userAvatar = itemView.findViewById(R.id.userAvatar);
|
||||
userFullName = itemView.findViewById(R.id.userFullName);
|
||||
userName = itemView.findViewById(R.id.userName);
|
||||
addCollaboratorButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
|
||||
addCollaboratorButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
|
||||
|
||||
holder.userFullName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
}
|
||||
else {
|
||||
addCollaboratorButtonAdd.setOnClickListener(v -> {
|
||||
|
||||
holder.userFullName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
}
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context).setTitle(R.string.newTeamPermission).setSingleChoiceItems(permissionList, permissionSelectedChoice, null)
|
||||
.setNeutralButton(R.string.cancelButton, null).setPositiveButton(R.string.addButton, (dialog, which) -> {
|
||||
|
||||
holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
ListView lw = ((AlertDialog) dialog).getListView();
|
||||
Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition());
|
||||
|
||||
if (!currentItem.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
||||
}
|
||||
CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userInfo.getLogin(), repository);
|
||||
});
|
||||
|
||||
if(getItemCount() > 0) {
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
|
||||
final String loginUid = ((BaseActivity) context).getAccount().getAccount().getUserName();
|
||||
addCollaboratorButtonRemove.setOnClickListener(v -> AlertDialogs.collaboratorRemoveDialog(context, userInfo.getLogin(), repository));
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.repoCheckCollaborator(repository.getOwner(), repository.getName(), currentItem.getLogin());
|
||||
new Handler().postDelayed(() -> {
|
||||
if(!AppUtil.checkGhostUsers(userInfo.getLogin())) {
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
userAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userInfo.getLogin());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
userAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userInfo.getLogin(), context.getString(R.string.copyLoginIdToClipBoard, userInfo.getLogin()));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
if(response.code() == 204) {
|
||||
if(!currentItem.getLogin().equals(loginUid) && !currentItem.getLogin().equals(repository.getOwner())) {
|
||||
holder.addCollaboratorButtonRemove.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.addCollaboratorButtonRemove.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
if(!currentItem.getLogin().equals(loginUid) && !currentItem.getLogin().equals(repository.getOwner())) {
|
||||
holder.addCollaboratorButtonAdd.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.addCollaboratorButtonAdd.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
holder.addCollaboratorButtonRemove.setVisibility(View.GONE);
|
||||
holder.addCollaboratorButtonAdd.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return usersSearchList.size();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,96 +22,97 @@ import java.util.List;
|
|||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CollaboratorsAdapter extends BaseAdapter {
|
||||
public class CollaboratorsAdapter extends BaseAdapter {
|
||||
|
||||
private final List<User> collaboratorsList;
|
||||
private final Context context;
|
||||
private final List<User> collaboratorsList;
|
||||
private final Context context;
|
||||
|
||||
private class ViewHolder {
|
||||
public CollaboratorsAdapter(Context ctx, List<User> collaboratorsListMain) {
|
||||
|
||||
private String userLoginId;
|
||||
this.context = ctx;
|
||||
this.collaboratorsList = collaboratorsListMain;
|
||||
}
|
||||
|
||||
private final ImageView collaboratorAvatar;
|
||||
private final TextView collaboratorName;
|
||||
@Override
|
||||
public int getCount() {
|
||||
return collaboratorsList.size();
|
||||
}
|
||||
|
||||
ViewHolder(View v) {
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
collaboratorAvatar = v.findViewById(R.id.collaboratorAvatar);
|
||||
collaboratorName = v.findViewById(R.id.collaboratorName);
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
collaboratorAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userLoginId);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
@SuppressLint("InflateParams")
|
||||
@Override
|
||||
public View getView(int position, View finalView, ViewGroup parent) {
|
||||
|
||||
collaboratorAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
ViewHolder viewHolder;
|
||||
|
||||
public CollaboratorsAdapter(Context ctx, List<User> collaboratorsListMain) {
|
||||
if(finalView == null) {
|
||||
|
||||
this.context = ctx;
|
||||
this.collaboratorsList = collaboratorsListMain;
|
||||
}
|
||||
finalView = LayoutInflater.from(context).inflate(R.layout.list_collaborators, null);
|
||||
viewHolder = new ViewHolder(finalView);
|
||||
finalView.setTag(viewHolder);
|
||||
}
|
||||
else {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return collaboratorsList.size();
|
||||
}
|
||||
viewHolder = (ViewHolder) finalView.getTag();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
initData(viewHolder, position);
|
||||
return finalView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
private void initData(ViewHolder viewHolder, int position) {
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
@Override
|
||||
public View getView(int position, View finalView, ViewGroup parent) {
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 90);
|
||||
|
||||
ViewHolder viewHolder;
|
||||
User currentItem = collaboratorsList.get(position);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop()
|
||||
.into(viewHolder.collaboratorAvatar);
|
||||
|
||||
if (finalView == null) {
|
||||
viewHolder.userLoginId = currentItem.getLogin();
|
||||
|
||||
finalView = LayoutInflater.from(context).inflate(R.layout.list_collaborators, null);
|
||||
viewHolder = new ViewHolder(finalView);
|
||||
finalView.setTag(viewHolder);
|
||||
}
|
||||
else {
|
||||
if(!currentItem.getFullName().equals("")) {
|
||||
|
||||
viewHolder = (ViewHolder) finalView.getTag();
|
||||
}
|
||||
viewHolder.collaboratorName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
}
|
||||
else {
|
||||
|
||||
initData(viewHolder, position);
|
||||
return finalView;
|
||||
}
|
||||
viewHolder.collaboratorName.setText(currentItem.getLogin());
|
||||
}
|
||||
|
||||
private void initData(ViewHolder viewHolder, int position) {
|
||||
}
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 90);
|
||||
private class ViewHolder {
|
||||
|
||||
User currentItem = collaboratorsList.get(position);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(viewHolder.collaboratorAvatar);
|
||||
private final ImageView collaboratorAvatar;
|
||||
private final TextView collaboratorName;
|
||||
private String userLoginId;
|
||||
|
||||
viewHolder.userLoginId = currentItem.getLogin();
|
||||
ViewHolder(View v) {
|
||||
|
||||
if(!currentItem.getFullName().equals("")) {
|
||||
collaboratorAvatar = v.findViewById(R.id.collaboratorAvatar);
|
||||
collaboratorName = v.findViewById(R.id.collaboratorName);
|
||||
|
||||
viewHolder.collaboratorName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
}
|
||||
else {
|
||||
collaboratorAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userLoginId);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
viewHolder.collaboratorName.setText(currentItem.getLogin());
|
||||
}
|
||||
collaboratorAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,163 +31,154 @@ import java.util.Objects;
|
|||
|
||||
public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private List<Commit> commitsList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false;
|
||||
private boolean isMoreDataAvailable = true;
|
||||
private final Context context;
|
||||
private List<Commit> commitsList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false;
|
||||
private boolean isMoreDataAvailable = true;
|
||||
|
||||
public CommitsAdapter(Context ctx, List<Commit> commitsListMain) {
|
||||
public CommitsAdapter(Context ctx, List<Commit> commitsListMain) {
|
||||
|
||||
this.context = ctx;
|
||||
this.commitsList = commitsListMain;
|
||||
}
|
||||
this.context = ctx;
|
||||
this.commitsList = commitsListMain;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
return new CommitsHolder(inflater.inflate(R.layout.list_commits, parent, false));
|
||||
}
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
return new CommitsHolder(inflater.inflate(R.layout.list_commits, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
isLoading = true;
|
||||
loadMoreListener.run();
|
||||
}
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
isLoading = true;
|
||||
loadMoreListener.run();
|
||||
}
|
||||
|
||||
((CommitsHolder) holder).bindData(commitsList.get(position));
|
||||
}
|
||||
((CommitsHolder) holder).bindData(commitsList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return commitsList.size();
|
||||
}
|
||||
|
||||
class CommitsHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
View rootView;
|
||||
|
||||
TextView commitSubject;
|
||||
TextView commitAuthorAndCommitter;
|
||||
ImageView commitAuthorAvatar;
|
||||
ImageView commitCommitterAvatar;
|
||||
TextView commitSha;
|
||||
|
||||
CommitsHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
rootView = itemView;
|
||||
|
||||
commitSubject = itemView.findViewById(R.id.commitSubject);
|
||||
commitAuthorAndCommitter = itemView.findViewById(R.id.commitAuthorAndCommitter);
|
||||
commitAuthorAvatar = itemView.findViewById(R.id.commitAuthorAvatar);
|
||||
commitCommitterAvatar = itemView.findViewById(R.id.commitCommitterAvatar);
|
||||
commitSha = itemView.findViewById(R.id.commitSha);
|
||||
|
||||
}
|
||||
|
||||
void bindData(Commit commitsModel) {
|
||||
|
||||
String[] commitMessageParts = commitsModel.getCommit().getMessage().split("(\r\n|\n)", 2);
|
||||
|
||||
commitSubject.setText(EmojiParser.parseToUnicode(commitMessageParts[0].trim()));
|
||||
|
||||
|
||||
if(!Objects.equals(commitsModel.getCommit().getCommitter().getEmail(), commitsModel.getCommit().getAuthor().getEmail())) {
|
||||
commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(context
|
||||
.getString(R.string.commitAuthoredByAndCommittedByWhen, commitsModel.getCommit().getAuthor().getName(), commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper
|
||||
.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), context.getResources().getConfiguration().locale, "pretty",
|
||||
context)), HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
} else {
|
||||
commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(context
|
||||
.getString(R.string.commitCommittedByWhen, commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper
|
||||
.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), context.getResources().getConfiguration().locale, "pretty",
|
||||
context)), HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
}
|
||||
|
||||
if(commitsModel.getAuthor() != null && commitsModel.getAuthor().getAvatarUrl() != null &&
|
||||
!commitsModel.getAuthor().getAvatarUrl().isEmpty()) {
|
||||
|
||||
commitAuthorAvatar.setVisibility(View.VISIBLE);
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(commitsModel.getAuthor().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
.centerCrop().into(commitAuthorAvatar);
|
||||
|
||||
} else {
|
||||
commitAuthorAvatar.setImageDrawable(null);
|
||||
commitAuthorAvatar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(commitsModel.getCommitter() != null &&
|
||||
(commitsModel.getAuthor() == null || !commitsModel.getAuthor().getLogin().equals(commitsModel.getCommitter().getLogin())) &&
|
||||
commitsModel.getCommitter().getAvatarUrl() != null &&
|
||||
!commitsModel.getCommitter().getAvatarUrl().isEmpty()) {
|
||||
|
||||
commitCommitterAvatar.setVisibility(View.VISIBLE);
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(commitsModel.getCommitter().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
.centerCrop().into(commitCommitterAvatar);
|
||||
|
||||
} else {
|
||||
commitCommitterAvatar.setImageDrawable(null);
|
||||
commitCommitterAvatar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
commitSha.setText(commitsModel.getSha().substring(0, Math.min(commitsModel.getSha().length(), 10)));
|
||||
rootView.setOnClickListener(v -> {
|
||||
Intent intent;
|
||||
if(context instanceof CommitsActivity) {
|
||||
intent = ((CommitsActivity) context).repository.getIntent(context, CommitDetailActivity.class);
|
||||
} else {
|
||||
intent = IssueContext.fromIntent(((DiffActivity) context).getIntent()).getRepository()
|
||||
.getIntent(context, CommitDetailActivity.class);
|
||||
}
|
||||
intent.putExtra("sha", commitsModel.getSha());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return commitsList.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Commit> list) {
|
||||
commitsList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class CommitsHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
View rootView;
|
||||
|
||||
TextView commitSubject;
|
||||
TextView commitAuthorAndCommitter;
|
||||
ImageView commitAuthorAvatar;
|
||||
ImageView commitCommitterAvatar;
|
||||
TextView commitSha;
|
||||
|
||||
CommitsHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
rootView = itemView;
|
||||
|
||||
commitSubject = itemView.findViewById(R.id.commitSubject);
|
||||
commitAuthorAndCommitter = itemView.findViewById(R.id.commitAuthorAndCommitter);
|
||||
commitAuthorAvatar = itemView.findViewById(R.id.commitAuthorAvatar);
|
||||
commitCommitterAvatar = itemView.findViewById(R.id.commitCommitterAvatar);
|
||||
commitSha = itemView.findViewById(R.id.commitSha);
|
||||
|
||||
}
|
||||
|
||||
void bindData(Commit commitsModel) {
|
||||
|
||||
String[] commitMessageParts = commitsModel.getCommit().getMessage().split("(\r\n|\n)", 2);
|
||||
|
||||
commitSubject.setText(EmojiParser.parseToUnicode(commitMessageParts[0].trim()));
|
||||
|
||||
|
||||
if(!Objects.equals(commitsModel.getCommit().getCommitter().getEmail(), commitsModel.getCommit().getAuthor().getEmail())) {
|
||||
commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(
|
||||
context.getString(R.string.commitAuthoredByAndCommittedByWhen, commitsModel.getCommit().getAuthor().getName(), commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), context.getResources().getConfiguration().locale, "pretty", context)),
|
||||
HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
}
|
||||
else {
|
||||
commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(context.getString(R.string.commitCommittedByWhen, commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), context.getResources().getConfiguration().locale, "pretty", context)),
|
||||
HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
}
|
||||
|
||||
if(commitsModel.getAuthor() != null && commitsModel.getAuthor().getAvatarUrl() != null && !commitsModel.getAuthor().getAvatarUrl().isEmpty()) {
|
||||
|
||||
commitAuthorAvatar.setVisibility(View.VISIBLE);
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
|
||||
PicassoService.getInstance(context).get().load(commitsModel.getAuthor().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120)
|
||||
.centerCrop().into(commitAuthorAvatar);
|
||||
|
||||
}
|
||||
else {
|
||||
commitAuthorAvatar.setImageDrawable(null);
|
||||
commitAuthorAvatar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(commitsModel.getCommitter() != null && (commitsModel.getAuthor() == null || !commitsModel.getAuthor().getLogin().equals(commitsModel.getCommitter().getLogin())) && commitsModel.getCommitter()
|
||||
.getAvatarUrl() != null && !commitsModel.getCommitter().getAvatarUrl().isEmpty()) {
|
||||
|
||||
commitCommitterAvatar.setVisibility(View.VISIBLE);
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
|
||||
PicassoService.getInstance(context).get().load(commitsModel.getCommitter().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120)
|
||||
.centerCrop().into(commitCommitterAvatar);
|
||||
|
||||
}
|
||||
else {
|
||||
commitCommitterAvatar.setImageDrawable(null);
|
||||
commitCommitterAvatar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
commitSha.setText(commitsModel.getSha().substring(0, Math.min(commitsModel.getSha().length(), 10)));
|
||||
rootView.setOnClickListener(v -> {
|
||||
Intent intent;
|
||||
if(context instanceof CommitsActivity) {
|
||||
intent = ((CommitsActivity) context).repository.getIntent(context, CommitDetailActivity.class);
|
||||
}
|
||||
else {
|
||||
intent = IssueContext.fromIntent(((DiffActivity) context).getIntent()).getRepository().getIntent(context, CommitDetailActivity.class);
|
||||
}
|
||||
intent.putExtra("sha", commitsModel.getSha());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateList(List<Commit> list) {
|
||||
commitsList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,121 +33,57 @@ import java.util.List;
|
|||
|
||||
public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsViewHolder> {
|
||||
|
||||
private List<DraftWithRepository> draftsList;
|
||||
private final FragmentManager fragmentManager;
|
||||
private final Context context;
|
||||
private final FragmentManager fragmentManager;
|
||||
private final Context context;
|
||||
private List<DraftWithRepository> draftsList;
|
||||
|
||||
class DraftsViewHolder extends RecyclerView.ViewHolder {
|
||||
public DraftsAdapter(Context ctx, FragmentManager fragmentManager, List<DraftWithRepository> draftsListMain) {
|
||||
this.context = ctx;
|
||||
this.fragmentManager = fragmentManager;
|
||||
this.draftsList = draftsListMain;
|
||||
}
|
||||
|
||||
private DraftWithRepository draftWithRepository;
|
||||
private void deleteDraft(int position) {
|
||||
|
||||
private final TextView draftText;
|
||||
private final TextView repoInfo;
|
||||
private final ImageView editCommentStatus;
|
||||
draftsList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, draftsList.size());
|
||||
Toasty.success(context, context.getResources().getString(R.string.draftsSingleDeleteSuccess));
|
||||
}
|
||||
|
||||
private DraftsViewHolder(View itemView) {
|
||||
@NonNull
|
||||
@Override
|
||||
public DraftsAdapter.DraftsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_drafts, parent, false);
|
||||
return new DraftsViewHolder(v);
|
||||
}
|
||||
|
||||
super(itemView);
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DraftsAdapter.DraftsViewHolder holder, int position) {
|
||||
|
||||
draftText = itemView.findViewById(R.id.draftText);
|
||||
repoInfo = itemView.findViewById(R.id.repoInfo);
|
||||
ImageView deleteDraft = itemView.findViewById(R.id.deleteDraft);
|
||||
editCommentStatus = itemView.findViewById(R.id.editCommentStatus);
|
||||
DraftWithRepository currentItem = draftsList.get(position);
|
||||
|
||||
deleteDraft.setOnClickListener(itemDelete -> {
|
||||
String issueNumber = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
|
||||
Spanned headTitle = HtmlCompat.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName(), HtmlCompat.FROM_HTML_MODE_LEGACY);
|
||||
|
||||
int getDraftId = draftWithRepository.getDraftId();
|
||||
deleteDraft(getBindingAdapterPosition());
|
||||
holder.repoInfo.setText(headTitle);
|
||||
holder.draftWithRepository = currentItem;
|
||||
|
||||
DraftsApi draftsApi = BaseApi.getInstance(context, DraftsApi.class);
|
||||
assert draftsApi != null;
|
||||
draftsApi.deleteSingleDraft(getDraftId);
|
||||
});
|
||||
Markdown.render(context, currentItem.getDraftText(), holder.draftText);
|
||||
|
||||
itemView.setOnClickListener(itemEdit -> {
|
||||
if(!currentItem.getCommentId().equalsIgnoreCase("new")) {
|
||||
holder.editCommentStatus.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.editCommentStatus.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
RepositoryContext repository = new RepositoryContext(draftWithRepository.getRepositoryOwner(), draftWithRepository.getRepositoryName(), context);
|
||||
repository.setRepositoryId(draftWithRepository.getRepositoryId());
|
||||
IssueContext issue = new IssueContext(repository, draftWithRepository.getIssueId(), draftWithRepository.getIssueType());
|
||||
Bundle bundle = issue.getBundle();
|
||||
|
||||
bundle.putString("commentBody", draftWithRepository.getDraftText());
|
||||
bundle.putString("issueNumber", String.valueOf(draftWithRepository.getIssueId()));
|
||||
bundle.putString("draftTitle", repoInfo.getText().toString());
|
||||
bundle.putString("commentId", draftWithRepository.getCommentId());
|
||||
bundle.putString("draftId", String.valueOf(draftWithRepository.getDraftId()));
|
||||
|
||||
if(!draftWithRepository.getCommentId().isEmpty()) {
|
||||
bundle.putString("commentAction", "edit");
|
||||
}
|
||||
|
||||
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle, issue);
|
||||
bottomSheetReplyFragment.setOnInteractedListener(() -> {
|
||||
Intent i = new IssueContext(
|
||||
new RepositoryContext(
|
||||
draftWithRepository.getRepositoryOwner(),
|
||||
draftWithRepository.getRepositoryName(),
|
||||
context
|
||||
),
|
||||
draftWithRepository.getIssueId(),
|
||||
draftWithRepository.getIssueType()
|
||||
).getIntent(context, IssueDetailActivity.class);
|
||||
i.putExtra("openedFromLink", "true");
|
||||
context.startActivity(i);
|
||||
});
|
||||
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public DraftsAdapter(Context ctx, FragmentManager fragmentManager, List<DraftWithRepository> draftsListMain) {
|
||||
this.context = ctx;
|
||||
this.fragmentManager = fragmentManager;
|
||||
this.draftsList = draftsListMain;
|
||||
}
|
||||
|
||||
private void deleteDraft(int position) {
|
||||
|
||||
draftsList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, draftsList.size());
|
||||
Toasty.success(context, context.getResources().getString(R.string.draftsSingleDeleteSuccess));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DraftsAdapter.DraftsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_drafts, parent, false);
|
||||
return new DraftsViewHolder(v);
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DraftsAdapter.DraftsViewHolder holder, int position) {
|
||||
|
||||
DraftWithRepository currentItem = draftsList.get(position);
|
||||
|
||||
String issueNumber = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
|
||||
Spanned headTitle = HtmlCompat
|
||||
.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName(), HtmlCompat.FROM_HTML_MODE_LEGACY);
|
||||
|
||||
holder.repoInfo.setText(headTitle);
|
||||
holder.draftWithRepository = currentItem;
|
||||
|
||||
Markdown.render(context, currentItem.getDraftText(), holder.draftText);
|
||||
|
||||
if(!currentItem.getCommentId().equalsIgnoreCase("new")) {
|
||||
holder.editCommentStatus.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.editCommentStatus.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return draftsList.size();
|
||||
}
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return draftsList.size();
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
|
@ -159,4 +95,61 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||
draftsList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class DraftsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView draftText;
|
||||
private final TextView repoInfo;
|
||||
private final ImageView editCommentStatus;
|
||||
private DraftWithRepository draftWithRepository;
|
||||
|
||||
private DraftsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
draftText = itemView.findViewById(R.id.draftText);
|
||||
repoInfo = itemView.findViewById(R.id.repoInfo);
|
||||
ImageView deleteDraft = itemView.findViewById(R.id.deleteDraft);
|
||||
editCommentStatus = itemView.findViewById(R.id.editCommentStatus);
|
||||
|
||||
deleteDraft.setOnClickListener(itemDelete -> {
|
||||
|
||||
int getDraftId = draftWithRepository.getDraftId();
|
||||
deleteDraft(getBindingAdapterPosition());
|
||||
|
||||
DraftsApi draftsApi = BaseApi.getInstance(context, DraftsApi.class);
|
||||
assert draftsApi != null;
|
||||
draftsApi.deleteSingleDraft(getDraftId);
|
||||
});
|
||||
|
||||
itemView.setOnClickListener(itemEdit -> {
|
||||
|
||||
RepositoryContext repository = new RepositoryContext(draftWithRepository.getRepositoryOwner(), draftWithRepository.getRepositoryName(), context);
|
||||
repository.setRepositoryId(draftWithRepository.getRepositoryId());
|
||||
IssueContext issue = new IssueContext(repository, draftWithRepository.getIssueId(), draftWithRepository.getIssueType());
|
||||
Bundle bundle = issue.getBundle();
|
||||
|
||||
bundle.putString("commentBody", draftWithRepository.getDraftText());
|
||||
bundle.putString("issueNumber", String.valueOf(draftWithRepository.getIssueId()));
|
||||
bundle.putString("draftTitle", repoInfo.getText().toString());
|
||||
bundle.putString("commentId", draftWithRepository.getCommentId());
|
||||
bundle.putString("draftId", String.valueOf(draftWithRepository.getDraftId()));
|
||||
|
||||
if(!draftWithRepository.getCommentId().isEmpty()) {
|
||||
bundle.putString("commentAction", "edit");
|
||||
}
|
||||
|
||||
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle, issue);
|
||||
bottomSheetReplyFragment.setOnInteractedListener(() -> {
|
||||
Intent i = new IssueContext(new RepositoryContext(draftWithRepository.getRepositoryOwner(), draftWithRepository.getRepositoryName(), context), draftWithRepository.getIssueId(),
|
||||
draftWithRepository.getIssueType()).getIntent(context, IssueDetailActivity.class);
|
||||
i.putExtra("openedFromLink", "true");
|
||||
context.startActivity(i);
|
||||
});
|
||||
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,13 +24,7 @@ import org.mian.gitnex.R;
|
|||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
|
|
|
@ -17,11 +17,7 @@ import com.amulyakhare.textdrawable.util.ColorGenerator;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
|
|
|
@ -4,11 +4,7 @@ import android.content.Context;
|
|||
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 android.widget.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
|
|
@ -27,13 +27,7 @@ import org.mian.gitnex.clients.PicassoService;
|
|||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||
import org.mian.gitnex.fragments.IssuesFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.views.ReactionList;
|
||||
import org.mian.gitnex.views.ReactionSpinner;
|
||||
|
|
|
@ -26,13 +26,7 @@ import org.mian.gitnex.activities.IssueDetailActivity;
|
|||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
|
|
|
@ -29,122 +29,122 @@ import java.util.List;
|
|||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsViewHolder> {
|
||||
public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsViewHolder> {
|
||||
|
||||
private final List<Label> labelsList;
|
||||
private final String type;
|
||||
private final List<Label> labelsList;
|
||||
private final String type;
|
||||
private final String orgName;
|
||||
|
||||
class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||
public LabelsAdapter(Context ctx, List<Label> labelsMain, String type, String orgName) {
|
||||
|
||||
private Label labels;
|
||||
this.labelsList = labelsMain;
|
||||
this.type = type;
|
||||
this.orgName = orgName;
|
||||
}
|
||||
|
||||
private final MaterialCardView labelView;
|
||||
private final ImageView labelIcon;
|
||||
private final TextView labelName;
|
||||
@NonNull
|
||||
@Override
|
||||
public LabelsAdapter.LabelsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_labels, parent, false);
|
||||
return new LabelsAdapter.LabelsViewHolder(v);
|
||||
}
|
||||
|
||||
private LabelsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull LabelsAdapter.LabelsViewHolder holder, int position) {
|
||||
|
||||
labelView = itemView.findViewById(R.id.labelView);
|
||||
labelIcon = itemView.findViewById(R.id.labelIcon);
|
||||
labelName = itemView.findViewById(R.id.labelName);
|
||||
ImageView labelsOptionsMenu = itemView.findViewById(R.id.labelsOptionsMenu);
|
||||
Label currentItem = labelsList.get(position);
|
||||
holder.labels = currentItem;
|
||||
|
||||
if((type.equals("repo") && !((RepoDetailActivity) itemView.getContext()).repository.getPermissions().isPush()) ||
|
||||
(type.equals("org") && (((OrganizationDetailActivity) itemView.getContext()).permissions == null || !((OrganizationDetailActivity) itemView.getContext()).permissions.isIsOwner()))) {
|
||||
labelsOptionsMenu.setVisibility(View.GONE);
|
||||
}
|
||||
labelsOptionsMenu.setOnClickListener(v -> {
|
||||
String labelColor = currentItem.getColor();
|
||||
String labelName = currentItem.getName();
|
||||
|
||||
final Context context = v.getContext();
|
||||
int color = Color.parseColor("#" + labelColor);
|
||||
int contrastColor = new ColorInverter().getContrastColor(color);
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_labels_in_list, null);
|
||||
ImageViewCompat.setImageTintList(holder.labelIcon, ColorStateList.valueOf(contrastColor));
|
||||
|
||||
TextView labelMenuEdit = view.findViewById(R.id.labelMenuEdit);
|
||||
TextView labelMenuDelete = view.findViewById(R.id.labelMenuDelete);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
holder.labelName.setTextColor(contrastColor);
|
||||
holder.labelName.setText(labelName);
|
||||
holder.labelView.setCardBackgroundColor(color);
|
||||
}
|
||||
|
||||
bottomSheetHeader.setText(labels.getName());
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
labelMenuEdit.setOnClickListener(editLabel -> {
|
||||
|
||||
Intent intent = new Intent(context, CreateLabelActivity.class);
|
||||
intent.putExtra("labelId", String.valueOf(labels.getId()));
|
||||
intent.putExtra("labelTitle", labels.getName());
|
||||
intent.putExtra("labelColor", labels.getColor());
|
||||
intent.putExtra("labelAction", "edit");
|
||||
intent.putExtra("type", type);
|
||||
intent.putExtra("orgName", orgName);
|
||||
if(type.equals("repo")) {
|
||||
intent.putExtra(RepositoryContext.INTENT_EXTRA, ((RepoDetailActivity) itemView.getContext()).repository);
|
||||
}
|
||||
context.startActivity(intent);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
labelMenuDelete.setOnClickListener(deleteLabel -> {
|
||||
RepositoryContext repo;
|
||||
if(type.equals("repo")) {
|
||||
repo = ((RepoDetailActivity) itemView.getContext()).repository;
|
||||
} else {
|
||||
repo = null;
|
||||
}
|
||||
|
||||
AlertDialogs.labelDeleteDialog(context, labels.getName(), String.valueOf(labels.getId()),
|
||||
type, orgName, repo);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public LabelsAdapter(Context ctx, List<Label> labelsMain, String type, String orgName) {
|
||||
|
||||
this.labelsList = labelsMain;
|
||||
this.type = type;
|
||||
this.orgName = orgName;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LabelsAdapter.LabelsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_labels, parent, false);
|
||||
return new LabelsAdapter.LabelsViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull LabelsAdapter.LabelsViewHolder holder, int position) {
|
||||
|
||||
Label currentItem = labelsList.get(position);
|
||||
holder.labels = currentItem;
|
||||
|
||||
String labelColor = currentItem.getColor();
|
||||
String labelName = currentItem.getName();
|
||||
|
||||
int color = Color.parseColor("#" + labelColor);
|
||||
int contrastColor = new ColorInverter().getContrastColor(color);
|
||||
|
||||
ImageViewCompat.setImageTintList(holder.labelIcon, ColorStateList.valueOf(contrastColor));
|
||||
|
||||
holder.labelName.setTextColor(contrastColor);
|
||||
holder.labelName.setText(labelName);
|
||||
holder.labelView.setCardBackgroundColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return labelsList.size();
|
||||
}
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return labelsList.size();
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final MaterialCardView labelView;
|
||||
private final ImageView labelIcon;
|
||||
private final TextView labelName;
|
||||
private Label labels;
|
||||
|
||||
private LabelsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
labelView = itemView.findViewById(R.id.labelView);
|
||||
labelIcon = itemView.findViewById(R.id.labelIcon);
|
||||
labelName = itemView.findViewById(R.id.labelName);
|
||||
ImageView labelsOptionsMenu = itemView.findViewById(R.id.labelsOptionsMenu);
|
||||
|
||||
if((type.equals("repo") && !((RepoDetailActivity) itemView.getContext()).repository.getPermissions().isPush()) || (type.equals(
|
||||
"org") && (((OrganizationDetailActivity) itemView.getContext()).permissions == null || !((OrganizationDetailActivity) itemView.getContext()).permissions.isIsOwner()))) {
|
||||
labelsOptionsMenu.setVisibility(View.GONE);
|
||||
}
|
||||
labelsOptionsMenu.setOnClickListener(v -> {
|
||||
|
||||
final Context context = v.getContext();
|
||||
|
||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_labels_in_list, null);
|
||||
|
||||
TextView labelMenuEdit = view.findViewById(R.id.labelMenuEdit);
|
||||
TextView labelMenuDelete = view.findViewById(R.id.labelMenuDelete);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
bottomSheetHeader.setText(labels.getName());
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
labelMenuEdit.setOnClickListener(editLabel -> {
|
||||
|
||||
Intent intent = new Intent(context, CreateLabelActivity.class);
|
||||
intent.putExtra("labelId", String.valueOf(labels.getId()));
|
||||
intent.putExtra("labelTitle", labels.getName());
|
||||
intent.putExtra("labelColor", labels.getColor());
|
||||
intent.putExtra("labelAction", "edit");
|
||||
intent.putExtra("type", type);
|
||||
intent.putExtra("orgName", orgName);
|
||||
if(type.equals("repo")) {
|
||||
intent.putExtra(RepositoryContext.INTENT_EXTRA, ((RepoDetailActivity) itemView.getContext()).repository);
|
||||
}
|
||||
context.startActivity(intent);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
labelMenuDelete.setOnClickListener(deleteLabel -> {
|
||||
RepositoryContext repo;
|
||||
if(type.equals("repo")) {
|
||||
repo = ((RepoDetailActivity) itemView.getContext()).repository;
|
||||
}
|
||||
else {
|
||||
repo = null;
|
||||
}
|
||||
|
||||
AlertDialogs.labelDeleteDialog(context, labels.getName(), String.valueOf(labels.getId()), type, orgName, repo);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,34 +28,6 @@ public class MostVisitedReposAdapter extends RecyclerView.Adapter<MostVisitedRep
|
|||
|
||||
private List<Repository> mostVisitedReposList;
|
||||
|
||||
static class MostVisitedViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Repository repository;
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView repoName;
|
||||
private final TextView orgName;
|
||||
private final TextView mostVisited;
|
||||
|
||||
private MostVisitedViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
image = itemView.findViewById(R.id.image);
|
||||
repoName = itemView.findViewById(R.id.repo_name);
|
||||
orgName = itemView.findViewById(R.id.org_name);
|
||||
mostVisited = itemView.findViewById(R.id.most_visited);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
Context context = v.getContext();
|
||||
RepositoryContext repositoryContext = new RepositoryContext(repository.getRepositoryOwner(), repository.getRepositoryName(), context);
|
||||
Intent intent = repositoryContext.getIntent(context, RepoDetailActivity.class);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public MostVisitedReposAdapter(List<Repository> reposListMain) {
|
||||
this.mostVisitedReposList = reposListMain;
|
||||
}
|
||||
|
@ -100,4 +72,33 @@ public class MostVisitedReposAdapter extends RecyclerView.Adapter<MostVisitedRep
|
|||
mostVisitedReposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
static class MostVisitedViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView repoName;
|
||||
private final TextView orgName;
|
||||
private final TextView mostVisited;
|
||||
private Repository repository;
|
||||
|
||||
private MostVisitedViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
image = itemView.findViewById(R.id.image);
|
||||
repoName = itemView.findViewById(R.id.repo_name);
|
||||
orgName = itemView.findViewById(R.id.org_name);
|
||||
mostVisited = itemView.findViewById(R.id.most_visited);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
Context context = v.getContext();
|
||||
RepositoryContext repositoryContext = new RepositoryContext(repository.getRepositoryOwner(), repository.getRepositoryName(), context);
|
||||
Intent intent = repositoryContext.getIntent(context, RepoDetailActivity.class);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,121 +28,10 @@ import java.util.List;
|
|||
public class OrganizationsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Filterable {
|
||||
|
||||
private final Context context;
|
||||
private List<Organization> orgList;
|
||||
private final List<Organization> orgListFull;
|
||||
private List<Organization> orgList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public OrganizationsListAdapter(Context ctx, List<Organization> orgListMain) {
|
||||
this.context = ctx;
|
||||
this.orgList = orgListMain;
|
||||
orgListFull = new ArrayList<>(orgList);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
return new OrganizationsListAdapter.OrgHolder(inflater.inflate(R.layout.list_organizations, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
}
|
||||
|
||||
((OrganizationsListAdapter.OrgHolder) holder).bindData(orgList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return orgList.size();
|
||||
}
|
||||
|
||||
class OrgHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Organization userOrganizations;
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView orgName;
|
||||
private final TextView orgDescription;
|
||||
|
||||
OrgHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
orgName = itemView.findViewById(R.id.orgName);
|
||||
orgDescription = itemView.findViewById(R.id.orgDescription);
|
||||
image = itemView.findViewById(R.id.imageAvatar);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
||||
intent.putExtra("orgName", userOrganizations.getUsername());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
void bindData(Organization org) {
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
|
||||
this.userOrganizations = org;
|
||||
orgName.setText(org.getUsername());
|
||||
|
||||
PicassoService.getInstance(context).get().load(org.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
|
||||
if(!org.getDescription().equals("")) {
|
||||
orgDescription.setVisibility(View.VISIBLE);
|
||||
orgDescription.setText(org.getDescription());
|
||||
}
|
||||
else {
|
||||
orgDescription.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public abstract static class OnLoadMoreListener {
|
||||
protected abstract void onLoadMore();
|
||||
public void onLoadFinished() {}
|
||||
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Organization> list) {
|
||||
orgList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return orgFilter;
|
||||
}
|
||||
|
||||
private final Filter orgFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
|
@ -179,4 +68,117 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||
notifyDataChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public OrganizationsListAdapter(Context ctx, List<Organization> orgListMain) {
|
||||
this.context = ctx;
|
||||
this.orgList = orgListMain;
|
||||
orgListFull = new ArrayList<>(orgList);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
return new OrganizationsListAdapter.OrgHolder(inflater.inflate(R.layout.list_organizations, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
}
|
||||
|
||||
((OrganizationsListAdapter.OrgHolder) holder).bindData(orgList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return orgList.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Organization> list) {
|
||||
orgList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return orgFilter;
|
||||
}
|
||||
|
||||
public abstract static class OnLoadMoreListener {
|
||||
|
||||
protected abstract void onLoadMore();
|
||||
|
||||
public void onLoadFinished() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class OrgHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView orgName;
|
||||
private final TextView orgDescription;
|
||||
private Organization userOrganizations;
|
||||
|
||||
OrgHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
orgName = itemView.findViewById(R.id.orgName);
|
||||
orgDescription = itemView.findViewById(R.id.orgDescription);
|
||||
image = itemView.findViewById(R.id.imageAvatar);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
||||
intent.putExtra("orgName", userOrganizations.getUsername());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
void bindData(Organization org) {
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
|
||||
this.userOrganizations = org;
|
||||
orgName.setText(org.getUsername());
|
||||
|
||||
PicassoService.getInstance(context).get().load(org.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
|
||||
if(!org.getDescription().equals("")) {
|
||||
orgDescription.setVisibility(View.VISIBLE);
|
||||
orgDescription.setText(org.getDescription());
|
||||
}
|
||||
else {
|
||||
orgDescription.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,13 +26,7 @@ import org.mian.gitnex.activities.IssueDetailActivity;
|
|||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
|
|
@ -23,13 +23,7 @@ import org.mian.gitnex.activities.RepoDetailActivity;
|
|||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentReleasesBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.structs.FragmentRefreshListener;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -43,192 +37,118 @@ import retrofit2.Response;
|
|||
|
||||
public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.ReleasesViewHolder> {
|
||||
|
||||
private List<Release> releasesList;
|
||||
private final Context context;
|
||||
private final Context context;
|
||||
private final String repoOwner;
|
||||
private final String repoName;
|
||||
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final FragmentRefreshListener startDownload;
|
||||
private final FragmentReleasesBinding fragmentReleasesBinding;
|
||||
private List<Release> releasesList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
protected class ReleasesViewHolder extends RecyclerView.ViewHolder {
|
||||
public ReleasesAdapter(Context ctx, List<Release> releasesMain, FragmentRefreshListener startDownload, String repoOwner, String repoName, FragmentReleasesBinding fragmentReleasesBinding) {
|
||||
this.context = ctx;
|
||||
this.releasesList = releasesMain;
|
||||
this.startDownload = startDownload;
|
||||
this.repoOwner = repoOwner;
|
||||
this.repoName = repoName;
|
||||
this.fragmentReleasesBinding = fragmentReleasesBinding;
|
||||
}
|
||||
|
||||
private Release releases;
|
||||
@NonNull
|
||||
@Override
|
||||
public ReleasesAdapter.ReleasesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_releases, parent, false);
|
||||
return new ReleasesAdapter.ReleasesViewHolder(v);
|
||||
}
|
||||
|
||||
private final TextView releaseType;
|
||||
private final TextView releaseName;
|
||||
private final ImageView authorAvatar;
|
||||
private final TextView authorName;
|
||||
private final TextView releaseTag;
|
||||
private final TextView releaseDate;
|
||||
private final TextView releaseBodyContent;
|
||||
private final LinearLayout downloadCopyFrame;
|
||||
private final LinearLayout downloads;
|
||||
private final LinearLayout releaseZipDownloadFrame;
|
||||
private final LinearLayout releaseTarDownloadFrame;
|
||||
private final ImageView downloadDropdownIcon;
|
||||
private final RecyclerView downloadList;
|
||||
private final ImageView optionsMenu;
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ReleasesAdapter.ReleasesViewHolder holder, int position) {
|
||||
|
||||
private ReleasesViewHolder(View itemView) {
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
final Locale locale = context.getResources().getConfiguration().locale;
|
||||
final String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
super(itemView);
|
||||
Release currentItem = releasesList.get(position);
|
||||
holder.releases = currentItem;
|
||||
|
||||
releaseType = itemView.findViewById(R.id.releaseType);
|
||||
releaseName = itemView.findViewById(R.id.releaseName);
|
||||
authorAvatar = itemView.findViewById(R.id.authorAvatar);
|
||||
authorName = itemView.findViewById(R.id.authorName);
|
||||
releaseTag = itemView.findViewById(R.id.releaseTag);
|
||||
TextView releaseCommitSha = itemView.findViewById(R.id.releaseCommitSha);
|
||||
releaseDate = itemView.findViewById(R.id.releaseDate);
|
||||
releaseBodyContent = itemView.findViewById(R.id.releaseBodyContent);
|
||||
downloadCopyFrame = itemView.findViewById(R.id.downloadCopyFrame);
|
||||
downloads = itemView.findViewById(R.id.downloads);
|
||||
releaseZipDownloadFrame = itemView.findViewById(R.id.releaseZipDownloadFrame);
|
||||
releaseTarDownloadFrame = itemView.findViewById(R.id.releaseTarDownloadFrame);
|
||||
downloadDropdownIcon = itemView.findViewById(R.id.downloadDropdownIcon);
|
||||
downloadList = itemView.findViewById(R.id.downloadList);
|
||||
optionsMenu = itemView.findViewById(R.id.releasesOptionsMenu);
|
||||
holder.releaseName.setText(currentItem.getName());
|
||||
|
||||
downloadList.setHasFixedSize(true);
|
||||
downloadList.setLayoutManager(new LinearLayoutManager(itemView.getContext()));
|
||||
if(currentItem.isPrerelease()) {
|
||||
holder.releaseType.setBackgroundResource(R.drawable.shape_pre_release);
|
||||
holder.releaseType.setText(R.string.releaseTypePre);
|
||||
}
|
||||
else if(currentItem.isDraft()) {
|
||||
holder.releaseType.setBackgroundResource(R.drawable.shape_draft_release);
|
||||
holder.releaseType.setText(R.string.releaseDraftText);
|
||||
}
|
||||
else {
|
||||
holder.releaseType.setBackgroundResource(R.drawable.shape_stable_release);
|
||||
holder.releaseType.setText(R.string.releaseTypeStable);
|
||||
}
|
||||
|
||||
new Handler().postDelayed(() -> {
|
||||
if(!AppUtil.checkGhostUsers(releases.getAuthor().getLogin())) {
|
||||
if(currentItem.getAuthor().getAvatarUrl() != null) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAuthor().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(holder.authorAvatar);
|
||||
}
|
||||
|
||||
authorAvatar.setOnClickListener(loginId -> {
|
||||
Context context = loginId.getContext();
|
||||
holder.authorName.setText(context.getResources().getString(R.string.releasePublishedBy, currentItem.getAuthor().getLogin()));
|
||||
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", releases.getAuthor().getLogin());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
if(currentItem.getTagName() != null) {
|
||||
holder.releaseTag.setText(currentItem.getTagName());
|
||||
}
|
||||
|
||||
optionsMenu.setOnClickListener(v -> {
|
||||
final Context context = v.getContext();
|
||||
if(currentItem.getPublishedAt() != null) {
|
||||
holder.releaseDate.setText(TimeHelper.formatTime(currentItem.getPublishedAt(), locale, timeFormat, context));
|
||||
}
|
||||
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_release_in_list, itemView.findViewById(android.R.id.content), false);
|
||||
if(timeFormat.equals("pretty")) {
|
||||
holder.releaseDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getPublishedAt()), context));
|
||||
}
|
||||
|
||||
TextView deleteRelease = view.findViewById(R.id.deleteRelease);
|
||||
if(!currentItem.getBody().equals("")) {
|
||||
Markdown.render(context, currentItem.getBody(), holder.releaseBodyContent);
|
||||
}
|
||||
else {
|
||||
holder.releaseBodyContent.setText(R.string.noReleaseBodyContent);
|
||||
}
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
holder.downloadCopyFrame.setOnClickListener(v -> {
|
||||
|
||||
deleteRelease.setOnClickListener(v1 -> {
|
||||
deleteRelease(context, releases.getName(), releases.getId(), repoOwner, repoName, getBindingAdapterPosition());
|
||||
dialog.dismiss();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
if(holder.downloads.getVisibility() == View.GONE) {
|
||||
|
||||
public ReleasesAdapter(Context ctx, List<Release> releasesMain, FragmentRefreshListener startDownload, String repoOwner, String repoName, FragmentReleasesBinding fragmentReleasesBinding) {
|
||||
this.context = ctx;
|
||||
this.releasesList = releasesMain;
|
||||
this.startDownload = startDownload;
|
||||
this.repoOwner = repoOwner;
|
||||
this.repoName = repoName;
|
||||
this.fragmentReleasesBinding = fragmentReleasesBinding;
|
||||
}
|
||||
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_down);
|
||||
holder.downloads.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ReleasesAdapter.ReleasesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_releases, parent, false);
|
||||
return new ReleasesAdapter.ReleasesViewHolder(v);
|
||||
}
|
||||
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_right);
|
||||
holder.downloads.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ReleasesAdapter.ReleasesViewHolder holder, int position) {
|
||||
});
|
||||
|
||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||
final Locale locale = context.getResources().getConfiguration().locale;
|
||||
final String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
holder.releaseZipDownloadFrame.setOnClickListener(v -> startDownload.onRefresh(currentItem.getZipballUrl()));
|
||||
holder.releaseTarDownloadFrame.setOnClickListener(v -> startDownload.onRefresh(currentItem.getTarballUrl()));
|
||||
|
||||
Release currentItem = releasesList.get(position);
|
||||
holder.releases = currentItem;
|
||||
ReleasesDownloadsAdapter adapter = new ReleasesDownloadsAdapter(currentItem.getAssets(), startDownload);
|
||||
holder.downloadList.setAdapter(adapter);
|
||||
|
||||
holder.releaseName.setText(currentItem.getName());
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
}
|
||||
|
||||
if(currentItem.isPrerelease()) {
|
||||
holder.releaseType.setBackgroundResource(R.drawable.shape_pre_release);
|
||||
holder.releaseType.setText(R.string.releaseTypePre);
|
||||
}
|
||||
else if(currentItem.isDraft()) {
|
||||
holder.releaseType.setBackgroundResource(R.drawable.shape_draft_release);
|
||||
holder.releaseType.setText(R.string.releaseDraftText);
|
||||
}
|
||||
else {
|
||||
holder.releaseType.setBackgroundResource(R.drawable.shape_stable_release);
|
||||
holder.releaseType.setText(R.string.releaseTypeStable);
|
||||
}
|
||||
if(!((RepoDetailActivity) context).repository.getPermissions().isPush()) {
|
||||
holder.optionsMenu.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if(currentItem.getAuthor().getAvatarUrl() != null) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAuthor().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.authorAvatar);
|
||||
}
|
||||
|
||||
holder.authorName.setText(context.getResources().getString(R.string.releasePublishedBy, currentItem.getAuthor().getLogin()));
|
||||
|
||||
if(currentItem.getTagName() != null) {
|
||||
holder.releaseTag.setText(currentItem.getTagName());
|
||||
}
|
||||
|
||||
if(currentItem.getPublishedAt() != null) {
|
||||
holder.releaseDate.setText(TimeHelper.formatTime(currentItem.getPublishedAt(), locale, timeFormat, context));
|
||||
}
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
holder.releaseDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getPublishedAt()), context));
|
||||
}
|
||||
|
||||
if(!currentItem.getBody().equals("")) {
|
||||
Markdown.render(context, currentItem.getBody(), holder.releaseBodyContent);
|
||||
}
|
||||
else {
|
||||
holder.releaseBodyContent.setText(R.string.noReleaseBodyContent);
|
||||
}
|
||||
|
||||
holder.downloadCopyFrame.setOnClickListener(v -> {
|
||||
|
||||
if(holder.downloads.getVisibility() == View.GONE) {
|
||||
|
||||
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_down);
|
||||
holder.downloads.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
|
||||
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_right);
|
||||
holder.downloads.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
holder.releaseZipDownloadFrame.setOnClickListener(v -> startDownload.onRefresh(currentItem.getZipballUrl()));
|
||||
holder.releaseTarDownloadFrame.setOnClickListener(v -> startDownload.onRefresh(currentItem.getTarballUrl()));
|
||||
|
||||
ReleasesDownloadsAdapter adapter = new ReleasesDownloadsAdapter(currentItem.getAssets(), startDownload);
|
||||
holder.downloadList.setAdapter(adapter);
|
||||
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
}
|
||||
|
||||
if(!((RepoDetailActivity) context).repository.getPermissions().isPush()) {
|
||||
holder.optionsMenu.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return releasesList.size();
|
||||
}
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return releasesList.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
|
@ -244,12 +164,6 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
@ -269,36 +183,116 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
materialAlertDialogBuilder.setTitle(String.format(context.getString(R.string.deleteGenericTitle), releaseName))
|
||||
.setMessage(R.string.deleteReleaseConfirmation)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient
|
||||
.getApiInterface(context).repoDeleteRelease(owner, repo, releaseId).enqueue(new Callback<>() {
|
||||
materialAlertDialogBuilder.setTitle(String.format(context.getString(R.string.deleteGenericTitle), releaseName)).setMessage(R.string.deleteReleaseConfirmation)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient.getApiInterface(context).repoDeleteRelease(owner, repo, releaseId).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
updateAdapter(position);
|
||||
Toasty.success(context, context.getString(R.string.releaseDeleted));
|
||||
MainActivity.reloadRepos = true;
|
||||
if(getItemCount() == 0) {
|
||||
fragmentReleasesBinding.noDataReleases.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
if(response.isSuccessful()) {
|
||||
updateAdapter(position);
|
||||
Toasty.success(context, context.getString(R.string.releaseDeleted));
|
||||
MainActivity.reloadRepos = true;
|
||||
if(getItemCount() == 0) {
|
||||
fragmentReleasesBinding.noDataReleases.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}))
|
||||
.setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
})).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
protected class ReleasesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView releaseType;
|
||||
private final TextView releaseName;
|
||||
private final ImageView authorAvatar;
|
||||
private final TextView authorName;
|
||||
private final TextView releaseTag;
|
||||
private final TextView releaseDate;
|
||||
private final TextView releaseBodyContent;
|
||||
private final LinearLayout downloadCopyFrame;
|
||||
private final LinearLayout downloads;
|
||||
private final LinearLayout releaseZipDownloadFrame;
|
||||
private final LinearLayout releaseTarDownloadFrame;
|
||||
private final ImageView downloadDropdownIcon;
|
||||
private final RecyclerView downloadList;
|
||||
private final ImageView optionsMenu;
|
||||
private Release releases;
|
||||
|
||||
private ReleasesViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
releaseType = itemView.findViewById(R.id.releaseType);
|
||||
releaseName = itemView.findViewById(R.id.releaseName);
|
||||
authorAvatar = itemView.findViewById(R.id.authorAvatar);
|
||||
authorName = itemView.findViewById(R.id.authorName);
|
||||
releaseTag = itemView.findViewById(R.id.releaseTag);
|
||||
TextView releaseCommitSha = itemView.findViewById(R.id.releaseCommitSha);
|
||||
releaseDate = itemView.findViewById(R.id.releaseDate);
|
||||
releaseBodyContent = itemView.findViewById(R.id.releaseBodyContent);
|
||||
downloadCopyFrame = itemView.findViewById(R.id.downloadCopyFrame);
|
||||
downloads = itemView.findViewById(R.id.downloads);
|
||||
releaseZipDownloadFrame = itemView.findViewById(R.id.releaseZipDownloadFrame);
|
||||
releaseTarDownloadFrame = itemView.findViewById(R.id.releaseTarDownloadFrame);
|
||||
downloadDropdownIcon = itemView.findViewById(R.id.downloadDropdownIcon);
|
||||
downloadList = itemView.findViewById(R.id.downloadList);
|
||||
optionsMenu = itemView.findViewById(R.id.releasesOptionsMenu);
|
||||
|
||||
downloadList.setHasFixedSize(true);
|
||||
downloadList.setLayoutManager(new LinearLayoutManager(itemView.getContext()));
|
||||
|
||||
new Handler().postDelayed(() -> {
|
||||
if(!AppUtil.checkGhostUsers(releases.getAuthor().getLogin())) {
|
||||
|
||||
authorAvatar.setOnClickListener(loginId -> {
|
||||
Context context = loginId.getContext();
|
||||
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", releases.getAuthor().getLogin());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
|
||||
optionsMenu.setOnClickListener(v -> {
|
||||
final Context context = v.getContext();
|
||||
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_release_in_list, itemView.findViewById(android.R.id.content), false);
|
||||
|
||||
TextView deleteRelease = view.findViewById(R.id.deleteRelease);
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
deleteRelease.setOnClickListener(v1 -> {
|
||||
deleteRelease(context, releases.getName(), releases.getId(), repoOwner, repoName, getBindingAdapterPosition());
|
||||
dialog.dismiss();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,11 +17,7 @@ import com.amulyakhare.textdrawable.util.ColorGenerator;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
|
@ -200,6 +196,7 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,11 +7,7 @@ import android.graphics.Typeface;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
|
@ -19,11 +15,7 @@ import com.amulyakhare.textdrawable.util.ColorGenerator;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
|
|
|
@ -31,122 +31,77 @@ import retrofit2.Response;
|
|||
|
||||
public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder> {
|
||||
|
||||
private List<Tag> tags;
|
||||
private final Context context;
|
||||
private final String repo;
|
||||
private final String owner;
|
||||
private final Context context;
|
||||
private final String repo;
|
||||
private final String owner;
|
||||
private final FragmentRefreshListener startDownload;
|
||||
private final FragmentReleasesBinding fragmentReleasesBinding;
|
||||
private List<Tag> tags;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
protected class TagsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Tag tagsHolder;
|
||||
private final TextView tagName;
|
||||
private final TextView tagBody;
|
||||
private final LinearLayout downloadCopyFrame;
|
||||
private final LinearLayout downloads;
|
||||
private final LinearLayout releaseZipDownloadFrame;
|
||||
private final LinearLayout releaseTarDownloadFrame;
|
||||
private final ImageView downloadDropdownIcon;
|
||||
private final ImageView options;
|
||||
|
||||
private TagsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
tagName = itemView.findViewById(R.id.tagName);
|
||||
tagBody = itemView.findViewById(R.id.tagBodyContent);
|
||||
downloadCopyFrame = itemView.findViewById(R.id.downloadCopyFrame);
|
||||
downloads = itemView.findViewById(R.id.downloads);
|
||||
releaseZipDownloadFrame = itemView.findViewById(R.id.releaseZipDownloadFrame);
|
||||
releaseTarDownloadFrame = itemView.findViewById(R.id.releaseTarDownloadFrame);
|
||||
downloadDropdownIcon = itemView.findViewById(R.id.downloadDropdownIcon);
|
||||
options = itemView.findViewById(R.id.tagsOptionsMenu);
|
||||
|
||||
options.setOnClickListener(v -> {
|
||||
final Context context = v.getContext();
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_tag_in_list, null);
|
||||
|
||||
TextView delete = view.findViewById(R.id.tagMenuDelete);
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
delete.setOnClickListener(v1 -> {
|
||||
tagDeleteDialog(context, tagsHolder.getName(), owner, repo, getBindingAdapterPosition());
|
||||
dialog.dismiss();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public TagsAdapter(Context ctx, List<Tag> releasesMain, String repoOwner, String repoName, FragmentRefreshListener startDownload, FragmentReleasesBinding fragmentReleasesBinding) {
|
||||
this.context = ctx;
|
||||
this.tags = releasesMain;
|
||||
owner = repoOwner;
|
||||
repo = repoName;
|
||||
public TagsAdapter(Context ctx, List<Tag> releasesMain, String repoOwner, String repoName, FragmentRefreshListener startDownload, FragmentReleasesBinding fragmentReleasesBinding) {
|
||||
this.context = ctx;
|
||||
this.tags = releasesMain;
|
||||
owner = repoOwner;
|
||||
repo = repoName;
|
||||
this.startDownload = startDownload;
|
||||
this.fragmentReleasesBinding = fragmentReleasesBinding;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public TagsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_tags, parent, false);
|
||||
return new TagsViewHolder(v);
|
||||
}
|
||||
@NonNull
|
||||
@Override
|
||||
public TagsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_tags, parent, false);
|
||||
return new TagsViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull TagsViewHolder holder, int position) {
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull TagsViewHolder holder, int position) {
|
||||
|
||||
Tag currentItem = tags.get(position);
|
||||
holder.tagsHolder = currentItem;
|
||||
Tag currentItem = tags.get(position);
|
||||
holder.tagsHolder = currentItem;
|
||||
|
||||
holder.tagName.setText(currentItem.getName());
|
||||
holder.tagName.setText(currentItem.getName());
|
||||
|
||||
if(!currentItem.getMessage().equals("")) {
|
||||
Markdown.render(context, currentItem.getMessage(), holder.tagBody);
|
||||
}
|
||||
else {
|
||||
holder.tagBody.setVisibility(View.GONE);
|
||||
}
|
||||
if(!currentItem.getMessage().equals("")) {
|
||||
Markdown.render(context, currentItem.getMessage(), holder.tagBody);
|
||||
}
|
||||
else {
|
||||
holder.tagBody.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
holder.downloadCopyFrame.setOnClickListener(v -> {
|
||||
holder.downloadCopyFrame.setOnClickListener(v -> {
|
||||
|
||||
if(holder.downloads.getVisibility() == View.GONE) {
|
||||
if(holder.downloads.getVisibility() == View.GONE) {
|
||||
|
||||
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_down);
|
||||
holder.downloads.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_down);
|
||||
holder.downloads.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
|
||||
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_right);
|
||||
holder.downloads.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_right);
|
||||
holder.downloads.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
if(!((RepoDetailActivity) context).repository.getPermissions().isPush()) {
|
||||
holder.options.setVisibility(View.GONE);
|
||||
}
|
||||
if(!((RepoDetailActivity) context).repository.getPermissions().isPush()) {
|
||||
holder.options.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
holder.releaseZipDownloadFrame.setOnClickListener(v -> startDownload.onRefresh(currentItem.getZipballUrl()));
|
||||
holder.releaseTarDownloadFrame.setOnClickListener(v -> startDownload.onRefresh(currentItem.getTarballUrl()));
|
||||
holder.releaseZipDownloadFrame.setOnClickListener(v -> startDownload.onRefresh(currentItem.getZipballUrl()));
|
||||
holder.releaseTarDownloadFrame.setOnClickListener(v -> startDownload.onRefresh(currentItem.getTarballUrl()));
|
||||
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
}
|
||||
}
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return tags.size();
|
||||
}
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return tags.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
|
@ -162,11 +117,6 @@ public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder
|
|||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
void onLoadMore();
|
||||
void onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
@ -184,43 +134,92 @@ public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder
|
|||
|
||||
private void tagDeleteDialog(final Context context, final String tagName, final String owner, final String repo, int position) {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context)
|
||||
.setTitle(String.format(context.getString(R.string.deleteGenericTitle), tagName))
|
||||
.setMessage(R.string.deleteTagConfirmation)
|
||||
.setCancelable(false)
|
||||
.setNeutralButton(R.string.cancelButton, null)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient
|
||||
.getApiInterface(context).repoDeleteTag(owner, repo, tagName).enqueue(new Callback<>() {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context).setTitle(String.format(context.getString(R.string.deleteGenericTitle), tagName))
|
||||
.setMessage(R.string.deleteTagConfirmation).setCancelable(false).setNeutralButton(R.string.cancelButton, null)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient.getApiInterface(context).repoDeleteTag(owner, repo, tagName).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
updateAdapter(position);
|
||||
Toasty.success(context, context.getString(R.string.tagDeleted));
|
||||
if(getItemCount() == 0) {
|
||||
fragmentReleasesBinding.noDataReleases.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 409) {
|
||||
Toasty.error(context, context.getString(R.string.tagDeleteError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
if(response.isSuccessful()) {
|
||||
updateAdapter(position);
|
||||
Toasty.success(context, context.getString(R.string.tagDeleted));
|
||||
if(getItemCount() == 0) {
|
||||
fragmentReleasesBinding.noDataReleases.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 409) {
|
||||
Toasty.error(context, context.getString(R.string.tagDeleteError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}))
|
||||
.setNeutralButton(R.string.cancelButton, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
})).setNeutralButton(R.string.cancelButton, null);
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
protected class TagsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView tagName;
|
||||
private final TextView tagBody;
|
||||
private final LinearLayout downloadCopyFrame;
|
||||
private final LinearLayout downloads;
|
||||
private final LinearLayout releaseZipDownloadFrame;
|
||||
private final LinearLayout releaseTarDownloadFrame;
|
||||
private final ImageView downloadDropdownIcon;
|
||||
private final ImageView options;
|
||||
private Tag tagsHolder;
|
||||
|
||||
private TagsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
tagName = itemView.findViewById(R.id.tagName);
|
||||
tagBody = itemView.findViewById(R.id.tagBodyContent);
|
||||
downloadCopyFrame = itemView.findViewById(R.id.downloadCopyFrame);
|
||||
downloads = itemView.findViewById(R.id.downloads);
|
||||
releaseZipDownloadFrame = itemView.findViewById(R.id.releaseZipDownloadFrame);
|
||||
releaseTarDownloadFrame = itemView.findViewById(R.id.releaseTarDownloadFrame);
|
||||
downloadDropdownIcon = itemView.findViewById(R.id.downloadDropdownIcon);
|
||||
options = itemView.findViewById(R.id.tagsOptionsMenu);
|
||||
|
||||
options.setOnClickListener(v -> {
|
||||
final Context context = v.getContext();
|
||||
|
||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_tag_in_list, null);
|
||||
|
||||
TextView delete = view.findViewById(R.id.tagMenuDelete);
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
delete.setOnClickListener(v1 -> {
|
||||
tagDeleteDialog(context, tagsHolder.getName(), owner, repo, getBindingAdapterPosition());
|
||||
dialog.dismiss();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,13 +49,70 @@ public class TeamRepositoriesAdapter extends RecyclerView.Adapter<TeamRepositori
|
|||
reposArr = new ArrayList<>();
|
||||
}
|
||||
|
||||
class TeamReposViewHolder extends RecyclerView.ViewHolder {
|
||||
@NonNull
|
||||
@Override
|
||||
public TeamRepositoriesAdapter.TeamReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_collaborators_search, parent, false);
|
||||
return new TeamRepositoriesAdapter.TeamReposViewHolder(v);
|
||||
}
|
||||
|
||||
private Repository repoInfo;
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final TeamRepositoriesAdapter.TeamReposViewHolder holder, int position) {
|
||||
|
||||
Repository currentItem = reposList.get(position);
|
||||
holder.repoInfo = currentItem;
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
|
||||
holder.name.setText(currentItem.getName());
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig()
|
||||
.buildRoundRect(String.valueOf(currentItem.getFullName().charAt(0)), ColorGenerator.Companion.getMATERIAL().getColor(currentItem.getName()), 14);
|
||||
|
||||
if(currentItem.getAvatarUrl() != null && !currentItem.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(holder.repoAvatar);
|
||||
}
|
||||
else {
|
||||
holder.repoAvatar.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return reposList.size();
|
||||
}
|
||||
|
||||
private void getTeamRepos() {
|
||||
|
||||
if(getItemCount() > 0) {
|
||||
Call<List<Repository>> call = RetrofitClient.getApiInterface(context).orgListTeamRepos((long) teamId, 1, 50);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
for(int i = 0; i < Objects.requireNonNull(response.body()).size(); i++) {
|
||||
reposArr.addAll(response.body());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Repository>> call, @NonNull Throwable t) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class TeamReposViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView repoAvatar;
|
||||
private final TextView name;
|
||||
private final ImageView addRepoButtonAdd;
|
||||
private Repository repoInfo;
|
||||
|
||||
private TeamReposViewHolder(View itemView) {
|
||||
|
||||
|
@ -89,69 +146,9 @@ public class TeamRepositoriesAdapter extends RecyclerView.Adapter<TeamRepositori
|
|||
|
||||
addRepoButtonAdd.setOnClickListener(v -> AlertDialogs.addRepoDialog(context, orgName, repoInfo.getName(), Integer.parseInt(String.valueOf(teamId)), teamName));
|
||||
|
||||
addRepoButtonRemove.setOnClickListener(v ->
|
||||
AlertDialogs.removeRepoDialog(context, orgName, repoInfo.getName(), Integer.parseInt(String.valueOf(teamId)), teamName));
|
||||
addRepoButtonRemove.setOnClickListener(v -> AlertDialogs.removeRepoDialog(context, orgName, repoInfo.getName(), Integer.parseInt(String.valueOf(teamId)), teamName));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public TeamRepositoriesAdapter.TeamReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_collaborators_search, parent, false);
|
||||
return new TeamRepositoriesAdapter.TeamReposViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final TeamRepositoriesAdapter.TeamReposViewHolder holder, int position) {
|
||||
|
||||
Repository currentItem = reposList.get(position);
|
||||
holder.repoInfo = currentItem;
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
|
||||
holder.name.setText(currentItem.getName());
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28)
|
||||
.endConfig().buildRoundRect(String.valueOf(currentItem.getFullName().charAt(0)), ColorGenerator.Companion.getMATERIAL().getColor(currentItem.getName()), 14);
|
||||
|
||||
if(currentItem.getAvatarUrl() != null && !currentItem.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.repoAvatar);
|
||||
}
|
||||
else {
|
||||
holder.repoAvatar.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return reposList.size();
|
||||
}
|
||||
|
||||
private void getTeamRepos() {
|
||||
|
||||
if(getItemCount() > 0) {
|
||||
Call<List<Repository>> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.orgListTeamRepos((long) teamId, 1, 50);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
for(int i = 0; i < Objects.requireNonNull(response.body()).size(); i++) {
|
||||
reposArr.addAll(response.body());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Repository>> call, @NonNull Throwable t) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,98 +42,6 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||
private final Context context;
|
||||
private final Dialog dialog;
|
||||
|
||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private int accountId;
|
||||
private String accountName;
|
||||
|
||||
private final TextView accountUrl;
|
||||
private final TextView userId;
|
||||
private final ImageView activeAccount;
|
||||
private final ImageView deleteAccount;
|
||||
private final ImageView repoAvatar;
|
||||
|
||||
private UserAccountsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
accountUrl = itemView.findViewById(R.id.accountUrl);
|
||||
userId = itemView.findViewById(R.id.userId);
|
||||
activeAccount = itemView.findViewById(R.id.activeAccount);
|
||||
deleteAccount = itemView.findViewById(R.id.deleteAccount);
|
||||
repoAvatar = itemView.findViewById(R.id.repoAvatar);
|
||||
|
||||
deleteAccount.setOnClickListener(itemDelete -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context)
|
||||
.setTitle(context.getResources().getString(R.string.removeAccountPopupTitle))
|
||||
.setMessage(context.getResources().getString(R.string.removeAccountPopupMessage))
|
||||
.setNeutralButton(context.getResources().getString(R.string.cancelButton), null)
|
||||
.setPositiveButton(context.getResources().getString(R.string.removeButton), (dialog, which) -> {
|
||||
|
||||
updateLayoutByPosition(getBindingAdapterPosition());
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
|
||||
assert userAccountsApi != null;
|
||||
userAccountsApi.deleteAccount(Integer.parseInt(String.valueOf(accountId)));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
|
||||
itemView.setOnClickListener(switchAccount -> {
|
||||
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
|
||||
assert userAccountsApi != null;
|
||||
UserAccount userAccount = userAccountsApi.getAccountByName(accountName);
|
||||
|
||||
if(!userAccount.isLoggedIn()) {
|
||||
UrlBuilder url = UrlBuilder.fromString(userAccount.getInstanceUrl())
|
||||
.withPath("/");
|
||||
|
||||
String host;
|
||||
if(url.scheme.equals("http")) {
|
||||
if(url.port == 80 || url.port == 0) {
|
||||
host = url.hostName;
|
||||
} else {
|
||||
host = url.hostName + ":" + url.port;
|
||||
}
|
||||
} else {
|
||||
if(url.port == 443 || url.port == 0) {
|
||||
host = url.hostName;
|
||||
} else {
|
||||
host = url.hostName + ":" + url.port;
|
||||
}
|
||||
}
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.logInAgain));
|
||||
dialog.dismiss();
|
||||
|
||||
Intent i = new Intent(context, AddNewAccountActivity.class);
|
||||
i.putExtra("instanceUrl", host);
|
||||
i.putExtra("scheme", url.scheme);
|
||||
i.putExtra("token", userAccount.getToken());
|
||||
context.startActivity(i);
|
||||
return;
|
||||
}
|
||||
|
||||
if(AppUtil.switchToAccount(context, userAccount)) {
|
||||
|
||||
String url = UrlBuilder.fromString(userAccount.getInstanceUrl())
|
||||
.withPath("/")
|
||||
.toString();
|
||||
|
||||
Toasty.success(context, context.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url));
|
||||
getNotificationsCount();
|
||||
((Activity) context).recreate();
|
||||
dialog.dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public UserAccountsAdapter(Context ctx, Dialog dialog) {
|
||||
this.dialog = dialog;
|
||||
this.context = ctx;
|
||||
|
@ -190,9 +98,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||
UserAccount currentItem = userAccountsList.get(position);
|
||||
TinyDB tinyDB = TinyDB.getInstance(context);
|
||||
|
||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
||||
.withPath("/")
|
||||
.toString();
|
||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl()).withPath("/").toString();
|
||||
|
||||
holder.accountId = currentItem.getAccountId();
|
||||
holder.accountName = currentItem.getAccountName();
|
||||
|
@ -200,18 +106,14 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||
holder.userId.setText(currentItem.getUserName());
|
||||
if(currentItem.isLoggedIn()) {
|
||||
holder.accountUrl.setText(url);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
holder.accountUrl.setText(context.getString(R.string.notLoggedIn, url));
|
||||
}
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(url + "assets/img/favicon.png")
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
.centerCrop()
|
||||
PicassoService.getInstance(context).get().load(url + "assets/img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(holder.repoAvatar);
|
||||
|
||||
if(tinyDB.getInt("currentActiveAccountId") == currentItem.getAccountId()) {
|
||||
|
@ -227,4 +129,93 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||
return userAccountsList.size();
|
||||
}
|
||||
|
||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView accountUrl;
|
||||
private final TextView userId;
|
||||
private final ImageView activeAccount;
|
||||
private final ImageView deleteAccount;
|
||||
private final ImageView repoAvatar;
|
||||
private int accountId;
|
||||
private String accountName;
|
||||
|
||||
private UserAccountsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
accountUrl = itemView.findViewById(R.id.accountUrl);
|
||||
userId = itemView.findViewById(R.id.userId);
|
||||
activeAccount = itemView.findViewById(R.id.activeAccount);
|
||||
deleteAccount = itemView.findViewById(R.id.deleteAccount);
|
||||
repoAvatar = itemView.findViewById(R.id.repoAvatar);
|
||||
|
||||
deleteAccount.setOnClickListener(itemDelete -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context).setTitle(context.getResources().getString(R.string.removeAccountPopupTitle))
|
||||
.setMessage(context.getResources().getString(R.string.removeAccountPopupMessage)).setNeutralButton(context.getResources().getString(R.string.cancelButton), null)
|
||||
.setPositiveButton(context.getResources().getString(R.string.removeButton), (dialog, which) -> {
|
||||
|
||||
updateLayoutByPosition(getBindingAdapterPosition());
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
|
||||
assert userAccountsApi != null;
|
||||
userAccountsApi.deleteAccount(Integer.parseInt(String.valueOf(accountId)));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
|
||||
itemView.setOnClickListener(switchAccount -> {
|
||||
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
|
||||
assert userAccountsApi != null;
|
||||
UserAccount userAccount = userAccountsApi.getAccountByName(accountName);
|
||||
|
||||
if(!userAccount.isLoggedIn()) {
|
||||
UrlBuilder url = UrlBuilder.fromString(userAccount.getInstanceUrl()).withPath("/");
|
||||
|
||||
String host;
|
||||
if(url.scheme.equals("http")) {
|
||||
if(url.port == 80 || url.port == 0) {
|
||||
host = url.hostName;
|
||||
}
|
||||
else {
|
||||
host = url.hostName + ":" + url.port;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(url.port == 443 || url.port == 0) {
|
||||
host = url.hostName;
|
||||
}
|
||||
else {
|
||||
host = url.hostName + ":" + url.port;
|
||||
}
|
||||
}
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.logInAgain));
|
||||
dialog.dismiss();
|
||||
|
||||
Intent i = new Intent(context, AddNewAccountActivity.class);
|
||||
i.putExtra("instanceUrl", host);
|
||||
i.putExtra("scheme", url.scheme);
|
||||
i.putExtra("token", userAccount.getToken());
|
||||
context.startActivity(i);
|
||||
return;
|
||||
}
|
||||
|
||||
if(AppUtil.switchToAccount(context, userAccount)) {
|
||||
|
||||
String url = UrlBuilder.fromString(userAccount.getInstanceUrl()).withPath("/").toString();
|
||||
|
||||
Toasty.success(context, context.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url));
|
||||
getNotificationsCount();
|
||||
((Activity) context).recreate();
|
||||
dialog.dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,11 +7,7 @@ import android.text.Html;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.*;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
|
@ -27,135 +23,135 @@ import java.util.List;
|
|||
|
||||
public class UserGridAdapter extends BaseAdapter implements Filterable {
|
||||
|
||||
private final List<User> membersList;
|
||||
private final Context context;
|
||||
private final List<User> membersListFull;
|
||||
private final List<User> membersList;
|
||||
private final Context context;
|
||||
private final List<User> membersListFull;
|
||||
private final Filter membersFilter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<User> filteredList = new ArrayList<>();
|
||||
|
||||
private class ViewHolder {
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
|
||||
private String userLoginId;
|
||||
filteredList.addAll(membersListFull);
|
||||
}
|
||||
else {
|
||||
|
||||
private final ImageView memberAvatar;
|
||||
private final TextView memberName;
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
ViewHolder(View v) {
|
||||
for(User item : membersListFull) {
|
||||
if(item.getFullName().toLowerCase().contains(filterPattern) || item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
memberAvatar = v.findViewById(R.id.userAvatarImageView);
|
||||
memberName = v.findViewById(R.id.userNameTv);
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
v.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userLoginId);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
v.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
public UserGridAdapter(Context ctx, List<User> membersListMain) {
|
||||
membersList.clear();
|
||||
membersList.addAll((List) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
this.context = ctx;
|
||||
this.membersList = membersListMain;
|
||||
membersListFull = new ArrayList<>(membersList);
|
||||
}
|
||||
public UserGridAdapter(Context ctx, List<User> membersListMain) {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return membersList.size();
|
||||
}
|
||||
this.context = ctx;
|
||||
this.membersList = membersListMain;
|
||||
membersListFull = new ArrayList<>(membersList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int getCount() {
|
||||
return membersList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
@Override
|
||||
public View getView(int position, View finalView, ViewGroup parent) {
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
UserGridAdapter.ViewHolder viewHolder;
|
||||
@SuppressLint("InflateParams")
|
||||
@Override
|
||||
public View getView(int position, View finalView, ViewGroup parent) {
|
||||
|
||||
if (finalView == null) {
|
||||
UserGridAdapter.ViewHolder viewHolder;
|
||||
|
||||
finalView = LayoutInflater.from(context).inflate(R.layout.list_users_grid, null);
|
||||
viewHolder = new ViewHolder(finalView);
|
||||
finalView.setTag(viewHolder);
|
||||
}
|
||||
else {
|
||||
if(finalView == null) {
|
||||
|
||||
viewHolder = (UserGridAdapter.ViewHolder) finalView.getTag();
|
||||
}
|
||||
finalView = LayoutInflater.from(context).inflate(R.layout.list_users_grid, null);
|
||||
viewHolder = new ViewHolder(finalView);
|
||||
finalView.setTag(viewHolder);
|
||||
}
|
||||
else {
|
||||
|
||||
initData(viewHolder, position);
|
||||
return finalView;
|
||||
}
|
||||
viewHolder = (UserGridAdapter.ViewHolder) finalView.getTag();
|
||||
}
|
||||
|
||||
private void initData(UserGridAdapter.ViewHolder viewHolder, int position) {
|
||||
initData(viewHolder, position);
|
||||
return finalView;
|
||||
}
|
||||
|
||||
User currentItem = membersList.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 0);
|
||||
private void initData(UserGridAdapter.ViewHolder viewHolder, int position) {
|
||||
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(viewHolder.memberAvatar);
|
||||
User currentItem = membersList.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 0);
|
||||
|
||||
viewHolder.userLoginId = currentItem.getLogin();
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(viewHolder.memberAvatar);
|
||||
|
||||
if(!currentItem.getFullName().equals("")) {
|
||||
viewHolder.userLoginId = currentItem.getLogin();
|
||||
|
||||
viewHolder.memberName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
}
|
||||
else {
|
||||
if(!currentItem.getFullName().equals("")) {
|
||||
|
||||
viewHolder.memberName.setText(currentItem.getLogin());
|
||||
}
|
||||
}
|
||||
viewHolder.memberName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
}
|
||||
else {
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return membersFilter;
|
||||
}
|
||||
viewHolder.memberName.setText(currentItem.getLogin());
|
||||
}
|
||||
}
|
||||
|
||||
private final Filter membersFilter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<User> filteredList = new ArrayList<>();
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return membersFilter;
|
||||
}
|
||||
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
private class ViewHolder {
|
||||
|
||||
filteredList.addAll(membersListFull);
|
||||
}
|
||||
else {
|
||||
private final ImageView memberAvatar;
|
||||
private final TextView memberName;
|
||||
private String userLoginId;
|
||||
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
ViewHolder(View v) {
|
||||
|
||||
for (User item : membersListFull) {
|
||||
if (item.getFullName().toLowerCase().contains(filterPattern) || item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
memberAvatar = v.findViewById(R.id.userAvatarImageView);
|
||||
memberName = v.findViewById(R.id.userNameTv);
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
v.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userLoginId);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
return results;
|
||||
}
|
||||
v.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
membersList.clear();
|
||||
membersList.addAll((List) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,12 +38,12 @@ import retrofit2.Response;
|
|||
public class WikiListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context ctx;
|
||||
private List<WikiPageMetaData> wikiList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final FragmentWikiBinding fragmentWikiBinding;
|
||||
private final String repoOwner;
|
||||
private final String repoName;
|
||||
private List<WikiPageMetaData> wikiList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public WikiListAdapter(List<WikiPageMetaData> wikiListMain, Context ctx, String repoOwner, String repoName, FragmentWikiBinding fragmentWikiBinding) {
|
||||
this.ctx = ctx;
|
||||
|
@ -80,14 +80,83 @@ public class WikiListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
return wikiList.size();
|
||||
}
|
||||
|
||||
class WikisHolder extends RecyclerView.ViewHolder {
|
||||
private void updateAdapter(int position) {
|
||||
wikiList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, wikiList.size());
|
||||
}
|
||||
|
||||
private WikiPageMetaData wikiPageMeta;
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<WikiPageMetaData> list) {
|
||||
wikiList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
private void deleteWiki(final String owner, final String repo, final String pageName, int position, final Context context) {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
materialAlertDialogBuilder.setTitle(String.format(context.getString(R.string.deleteGenericTitle), pageName)).setMessage(context.getString(R.string.deleteWikiPageMessage, pageName))
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient.getApiInterface(context).repoDeleteWikiPage(owner, repo, pageName).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
updateAdapter(position);
|
||||
Toasty.success(context, context.getString(R.string.wikiPageDeleted));
|
||||
if(getItemCount() == 0) {
|
||||
fragmentWikiBinding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
})).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
class WikisHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView avatar;
|
||||
private final TextView pageName;
|
||||
private final TextView wikiLastUpdatedBy;
|
||||
private final ImageView wikiMenu;
|
||||
private WikiPageMetaData wikiPageMeta;
|
||||
|
||||
WikisHolder(View itemView) {
|
||||
|
||||
|
@ -145,10 +214,8 @@ public class WikiListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
this.wikiPageMeta = wikiPageMetaData;
|
||||
|
||||
pageName.setText(wikiPageMetaData.getTitle());
|
||||
wikiLastUpdatedBy.setText(
|
||||
HtmlCompat.fromHtml(ctx.getResources().getString(R.string.wikiAuthor, wikiPageMetaData.getLastCommit().getAuthor().getName(),
|
||||
TimeHelper.formatTime(TimeHelper.parseIso8601(wikiPageMetaData.getLastCommit().getAuthor().getDate()), ctx.getResources().getConfiguration().locale, "pretty",
|
||||
ctx)), HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
wikiLastUpdatedBy.setText(HtmlCompat.fromHtml(ctx.getResources().getString(R.string.wikiAuthor, wikiPageMetaData.getLastCommit().getAuthor().getName(),
|
||||
TimeHelper.formatTime(TimeHelper.parseIso8601(wikiPageMetaData.getLastCommit().getAuthor().getDate()), ctx.getResources().getConfiguration().locale, "pretty", ctx)), HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
this.wikiLastUpdatedBy.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(TimeHelper.parseIso8601(wikiPageMetaData.getLastCommit().getAuthor().getDate())), ctx));
|
||||
|
||||
ColorGenerator generator = ColorGenerator.Companion.getMATERIAL();
|
||||
|
@ -162,75 +229,7 @@ public class WikiListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
wikiMenu.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateAdapter(int position) {
|
||||
wikiList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, wikiList.size());
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
void onLoadMore();
|
||||
void onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<WikiPageMetaData> list) {
|
||||
wikiList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
private void deleteWiki(final String owner, final String repo, final String pageName, int position, final Context context) {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
materialAlertDialogBuilder.setTitle(String.format(context.getString(R.string.deleteGenericTitle), pageName))
|
||||
.setMessage(context.getString(R.string.deleteWikiPageMessage, pageName))
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient
|
||||
.getApiInterface(context).repoDeleteWikiPage(owner, repo, pageName).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
updateAdapter(position);
|
||||
Toasty.success(context, context.getString(R.string.wikiPageDeleted));
|
||||
if(getItemCount() == 0) {
|
||||
fragmentWikiBinding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}))
|
||||
.setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,7 @@ package org.mian.gitnex.clients;
|
|||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.gitnex.tea4j.v2.apis.AdminApi;
|
||||
import org.gitnex.tea4j.v2.apis.IssueApi;
|
||||
import org.gitnex.tea4j.v2.apis.MiscellaneousApi;
|
||||
import org.gitnex.tea4j.v2.apis.NotificationApi;
|
||||
import org.gitnex.tea4j.v2.apis.OrganizationApi;
|
||||
import org.gitnex.tea4j.v2.apis.PackageApi;
|
||||
import org.gitnex.tea4j.v2.apis.RepositoryApi;
|
||||
import org.gitnex.tea4j.v2.apis.SettingsApi;
|
||||
import org.gitnex.tea4j.v2.apis.UserApi;
|
||||
import org.gitnex.tea4j.v2.apis.*;
|
||||
import org.gitnex.tea4j.v2.apis.custom.CustomApi;
|
||||
import org.gitnex.tea4j.v2.apis.custom.OTPApi;
|
||||
import org.gitnex.tea4j.v2.apis.custom.WebApi;
|
||||
|
|
|
@ -77,4 +77,5 @@ public class RepositoriesApi extends BaseApi {
|
|||
public LiveData<List<Repository>> fetchAllMostVisited(int repoAccountId) {
|
||||
return repositoriesDao.fetchAllMostVisited(repoAccountId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,4 +49,5 @@ public interface RepositoriesDao {
|
|||
|
||||
@Query("SELECT * FROM Repositories WHERE mostVisited > 0 AND repoAccountId = :repoAccountId ORDER BY mostVisited DESC LIMIT 50")
|
||||
LiveData<List<Repository>> fetchAllMostVisited(int repoAccountId);
|
||||
|
||||
}
|
||||
|
|
|
@ -18,32 +18,23 @@ import org.mian.gitnex.database.models.UserAccount;
|
|||
* @author M M Arif
|
||||
*/
|
||||
|
||||
@Database(entities = {Draft.class, Repository.class, UserAccount.class},
|
||||
version = 6, exportSchema = false)
|
||||
@Database(entities = {Draft.class, Repository.class, UserAccount.class}, version = 6, exportSchema = false)
|
||||
public abstract class GitnexDatabase extends RoomDatabase {
|
||||
|
||||
private static final String DB_NAME = "gitnex";
|
||||
private static volatile GitnexDatabase gitnexDatabase;
|
||||
|
||||
public abstract DraftsDao draftsDao();
|
||||
public abstract RepositoriesDao repositoriesDao();
|
||||
public abstract UserAccountsDao userAccountsDao();
|
||||
|
||||
private static final Migration MIGRATION_1_2 = new Migration(1, 2) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
//database.execSQL("DROP TABLE Drafts");
|
||||
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'commentId' TEXT");
|
||||
}
|
||||
};
|
||||
|
||||
private static final Migration MIGRATION_1_2 = new Migration(1, 2) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
//database.execSQL("DROP TABLE Drafts");
|
||||
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'commentId' TEXT");
|
||||
}
|
||||
};
|
||||
private static final Migration MIGRATION_2_3 = new Migration(2, 3) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'issueType' TEXT");
|
||||
}
|
||||
};
|
||||
|
||||
private static final Migration MIGRATION_3_4 = new Migration(3, 4) {
|
||||
|
||||
@Override
|
||||
|
@ -51,7 +42,6 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||
database.execSQL("ALTER TABLE 'userAccounts' ADD COLUMN 'isLoggedIn' INTEGER NOT NULL DEFAULT 1");
|
||||
}
|
||||
};
|
||||
|
||||
private static final Migration MIGRATION_4_5 = new Migration(4, 5) {
|
||||
|
||||
@Override
|
||||
|
@ -60,7 +50,6 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||
database.execSQL("ALTER TABLE 'userAccounts' ADD COLUMN 'defaultPagingNumber' INTEGER NOT NULL DEFAULT 30");
|
||||
}
|
||||
};
|
||||
|
||||
private static final Migration MIGRATION_5_6 = new Migration(5, 6) {
|
||||
|
||||
@Override
|
||||
|
@ -68,18 +57,17 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||
database.execSQL("ALTER TABLE 'Repositories' ADD COLUMN 'mostVisited' INTEGER NOT NULL DEFAULT 0");
|
||||
}
|
||||
};
|
||||
private static volatile GitnexDatabase gitnexDatabase;
|
||||
|
||||
public static GitnexDatabase getDatabaseInstance(Context context) {
|
||||
|
||||
if (gitnexDatabase == null) {
|
||||
if(gitnexDatabase == null) {
|
||||
synchronized(GitnexDatabase.class) {
|
||||
if(gitnexDatabase == null) {
|
||||
|
||||
gitnexDatabase = Room.databaseBuilder(context, GitnexDatabase.class, DB_NAME)
|
||||
//.fallbackToDestructiveMigration()
|
||||
.allowMainThreadQueries()
|
||||
.addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5, MIGRATION_5_6)
|
||||
.build();
|
||||
.allowMainThreadQueries().addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5, MIGRATION_5_6).build();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -88,4 +76,11 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||
return gitnexDatabase;
|
||||
|
||||
}
|
||||
|
||||
public abstract DraftsDao draftsDao();
|
||||
|
||||
public abstract RepositoriesDao repositoriesDao();
|
||||
|
||||
public abstract UserAccountsDao userAccountsDao();
|
||||
|
||||
}
|
||||
|
|
|
@ -11,52 +11,48 @@ import static androidx.room.ForeignKey.CASCADE;
|
|||
* @author M M Arif
|
||||
*/
|
||||
|
||||
@Entity(tableName = "Repositories", foreignKeys = @ForeignKey(entity = UserAccount.class,
|
||||
parentColumns = "accountId",
|
||||
childColumns = "repoAccountId",
|
||||
onDelete = CASCADE),
|
||||
indices = {@Index("repoAccountId")})
|
||||
@Entity(tableName = "Repositories", foreignKeys = @ForeignKey(entity = UserAccount.class, parentColumns = "accountId", childColumns = "repoAccountId", onDelete = CASCADE), indices = {@Index("repoAccountId")})
|
||||
public class Repository implements Serializable {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int repositoryId;
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int repositoryId;
|
||||
|
||||
private int repoAccountId;
|
||||
private String repositoryOwner;
|
||||
private String repositoryName;
|
||||
private int repoAccountId;
|
||||
private String repositoryOwner;
|
||||
private String repositoryName;
|
||||
private int mostVisited;
|
||||
|
||||
public int getRepositoryId() {
|
||||
return repositoryId;
|
||||
}
|
||||
public int getRepositoryId() {
|
||||
return repositoryId;
|
||||
}
|
||||
|
||||
public void setRepositoryId(int repositoryId) {
|
||||
this.repositoryId = repositoryId;
|
||||
}
|
||||
public void setRepositoryId(int repositoryId) {
|
||||
this.repositoryId = repositoryId;
|
||||
}
|
||||
|
||||
public int getRepoAccountId() {
|
||||
return repoAccountId;
|
||||
}
|
||||
public int getRepoAccountId() {
|
||||
return repoAccountId;
|
||||
}
|
||||
|
||||
public void setRepoAccountId(int repoAccountId) {
|
||||
this.repoAccountId = repoAccountId;
|
||||
}
|
||||
public void setRepoAccountId(int repoAccountId) {
|
||||
this.repoAccountId = repoAccountId;
|
||||
}
|
||||
|
||||
public String getRepositoryOwner() {
|
||||
return repositoryOwner;
|
||||
}
|
||||
public String getRepositoryOwner() {
|
||||
return repositoryOwner;
|
||||
}
|
||||
|
||||
public void setRepositoryOwner(String repositoryOwner) {
|
||||
this.repositoryOwner = repositoryOwner;
|
||||
}
|
||||
public void setRepositoryOwner(String repositoryOwner) {
|
||||
this.repositoryOwner = repositoryOwner;
|
||||
}
|
||||
|
||||
public String getRepositoryName() {
|
||||
return repositoryName;
|
||||
}
|
||||
public String getRepositoryName() {
|
||||
return repositoryName;
|
||||
}
|
||||
|
||||
public void setRepositoryName(String repositoryName) {
|
||||
this.repositoryName = repositoryName;
|
||||
}
|
||||
public void setRepositoryName(String repositoryName) {
|
||||
this.repositoryName = repositoryName;
|
||||
}
|
||||
|
||||
public int getMostVisited() {
|
||||
return mostVisited;
|
||||
|
@ -65,4 +61,5 @@ public class Repository implements Serializable {
|
|||
public void setMostVisited(int mostVisited) {
|
||||
this.mostVisited = mostVisited;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,11 +13,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.IssueActions;
|
||||
import org.mian.gitnex.actions.PullRequestActions;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.DiffActivity;
|
||||
import org.mian.gitnex.activities.EditIssueActivity;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.activities.MergePullRequestActivity;
|
||||
import org.mian.gitnex.activities.*;
|
||||
import org.mian.gitnex.databinding.BottomSheetSingleIssueBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
|
|
|
@ -22,13 +22,7 @@ import org.mian.gitnex.adapters.DiffFilesAdapter;
|
|||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentCommitDetailsBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.FileDiffView;
|
||||
import org.mian.gitnex.helpers.ParseDiff;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -38,75 +33,73 @@ import java.util.List;
|
|||
public class DraftsFragment extends Fragment {
|
||||
|
||||
private Context ctx;
|
||||
private DraftsAdapter adapter;
|
||||
private RecyclerView mRecyclerView;
|
||||
private DraftsApi draftsApi;
|
||||
private TextView noData;
|
||||
private DraftsAdapter adapter;
|
||||
private RecyclerView mRecyclerView;
|
||||
private DraftsApi draftsApi;
|
||||
private TextView noData;
|
||||
private List<DraftWithRepository> draftsList_;
|
||||
private int currentActiveAccountId;
|
||||
private SwipeRefreshLayout swipeRefresh;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
FragmentDraftsBinding fragmentDraftsBinding = FragmentDraftsBinding.inflate(inflater, container, false);
|
||||
FragmentDraftsBinding fragmentDraftsBinding = FragmentDraftsBinding.inflate(inflater, container, false);
|
||||
|
||||
ctx = getContext();
|
||||
setHasOptionsMenu(true);
|
||||
ctx = getContext();
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.titleDrafts));
|
||||
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.titleDrafts));
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||
TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||
|
||||
draftsList_ = new ArrayList<>();
|
||||
draftsApi = BaseApi.getInstance(ctx, DraftsApi.class);
|
||||
draftsList_ = new ArrayList<>();
|
||||
draftsApi = BaseApi.getInstance(ctx, DraftsApi.class);
|
||||
|
||||
noData = fragmentDraftsBinding.noData;
|
||||
mRecyclerView = fragmentDraftsBinding.recyclerView;
|
||||
swipeRefresh = fragmentDraftsBinding.pullToRefresh;
|
||||
noData = fragmentDraftsBinding.noData;
|
||||
mRecyclerView = fragmentDraftsBinding.recyclerView;
|
||||
swipeRefresh = fragmentDraftsBinding.pullToRefresh;
|
||||
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
adapter = new DraftsAdapter(getContext(), getChildFragmentManager(), draftsList_);
|
||||
currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
adapter = new DraftsAdapter(getContext(), getChildFragmentManager(), draftsList_);
|
||||
currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
draftsList_.clear();
|
||||
fetchDataAsync(currentActiveAccountId);
|
||||
draftsList_.clear();
|
||||
fetchDataAsync(currentActiveAccountId);
|
||||
|
||||
}, 250));
|
||||
}, 250));
|
||||
|
||||
fetchDataAsync(currentActiveAccountId);
|
||||
fetchDataAsync(currentActiveAccountId);
|
||||
|
||||
return fragmentDraftsBinding.getRoot();
|
||||
}
|
||||
return fragmentDraftsBinding.getRoot();
|
||||
}
|
||||
|
||||
private void fetchDataAsync(int accountId) {
|
||||
private void fetchDataAsync(int accountId) {
|
||||
|
||||
draftsApi.getDrafts(accountId).observe(getViewLifecycleOwner(), drafts -> {
|
||||
draftsApi.getDrafts(accountId).observe(getViewLifecycleOwner(), drafts -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
assert drafts != null;
|
||||
if(drafts.size() > 0) {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
assert drafts != null;
|
||||
if(drafts.size() > 0) {
|
||||
|
||||
draftsList_.clear();
|
||||
noData.setVisibility(View.GONE);
|
||||
draftsList_.addAll(drafts);
|
||||
adapter.notifyDataChanged();
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
}
|
||||
else {
|
||||
draftsList_.clear();
|
||||
noData.setVisibility(View.GONE);
|
||||
draftsList_.addAll(drafts);
|
||||
adapter.notifyDataChanged();
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
}
|
||||
else {
|
||||
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
@ -117,16 +110,16 @@ public class DraftsFragment extends Fragment {
|
|||
|
||||
public void deleteAllDrafts(int accountId) {
|
||||
|
||||
if(draftsList_.size() > 0) {
|
||||
if(draftsList_.size() > 0) {
|
||||
|
||||
BaseApi.getInstance(ctx, DraftsApi.class).deleteAllDrafts(accountId);
|
||||
draftsList_.clear();
|
||||
adapter.notifyDataChanged();
|
||||
Toasty.success(ctx, getResources().getString(R.string.draftsDeleteSuccess));
|
||||
}
|
||||
else {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.draftsListEmpty));
|
||||
}
|
||||
BaseApi.getInstance(ctx, DraftsApi.class).deleteAllDrafts(accountId);
|
||||
draftsList_.clear();
|
||||
adapter.notifyDataChanged();
|
||||
Toasty.success(ctx, getResources().getString(R.string.draftsDeleteSuccess));
|
||||
}
|
||||
else {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.draftsListEmpty));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -168,12 +161,13 @@ public class DraftsFragment extends Fragment {
|
|||
continue;
|
||||
}
|
||||
|
||||
if(d.getRepositoryOwner().toLowerCase().contains(text) || d.getRepositoryName().toLowerCase().contains(text)
|
||||
|| d.getDraftText().toLowerCase().contains(text) || String.valueOf(d.getIssueId()).contains(text)) {
|
||||
if(d.getRepositoryOwner().toLowerCase().contains(text) || d.getRepositoryName().toLowerCase().contains(text) || d.getDraftText().toLowerCase().contains(text) || String.valueOf(d.getIssueId())
|
||||
.contains(text)) {
|
||||
arr.add(d);
|
||||
}
|
||||
}
|
||||
|
||||
adapter.updateList(arr);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,12 +3,7 @@ package org.mian.gitnex.fragments;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
@ -39,13 +34,12 @@ import retrofit2.Response;
|
|||
|
||||
public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
private FragmentExploreRepoBinding viewBinding;
|
||||
private Context context;
|
||||
|
||||
private int pageSize;
|
||||
private final boolean repoTypeInclude = true;
|
||||
private final String sort = "updated";
|
||||
private final String order = "desc";
|
||||
private FragmentExploreRepoBinding viewBinding;
|
||||
private Context context;
|
||||
private int pageSize;
|
||||
private int resultLimit;
|
||||
private List<Repository> dataList;
|
||||
private ExploreRepositoriesAdapter adapter;
|
||||
|
@ -96,9 +90,8 @@ public class ExploreRepositoriesFragment extends Fragment {
|
|||
|
||||
private void loadInitial(String searchKeyword, int resultLimit) {
|
||||
|
||||
Call<SearchResults> call = RetrofitClient
|
||||
.getApiInterface(context).repoSearch(searchKeyword, includeTopic, includeDescription, null, null, null, null,
|
||||
repoTypeInclude, null, includeTemplate, onlyArchived, null, null, sort, order, 1, resultLimit);
|
||||
Call<SearchResults> call = RetrofitClient.getApiInterface(context)
|
||||
.repoSearch(searchKeyword, includeTopic, includeDescription, null, null, null, null, repoTypeInclude, null, includeTemplate, onlyArchived, null, null, sort, order, 1, resultLimit);
|
||||
call.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<SearchResults> call, @NonNull Response<SearchResults> response) {
|
||||
|
@ -137,8 +130,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
|||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
Call<SearchResults> call = RetrofitClient.getApiInterface(context)
|
||||
.repoSearch(searchKeyword, includeTopic, includeDescription, null, null, null, null,
|
||||
repoTypeInclude, null, includeTemplate, onlyArchived, null, null, sort, order, page, resultLimit);
|
||||
.repoSearch(searchKeyword, includeTopic, includeDescription, null, null, null, null, repoTypeInclude, null, includeTemplate, onlyArchived, null, null, sort, order, page, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
@Override
|
||||
|
@ -249,4 +241,5 @@ public class ExploreRepositoriesFragment extends Fragment {
|
|||
MainActivity.reloadRepos = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.annotation.SuppressLint;
|
|||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -27,93 +27,92 @@ import org.mian.gitnex.viewmodels.LabelsViewModel;
|
|||
|
||||
public class LabelsFragment extends Fragment {
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private RecyclerView mRecyclerView;
|
||||
private LabelsAdapter adapter;
|
||||
private TextView noData;
|
||||
private ProgressBar mProgressBar;
|
||||
private RecyclerView mRecyclerView;
|
||||
private LabelsAdapter adapter;
|
||||
private TextView noData;
|
||||
|
||||
private RepositoryContext repository;
|
||||
private RepositoryContext repository;
|
||||
|
||||
public LabelsFragment() {
|
||||
}
|
||||
public LabelsFragment() {
|
||||
}
|
||||
|
||||
public static LabelsFragment newInstance(RepositoryContext repository) {
|
||||
public static LabelsFragment newInstance(RepositoryContext repository) {
|
||||
|
||||
LabelsFragment fragment = new LabelsFragment();
|
||||
fragment.setArguments(repository.getBundle());
|
||||
return fragment;
|
||||
}
|
||||
LabelsFragment fragment = new LabelsFragment();
|
||||
fragment.setArguments(repository.getBundle());
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
repository = RepositoryContext.fromBundle(requireArguments());
|
||||
}
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
repository = RepositoryContext.fromBundle(requireArguments());
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
FragmentLabelsBinding fragmentLabelsBinding = FragmentLabelsBinding.inflate(inflater, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
FragmentLabelsBinding fragmentLabelsBinding = FragmentLabelsBinding.inflate(inflater, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
final SwipeRefreshLayout swipeRefresh = fragmentLabelsBinding.pullToRefresh;
|
||||
noData = fragmentLabelsBinding.noData;
|
||||
final SwipeRefreshLayout swipeRefresh = fragmentLabelsBinding.pullToRefresh;
|
||||
noData = fragmentLabelsBinding.noData;
|
||||
|
||||
mRecyclerView = fragmentLabelsBinding.recyclerView;
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
mRecyclerView = fragmentLabelsBinding.recyclerView;
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
mProgressBar = fragmentLabelsBinding.progressBar;
|
||||
mProgressBar = fragmentLabelsBinding.progressBar;
|
||||
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
LabelsViewModel.loadLabelsList(repository.getOwner(), repository.getName(), getContext());
|
||||
}, 200));
|
||||
swipeRefresh.setRefreshing(false);
|
||||
LabelsViewModel.loadLabelsList(repository.getOwner(), repository.getName(), getContext());
|
||||
}, 200));
|
||||
|
||||
fetchDataAsync(repository.getOwner(), repository.getName());
|
||||
fetchDataAsync(repository.getOwner(), repository.getName());
|
||||
|
||||
return fragmentLabelsBinding.getRoot();
|
||||
}
|
||||
return fragmentLabelsBinding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
super.onResume();
|
||||
super.onResume();
|
||||
|
||||
if(CreateLabelActivity.refreshLabels) {
|
||||
if(CreateLabelActivity.refreshLabels) {
|
||||
|
||||
LabelsViewModel.loadLabelsList(repository.getOwner(), repository.getName(), getContext());
|
||||
CreateLabelActivity.refreshLabels = false;
|
||||
}
|
||||
}
|
||||
LabelsViewModel.loadLabelsList(repository.getOwner(), repository.getName(), getContext());
|
||||
CreateLabelActivity.refreshLabels = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String owner, String repo) {
|
||||
private void fetchDataAsync(String owner, String repo) {
|
||||
|
||||
LabelsViewModel labelsModel = new ViewModelProvider(this).get(LabelsViewModel.class);
|
||||
LabelsViewModel labelsModel = new ViewModelProvider(this).get(LabelsViewModel.class);
|
||||
|
||||
labelsModel.getLabelsList(owner, repo, getContext()).observe(getViewLifecycleOwner(), labelsListMain -> {
|
||||
labelsModel.getLabelsList(owner, repo, getContext()).observe(getViewLifecycleOwner(), labelsListMain -> {
|
||||
|
||||
adapter = new LabelsAdapter(getContext(), labelsListMain, "repo", owner);
|
||||
adapter = new LabelsAdapter(getContext(), labelsListMain, "repo", owner);
|
||||
|
||||
if(adapter.getItemCount() > 0) {
|
||||
if(adapter.getItemCount() > 0) {
|
||||
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noData.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noData.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
|
||||
adapter.notifyDataChanged();
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
adapter.notifyDataChanged();
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ProgressBar;
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -41,8 +41,7 @@ public class MostVisitedReposFragment extends Fragment {
|
|||
private SwipeRefreshLayout swipeRefresh;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
FragmentDraftsBinding fragmentDraftsBinding = FragmentDraftsBinding.inflate(inflater, container, false);
|
||||
|
||||
|
@ -63,8 +62,7 @@ public class MostVisitedReposFragment extends Fragment {
|
|||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
adapter = new MostVisitedReposAdapter(mostVisitedReposList);
|
||||
|
@ -100,4 +98,5 @@ public class MostVisitedReposFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,12 +3,7 @@ package org.mian.gitnex.fragments;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
|
@ -24,63 +24,61 @@ import org.mian.gitnex.viewmodels.ProfileEmailsViewModel;
|
|||
|
||||
public class MyProfileEmailsFragment extends Fragment {
|
||||
|
||||
private ProfileEmailsViewModel profileEmailsViewModel;
|
||||
public static boolean refreshEmails = false;
|
||||
private ProfileEmailsViewModel profileEmailsViewModel;
|
||||
private ProgressBar mProgressBar;
|
||||
private MyProfileEmailsAdapter adapter;
|
||||
private RecyclerView mRecyclerView;
|
||||
private TextView noDataEmails;
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private MyProfileEmailsAdapter adapter;
|
||||
private RecyclerView mRecyclerView;
|
||||
private TextView noDataEmails;
|
||||
public MyProfileEmailsFragment() {
|
||||
}
|
||||
|
||||
public MyProfileEmailsFragment() {
|
||||
}
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
FragmentProfileEmailsBinding fragmentProfileEmailsBinding = FragmentProfileEmailsBinding.inflate(inflater, container, false);
|
||||
profileEmailsViewModel = new ViewModelProvider(this).get(ProfileEmailsViewModel.class);
|
||||
|
||||
FragmentProfileEmailsBinding fragmentProfileEmailsBinding = FragmentProfileEmailsBinding.inflate(inflater, container, false);
|
||||
profileEmailsViewModel = new ViewModelProvider(this).get(ProfileEmailsViewModel.class);
|
||||
final SwipeRefreshLayout swipeRefresh = fragmentProfileEmailsBinding.pullToRefresh;
|
||||
|
||||
final SwipeRefreshLayout swipeRefresh = fragmentProfileEmailsBinding.pullToRefresh;
|
||||
noDataEmails = fragmentProfileEmailsBinding.noDataEmails;
|
||||
mRecyclerView = fragmentProfileEmailsBinding.recyclerView;
|
||||
|
||||
noDataEmails = fragmentProfileEmailsBinding.noDataEmails;
|
||||
mRecyclerView = fragmentProfileEmailsBinding.recyclerView;
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
mProgressBar = fragmentProfileEmailsBinding.progressBar;
|
||||
|
||||
mProgressBar = fragmentProfileEmailsBinding.progressBar;
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
profileEmailsViewModel.loadEmailsList(getContext());
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
profileEmailsViewModel.loadEmailsList(getContext());
|
||||
}, 200));
|
||||
|
||||
}, 200));
|
||||
fetchDataAsync();
|
||||
|
||||
fetchDataAsync();
|
||||
return fragmentProfileEmailsBinding.getRoot();
|
||||
}
|
||||
|
||||
return fragmentProfileEmailsBinding.getRoot();
|
||||
}
|
||||
private void fetchDataAsync() {
|
||||
|
||||
private void fetchDataAsync() {
|
||||
profileEmailsViewModel.getEmailsList(getContext()).observe(getViewLifecycleOwner(), emailsListMain -> {
|
||||
adapter = new MyProfileEmailsAdapter(getContext(), emailsListMain);
|
||||
if(adapter.getItemCount() > 0) {
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noDataEmails.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
adapter.notifyDataSetChanged();
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noDataEmails.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
});
|
||||
|
||||
profileEmailsViewModel.getEmailsList(getContext()).observe(getViewLifecycleOwner(), emailsListMain -> {
|
||||
adapter = new MyProfileEmailsAdapter(getContext(), emailsListMain);
|
||||
if(adapter.getItemCount() > 0) {
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noDataEmails.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
adapter.notifyDataSetChanged();
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noDataEmails.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
@ -91,4 +89,5 @@ public class MyProfileEmailsFragment extends Fragment {
|
|||
refreshEmails = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,53 +30,49 @@ import retrofit2.Response;
|
|||
|
||||
public class MyProfileFollowersFragment extends Fragment {
|
||||
|
||||
private final String TAG = "MyProfileFollowersFragment";
|
||||
private FragmentProfileFollowersFollowingBinding viewBinding;
|
||||
private Context context;
|
||||
|
||||
private List<User> dataList;
|
||||
private UsersAdapter adapter;
|
||||
private int pageSize;
|
||||
private final String TAG = "MyProfileFollowersFragment";
|
||||
private int resultLimit;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
viewBinding = FragmentProfileFollowersFollowingBinding.inflate(inflater, container, false);
|
||||
context = getContext();
|
||||
viewBinding = FragmentProfileFollowersFollowingBinding.inflate(inflater, container, false);
|
||||
context = getContext();
|
||||
|
||||
dataList = new ArrayList<>();
|
||||
adapter = new UsersAdapter(dataList, context);
|
||||
resultLimit = Constants.getCurrentResultLimit(context);
|
||||
dataList = new ArrayList<>();
|
||||
adapter = new UsersAdapter(dataList, context);
|
||||
resultLimit = Constants.getCurrentResultLimit(context);
|
||||
|
||||
viewBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
loadInitial(resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
}, 200));
|
||||
viewBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
loadInitial(resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
}, 200));
|
||||
|
||||
adapter.setLoadMoreListener(() -> viewBinding.recyclerView.post(() -> {
|
||||
if(dataList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (dataList.size() + resultLimit) / resultLimit;
|
||||
loadMore(resultLimit, page);
|
||||
}
|
||||
}));
|
||||
adapter.setLoadMoreListener(() -> viewBinding.recyclerView.post(() -> {
|
||||
if(dataList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (dataList.size() + resultLimit) / resultLimit;
|
||||
loadMore(resultLimit, page);
|
||||
}
|
||||
}));
|
||||
|
||||
viewBinding.recyclerView.setHasFixedSize(true);
|
||||
viewBinding.recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||
viewBinding.recyclerView.setAdapter(adapter);
|
||||
viewBinding.recyclerView.setHasFixedSize(true);
|
||||
viewBinding.recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||
viewBinding.recyclerView.setAdapter(adapter);
|
||||
|
||||
loadInitial(resultLimit);
|
||||
loadInitial(resultLimit);
|
||||
|
||||
return viewBinding.getRoot();
|
||||
}
|
||||
return viewBinding.getRoot();
|
||||
}
|
||||
|
||||
private void loadInitial(int resultLimit) {
|
||||
|
||||
Call<List<User>> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.userCurrentListFollowers(1, resultLimit);
|
||||
Call<List<User>> call = RetrofitClient.getApiInterface(context).userCurrentListFollowers(1, resultLimit);
|
||||
call.enqueue(new Callback<List<User>>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<User>> call, @NonNull Response<List<User>> response) {
|
||||
|
@ -113,8 +109,7 @@ public class MyProfileFollowersFragment extends Fragment {
|
|||
private void loadMore(int resultLimit, int page) {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
Call<List<User>> call = RetrofitClient.getApiInterface(context)
|
||||
.userCurrentListFollowers(page, resultLimit);
|
||||
Call<List<User>> call = RetrofitClient.getApiInterface(context).userCurrentListFollowers(page, resultLimit);
|
||||
call.enqueue(new Callback<List<User>>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<User>> call, @NonNull Response<List<User>> response) {
|
||||
|
@ -143,4 +138,5 @@ public class MyProfileFollowersFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,12 +5,7 @@ import android.content.res.ColorStateList;
|
|||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
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.*;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -41,174 +36,176 @@ import jp.wasabeef.picasso.transformations.BlurTransformation;
|
|||
|
||||
public class MyProfileFragment extends Fragment {
|
||||
|
||||
private Context ctx;
|
||||
private Context ctx;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
ctx = getContext();
|
||||
ctx = getContext();
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_profile, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
View v = inflater.inflate(R.layout.fragment_profile, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.navProfile));
|
||||
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.navProfile));
|
||||
|
||||
AccountContext account = ((BaseActivity) requireActivity()).getAccount();
|
||||
if(account.getUserInfo() != null) {
|
||||
viewData(v, account);
|
||||
} else {
|
||||
// we have to wait until loading is finished
|
||||
LinearProgressIndicator loading = v.findViewById(R.id.loadingIndicator);
|
||||
loading.setVisibility(View.VISIBLE);
|
||||
((MainActivity) requireActivity()).setProfileInitListener((text) -> {
|
||||
loading.setVisibility(View.GONE);
|
||||
viewData(v, account);
|
||||
});
|
||||
}
|
||||
AccountContext account = ((BaseActivity) requireActivity()).getAccount();
|
||||
if(account.getUserInfo() != null) {
|
||||
viewData(v, account);
|
||||
}
|
||||
else {
|
||||
// we have to wait until loading is finished
|
||||
LinearProgressIndicator loading = v.findViewById(R.id.loadingIndicator);
|
||||
loading.setVisibility(View.VISIBLE);
|
||||
((MainActivity) requireActivity()).setProfileInitListener((text) -> {
|
||||
loading.setVisibility(View.GONE);
|
||||
viewData(v, account);
|
||||
});
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
public static class SectionsPagerAdapter extends FragmentStatePagerAdapter {
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
SectionsPagerAdapter(FragmentManager fm) {
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
menu.clear();
|
||||
requireActivity().getMenuInflater().inflate(R.menu.profile_dotted_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
|
||||
switch (position) {
|
||||
int id = item.getItemId();
|
||||
|
||||
case 0: // followers
|
||||
return new MyProfileFollowersFragment();
|
||||
if(id == android.R.id.home) {
|
||||
((MainActivity) ctx).finish();
|
||||
return true;
|
||||
}
|
||||
else if(id == R.id.profileMenu) {
|
||||
BottomSheetMyProfileFragment bottomSheet = new BottomSheetMyProfileFragment();
|
||||
bottomSheet.show(getChildFragmentManager(), "profileBottomSheet");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
case 1: // following
|
||||
return new MyProfileFollowingFragment();
|
||||
public void viewData(View v, AccountContext account) {
|
||||
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||
|
||||
case 2: // emails
|
||||
return new MyProfileEmailsFragment();
|
||||
TextView userFullName = v.findViewById(R.id.userFullName);
|
||||
ImageView userAvatarBackground = v.findViewById(R.id.userAvatarBackground);
|
||||
ImageView userAvatar = v.findViewById(R.id.userAvatar);
|
||||
TextView userLogin = v.findViewById(R.id.userLogin);
|
||||
View divider = v.findViewById(R.id.divider);
|
||||
TextView userLanguage = v.findViewById(R.id.userLanguage);
|
||||
ImageView userLanguageIcon = v.findViewById(R.id.userLanguageIcon);
|
||||
|
||||
}
|
||||
String[] userLanguageCodes = account.getUserInfo().getLanguage() != null ? account.getUserInfo().getLanguage().split("-") : new String[]{""};
|
||||
|
||||
return null;
|
||||
}
|
||||
if(userLanguageCodes.length >= 2) {
|
||||
Locale locale = new Locale(userLanguageCodes[0], userLanguageCodes[1]);
|
||||
userLanguage.setText(locale.getDisplayLanguage());
|
||||
}
|
||||
else {
|
||||
userLanguage.setText(getResources().getConfiguration().locale.getDisplayLanguage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
userAvatar.setOnClickListener(loginId -> AppUtil.copyToClipboard(ctx, account.getAccount().getUserName(), ctx.getString(R.string.copyLoginIdToClipBoard, account.getAccount().getUserName())));
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
userFullName.setText(Html.fromHtml(account.getFullName()));
|
||||
userLogin.setText(getString(R.string.usernameWithAt, account.getAccount().getUserName()));
|
||||
|
||||
menu.clear();
|
||||
requireActivity().getMenuInflater().inflate(R.menu.profile_dotted_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 60);
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
PicassoService.getInstance(ctx).get().load(account.getUserInfo().getAvatarUrl()).transform(new RoundedTransformation(avatarRadius, 0)).placeholder(R.drawable.loader_animated).resize(120, 120).centerCrop()
|
||||
.into(userAvatar);
|
||||
|
||||
int id = item.getItemId();
|
||||
PicassoService.getInstance(ctx).get().load(account.getUserInfo().getAvatarUrl()).transform(new BlurTransformation(ctx)).into(userAvatarBackground, new Callback() {
|
||||
|
||||
if(id == android.R.id.home) {
|
||||
((MainActivity)ctx).finish();
|
||||
return true;
|
||||
}
|
||||
else if(id == R.id.profileMenu) {
|
||||
BottomSheetMyProfileFragment bottomSheet = new BottomSheetMyProfileFragment();
|
||||
bottomSheet.show(getChildFragmentManager(), "profileBottomSheet");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
||||
public void viewData(View v, AccountContext account) {
|
||||
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||
int invertedColor = new ColorInverter().getImageViewContrastColor(userAvatarBackground);
|
||||
|
||||
TextView userFullName = v.findViewById(R.id.userFullName);
|
||||
ImageView userAvatarBackground = v.findViewById(R.id.userAvatarBackground);
|
||||
ImageView userAvatar = v.findViewById(R.id.userAvatar);
|
||||
TextView userLogin = v.findViewById(R.id.userLogin);
|
||||
View divider = v.findViewById(R.id.divider);
|
||||
TextView userLanguage = v.findViewById(R.id.userLanguage);
|
||||
ImageView userLanguageIcon = v.findViewById(R.id.userLanguageIcon);
|
||||
userFullName.setTextColor(invertedColor);
|
||||
divider.setBackgroundColor(invertedColor);
|
||||
userLogin.setTextColor(invertedColor);
|
||||
userLanguage.setTextColor(invertedColor);
|
||||
|
||||
String[] userLanguageCodes = account.getUserInfo().getLanguage() != null ? account.getUserInfo().getLanguage().split("-") : new String[]{""};
|
||||
ImageViewCompat.setImageTintList(userLanguageIcon, ColorStateList.valueOf(invertedColor));
|
||||
}
|
||||
|
||||
if(userLanguageCodes.length >= 2) {
|
||||
Locale locale = new Locale(userLanguageCodes[0], userLanguageCodes[1]);
|
||||
userLanguage.setText(locale.getDisplayLanguage());
|
||||
}
|
||||
else {
|
||||
userLanguage.setText(getResources().getConfiguration().locale.getDisplayLanguage());
|
||||
}
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
|
||||
userAvatar.setOnClickListener(loginId -> AppUtil.copyToClipboard(ctx, account.getAccount().getUserName(),
|
||||
ctx.getString(R.string.copyLoginIdToClipBoard, account.getAccount().getUserName())));
|
||||
}
|
||||
});
|
||||
|
||||
userFullName.setText(Html.fromHtml(account.getFullName()));
|
||||
userLogin.setText(getString(R.string.usernameWithAt, account.getAccount().getUserName()));
|
||||
MyProfileFragment.SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager());
|
||||
|
||||
int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 60);
|
||||
ViewPager mViewPager = v.findViewById(R.id.container);
|
||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(account.getUserInfo().getAvatarUrl()).transform(new RoundedTransformation(avatarRadius, 0)).placeholder(R.drawable.loader_animated).resize(120, 120).centerCrop().into(userAvatar);
|
||||
Typeface myTypeface = AppUtil.getTypeface(requireContext());
|
||||
TabLayout tabLayout = v.findViewById(R.id.tabs);
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(account.getUserInfo().getAvatarUrl()).transform(new BlurTransformation(ctx))
|
||||
.into(userAvatarBackground, new Callback() {
|
||||
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
|
||||
int tabsCount = vg.getChildCount();
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
for(int j = 0; j < tabsCount; j++) {
|
||||
|
||||
int invertedColor = new ColorInverter().getImageViewContrastColor(userAvatarBackground);
|
||||
ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
|
||||
int tabChildCount = vgTab.getChildCount();
|
||||
|
||||
userFullName.setTextColor(invertedColor);
|
||||
divider.setBackgroundColor(invertedColor);
|
||||
userLogin.setTextColor(invertedColor);
|
||||
userLanguage.setTextColor(invertedColor);
|
||||
for(int i = 0; i < tabChildCount; i++) {
|
||||
|
||||
ImageViewCompat.setImageTintList(userLanguageIcon, ColorStateList.valueOf(invertedColor));
|
||||
}
|
||||
View tabViewChild = vgTab.getChildAt(i);
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
if(tabViewChild instanceof TextView) {
|
||||
((TextView) tabViewChild).setTypeface(myTypeface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||
}
|
||||
|
||||
MyProfileFragment.SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager());
|
||||
public static class SectionsPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
ViewPager mViewPager = v.findViewById(R.id.container);
|
||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||
SectionsPagerAdapter(FragmentManager fm) {
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
Typeface myTypeface = AppUtil.getTypeface(requireContext());
|
||||
TabLayout tabLayout = v.findViewById(R.id.tabs);
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
|
||||
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
|
||||
int tabsCount = vg.getChildCount();
|
||||
switch(position) {
|
||||
|
||||
for(int j = 0; j < tabsCount; j++) {
|
||||
case 0: // followers
|
||||
return new MyProfileFollowersFragment();
|
||||
|
||||
ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
|
||||
int tabChildCount = vgTab.getChildCount();
|
||||
case 1: // following
|
||||
return new MyProfileFollowingFragment();
|
||||
|
||||
for(int i = 0; i < tabChildCount; i++) {
|
||||
case 2: // emails
|
||||
return new MyProfileEmailsFragment();
|
||||
|
||||
View tabViewChild = vgTab.getChildAt(i);
|
||||
}
|
||||
|
||||
if(tabViewChild instanceof TextView) {
|
||||
((TextView) tabViewChild).setTypeface(myTypeface);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.content.Intent;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.app.Activity;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
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.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
|
@ -3,12 +3,7 @@ package org.mian.gitnex.fragments;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.content.Intent;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
|
|
@ -5,12 +5,7 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.RelativeLayout;
|
||||
import androidx.annotation.NonNull;
|
||||
|
|
|
@ -5,12 +5,7 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -8,11 +8,7 @@ import android.net.Uri;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.*;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -45,11 +41,7 @@ import java.util.Objects;
|
|||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.*;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
|
|
|
@ -16,21 +16,10 @@ import org.gitnex.tea4j.v2.models.Organization;
|
|||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OrganizationDetailActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.activities.RepoForksActivity;
|
||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.activities.*;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentRepoInfoBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
@ -237,10 +226,7 @@ public class RepoInfoFragment extends Fragment {
|
|||
repoUrlContent.setText(repoInfo.getHtmlUrl());
|
||||
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.infoMoreInformation)
|
||||
.setView(view)
|
||||
.setNeutralButton(getString(R.string.close), null);
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.infoMoreInformation).setView(view).setNeutralButton(getString(R.string.close), null);
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
|
|
|
@ -3,12 +3,7 @@ package org.mian.gitnex.fragments;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.content.Intent;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
|
|
@ -13,15 +13,7 @@ import androidx.annotation.Nullable;
|
|||
import androidx.fragment.app.Fragment;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.activities.SettingsAppearanceActivity;
|
||||
import org.mian.gitnex.activities.SettingsDraftsActivity;
|
||||
import org.mian.gitnex.activities.SettingsGeneralActivity;
|
||||
import org.mian.gitnex.activities.SettingsNotificationsActivity;
|
||||
import org.mian.gitnex.activities.SettingsReportsActivity;
|
||||
import org.mian.gitnex.activities.SettingsSecurityActivity;
|
||||
import org.mian.gitnex.activities.SettingsTranslationActivity;
|
||||
import org.mian.gitnex.activities.*;
|
||||
import org.mian.gitnex.databinding.CustomAboutDialogBinding;
|
||||
import org.mian.gitnex.databinding.FragmentSettingsBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
|
@ -129,4 +121,5 @@ public class SettingsFragment extends Fragment {
|
|||
refreshParent = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.content.Intent;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
|
|
@ -3,12 +3,7 @@ package org.mian.gitnex.fragments;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
|
|
@ -12,14 +12,7 @@ import org.mian.gitnex.R;
|
|||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentProfileDetailBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import java.util.Locale;
|
||||
import jp.wasabeef.picasso.transformations.BlurTransformation;
|
||||
import retrofit2.Call;
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -4,12 +4,7 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -22,74 +22,59 @@ public class AlertDialogs {
|
|||
|
||||
private static MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
||||
|
||||
public static void authorizationTokenRevokedDialog(final Context context) {
|
||||
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
materialAlertDialogBuilder.setTitle(R.string.alertDialogTokenRevokedTitle)
|
||||
.setMessage(R.string.alertDialogTokenRevokedMessage)
|
||||
.setCancelable(true)
|
||||
.setNeutralButton(R.string.cancelButton, null)
|
||||
.setPositiveButton(R.string.navLogout, (dialog, which) -> AppUtil.logout(context))
|
||||
.show();
|
||||
}
|
||||
|
||||
public static void labelDeleteDialog(final Context context, final String labelTitle, final String labelId, String type, String orgName,
|
||||
RepositoryContext repository) {
|
||||
public static void authorizationTokenRevokedDialog(final Context context) {
|
||||
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
materialAlertDialogBuilder.setTitle(context.getString(R.string.deleteGenericTitle, labelTitle))
|
||||
.setMessage(R.string.labelDeleteMessage)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> {
|
||||
materialAlertDialogBuilder.setTitle(R.string.alertDialogTokenRevokedTitle).setMessage(R.string.alertDialogTokenRevokedMessage).setCancelable(true).setNeutralButton(R.string.cancelButton, null)
|
||||
.setPositiveButton(R.string.navLogout, (dialog, which) -> AppUtil.logout(context)).show();
|
||||
}
|
||||
|
||||
Intent intent = new Intent(context, CreateLabelActivity.class);
|
||||
intent.putExtra("labelId", labelId);
|
||||
intent.putExtra("labelAction", "delete");
|
||||
intent.putExtra("type", type);
|
||||
intent.putExtra("orgName", orgName);
|
||||
intent.putExtra(RepositoryContext.INTENT_EXTRA, repository);
|
||||
context.startActivity(intent);
|
||||
})
|
||||
.setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
public static void labelDeleteDialog(final Context context, final String labelTitle, final String labelId, String type, String orgName, RepositoryContext repository) {
|
||||
|
||||
public static void collaboratorRemoveDialog(final Context context, final String userNameMain, RepositoryContext repository) {
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
materialAlertDialogBuilder.setTitle(context.getString(R.string.deleteGenericTitle, labelTitle)).setMessage(R.string.labelDeleteMessage).setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> {
|
||||
|
||||
materialAlertDialogBuilder.setTitle(context.getString(R.string.removeCollaboratorDialogTitle, userNameMain))
|
||||
.setMessage(R.string.removeCollaboratorMessage)
|
||||
.setPositiveButton(R.string.removeButton, (dialog, whichButton) -> CollaboratorActions.deleteCollaborator(context, userNameMain, repository))
|
||||
.setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
Intent intent = new Intent(context, CreateLabelActivity.class);
|
||||
intent.putExtra("labelId", labelId);
|
||||
intent.putExtra("labelAction", "delete");
|
||||
intent.putExtra("type", type);
|
||||
intent.putExtra("orgName", orgName);
|
||||
intent.putExtra(RepositoryContext.INTENT_EXTRA, repository);
|
||||
context.startActivity(intent);
|
||||
}).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
public static void addMemberDialog(final Context context, final String userNameMain, int teamId) {
|
||||
public static void collaboratorRemoveDialog(final Context context, final String userNameMain, RepositoryContext repository) {
|
||||
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
materialAlertDialogBuilder.setTitle(context.getResources().getString(R.string.addTeamMember, userNameMain))
|
||||
.setMessage(R.string.addTeamMemberMessage)
|
||||
.setPositiveButton(R.string.addButton, (dialog, whichButton) -> TeamActions.addTeamMember(context, userNameMain, teamId))
|
||||
.setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
materialAlertDialogBuilder.setTitle(context.getString(R.string.removeCollaboratorDialogTitle, userNameMain)).setMessage(R.string.removeCollaboratorMessage)
|
||||
.setPositiveButton(R.string.removeButton, (dialog, whichButton) -> CollaboratorActions.deleteCollaborator(context, userNameMain, repository)).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
public static void removeMemberDialog(final Context context, final String userNameMain, int teamId) {
|
||||
public static void addMemberDialog(final Context context, final String userNameMain, int teamId) {
|
||||
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
materialAlertDialogBuilder.setTitle(context.getResources().getString(R.string.removeTeamMember, userNameMain))
|
||||
.setMessage(R.string.removeTeamMemberMessage)
|
||||
.setPositiveButton(R.string.removeButton, (dialog, whichButton) -> TeamActions.removeTeamMember(context, userNameMain, teamId))
|
||||
.setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
materialAlertDialogBuilder.setTitle(context.getResources().getString(R.string.addTeamMember, userNameMain)).setMessage(R.string.addTeamMemberMessage)
|
||||
.setPositiveButton(R.string.addButton, (dialog, whichButton) -> TeamActions.addTeamMember(context, userNameMain, teamId)).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
public static void removeMemberDialog(final Context context, final String userNameMain, int teamId) {
|
||||
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
materialAlertDialogBuilder.setTitle(context.getResources().getString(R.string.removeTeamMember, userNameMain)).setMessage(R.string.removeTeamMemberMessage)
|
||||
.setPositiveButton(R.string.removeButton, (dialog, whichButton) -> TeamActions.removeTeamMember(context, userNameMain, teamId)).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
public static void addRepoDialog(final Context context, final String orgName, String repo, int teamId, String teamName) {
|
||||
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
materialAlertDialogBuilder.setTitle(context.getResources().getString(R.string.addTeamMember, repo))
|
||||
.setMessage(context.getResources().getString(R.string.repoAddToTeamMessage, repo, orgName, teamName))
|
||||
materialAlertDialogBuilder.setTitle(context.getResources().getString(R.string.addTeamMember, repo)).setMessage(context.getResources().getString(R.string.repoAddToTeamMessage, repo, orgName, teamName))
|
||||
.setPositiveButton(context.getResources().getString(R.string.addButton), (dialog, whichButton) -> TeamActions.addTeamRepo(context, orgName, teamId, repo))
|
||||
.setNeutralButton(context.getResources().getString(R.string.cancelButton), null).show();
|
||||
}
|
||||
|
@ -98,30 +83,30 @@ public class AlertDialogs {
|
|||
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
materialAlertDialogBuilder.setTitle(context.getResources().getString(R.string.removeTeamMember, repo))
|
||||
.setMessage(context.getResources().getString(R.string.repoRemoveTeamMessage, repo, teamName))
|
||||
materialAlertDialogBuilder.setTitle(context.getResources().getString(R.string.removeTeamMember, repo)).setMessage(context.getResources().getString(R.string.repoRemoveTeamMessage, repo, teamName))
|
||||
.setPositiveButton(context.getResources().getString(R.string.removeButton), (dialog, whichButton) -> TeamActions.removeTeamRepo(context, orgName, teamId, repo))
|
||||
.setNeutralButton(context.getResources().getString(R.string.cancelButton), null).show();
|
||||
}
|
||||
|
||||
public static void selectPullUpdateStrategy(Context context, String repoOwner, String repo, String issueNumber) {
|
||||
public static void selectPullUpdateStrategy(Context context, String repoOwner, String repo, String issueNumber) {
|
||||
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
CustomPrUpdateStrategyDialogBinding binding = CustomPrUpdateStrategyDialogBinding.inflate(LayoutInflater.from(context));
|
||||
CustomPrUpdateStrategyDialogBinding binding = CustomPrUpdateStrategyDialogBinding.inflate(LayoutInflater.from(context));
|
||||
|
||||
View view = binding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
View view = binding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
|
||||
AlertDialog dialog = materialAlertDialogBuilder.show();
|
||||
AlertDialog dialog = materialAlertDialogBuilder.show();
|
||||
|
||||
binding.updatePullMerge.setOnClickListener((v) -> {
|
||||
PullRequestActions.updatePr(context, repoOwner, repo, issueNumber, false);
|
||||
dialog.dismiss();
|
||||
});
|
||||
binding.updatePullRebase.setOnClickListener((v) -> {
|
||||
PullRequestActions.updatePr(context, repoOwner, repo, issueNumber, true);
|
||||
dialog.dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
binding.updatePullMerge.setOnClickListener((v) -> {
|
||||
PullRequestActions.updatePr(context, repoOwner, repo, issueNumber, false);
|
||||
dialog.dismiss();
|
||||
});
|
||||
binding.updatePullRebase.setOnClickListener((v) -> {
|
||||
PullRequestActions.updatePr(context, repoOwner, repo, issueNumber, true);
|
||||
dialog.dismiss();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
package org.mian.gitnex.helpers;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.*;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
|
@ -36,12 +32,7 @@ import java.net.URL;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
|
|
@ -90,11 +90,8 @@ public class ChangeLog {
|
|||
|
||||
String changelogMessage = getChangelog(resId, res);
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(changelogActivity)
|
||||
.setTitle(R.string.changelogTitle)
|
||||
.setMessage(HtmlCompat.fromHtml("<small>" + changelogMessage + "</small>", HtmlCompat.FROM_HTML_MODE_LEGACY))
|
||||
.setCancelable(false)
|
||||
.setNeutralButton(R.string.close, null);
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(changelogActivity).setTitle(R.string.changelogTitle)
|
||||
.setMessage(HtmlCompat.fromHtml("<small>" + changelogMessage + "</small>", HtmlCompat.FROM_HTML_MODE_LEGACY)).setCancelable(false).setNeutralButton(R.string.close, null);
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
}
|
||||
|
|
|
@ -10,12 +10,7 @@ import androidx.core.content.res.ResourcesCompat;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.commonmark.ext.gfm.tables.TableBlock;
|
||||
import org.commonmark.node.AbstractVisitor;
|
||||
import org.commonmark.node.FencedCodeBlock;
|
||||
import org.commonmark.node.Image;
|
||||
import org.commonmark.node.Link;
|
||||
import org.commonmark.node.Node;
|
||||
import org.commonmark.node.Text;
|
||||
import org.commonmark.node.*;
|
||||
import org.commonmark.parser.InlineParserFactory;
|
||||
import org.commonmark.parser.Parser;
|
||||
import org.commonmark.parser.PostProcessor;
|
||||
|
@ -60,13 +55,7 @@ import io.noties.markwon.recycler.SimpleEntry;
|
|||
import io.noties.markwon.recycler.table.TableEntry;
|
||||
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
||||
import io.noties.prism4j.Prism4j;
|
||||
import stormpot.Allocator;
|
||||
import stormpot.BlazePool;
|
||||
import stormpot.Config;
|
||||
import stormpot.Pool;
|
||||
import stormpot.Poolable;
|
||||
import stormpot.Slot;
|
||||
import stormpot.Timeout;
|
||||
import stormpot.*;
|
||||
|
||||
/**
|
||||
* @author opyale
|
||||
|
|
|
@ -6,12 +6,7 @@ import android.graphics.BitmapFactory;
|
|||
import android.util.Log;
|
||||
import com.squareup.picasso.Cache;
|
||||
import org.mian.gitnex.R;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue