update app demo
This commit is contained in:
parent
27eb364aa7
commit
48a6c430aa
|
@ -18,15 +18,18 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import monnethic.mobile.history.HistoryActivity;
|
import monnethic.mobile.history.HistoryActivity;
|
||||||
|
import monnethic.mobile.restApi.Config;
|
||||||
import monnethic.mobile.restApi.ConfigApiHandler;
|
import monnethic.mobile.restApi.ConfigApiHandler;
|
||||||
|
|
||||||
public class DemoConfig extends AppCompatActivity {
|
public class DemoConfig extends AppCompatActivity {
|
||||||
private Spinner cSpinner;
|
private Spinner cSpinner;
|
||||||
private Switch cSwitch;
|
private Switch cSwitch;
|
||||||
|
private Switch apiSwitch;
|
||||||
private Button btnValidateConf;
|
private Button btnValidateConf;
|
||||||
private Button btnCloseConf;
|
private Button btnCloseConf;
|
||||||
private Button btnCheckConf;
|
private Button btnCheckConf;
|
||||||
private String ENV;
|
private String ENV;
|
||||||
|
private String API;
|
||||||
private String CHAINCODE;
|
private String CHAINCODE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,11 +42,12 @@ public class DemoConfig extends AppCompatActivity {
|
||||||
|
|
||||||
private void initView(){
|
private void initView(){
|
||||||
buttonInit();
|
buttonInit();
|
||||||
switchInit();
|
switchEnvInit();
|
||||||
|
switchApiInit();
|
||||||
spinnerInit();
|
spinnerInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void switchInit(){
|
public void switchEnvInit(){
|
||||||
cSwitch = findViewById(R.id.switchEnv);
|
cSwitch = findViewById(R.id.switchEnv);
|
||||||
cSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
cSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,6 +61,20 @@ public class DemoConfig extends AppCompatActivity {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void switchApiInit(){
|
||||||
|
apiSwitch = findViewById(R.id.switchApi);
|
||||||
|
apiSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||||
|
if(apiSwitch.isChecked()){
|
||||||
|
API = "1";
|
||||||
|
}else{
|
||||||
|
API = "0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void spinnerInit(){
|
public void spinnerInit(){
|
||||||
cSpinner = findViewById(R.id.spinnerConfig);
|
cSpinner = findViewById(R.id.spinnerConfig);
|
||||||
List<String> listOptions = new ArrayList<>();
|
List<String> listOptions = new ArrayList<>();
|
||||||
|
@ -126,6 +144,7 @@ public class DemoConfig extends AppCompatActivity {
|
||||||
ConfigApiHandler configApiHandler = new ConfigApiHandler();
|
ConfigApiHandler configApiHandler = new ConfigApiHandler();
|
||||||
configApiHandler.updateEnvironment(e);
|
configApiHandler.updateEnvironment(e);
|
||||||
configApiHandler.updateChaincode(c);
|
configApiHandler.updateChaincode(c);
|
||||||
|
Config.setAPI(API);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -165,7 +184,7 @@ public class DemoConfig extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(String result) {
|
protected void onPostExecute(String result) {
|
||||||
progDailog.dismiss();
|
progDailog.dismiss();
|
||||||
Toast.makeText(DemoConfig.this, result,Toast.LENGTH_SHORT).show();
|
Toast.makeText(DemoConfig.this, result+" - "+Config.getAPI(),Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
walletHomeIntent.putExtra("USER_HASH", jsonObject.getString("user_hash"));
|
walletHomeIntent.putExtra("USER_HASH", jsonObject.getString("user_hash"));
|
||||||
walletHomeIntent.putExtra("USER_PWD",password.getText().toString());
|
walletHomeIntent.putExtra("USER_PWD",password.getText().toString());
|
||||||
walletHomeIntent.putExtra("SESSION_ID",jsonObject.getString("session_id"));
|
walletHomeIntent.putExtra("SESSION_ID",jsonObject.getString("session_id"));
|
||||||
|
walletHomeIntent.putExtra("email",email.getText().toString());
|
||||||
LoginActivity.this.startActivity(walletHomeIntent);
|
LoginActivity.this.startActivity(walletHomeIntent);
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,49 +1,91 @@
|
||||||
package monnethic.mobile.restApi;
|
package monnethic.mobile.restApi;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
//BASE
|
static private int API = 0;
|
||||||
static private String BASE_URL = "http://37.187.101.44:10053/";
|
|
||||||
//static private String BASE_URL = "http://10.0.2.2:10053/";
|
/*
|
||||||
//static private String BASE_URL = "http://localhost:10053/";
|
static private String getBaseURl(){
|
||||||
static private String BASE_URL_USER = BASE_URL+"api/rest/user/";
|
if(API==0){
|
||||||
static private String BASE_URL_TRANSACTION = BASE_URL+"api/rest/transaction/";
|
return "http://5.39.76.139:10053/";
|
||||||
static private String BASE_URL_WALLET = BASE_URL+"api/rest/wallet/";
|
} else {
|
||||||
static private String BASE_URL_SESSION = BASE_URL+"api/rest/session/";
|
return "http://37.187.101.44:10053/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
static private String getBaseUrlUser(){
|
||||||
|
if(API==0){
|
||||||
|
return "http://5.39.76.139:10053/api/rest/user/";
|
||||||
|
} else {
|
||||||
|
return "http://37.187.101.44:10053/api/rest/user/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static private String getBaseUrlTransaction(){
|
||||||
|
if(API==0){
|
||||||
|
return "http://5.39.76.139:10053/api/rest/transaction/";
|
||||||
|
} else {
|
||||||
|
return "http://37.187.101.44:10053/api/rest/transaction/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static private String getBaseUrlWallet(){
|
||||||
|
if(API==0){
|
||||||
|
return "http://5.39.76.139:10053/api/rest/wallet/";
|
||||||
|
} else {
|
||||||
|
return "http://37.187.101.44:10053/api/rest/wallet/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static private String getBaseUrlSession(){
|
||||||
|
if(API==0){
|
||||||
|
return "http://5.39.76.139:10053/api/rest/session/";
|
||||||
|
} else {
|
||||||
|
return "http://37.187.101.44:10053/api/rest/session/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static private String getConfigBaseUrl(){
|
||||||
|
if(API==0){
|
||||||
|
return "http://5.39.76.139:10053/api/rest/demo/conf";
|
||||||
|
} else {
|
||||||
|
return "http://37.187.101.44:10053/api/rest/demo/conf";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//USER
|
//USER
|
||||||
static public String USER_LOGIN = BASE_URL_USER+"login";
|
static public String USER_LOGIN = getBaseUrlUser()+"login";
|
||||||
static public String USER_REGISTER = BASE_URL_USER+"register";
|
static public String USER_REGISTER = getBaseUrlUser()+"register";
|
||||||
static public String USER_GET = BASE_URL_USER+"get";
|
static public String USER_GET = getBaseUrlUser()+"get";
|
||||||
static public String USER_APPROVAL = BASE_URL_USER+"getApproval";
|
static public String USER_APPROVAL = getBaseUrlUser()+"getApproval";
|
||||||
static public String USER_APPROVE = BASE_URL_USER+"approve";
|
static public String USER_APPROVE = getBaseUrlUser()+"approve";
|
||||||
//Search
|
//Search
|
||||||
static public String FIND_BY_EMAIL= BASE_URL_USER+"findByEmail";
|
static public String FIND_BY_EMAIL= getBaseUrlUser()+"findByEmail";
|
||||||
static public String FIND_BY_PHONE = BASE_URL_USER+"findByPhone";
|
static public String FIND_BY_PHONE = getBaseUrlUser()+"findByPhone";
|
||||||
static public String FIND_BY_EMAIL_AND_PHONE = BASE_URL_USER+"findByEmailAndPhone";
|
static public String FIND_BY_EMAIL_AND_PHONE = getBaseUrlUser()+"findByEmailAndPhone";
|
||||||
//Session
|
//Session
|
||||||
static public String START_SESSION = BASE_URL_SESSION+"start";
|
static public String START_SESSION = getBaseUrlSession()+"start";
|
||||||
static public String END_SESSION = BASE_URL_SESSION+"end";
|
static public String END_SESSION = getBaseUrlSession()+"end";
|
||||||
|
|
||||||
//Config
|
//Config
|
||||||
static private String CONFIG_BASE_URL = BASE_URL+"/api/rest/demo/conf";
|
|
||||||
static public String CONFIG_ENVIRONMENT = CONFIG_BASE_URL+"/env";
|
static public String CONFIG_ENVIRONMENT = getConfigBaseUrl()+"/env";
|
||||||
static public String CONFIG_CHAINCODE = CONFIG_BASE_URL+"/chaincode";
|
static public String CONFIG_CHAINCODE = getConfigBaseUrl()+"/chaincode";
|
||||||
static public String CONFIG_DB = CONFIG_BASE_URL+"/db";
|
static public String CONFIG_DB = getConfigBaseUrl()+"/db";
|
||||||
|
|
||||||
|
|
||||||
//TRANSACTION
|
//TRANSACTION
|
||||||
static public String TRANSACTION_SEND = BASE_URL_TRANSACTION+"send";
|
static public String TRANSACTION_SEND = getBaseUrlTransaction()+"send";
|
||||||
static public String TRANSACTION_GET = BASE_URL_TRANSACTION+"get";
|
static public String TRANSACTION_GET = getBaseUrlTransaction()+"get";
|
||||||
static public String TRANSACTION_LATEST = BASE_URL_TRANSACTION+"get/latest";
|
static public String TRANSACTION_LATEST = getBaseUrlTransaction()+"get/latest";
|
||||||
static public String TRANSACTION_ALL = BASE_URL_TRANSACTION+"getTransactions";
|
static public String TRANSACTION_ALL = getBaseUrlTransaction()+"getTransactions";
|
||||||
static public String TRANSACTION_SENT = BASE_URL_TRANSACTION+"get/sent";
|
static public String TRANSACTION_SENT = getBaseUrlTransaction()+"get/sent";
|
||||||
static public String TRANSACTION_RECEIVED = BASE_URL_TRANSACTION+"get/received";
|
static public String TRANSACTION_RECEIVED = getBaseUrlTransaction()+"get/received";
|
||||||
|
|
||||||
//WALLET
|
//WALLET
|
||||||
static public String WALLET_CREATE = BASE_URL_WALLET+"create";
|
static public String WALLET_CREATE = getBaseUrlWallet()+"create";
|
||||||
static public String WALLET_GET_WALLET = BASE_URL_WALLET+"getWallet";
|
static public String WALLET_GET_WALLET = getBaseUrlWallet()+"getWallet";
|
||||||
static public String WALLET_GET_USER_WALLETS = BASE_URL_WALLET+"getUserWallets";
|
static public String WALLET_GET_USER_WALLETS = getBaseUrlWallet()+"getUserWallets";
|
||||||
static public String WALLET_DELETE = BASE_URL_WALLET+"delete";
|
static public String WALLET_DELETE = getBaseUrlWallet()+"delete";
|
||||||
static public String WALLET_TRANSFER = BASE_URL_WALLET+"transfer";
|
static public String WALLET_TRANSFER = getBaseUrlWallet()+"transfer";
|
||||||
|
|
||||||
|
static public void setAPI(String newApi){ API = Integer.parseInt(newApi); }
|
||||||
|
static public String getAPI(){ return String.valueOf(API); }
|
||||||
}
|
}
|
|
@ -20,6 +20,7 @@
|
||||||
android:id="@+id/prodEnv"
|
android:id="@+id/prodEnv"
|
||||||
android:layout_width="130dp"
|
android:layout_width="130dp"
|
||||||
android:layout_height="35dp"
|
android:layout_height="35dp"
|
||||||
|
android:gravity="center"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_marginStart="25dp"
|
android:layout_marginStart="25dp"
|
||||||
android:layout_marginTop="0dp"
|
android:layout_marginTop="0dp"
|
||||||
|
@ -43,6 +44,7 @@
|
||||||
android:id="@+id/bckpEnv"
|
android:id="@+id/bckpEnv"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="35dp"
|
android:layout_height="35dp"
|
||||||
|
android:gravity="center"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_marginTop="0dp"
|
android:layout_marginTop="0dp"
|
||||||
|
@ -57,6 +59,57 @@
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="35dp"
|
||||||
|
android:layout_marginLeft="3dp"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
|
android:layout_marginRight="3dp">
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/apiProd"
|
||||||
|
android:layout_width="130dp"
|
||||||
|
android:layout_height="35dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_marginStart="25dp"
|
||||||
|
android:layout_marginTop="0dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:editable="false"
|
||||||
|
android:ems="10"
|
||||||
|
android:hint="From"
|
||||||
|
android:inputType="none"
|
||||||
|
android:text="PROD API"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/switchApi"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_toEndOf="@+id/apiProd" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/bckpApi"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="35dp"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_marginTop="0dp"
|
||||||
|
android:layout_marginEnd="25dp"
|
||||||
|
android:layout_toEndOf="@+id/switchApi"
|
||||||
|
android:clickable="true"
|
||||||
|
android:editable="false"
|
||||||
|
android:ems="10"
|
||||||
|
android:hint="To"
|
||||||
|
android:inputType="none"
|
||||||
|
android:text="BACKPUP API"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
|
|
Loading…
Reference in a new issue