mirror of https://codeberg.org/gitnex/GitNex.git
Wiki link handler (#1186)
Closes #1163 Co-authored-by: M M Arif <mmarif@swatian.com> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1186 Reviewed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
parent
9fa2e3f506
commit
e5f7975109
|
@ -84,16 +84,25 @@ public class DeepLinksActivity extends BaseActivity {
|
||||||
|
|
||||||
String hostUri = userAccount.getInstanceUrl();
|
String hostUri = userAccount.getInstanceUrl();
|
||||||
|
|
||||||
String host = data.getHost();
|
String hostExternal = data.getHost();
|
||||||
if (host == null) host = "";
|
int portExternal = data.getPort();
|
||||||
|
|
||||||
if(hostUri.toLowerCase().contains(host.toLowerCase())) {
|
String hostUrlExternal;
|
||||||
|
if(portExternal > 0) {
|
||||||
|
hostUrlExternal = hostExternal + ":" + portExternal;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
hostUrlExternal = hostExternal;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hostUrlExternal == null) hostUrlExternal = "";
|
||||||
|
|
||||||
|
if(hostUri.toLowerCase().contains(hostUrlExternal.toLowerCase())) {
|
||||||
|
|
||||||
accountFound = true;
|
accountFound = true;
|
||||||
|
|
||||||
AppUtil.switchToAccount(ctx, userAccount, true);
|
AppUtil.switchToAccount(ctx, userAccount, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,6 +312,17 @@ public class DeepLinksActivity extends BaseActivity {
|
||||||
getFile(data.getPathSegments().get(0),
|
getFile(data.getPathSegments().get(0),
|
||||||
data.getPathSegments().get(1), filePath.toString(), data.getPathSegments().get(4)), 500);
|
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);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(
|
||||||
|
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "wiki"), 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
else { // no action, show options
|
else { // no action, show options
|
||||||
showNoActionButtons();
|
showNoActionButtons();
|
||||||
}
|
}
|
||||||
|
@ -355,7 +375,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||||
.getApiInterface(ctx)
|
.getApiInterface(ctx)
|
||||||
.repoGetPullRequest(repoOwner, repoName, (long) index);
|
.repoGetPullRequest(repoOwner, repoName, (long) index);
|
||||||
|
|
||||||
call.enqueue(new Callback<PullRequest>() {
|
call.enqueue(new Callback<>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<PullRequest> call, @NonNull retrofit2.Response<PullRequest> response) {
|
public void onResponse(@NonNull Call<PullRequest> call, @NonNull retrofit2.Response<PullRequest> response) {
|
||||||
|
@ -401,7 +421,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||||
.getApiInterface(ctx)
|
.getApiInterface(ctx)
|
||||||
.repoGet(repoOwner, repoName);
|
.repoGet(repoOwner, repoName);
|
||||||
|
|
||||||
call.enqueue(new Callback<Repository>() {
|
call.enqueue(new Callback<>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<Repository> call, @NonNull retrofit2.Response<Repository> response) {
|
public void onResponse(@NonNull Call<Repository> call, @NonNull retrofit2.Response<Repository> response) {
|
||||||
|
@ -420,10 +440,11 @@ public class DeepLinksActivity extends BaseActivity {
|
||||||
|
|
||||||
ctx.startActivity(repoIntent);
|
ctx.startActivity(repoIntent);
|
||||||
finish();
|
finish();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ctx.startActivity(mainIntent);
|
ctx.startActivity(mainIntent);
|
||||||
finish();
|
finish();
|
||||||
Log.e("onFailure-goToRepo", String.valueOf(response.code()));
|
Log.e("error-goToRepo", response.message());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -441,7 +462,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||||
private void getUserOrOrg(String userOrgName) {
|
private void getUserOrOrg(String userOrgName) {
|
||||||
Call<Organization> call = RetrofitClient.getApiInterface(ctx).orgGet(userOrgName);
|
Call<Organization> call = RetrofitClient.getApiInterface(ctx).orgGet(userOrgName);
|
||||||
|
|
||||||
call.enqueue(new Callback<Organization>() {
|
call.enqueue(new Callback<>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<Organization> call, @NonNull Response<Organization> response) {
|
public void onResponse(@NonNull Call<Organization> call, @NonNull Response<Organization> response) {
|
||||||
|
@ -474,7 +495,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||||
private void getUser(String userName) {
|
private void getUser(String userName) {
|
||||||
Call<User> call = RetrofitClient.getApiInterface(ctx).userGet(userName);
|
Call<User> call = RetrofitClient.getApiInterface(ctx).userGet(userName);
|
||||||
|
|
||||||
call.enqueue(new Callback<User>() {
|
call.enqueue(new Callback<>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<User> call, @NonNull Response<User> response) {
|
public void onResponse(@NonNull Call<User> call, @NonNull Response<User> response) {
|
||||||
|
@ -502,7 +523,7 @@ public class DeepLinksActivity extends BaseActivity {
|
||||||
private void getFile(String owner, String repo, String filePath, String branch) {
|
private void getFile(String owner, String repo, String filePath, String branch) {
|
||||||
Call<ContentsResponse> call = RetrofitClient.getApiInterface(ctx).repoGetContents(owner, repo, filePath, branch);
|
Call<ContentsResponse> call = RetrofitClient.getApiInterface(ctx).repoGetContents(owner, repo, filePath, branch);
|
||||||
|
|
||||||
call.enqueue(new Callback<ContentsResponse>() {
|
call.enqueue(new Callback<>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<ContentsResponse> call, @NonNull Response<ContentsResponse> response) {
|
public void onResponse(@NonNull Call<ContentsResponse> call, @NonNull Response<ContentsResponse> response) {
|
||||||
|
|
|
@ -86,6 +86,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||||
|
|
||||||
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
||||||
|
|
||||||
|
private Intent intentWiki;
|
||||||
|
|
||||||
private final ActivityResultLauncher<Intent> createReleaseLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
private final ActivityResultLauncher<Intent> createReleaseLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||||
result -> {
|
result -> {
|
||||||
if(result.getResultCode() == 201) {
|
if(result.getResultCode() == 201) {
|
||||||
|
@ -141,6 +143,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||||
|
|
||||||
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||||
|
|
||||||
|
intentWiki = new Intent(ctx, WikiActivity.class);
|
||||||
|
|
||||||
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
||||||
toolbarTitle.setText(repository.getFullName());
|
toolbarTitle.setText(repository.getFullName());
|
||||||
|
|
||||||
|
@ -762,15 +766,24 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||||
viewPager.setCurrentItem(4);
|
viewPager.setCurrentItem(4);
|
||||||
createReleaseLauncher.launch(repository.getIntent(ctx, CreateReleaseActivity.class));
|
createReleaseLauncher.launch(repository.getIntent(ctx, CreateReleaseActivity.class));
|
||||||
break;
|
break;
|
||||||
case "milestones":
|
case "wiki":
|
||||||
viewPager.setCurrentItem(5);
|
viewPager.setCurrentItem(5);
|
||||||
break;
|
break;
|
||||||
case "milestonesNew":
|
case "wikiNew":
|
||||||
viewPager.setCurrentItem(5);
|
viewPager.setCurrentItem(5);
|
||||||
|
intentWiki.putExtra("action", "add");
|
||||||
|
intentWiki.putExtra(RepositoryContext.INTENT_EXTRA, ((RepoDetailActivity) ctx).repository);
|
||||||
|
ctx.startActivity(intentWiki);
|
||||||
|
break;
|
||||||
|
case "milestones":
|
||||||
|
viewPager.setCurrentItem(6);
|
||||||
|
break;
|
||||||
|
case "milestonesNew":
|
||||||
|
viewPager.setCurrentItem(6);
|
||||||
createMilestoneLauncher.launch(repository.getIntent(ctx, CreateMilestoneActivity.class));
|
createMilestoneLauncher.launch(repository.getIntent(ctx, CreateMilestoneActivity.class));
|
||||||
break;
|
break;
|
||||||
case "labels":
|
case "labels":
|
||||||
viewPager.setCurrentItem(6);
|
viewPager.setCurrentItem(7);
|
||||||
break;
|
break;
|
||||||
case "settings":
|
case "settings":
|
||||||
settingsLauncher.launch(repository.getIntent(ctx, RepositorySettingsActivity.class));
|
settingsLauncher.launch(repository.getIntent(ctx, RepositorySettingsActivity.class));
|
||||||
|
|
Loading…
Reference in New Issue