Copy urls (#631)

fix url open in browser

Copy org and repo url

Copy urls

Co-authored-by: M M Arif <mmarif@swatian.com>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/631
This commit is contained in:
M M Arif 2020-08-06 17:18:02 +02:00
parent 24064192e4
commit 96fad2d73e
15 changed files with 195 additions and 21 deletions

View File

@ -30,7 +30,9 @@ public class OpenRepoInBrowserActivity extends AppCompatActivity {
try { try {
URI instanceUrl = new URI(tinyDb.getString("instanceUrlWithProtocol")); URI instanceUrl = new URI(UrlBuilder.fromString(tinyDb.getString("instanceUrl"))
.withPath("/")
.toString());
String browserPath = PathsHelper.join(instanceUrl.getPath(), getIntent().getStringExtra("repoFullNameBrowser")); String browserPath = PathsHelper.join(instanceUrl.getPath(), getIntent().getStringExtra("repoFullNameBrowser"));

View File

@ -1,5 +1,7 @@
package org.mian.gitnex.activities; package org.mian.gitnex.activities;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
@ -24,7 +26,9 @@ import org.mian.gitnex.fragments.OrganizationInfoFragment;
import org.mian.gitnex.fragments.RepositoriesByOrgFragment; import org.mian.gitnex.fragments.RepositoriesByOrgFragment;
import org.mian.gitnex.fragments.TeamsByOrgFragment; import org.mian.gitnex.fragments.TeamsByOrgFragment;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty;
import java.util.Objects; import java.util.Objects;
import io.mikael.urlbuilder.UrlBuilder;
/** /**
* Author M M Arif * Author M M Arif
@ -34,6 +38,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
final Context ctx = this; final Context ctx = this;
private Context appCtx; private Context appCtx;
private TinyDB tinyDb;
@Override @Override
protected int getLayoutResourceId(){ protected int getLayoutResourceId(){
@ -45,6 +50,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
appCtx = getApplicationContext(); appCtx = getApplicationContext();
tinyDb = new TinyDB(appCtx);
TinyDB tinyDb = new TinyDB(appCtx); TinyDB tinyDb = new TinyDB(appCtx);
String orgName = tinyDb.getString("orgName"); String orgName = tinyDb.getString("orgName");
@ -105,6 +111,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater(); MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.repo_dotted_menu, menu); inflater.inflate(R.menu.repo_dotted_menu, menu);
return true; return true;
@ -132,19 +139,28 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
@Override @Override
public void onButtonClicked(String text) { public void onButtonClicked(String text) {
TinyDB tinyDb = new TinyDB(appCtx);
switch (text) { switch (text) {
case "repository": case "repository":
tinyDb.putBoolean("organizationAction", true); tinyDb.putBoolean("organizationAction", true);
startActivity(new Intent(OrganizationDetailActivity.this, CreateRepoActivity.class)); startActivity(new Intent(OrganizationDetailActivity.this, CreateRepoActivity.class));
break; break;
case "team": case "team":
startActivity(new Intent(OrganizationDetailActivity.this, CreateTeamByOrgActivity.class)); startActivity(new Intent(OrganizationDetailActivity.this, CreateTeamByOrgActivity.class));
break; break;
} case "copyOrgUrl":
//Log.i("clicked", text);
String url = UrlBuilder.fromString(tinyDb.getString("instanceUrl"))
.withPath("/")
.toString();
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("orgUrl", url + tinyDb.getString("orgName"));
assert clipboard != null;
clipboard.setPrimaryClip(clip);
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
break;
}
} }
public class SectionsPagerAdapter extends FragmentPagerAdapter { public class SectionsPagerAdapter extends FragmentPagerAdapter {
@ -157,7 +173,6 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
@Override @Override
public Fragment getItem(int position) { public Fragment getItem(int position) {
TinyDB tinyDb = new TinyDB(appCtx);
String orgName; String orgName;
if(getIntent().getStringExtra("orgName") != null || !Objects.equals(getIntent().getStringExtra("orgName"), "")) { if(getIntent().getStringExtra("orgName") != null || !Objects.equals(getIntent().getStringExtra("orgName"), "")) {
orgName = getIntent().getStringExtra("orgName"); orgName = getIntent().getStringExtra("orgName");

View File

@ -1,6 +1,8 @@
package org.mian.gitnex.activities; package org.mian.gitnex.activities;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
@ -42,6 +44,7 @@ import org.mian.gitnex.fragments.ReleasesFragment;
import org.mian.gitnex.fragments.RepoInfoFragment; import org.mian.gitnex.fragments.RepoInfoFragment;
import org.mian.gitnex.helpers.Authorization; import org.mian.gitnex.helpers.Authorization;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Toasty;
import org.mian.gitnex.helpers.Version; import org.mian.gitnex.helpers.Version;
import org.mian.gitnex.models.Branches; import org.mian.gitnex.models.Branches;
import org.mian.gitnex.models.UserRepositories; import org.mian.gitnex.models.UserRepositories;
@ -345,6 +348,14 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
startActivity(Intent.createChooser(sharingIntent, tinyDB.getString("repoHtmlUrl"))); startActivity(Intent.createChooser(sharingIntent, tinyDB.getString("repoHtmlUrl")));
break; break;
case "copyRepoUrl":
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("repoUrl", tinyDB.getString("repoHtmlUrl"));
assert clipboard != null;
clipboard.setPrimaryClip(clip);
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
break;
case "newFile": case "newFile":
startActivity(new Intent(RepoDetailActivity.this, CreateFileActivity.class)); startActivity(new Intent(RepoDetailActivity.this, CreateFileActivity.class));
break; break;

View File

@ -1,6 +1,8 @@
package org.mian.gitnex.adapters; package org.mian.gitnex.adapters;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
@ -19,9 +21,9 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.activities.OpenRepoInBrowserActivity; import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity; import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.activities.RepoStargazersActivity; import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity; import org.mian.gitnex.activities.RepoWatchersActivity;
import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.database.api.RepositoriesApi; import org.mian.gitnex.database.api.RepositoriesApi;
@ -32,6 +34,7 @@ import org.mian.gitnex.helpers.Toasty;
import org.mian.gitnex.models.UserRepositories; import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.models.WatchInfo; import org.mian.gitnex.models.WatchInfo;
import java.util.List; import java.util.List;
import java.util.Objects;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -41,7 +44,6 @@ import retrofit2.Callback;
public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepositoriesAdapter.ReposSearchViewHolder> { public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepositoriesAdapter.ReposSearchViewHolder> {
private List<UserRepositories> searchedReposList; private List<UserRepositories> searchedReposList;
private Context mCtx; private Context mCtx;
@ -65,6 +67,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
private TextView repoType; private TextView repoType;
private LinearLayout archiveRepo; private LinearLayout archiveRepo;
private TextView repoBranch; private TextView repoBranch;
private TextView htmlUrl;
private ReposSearchViewHolder(View itemView) { private ReposSearchViewHolder(View itemView) {
@ -83,6 +86,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
repoType = itemView.findViewById(R.id.repoType); repoType = itemView.findViewById(R.id.repoType);
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame); archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
repoBranch = itemView.findViewById(R.id.repoBranch); repoBranch = itemView.findViewById(R.id.repoBranch);
htmlUrl = itemView.findViewById(R.id.htmlUrl);
itemView.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
@ -182,6 +186,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
TextView repoStargazers = view.findViewById(R.id.repoStargazers); TextView repoStargazers = view.findViewById(R.id.repoStargazers);
TextView repoWatchers = view.findViewById(R.id.repoWatchers); TextView repoWatchers = view.findViewById(R.id.repoWatchers);
TextView repoForksList = view.findViewById(R.id.repoForksList); TextView repoForksList = view.findViewById(R.id.repoForksList);
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader); TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1])); bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
@ -189,6 +194,17 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
dialog.setContentView(view); dialog.setContentView(view);
dialog.show(); dialog.show();
repoCopyUrl.setOnClickListener(openInBrowser -> {
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
assert clipboard != null;
clipboard.setPrimaryClip(clip);
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
dialog.dismiss();
});
repoOpenInBrowser.setOnClickListener(openInBrowser -> { repoOpenInBrowser.setOnClickListener(openInBrowser -> {
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class); Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
@ -245,6 +261,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
UserRepositories currentItem = searchedReposList.get(position); UserRepositories currentItem = searchedReposList.get(position);
holder.repoDescription.setVisibility(View.GONE); holder.repoDescription.setVisibility(View.GONE);
holder.repoBranch.setText(currentItem.getDefault_branch()); holder.repoBranch.setText(currentItem.getDefault_branch());
holder.htmlUrl.setText(currentItem.getHtml_url());
ColorGenerator generator = ColorGenerator.MATERIAL; ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(currentItem.getName()); int color = generator.getColor(currentItem.getName());

View File

@ -1,6 +1,8 @@
package org.mian.gitnex.adapters; package org.mian.gitnex.adapters;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
@ -21,9 +23,9 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.activities.OpenRepoInBrowserActivity; import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity; import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.activities.RepoStargazersActivity; import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity; import org.mian.gitnex.activities.RepoWatchersActivity;
import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.database.api.RepositoriesApi; import org.mian.gitnex.database.api.RepositoriesApi;
@ -35,6 +37,7 @@ import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.models.WatchInfo; import org.mian.gitnex.models.WatchInfo;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -62,6 +65,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
private CheckBox isRepoAdmin; private CheckBox isRepoAdmin;
private LinearLayout archiveRepo; private LinearLayout archiveRepo;
private TextView repoBranch; private TextView repoBranch;
private TextView htmlUrl;
private MyReposViewHolder(View itemView) { private MyReposViewHolder(View itemView) {
@ -79,6 +83,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin); isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame); archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
repoBranch = itemView.findViewById(R.id.repoBranch); repoBranch = itemView.findViewById(R.id.repoBranch);
htmlUrl = itemView.findViewById(R.id.htmlUrl);
itemView.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
@ -179,6 +184,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
TextView repoStargazers = view.findViewById(R.id.repoStargazers); TextView repoStargazers = view.findViewById(R.id.repoStargazers);
TextView repoWatchers = view.findViewById(R.id.repoWatchers); TextView repoWatchers = view.findViewById(R.id.repoWatchers);
TextView repoForksList = view.findViewById(R.id.repoForksList); TextView repoForksList = view.findViewById(R.id.repoForksList);
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader); TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
bottomSheetHeader.setText(String.format("%s / %s", repoFullName.getText().toString().split("/")[0], repoFullName.getText().toString().split("/")[1])); bottomSheetHeader.setText(String.format("%s / %s", repoFullName.getText().toString().split("/")[0], repoFullName.getText().toString().split("/")[1]));
@ -186,6 +192,17 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
dialog.setContentView(view); dialog.setContentView(view);
dialog.show(); dialog.show();
repoCopyUrl.setOnClickListener(openInBrowser -> {
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
assert clipboard != null;
clipboard.setPrimaryClip(clip);
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
dialog.dismiss();
});
repoOpenInBrowser.setOnClickListener(openInBrowser -> { repoOpenInBrowser.setOnClickListener(openInBrowser -> {
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class); Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
@ -249,6 +266,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
UserRepositories currentItem = reposList.get(position); UserRepositories currentItem = reposList.get(position);
holder.repoDescription.setVisibility(View.GONE); holder.repoDescription.setVisibility(View.GONE);
holder.repoBranch.setText(currentItem.getDefault_branch()); holder.repoBranch.setText(currentItem.getDefault_branch());
holder.htmlUrl.setText(currentItem.getHtml_url());
ColorGenerator generator = ColorGenerator.MATERIAL; ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(currentItem.getName()); int color = generator.getColor(currentItem.getName());

View File

@ -1,6 +1,8 @@
package org.mian.gitnex.adapters; package org.mian.gitnex.adapters;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
@ -35,6 +37,7 @@ import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.models.WatchInfo; import org.mian.gitnex.models.WatchInfo;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -62,6 +65,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
private TextView repoType; private TextView repoType;
private LinearLayout archiveRepo; private LinearLayout archiveRepo;
private TextView repoBranch; private TextView repoBranch;
private TextView htmlUrl;
private ReposViewHolder(View itemView) { private ReposViewHolder(View itemView) {
@ -79,6 +83,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
repoType = itemView.findViewById(R.id.repoType); repoType = itemView.findViewById(R.id.repoType);
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame); archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
repoBranch = itemView.findViewById(R.id.repoBranch); repoBranch = itemView.findViewById(R.id.repoBranch);
htmlUrl = itemView.findViewById(R.id.htmlUrl);
itemView.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
@ -180,6 +185,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
TextView repoStargazers = view.findViewById(R.id.repoStargazers); TextView repoStargazers = view.findViewById(R.id.repoStargazers);
TextView repoWatchers = view.findViewById(R.id.repoWatchers); TextView repoWatchers = view.findViewById(R.id.repoWatchers);
TextView repoForksList = view.findViewById(R.id.repoForksList); TextView repoForksList = view.findViewById(R.id.repoForksList);
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader); TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1])); bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
@ -187,6 +193,17 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
dialog.setContentView(view); dialog.setContentView(view);
dialog.show(); dialog.show();
repoCopyUrl.setOnClickListener(openInBrowser -> {
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
assert clipboard != null;
clipboard.setPrimaryClip(clip);
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
dialog.dismiss();
});
repoOpenInBrowser.setOnClickListener(openInBrowser -> { repoOpenInBrowser.setOnClickListener(openInBrowser -> {
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class); Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
@ -250,6 +267,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
UserRepositories currentItem = reposList.get(position); UserRepositories currentItem = reposList.get(position);
holder.repoDescription.setVisibility(View.GONE); holder.repoDescription.setVisibility(View.GONE);
holder.repoBranch.setText(currentItem.getDefault_branch()); holder.repoBranch.setText(currentItem.getDefault_branch());
holder.htmlUrl.setText(currentItem.getHtml_url());
ColorGenerator generator = ColorGenerator.MATERIAL; ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(currentItem.getName()); int color = generator.getColor(currentItem.getName());

View File

@ -1,6 +1,8 @@
package org.mian.gitnex.adapters; package org.mian.gitnex.adapters;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
@ -35,6 +37,7 @@ import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.models.WatchInfo; import org.mian.gitnex.models.WatchInfo;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -62,6 +65,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
private TextView repoType; private TextView repoType;
private LinearLayout archiveRepo; private LinearLayout archiveRepo;
private TextView repoBranch; private TextView repoBranch;
private TextView htmlUrl;
private OrgReposViewHolder(View itemView) { private OrgReposViewHolder(View itemView) {
super(itemView); super(itemView);
@ -78,6 +82,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
repoType = itemView.findViewById(R.id.repoType); repoType = itemView.findViewById(R.id.repoType);
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame); archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
repoBranch = itemView.findViewById(R.id.repoBranch); repoBranch = itemView.findViewById(R.id.repoBranch);
htmlUrl = itemView.findViewById(R.id.htmlUrl);
itemView.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
@ -175,6 +180,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
TextView repoStargazers = view.findViewById(R.id.repoStargazers); TextView repoStargazers = view.findViewById(R.id.repoStargazers);
TextView repoWatchers = view.findViewById(R.id.repoWatchers); TextView repoWatchers = view.findViewById(R.id.repoWatchers);
TextView repoForksList = view.findViewById(R.id.repoForksList); TextView repoForksList = view.findViewById(R.id.repoForksList);
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader); TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1])); bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
@ -182,6 +188,17 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
dialog.setContentView(view); dialog.setContentView(view);
dialog.show(); dialog.show();
repoCopyUrl.setOnClickListener(openInBrowser -> {
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
assert clipboard != null;
clipboard.setPrimaryClip(clip);
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
dialog.dismiss();
});
repoOpenInBrowser.setOnClickListener(openInBrowser -> { repoOpenInBrowser.setOnClickListener(openInBrowser -> {
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class); Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
@ -243,6 +260,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
UserRepositories currentItem = reposList.get(position); UserRepositories currentItem = reposList.get(position);
holder.repoDescription.setVisibility(View.GONE); holder.repoDescription.setVisibility(View.GONE);
holder.repoBranch.setText(currentItem.getDefault_branch()); holder.repoBranch.setText(currentItem.getDefault_branch());
holder.htmlUrl.setText(currentItem.getHtml_url());
ColorGenerator generator = ColorGenerator.MATERIAL; ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(currentItem.getName()); int color = generator.getColor(currentItem.getName());

View File

@ -1,6 +1,8 @@
package org.mian.gitnex.adapters; package org.mian.gitnex.adapters;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
@ -35,6 +37,7 @@ import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.models.WatchInfo; import org.mian.gitnex.models.WatchInfo;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -62,6 +65,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
private TextView repoType; private TextView repoType;
private LinearLayout archiveRepo; private LinearLayout archiveRepo;
private TextView repoBranch; private TextView repoBranch;
private TextView htmlUrl;
private StarredReposViewHolder(View itemView) { private StarredReposViewHolder(View itemView) {
super(itemView); super(itemView);
@ -78,6 +82,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
repoType = itemView.findViewById(R.id.repoType); repoType = itemView.findViewById(R.id.repoType);
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame); archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
repoBranch = itemView.findViewById(R.id.repoBranch); repoBranch = itemView.findViewById(R.id.repoBranch);
htmlUrl = itemView.findViewById(R.id.htmlUrl);
itemView.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
@ -178,6 +183,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
TextView repoStargazers = view.findViewById(R.id.repoStargazers); TextView repoStargazers = view.findViewById(R.id.repoStargazers);
TextView repoWatchers = view.findViewById(R.id.repoWatchers); TextView repoWatchers = view.findViewById(R.id.repoWatchers);
TextView repoForksList = view.findViewById(R.id.repoForksList); TextView repoForksList = view.findViewById(R.id.repoForksList);
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader); TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1])); bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
@ -185,6 +191,17 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
dialog.setContentView(view); dialog.setContentView(view);
dialog.show(); dialog.show();
repoCopyUrl.setOnClickListener(openInBrowser -> {
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
assert clipboard != null;
clipboard.setPrimaryClip(clip);
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
dialog.dismiss();
});
repoOpenInBrowser.setOnClickListener(openInBrowser -> { repoOpenInBrowser.setOnClickListener(openInBrowser -> {
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class); Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
@ -246,6 +263,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
UserRepositories currentItem = reposList.get(position); UserRepositories currentItem = reposList.get(position);
holder.repoDescription.setVisibility(View.GONE); holder.repoDescription.setVisibility(View.GONE);
holder.repoBranch.setText(currentItem.getDefault_branch()); holder.repoBranch.setText(currentItem.getDefault_branch());
holder.htmlUrl.setText(currentItem.getHtml_url());
ColorGenerator generator = ColorGenerator.MATERIAL; ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(currentItem.getName()); int color = generator.getColor(currentItem.getName());

View File

@ -27,6 +27,7 @@ public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
TextView createTeam = v.findViewById(R.id.createTeam); TextView createTeam = v.findViewById(R.id.createTeam);
TextView createRepository = v.findViewById(R.id.createRepository); TextView createRepository = v.findViewById(R.id.createRepository);
TextView copyOrgUrl = v.findViewById(R.id.copyOrgUrl);
createTeam.setOnClickListener(v1 -> { createTeam.setOnClickListener(v1 -> {
@ -40,6 +41,12 @@ public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
dismiss(); dismiss();
}); });
copyOrgUrl.setOnClickListener(v1 -> {
bmListener.onButtonClicked("copyOrgUrl");
dismiss();
});
return v; return v;
} }

View File

@ -40,6 +40,7 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
TextView watchRepository = v.findViewById(R.id.watchRepository); TextView watchRepository = v.findViewById(R.id.watchRepository);
TextView unWatchRepository = v.findViewById(R.id.unWatchRepository); TextView unWatchRepository = v.findViewById(R.id.unWatchRepository);
TextView shareRepository = v.findViewById(R.id.shareRepository); TextView shareRepository = v.findViewById(R.id.shareRepository);
TextView copyRepoUrl = v.findViewById(R.id.copyRepoUrl);
createLabel.setOnClickListener(v112 -> { createLabel.setOnClickListener(v112 -> {
@ -93,6 +94,12 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
dismiss(); dismiss();
}); });
copyRepoUrl.setOnClickListener(copyUrl -> {
bmListener.onButtonClicked("copyRepoUrl");
dismiss();
});
newFile.setOnClickListener(v17 -> { newFile.setOnClickListener(v17 -> {
bmListener.onButtonClicked("newFile"); bmListener.onButtonClicked("newFile");

View File

@ -41,6 +41,18 @@
android:textSize="16sp" android:textSize="16sp"
android:padding="12dp" /> android:padding="12dp" />
<TextView
android:id="@+id/copyOrgUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/genericCopyUrl"
android:drawableStart="@drawable/ic_copy"
android:drawablePadding="24dp"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:padding="12dp" />
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>

View File

@ -153,6 +153,18 @@
android:layout_marginStart="64dp" android:layout_marginStart="64dp"
android:background="?attr/dividerColor" /> android:background="?attr/dividerColor" />
<TextView
android:id="@+id/copyRepoUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:drawableStart="@drawable/ic_copy"
android:drawablePadding="24dp"
android:text="@string/genericCopyUrl"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:padding="12dp" />
<TextView <TextView
android:id="@+id/shareRepository" android:id="@+id/shareRepository"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -35,18 +35,6 @@
android:layout_marginBottom="12dp" android:layout_marginBottom="12dp"
android:background="?attr/dividerColor" /> android:background="?attr/dividerColor" />
<TextView
android:id="@+id/repoOpenInBrowser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/openWebRepo"
android:drawableStart="@drawable/ic_browser"
android:drawablePadding="24dp"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:padding="12dp" />
<TextView <TextView
android:id="@+id/repoStargazers" android:id="@+id/repoStargazers"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -83,6 +71,30 @@
android:textSize="16sp" android:textSize="16sp"
android:padding="12dp" /> android:padding="12dp" />
<TextView
android:id="@+id/repoCopyUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/genericCopyUrl"
android:drawableStart="@drawable/ic_copy"
android:drawablePadding="24dp"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:padding="12dp" />
<TextView
android:id="@+id/repoOpenInBrowser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/openWebRepo"
android:drawableStart="@drawable/ic_browser"
android:drawablePadding="24dp"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:padding="12dp" />
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>

View File

@ -18,6 +18,12 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="invisible" /> android:visibility="invisible" />
<TextView
android:id="@+id/htmlUrl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible" />
<RelativeLayout <RelativeLayout
android:id="@+id/linearLayoutFrame" android:id="@+id/linearLayoutFrame"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -512,6 +512,7 @@
<string name="isOpen">Open</string> <string name="isOpen">Open</string>
<string name="isClosed">Closed</string> <string name="isClosed">Closed</string>
<string name="genericServerResponseError">We cannot reach the server at the moment, please check your server status and try again</string> <string name="genericServerResponseError">We cannot reach the server at the moment, please check your server status and try again</string>
<string name="genericCopyUrl">Copy URL</string>
<!-- generic copy --> <!-- generic copy -->
<string name="translateText">Translate GitNex with Crowdin</string> <string name="translateText">Translate GitNex with Crowdin</string>