Skip to content

Commit

Permalink
Allow title to copy address
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesSmartCell committed Sep 23, 2023
1 parent 3e7ff79 commit 72fa7cc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/src/main/java/com/alphawallet/app/ui/BaseFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ private void initToolbar(View view)
{
toolbar = view.findViewById(R.id.toolbar);
toolbarTitle = toolbar.findViewById(R.id.toolbar_title);

toolbar.setOnClickListener(this::onToolbarClicked);
}

protected void toolbar(View view)
Expand Down Expand Up @@ -121,6 +123,11 @@ public void onItemClick(String url)
{
}

public void onToolbarClicked(View view)
{

}

public void signalPlayStoreUpdate(int updateVersion)
{
}
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/com/alphawallet/app/ui/WalletFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
import static com.alphawallet.app.C.ErrorCode.EMPTY_COLLECTION;
import static com.alphawallet.app.C.Key.WALLET;
import static com.alphawallet.app.ui.HomeActivity.RESET_TOKEN_SERVICE;
import static com.alphawallet.app.ui.MyAddressActivity.KEY_ADDRESS;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.drawable.ColorDrawable;
Expand Down Expand Up @@ -73,6 +77,8 @@
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;

import org.web3j.crypto.Keys;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -901,4 +907,17 @@ else if (dX < 0)
icon.draw(c);
}
}

@Override
public void onToolbarClicked(View view)
{
//can we do it this way?
//copy address
ClipboardManager clipboard = (ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText(KEY_ADDRESS, Keys.toChecksumAddress(viewModel.getWalletAddr()));
if (clipboard != null)
{
clipboard.setPrimaryClip(clip);
}
}
}

0 comments on commit 72fa7cc

Please sign in to comment.