Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1672 address book input address #3348

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This workflow will build a Java project with Ant
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-ant

name: Java CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Build with Ant
run: ant -noinput -buildfile build.xml
19 changes: 19 additions & 0 deletions .github/workflows/clojure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Clojure CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: lein deps
- name: Run tests
run: lein test
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ android {
def DEFAULT_OPENSEA_API_KEY = "\"...\""; //Put your OpenSea developer API key in here, otherwise you are reliant on the backup NFT fetch method
def DEFAULT_POLYGONSCAN_API_KEY = "\"\""; //Put your Polygonscan developer API key in here to get access to Polygon/Mumbai token discovery and transactions

buildConfigField 'int', 'DB_VERSION', '43'
buildConfigField 'int', 'DB_VERSION', '44'
buildConfigField "String", XInfuraAPI, DEFAULT_INFURA_API_KEY

ndk {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,12 @@
android:name=".ui.QRScanning.QRScanner"
android:label="@string/qr_scanner" />

<activity android:name=".ui.AddressBookActivity"
android:label="@string/title_address_book" />

<activity android:name=".ui.AddEditAddressActivity"
android:label="@string/title_add_address" />

<service
android:name=".service.PriceAlertsService"
android:enabled="true"
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/alphawallet/app/C.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public abstract class C {
public static final int SEND_INTENT_REQUEST_CODE = 4;
public static final int TERMINATE_ACTIVITY = 5;
public static final int ADDED_TOKEN_RETURN = 9;
public static final int ADD_ADDRESS_REQUEST_CODE = 6;
public static final int ADDRESS_BOOK_CONTACT_REQUEST_CODE = 7;
public static final int UPDATE_ADDRESS_REQUEST_CODE = 8;

public static final String ETHEREUM_NETWORK_NAME = "Ethereum";
public static final String CLASSIC_NETWORK_NAME = "Ethereum Classic";
Expand Down Expand Up @@ -138,6 +141,8 @@ public abstract class C {
public static final String DAPP_URL_LOAD = "DAPP_URL";
public static final String EXTRA_LOCAL_NETWORK_SELECT_FLAG = "EXTRA_LOCAL_NETWORK_SELECT";
public static final String EXTRA_PRICE_ALERT = "EXTRA_PRICE_ALERT";
public static final String EXTRA_CONTACT_WALLET_ADDRESS = "WALLET_ADDRESS";
public static final String EXTRA_CONTACT = "CONTACT";

public static final String PRUNE_ACTIVITY =
"com.stormbird.wallet.PRUNE_ACTIVITY";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.content.Context;

import com.alphawallet.app.repository.ContactRepository;
import com.alphawallet.app.repository.ContactRepositoryType;
import com.alphawallet.app.repository.EthereumNetworkRepository;
import com.alphawallet.app.repository.EthereumNetworkRepositoryType;
import com.alphawallet.app.repository.OnRampRepository;
Expand Down Expand Up @@ -219,4 +221,10 @@ KeyService provideKeyService(@ApplicationContext Context ctx, AnalyticsServiceTy
AnalyticsServiceType provideAnalyticsService(@ApplicationContext Context ctx) {
return new AnalyticsService(ctx);
}

@Singleton
@Provides
ContactRepositoryType provideContactRepository(TokensService tokensService, RealmManager realmManager) {
return new ContactRepository(tokensService, realmManager);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.alphawallet.app.di;

import com.alphawallet.app.interact.AddressBookInteract;
import com.alphawallet.app.interact.ChangeTokenEnableInteract;
import com.alphawallet.app.interact.CreateTransactionInteract;
import com.alphawallet.app.interact.DeleteWalletInteract;
Expand All @@ -13,6 +14,7 @@
import com.alphawallet.app.interact.MemPoolInteract;
import com.alphawallet.app.interact.SetDefaultWalletInteract;
import com.alphawallet.app.interact.SignatureGenerateInteract;
import com.alphawallet.app.repository.ContactRepositoryType;
import com.alphawallet.app.repository.CurrencyRepository;
import com.alphawallet.app.repository.CurrencyRepositoryType;
import com.alphawallet.app.repository.EthereumNetworkRepositoryType;
Expand Down Expand Up @@ -174,4 +176,9 @@ ImportTokenRouter provideImportTokenRouter() {
RedeemSignatureDisplayRouter provideRedeemSignatureDisplayRouter() {
return new RedeemSignatureDisplayRouter();
}

@Provides
AddressBookInteract provideAddressBookInteract(ContactRepositoryType contactRepository) {
return new AddressBookInteract(contactRepository);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package com.alphawallet.app.entity;

import android.os.Parcel;
import android.os.Parcelable;

import io.realm.annotations.PrimaryKey;

public class AddressBookContact implements Parcelable
{
/**
* This is contact wallet address
*/
@PrimaryKey
private String walletAddress;

/**
* This is contact name
*/
private String name;

/**
* This is associated ETH name of #walletAddress
*/
private String ethName;

public String getWalletAddress() {
return walletAddress;
}

public AddressBookContact(String walletAddress, String name, String ethName)
{
this.walletAddress = walletAddress;
this.name = name;
this.ethName = ethName;
}

private AddressBookContact(Parcel in) {
walletAddress = in.readString();
name = in.readString();
ethName = in.readString();
}

public void setWalletAddress(String walletAddress) {
this.walletAddress = walletAddress;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getEthName() {
return ethName;
}

public void setEthName(String ethName) {
this.ethName = ethName;
}

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(walletAddress);
dest.writeString(name);
dest.writeString(ethName);
}

public static final Creator<AddressBookContact> CREATOR = new Creator<AddressBookContact>() {
@Override
public AddressBookContact createFromParcel(Parcel source) {
return new AddressBookContact(source);
}

@Override
public AddressBookContact[] newArray(int size) {
return new AddressBookContact[size];
}
};

@Override
public String toString() {
return "UserInfo{" +
"walletAddress='" + walletAddress + '\'' +
", name='" + name + '\'' +
", ethName='" + ethName + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.alphawallet.app.interact;

import com.alphawallet.app.entity.AddressBookContact;
import com.alphawallet.app.repository.ContactRepositoryType;
import com.alphawallet.app.util.ItemCallback;

import java.util.List;

import io.reactivex.Completable;
import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class AddressBookInteract {

private ContactRepositoryType contactRepository;

public AddressBookInteract(ContactRepositoryType contactRepository) {
this.contactRepository = contactRepository;
}

public Single<List<AddressBookContact>> getAllContacts() {
return contactRepository.getContacts();
}

public Completable addContact(AddressBookContact addressBookContact) {
return contactRepository.addContact(addressBookContact);
}

public Completable updateContact(AddressBookContact oldContact, AddressBookContact newContact) {
return contactRepository.updateContact(oldContact, newContact);
}

public Completable removeContact(AddressBookContact addressBookContact) {
return contactRepository.removeContact(addressBookContact);
}

public Single<AddressBookContact> searchContact(String walletAddress) {
return contactRepository.searchContact(walletAddress);
}

/** Search a contact and invoke the callback*/
public void searchContactAsync(String walletAddress, ItemCallback<AddressBookContact> callback) {
contactRepository.searchContact(walletAddress)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe( (callback::call), (throwable -> callback.call(null)) )
.isDisposed();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,18 @@ else if (oldVersion == 8)

oldVersion = 43;
}

if (oldVersion == 43)
{
RealmObjectSchema userData = schema.get("RealmContact");
if (userData == null)
schema.create("RealmContact")
.addField("walletAddress", String.class, FieldAttribute.PRIMARY_KEY)
.addField("name", String.class)
.addField("ethName", String.class);

oldVersion++;
}
}

@Override
Expand Down
Loading