mirror of
https://github.com/gitnex-org/gitnex.git
synced 2026-07-21 17:19:22 -05:00
Add common actions where required
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
@@ -28,7 +25,7 @@ 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.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import java.util.Objects;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
@@ -37,7 +34,7 @@ import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class OrganizationDetailActivity extends BaseActivity implements BottomSheetListener {
|
||||
@@ -168,6 +165,11 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
|
||||
String url = UrlBuilder.fromString(getAccount().getAccount().getInstanceUrl())
|
||||
.withPath("/")
|
||||
.toString();
|
||||
url = url + getIntent().getStringExtra("orgName");
|
||||
|
||||
switch (text) {
|
||||
case "repository":
|
||||
Intent intentRepo = new Intent(this, CreateRepoActivity.class);
|
||||
@@ -189,15 +191,13 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
startActivity(intentTeam);
|
||||
break;
|
||||
case "copyOrgUrl":
|
||||
|
||||
String url = UrlBuilder.fromString(getAccount().getAccount().getInstanceUrl())
|
||||
.withPath("/")
|
||||
.toString();
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("orgUrl", url + getIntent().getStringExtra("orgName"));
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||
AppUtil.copyToClipboard(this, url, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||
break;
|
||||
case "share":
|
||||
AppUtil.sharingIntent(this, url);
|
||||
break;
|
||||
case "open":
|
||||
AppUtil.openUrlInBrowser(this, url);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@ package org.mian.gitnex.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Typeface;
|
||||
@@ -279,20 +276,10 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
AppUtil.openUrlInBrowser(this, repository.getRepository().getHtmlUrl());
|
||||
break;
|
||||
case "shareRepo":
|
||||
|
||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
sharingIntent.setType("text/plain");
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, repository.getRepository().getHtmlUrl());
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, repository.getRepository().getHtmlUrl());
|
||||
startActivity(Intent.createChooser(sharingIntent, repository.getRepository().getHtmlUrl()));
|
||||
AppUtil.sharingIntent(this, repository.getRepository().getHtmlUrl());
|
||||
break;
|
||||
case "copyRepoUrl":
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("repoUrl", repository.getRepository().getHtmlUrl());
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||
AppUtil.copyToClipboard(this, repository.getRepository().getHtmlUrl(), ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||
break;
|
||||
case "newFile":
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdapter.IssueCommentViewHolder> {
|
||||
@@ -103,6 +103,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
TextView commentMenuCopy = vw.findViewById(R.id.commentMenuCopy);
|
||||
TextView commentMenuDelete = vw.findViewById(R.id.commentMenuDelete);
|
||||
TextView issueCommentCopyUrl = vw.findViewById(R.id.issueCommentCopyUrl);
|
||||
TextView open = vw.findViewById(R.id.open);
|
||||
LinearLayout linearLayout = vw.findViewById(R.id.commentReactionButtons);
|
||||
|
||||
if(issue.getRepository().getRepository().isArchived()) {
|
||||
@@ -161,32 +162,21 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
});
|
||||
|
||||
commentShare.setOnClickListener(v1 -> {
|
||||
// get comment Url
|
||||
CharSequence commentUrl = issueComment.getHtmlUrl();
|
||||
|
||||
// share issue comment
|
||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
sharingIntent.setType("text/plain");
|
||||
String intentHeader = issue.getIssueIndex() + context.getResources().getString(R.string.hash) + "issuecomment-" + issueComment.getId() + " " + issue.getIssue().getTitle();
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, intentHeader);
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, commentUrl);
|
||||
context.startActivity(Intent.createChooser(sharingIntent, intentHeader));
|
||||
|
||||
AppUtil.sharingIntent(context, issueComment.getHtmlUrl());
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
issueCommentCopyUrl.setOnClickListener(v1 -> {
|
||||
// comment Url
|
||||
CharSequence commentUrl = issueComment.getHtmlUrl();
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
assert clipboard != null;
|
||||
|
||||
ClipData clip = ClipData.newPlainText(commentUrl, commentUrl);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
AppUtil.copyToClipboard(context, issueComment.getHtmlUrl(), context.getString(R.string.copyIssueUrlToastMsg));
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
open.setOnClickListener(v1 -> {
|
||||
|
||||
AppUtil.openUrlInBrowser(context, issueComment.getHtmlUrl());
|
||||
dialog.dismiss();
|
||||
Toasty.success(context, context.getString(R.string.copyIssueUrlToastMsg));
|
||||
});
|
||||
|
||||
commentMenuQuote.setOnClickListener(v1 -> {
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.mian.gitnex.databinding.BottomSheetOrganizationBinding;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
|
||||
@@ -70,6 +70,18 @@ public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
|
||||
dismiss();
|
||||
});
|
||||
|
||||
bottomSheetOrganizationBinding.share.setOnClickListener(v1 -> {
|
||||
|
||||
bmListener.onButtonClicked("share");
|
||||
dismiss();
|
||||
});
|
||||
|
||||
bottomSheetOrganizationBinding.open.setOnClickListener(v1 -> {
|
||||
|
||||
bmListener.onButtonClicked("open");
|
||||
dismiss();
|
||||
});
|
||||
|
||||
return bottomSheetOrganizationBinding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -23,7 +20,7 @@ import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.activities.MergePullRequestActivity;
|
||||
import org.mian.gitnex.databinding.BottomSheetSingleIssueBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import org.mian.gitnex.views.ReactionSpinner;
|
||||
@@ -174,25 +171,19 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
|
||||
binding.shareIssue.setOnClickListener(v1 -> {
|
||||
|
||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
sharingIntent.setType("text/plain");
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.hash) + issue.getIssueIndex() + " " + issue.getIssue().getTitle());
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, issue.getIssue().getHtmlUrl());
|
||||
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.hash) + issue.getIssueIndex() + " " + issue.getIssue().getTitle()));
|
||||
|
||||
AppUtil.sharingIntent(ctx, issue.getIssue().getHtmlUrl());
|
||||
dismiss();
|
||||
});
|
||||
|
||||
binding.copyIssueUrl.setOnClickListener(v12 -> {
|
||||
|
||||
// copy to clipboard
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("issueUrl", issue.getIssue().getHtmlUrl());
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
AppUtil.copyToClipboard(ctx, issue.getIssue().getHtmlUrl(), ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||
dismiss();
|
||||
});
|
||||
|
||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||
binding.open.setOnClickListener(v12 -> {
|
||||
|
||||
AppUtil.openUrlInBrowser(ctx, issue.getIssue().getHtmlUrl());
|
||||
dismiss();
|
||||
});
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class AppUtil {
|
||||
@@ -363,7 +363,6 @@ public class AppUtil {
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
Toasty.info(ctx, message);
|
||||
|
||||
}
|
||||
|
||||
public static boolean switchToAccount(Context context, UserAccount userAccount) {
|
||||
@@ -374,6 +373,15 @@ public class AppUtil {
|
||||
return ((MainApplication) context.getApplicationContext()).switchToAccount(userAccount, tmp);
|
||||
}
|
||||
|
||||
public static void sharingIntent(Context ctx, String url) {
|
||||
|
||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
sharingIntent.setType("text/plain");
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, url);
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, url);
|
||||
ctx.startActivity(Intent.createChooser(sharingIntent, url));
|
||||
}
|
||||
|
||||
public static void openUrlInBrowser(Context context, String url) {
|
||||
TinyDB tinyDB = TinyDB.getInstance(context);
|
||||
|
||||
|
||||
@@ -156,6 +156,19 @@
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/open"
|
||||
android:layout_width="98dp"
|
||||
android:layout_height="100dp"
|
||||
android:padding="8dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:gravity="center"
|
||||
app:layout_alignSelf="flex_start"
|
||||
app:drawableTopCompat="@drawable/ic_browser"
|
||||
android:text="@string/isOpen"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -132,6 +132,32 @@
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/share"
|
||||
android:layout_width="98dp"
|
||||
android:layout_height="100dp"
|
||||
android:padding="8dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:gravity="center"
|
||||
app:layout_alignSelf="flex_start"
|
||||
app:drawableTopCompat="@drawable/ic_share"
|
||||
android:text="@string/share"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/open"
|
||||
android:layout_width="98dp"
|
||||
android:layout_height="100dp"
|
||||
android:padding="8dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:gravity="center"
|
||||
app:layout_alignSelf="flex_start"
|
||||
app:drawableTopCompat="@drawable/ic_browser"
|
||||
android:text="@string/isOpen"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -236,6 +236,19 @@
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/open"
|
||||
android:layout_width="98dp"
|
||||
android:layout_height="100dp"
|
||||
android:padding="8dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:gravity="center"
|
||||
app:layout_alignSelf="flex_start"
|
||||
app:drawableTopCompat="@drawable/ic_browser"
|
||||
android:text="@string/isOpen"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
Reference in New Issue
Block a user