Skip to content

Commit

Permalink
- change api path from "get_transactions" to "get_actions". ( issue #13)
Browse files Browse the repository at this point in the history
  • Loading branch information
swapnibble committed Jul 20, 2018
1 parent 40c86d3 commit c44d200
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 54 deletions.
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
</p>

EOS commander is an Android client for EOSIO DApp developer.
It includes functions of wallet. Developers can test wallet, account, transaction, contract, etc. on the Android device. PLACTAL team hopes this makes more EOS mobile DApps activated.
It includes functions of wallet. Developers can test wallet, account, transaction, contract, etc. on the Android device.

EOS Commander is designed with MVP pattern.
You can use "io.plactal.eoscommander.data" and "io.plactal.eoscommander.crypto" package to any JAVA projects.


# Table of contents
Expand All @@ -17,6 +20,7 @@ It includes functions of wallet. Developers can test wallet, account, transactio
- [Currency](#currency)
- [Push](#push)
- [Get table](#get_tabel)
- [Apps using EOS Commander code](#using_code)
- [About PLACTAL](#about_plactal)
- [Contact](#contact)
- [License](#license)
Expand All @@ -31,7 +35,7 @@ You should have running nodeos node.
Set "http-server-address" other than "127.0.0.1" .
EOS commander includes wallet function, you don't need to specify "wallet_api_plugin" in config.ini.

EOS Commander has been tested with EOSIO version [1.0.6](https://github.com/EOSIO/eos/tree/v1.0.6).
EOS Commander has been tested with EOSIO version [1.1.0](https://github.com/EOSIO/eos/tree/v1.1.0).

See [EOSIO github](https://github.com/EOSIO/eos).

Expand All @@ -46,9 +50,9 @@ Open in Android studio 3.0 or later.

You can install the latest version from the Play store at: [link](https://play.google.com/store/apps/details?id=io.plactal.eoscommander)

Or download apk : [link](https://github.com/plactal/files/blob/master/eos_commander/EosCommander-v2.3.1-release.apk?raw=true)
SHA1 : 9e6c1a7f8f85975334dc13e9e40939bed510a336
SHA256: f3c3ac04dc29a2d7f23599d276835df422be4f34973c0e16fa71dce1b412bce0
Or download apk : [link](https://github.com/plactal/files/blob/master/eos_commander/EosCommander-v2.4.0-release.apk?raw=true)
SHA1 : 07102dcf7677a4fec36dc068f8beb8a5bcea8933
SHA256: fca9e5611ea6537565d54c0df21b27d592388413da5c5a03b48d08863598fc34



Expand All @@ -67,7 +71,7 @@ On connected state, you can use the command function.
## Wallet
### create default wallet and import key of eosio.
This creates a wallet named 'default' and import the private key of `eosio` account.
[See EOSIO wiki](https://github.com/EOSIO/eos/wiki/CLI%20Wallet)

### create wallet
You can also create wallets other than "default".
Also provides option for saving password for easy testing.
Expand Down Expand Up @@ -101,13 +105,20 @@ Run "get balance" or "get stats" commands for currency contract.
<a name="push"></a>
## Push
Push the contract message.
[See EOSIO wiki](https://github.com/EOSIO/eos/wiki/Command%20Reference#push-message-to-contract)
[See EOSIO Developer Portal](https://developers.eos.io/eosio-cleos/reference#cleos-push-action)
You can type json manually, or edit via form input UI( after reading ABI from EOS network), or importing JSON file.

<a name="get_table"></a>
## Get table
Lists the contract table.
[See EOSIO wiki](https://github.com/EOSIO/eos/wiki/Command%20Reference#querying-contract)
[See EOSIO Developer Portal](https://developers.eos.io/eosio-cleos/reference#cleos-get-table)

<a name="using_code"></a>
## Apps using EOS Commander source
Please [ping](mailto:eric.song@plactal.io) me or send a pull request if you would like to be added here.

[PocketEOS-Android]( https://github.com/OracleChain/PocketEOS-Android ) by orcalechain.io


<a name="about_plactal"></a>
## About plactal.io
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "io.plactal.eoscommander"
minSdkVersion 18
targetSdkVersion 27
versionCode 14
versionName "2.3.1"
versionCode 15
versionName "2.4.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

// 벡터 이미지
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,14 @@ public Observable<JsonObject> readAccountInfo(String accountName ) {



public Observable<JsonObject> getTransactions(String accountName ) {
public Observable<JsonObject> getActions(String accountName, int pos, int offset ) {

JsonObject gsonObject = new JsonObject();
gsonObject.addProperty( NodeosApi.GET_TRANSACTIONS_KEY, accountName);
gsonObject.addProperty( "account_name", accountName);
gsonObject.addProperty( "pos", pos);
gsonObject.addProperty( "offset", offset);

return mNodeosApi.getTransactions( gsonObject);
return mNodeosApi.getActions( gsonObject);
}

public Observable<JsonObject> getServants( String accountName ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,8 @@ public interface NodeosApi {
@POST("/v1/history/get_controlled_accounts")
Observable<JsonObject> getServants(@Body JsonObject body);

@POST("/v1/history/get_transactions")
Observable<JsonObject> getTransactions( @Body JsonObject body);
@POST("/v1/history/get_actions")
Observable<JsonObject> getActions(@Body JsonObject body);



// String ACCOUNT_HISTORY_GET_TRANSACTIONS = "get_transactions" ;
String GET_TRANSACTIONS_KEY = "account_name";
//
// String ACCOUNT_HISTORY_GET_SERVANTS = "get_controlled_accounts" ;
String GET_SERVANTS_KEY = "controlling_account";
//
// String ACCOUNT_HISTORY_GET_KEY_ACCOUNTS = "get_key_accounts";
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected void setUpView(View view) {
view.findViewById(R.id.btn_get_account).setOnClickListener(v -> openInputAccountDialog( AccountInfoType.REGISTRATION));

// eosc get transaction <account>
view.findViewById(R.id.btn_get_transaction).setOnClickListener(v -> openInputAccountDialog( AccountInfoType.TRANSACTIONS));
view.findViewById(R.id.btn_get_actions).setOnClickListener(v -> openInputAccountDialog( AccountInfoType.ACTIONS));

// eosc get servants <account>
view.findViewById(R.id.btn_get_servants).setOnClickListener(v -> openInputAccountDialog( AccountInfoType.SERVANTS));
Expand All @@ -102,7 +102,7 @@ public void openCreateAccountDialog() {

private void openInputAccountDialog( AccountInfoType infoType ) {
InputAccountDialog.newInstance( infoType)
.setCallback( (account, retInfoType) -> mPresenter.loadAccountInfo( account, retInfoType ) )
.setCallback( mPresenter::loadAccountInfo)
.show(getChildFragmentManager()) ;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void onClickCreateAccount(){
getMvpView().openCreateAccountDialog();
}

public void loadAccountInfo(String account, AccountInfoType infoType ){
public void loadAccountInfo(String account, int position, int offset, AccountInfoType infoType ){
if (StringUtils.isEmpty(account)) {
return;
}
Expand All @@ -71,12 +71,16 @@ public void loadAccountInfo(String account, AccountInfoType infoType ){
break;

case TRANSACTIONS:
getTransactions( account );
getMvpView().showToast("Not implemented, coming soon.");
break;

case SERVANTS:
getServents( account );
break;

case ACTIONS:
getActions( account, position, offset );
break;
}
}

Expand Down Expand Up @@ -112,11 +116,11 @@ public void onNext(JsonObject result) {
);
}

private void getTransactions( String account ) {
private void getActions(String account, int pos, int offset ) {
getMvpView().showLoading( true );

addDisposable( mDataManager
.getTransactions( account )
.getActions( account, pos, offset )
.subscribeOn(getSchedulerProvider().io())
.observeOn( getSchedulerProvider().ui())
.subscribeWith( new RxCallbackWrapper<JsonObject>( this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
*/

public enum AccountInfoType {
REGISTRATION( R.string.get_account), // eosc get account <account>
TRANSACTIONS(R.string.get_transactions), // eosc get transaction <account>
SERVANTS(R.string.get_servants) ; // eosc get servants <account>
REGISTRATION( R.string.get_account), // cleos get account <account>
TRANSACTIONS(R.string.get_transactions), // cleos get transaction <account>
SERVANTS(R.string.get_servants), // cleos get servants <account>
ACTIONS(R.string.get_actions);

private final int mTitleRscId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import io.plactal.eoscommander.ui.base.BaseDialog;
import io.plactal.eoscommander.util.RefValue;
import io.plactal.eoscommander.util.UiUtils;
import io.plactal.eoscommander.util.Utils;
import io.reactivex.disposables.CompositeDisposable;

/**
Expand All @@ -50,15 +51,9 @@ public class InputAccountDialog extends BaseDialog {
private static final String TAG = InputAccountDialog.class.getSimpleName();
private static final String ARG_INFO_TYPE = "type.for";

@Inject
EoscDataManager mDataManager;

private AccountInfoType mAccountInfoType = AccountInfoType.REGISTRATION;
private Callback mCallback;
private AutoCompleteTextView mEtAccount;
private CompositeDisposable mCompositeDisposable;

protected RefValue<Long> mAccountHistoryVersion = new RefValue<>(0L);

public static InputAccountDialog newInstance(AccountInfoType infoType ) {
InputAccountDialog fragment = new InputAccountDialog();
Expand All @@ -80,8 +75,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
Bundle args = getArguments();
mAccountInfoType = AccountInfoType.safeValueOf( args.getString( ARG_INFO_TYPE));

mCompositeDisposable = new CompositeDisposable();

View view = inflater.inflate(R.layout.dialog_input_account, container, false);

ActivityComponent component = getActivityComponent();
Expand All @@ -94,6 +87,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

@Override
protected void setUpView(View view) {
if ( AccountInfoType.ACTIONS.equals( mAccountInfoType ) ) {
((AutoCompleteTextView)view.findViewById(R.id.et_pos)).setText("-1");
((AutoCompleteTextView)view.findViewById(R.id.et_offset)).setText("-20");
}
else {
view.findViewById(R.id.et_pos).setVisibility( View.GONE );
view.findViewById(R.id.et_offset).setVisibility( View.GONE );
}

// title
((TextView)view.findViewById( R.id.tv_title)).setText( mAccountInfoType.getTitleId());

Expand All @@ -104,7 +106,18 @@ protected void setUpView(View view) {

// ok
view.findViewById( R.id.btn_ok ).setOnClickListener( v -> {
if ( null != mCallback) mCallback.onAccountEntered( mEtAccount.getText().toString(), mAccountInfoType);

if ( null != mCallback) {
if ( AccountInfoType.ACTIONS.equals( mAccountInfoType ) ) {
mCallback.onAccountEntered(mEtAccount.getText().toString()
, Utils.parseIntSafely( ((AutoCompleteTextView)view.findViewById(R.id.et_pos)).getText().toString(), -1 )
, Utils.parseIntSafely( ((AutoCompleteTextView)view.findViewById(R.id.et_offset)).getText().toString(), -20 )
, mAccountInfoType);
}
else {
mCallback.onAccountEntered(mEtAccount.getText().toString(), -1, -1, mAccountInfoType);
}
}

dismiss();
});
Expand All @@ -113,17 +126,18 @@ protected void setUpView(View view) {
view.findViewById( R.id.btn_cancel ).setOnClickListener( v -> dismiss());
}



public void show(FragmentManager fragmentManager) {
super.show(fragmentManager, TAG );
}

@Override
public void onDestroyView() {
mCompositeDisposable.clear();
super.onDestroyView();
}

public interface Callback {
void onAccountEntered( String account, AccountInfoType infoType );
void onAccountEntered( String account, int position, int offset, AccountInfoType infoType );
}
}
63 changes: 54 additions & 9 deletions app/src/main/res/layout/dialog_input_account.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,62 @@
android:textColor="@color/colorPrimary"
android:text="@string/get_account"/>

<AutoCompleteTextView
style="@style/EosNameTextWithDone"
android:id="@+id/et_account"
<android.support.design.widget.TextInputLayout
android:id="@+id/til_account"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:textColorHint="@color/colorLightGray"
android:background="@drawable/round_box_input"
android:padding="16dp"
android:hint="@string/input_account"/> <!-- EditText 2017.12.12. -->
android:layout_marginBottom="16dp">

<io.plactal.eoscommander.ui.widget.TextInputAutoCompleteTextView
android:id="@+id/et_account"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:inputType="textVisiblePassword"
android:digits=".12345abcdefghijklmnopqrstuvwxyz"
android:padding="16dp"
android:singleLine="true"
android:hint="@string/input_account"/>
</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout
android:id="@+id/til_pos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp">

<io.plactal.eoscommander.ui.widget.TextInputAutoCompleteTextView
android:id="@+id/et_pos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:inputType="numberSigned"
android:padding="16dp"
android:nextFocusDown="@+id/et_offset"
android:singleLine="true"
android:imeOptions="actionNext"
android:hint="@string/position"/>
</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout
android:id="@+id/til_offset"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp">

<io.plactal.eoscommander.ui.widget.TextInputAutoCompleteTextView
android:id="@+id/et_offset"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:inputType="numberSigned"
android:padding="16dp"
android:singleLine="true"
android:hint="@string/offset"/>
</android.support.design.widget.TextInputLayout>

<RelativeLayout
android:layout_width="match_parent"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_account.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
android:text="@string/get_account"/>

<io.plactal.eoscommander.ui.widget.TintVtDrTextView
android:id="@+id/btn_get_transaction"
android:id="@+id/btn_get_actions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
Expand All @@ -60,7 +60,7 @@
android:background="@drawable/round_box_btn"
android:textColor="@color/colorPrimary"
android:textSize="16sp"
android:text="@string/get_transactions"/>
android:text="@string/get_actions"/>

<io.plactal.eoscommander.ui.widget.TintVtDrTextView
android:id="@+id/btn_get_servants"
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,7 @@
<string name="buy_ram_eos">amount of EOS to buy ram for new account</string>

<string name="core_symbol">Core asset symbol</string>
<string name="get_actions">Get actions</string>
<string name="position">Position</string>
<string name="offset">Offset</string>
</resources>

0 comments on commit c44d200

Please sign in to comment.