mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2024-12-16 15:48:13 +08:00
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:
parent
24064192e4
commit
96fad2d73e
@ -30,7 +30,9 @@ public class OpenRepoInBrowserActivity extends AppCompatActivity {
|
||||
|
||||
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"));
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
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;
|
||||
@ -24,7 +26,9 @@ import org.mian.gitnex.fragments.OrganizationInfoFragment;
|
||||
import org.mian.gitnex.fragments.RepositoriesByOrgFragment;
|
||||
import org.mian.gitnex.fragments.TeamsByOrgFragment;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.Objects;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -34,6 +38,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
@ -45,6 +50,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String orgName = tinyDb.getString("orgName");
|
||||
@ -105,6 +111,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.repo_dotted_menu, menu);
|
||||
return true;
|
||||
@ -132,19 +139,28 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
switch (text) {
|
||||
case "repository":
|
||||
|
||||
tinyDb.putBoolean("organizationAction", true);
|
||||
startActivity(new Intent(OrganizationDetailActivity.this, CreateRepoActivity.class));
|
||||
break;
|
||||
case "team":
|
||||
|
||||
startActivity(new Intent(OrganizationDetailActivity.this, CreateTeamByOrgActivity.class));
|
||||
break;
|
||||
}
|
||||
//Log.i("clicked", text);
|
||||
case "copyOrgUrl":
|
||||
|
||||
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 {
|
||||
@ -157,7 +173,6 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String orgName;
|
||||
if(getIntent().getStringExtra("orgName") != null || !Objects.equals(getIntent().getStringExtra("orgName"), "")) {
|
||||
orgName = getIntent().getStringExtra("orgName");
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
@ -42,6 +44,7 @@ import org.mian.gitnex.fragments.ReleasesFragment;
|
||||
import org.mian.gitnex.fragments.RepoInfoFragment;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
@ -345,6 +348,14 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
startActivity(Intent.createChooser(sharingIntent, tinyDB.getString("repoHtmlUrl")));
|
||||
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":
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateFileActivity.class));
|
||||
break;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
@ -19,9 +21,9 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||
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.RepoForksActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
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.WatchInfo;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -41,7 +44,6 @@ import retrofit2.Callback;
|
||||
|
||||
public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepositoriesAdapter.ReposSearchViewHolder> {
|
||||
|
||||
|
||||
private List<UserRepositories> searchedReposList;
|
||||
private Context mCtx;
|
||||
|
||||
@ -65,6 +67,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
private TextView repoType;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
private TextView htmlUrl;
|
||||
|
||||
private ReposSearchViewHolder(View itemView) {
|
||||
|
||||
@ -83,6 +86,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
@ -182,6 +186,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
||||
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
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.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 -> {
|
||||
|
||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||
@ -245,6 +261,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
UserRepositories currentItem = searchedReposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
@ -21,9 +23,9 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||
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.RepoForksActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
@ -35,6 +37,7 @@ import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -62,6 +65,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
private CheckBox isRepoAdmin;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
private TextView htmlUrl;
|
||||
|
||||
private MyReposViewHolder(View itemView) {
|
||||
|
||||
@ -79,6 +83,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
@ -179,6 +184,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
||||
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
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.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 -> {
|
||||
|
||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||
@ -249,6 +266,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
@ -35,6 +37,7 @@ import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -62,6 +65,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
private TextView repoType;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
private TextView htmlUrl;
|
||||
|
||||
private ReposViewHolder(View itemView) {
|
||||
|
||||
@ -79,6 +83,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
@ -180,6 +185,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
||||
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
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.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 -> {
|
||||
|
||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||
@ -250,6 +267,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
@ -35,6 +37,7 @@ import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -62,6 +65,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
private TextView repoType;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
private TextView htmlUrl;
|
||||
|
||||
private OrgReposViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@ -78,6 +82,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
@ -175,6 +180,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
||||
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
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.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 -> {
|
||||
|
||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||
@ -243,6 +260,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
@ -35,6 +37,7 @@ import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -62,6 +65,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
private TextView repoType;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
private TextView htmlUrl;
|
||||
|
||||
private StarredReposViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@ -78,6 +82,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
@ -178,6 +183,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
||||
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
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.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 -> {
|
||||
|
||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||
@ -246,6 +263,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
|
@ -27,6 +27,7 @@ public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
|
||||
|
||||
TextView createTeam = v.findViewById(R.id.createTeam);
|
||||
TextView createRepository = v.findViewById(R.id.createRepository);
|
||||
TextView copyOrgUrl = v.findViewById(R.id.copyOrgUrl);
|
||||
|
||||
createTeam.setOnClickListener(v1 -> {
|
||||
|
||||
@ -40,6 +41,12 @@ public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
|
||||
dismiss();
|
||||
});
|
||||
|
||||
copyOrgUrl.setOnClickListener(v1 -> {
|
||||
|
||||
bmListener.onButtonClicked("copyOrgUrl");
|
||||
dismiss();
|
||||
});
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
TextView watchRepository = v.findViewById(R.id.watchRepository);
|
||||
TextView unWatchRepository = v.findViewById(R.id.unWatchRepository);
|
||||
TextView shareRepository = v.findViewById(R.id.shareRepository);
|
||||
TextView copyRepoUrl = v.findViewById(R.id.copyRepoUrl);
|
||||
|
||||
createLabel.setOnClickListener(v112 -> {
|
||||
|
||||
@ -93,6 +94,12 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
dismiss();
|
||||
});
|
||||
|
||||
copyRepoUrl.setOnClickListener(copyUrl -> {
|
||||
|
||||
bmListener.onButtonClicked("copyRepoUrl");
|
||||
dismiss();
|
||||
});
|
||||
|
||||
newFile.setOnClickListener(v17 -> {
|
||||
|
||||
bmListener.onButtonClicked("newFile");
|
||||
|
@ -41,6 +41,18 @@
|
||||
android:textSize="16sp"
|
||||
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>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
@ -153,6 +153,18 @@
|
||||
android:layout_marginStart="64dp"
|
||||
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
|
||||
android:id="@+id/shareRepository"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -35,18 +35,6 @@
|
||||
android:layout_marginBottom="12dp"
|
||||
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
|
||||
android:id="@+id/repoStargazers"
|
||||
android:layout_width="match_parent"
|
||||
@ -83,6 +71,30 @@
|
||||
android:textSize="16sp"
|
||||
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>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
@ -18,6 +18,12 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/htmlUrl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/linearLayoutFrame"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -512,6 +512,7 @@
|
||||
<string name="isOpen">Open</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="genericCopyUrl">Copy URL</string>
|
||||
<!-- generic copy -->
|
||||
|
||||
<string name="translateText">Translate GitNex with Crowdin</string>
|
||||
|
Loading…
Reference in New Issue
Block a user