setup async for user balance
This commit is contained in:
parent
e806c990ff
commit
e547852d79
Binary file not shown.
|
@ -5,27 +5,33 @@
|
|||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||
<option name="myNullables">
|
||||
<value>
|
||||
<list size="5">
|
||||
<list size="7">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
|
||||
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myNotNulls">
|
||||
<value>
|
||||
<list size="4">
|
||||
<list size="6">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
|
||||
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -1,12 +1,12 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 26
|
||||
compileSdkVersion 27
|
||||
defaultConfig {
|
||||
applicationId 'com.monnethic.appmobile'
|
||||
multiDexEnabled true
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 26
|
||||
targetSdkVersion 27
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
@ -28,7 +28,7 @@ android {
|
|||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'com.android.support:appcompat-v7:26.1.0'
|
||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
<!-- To auto-complete the email text field in the login form with Useruser's emails -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.READ_PROFILE" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package monnethic.mobile.blockchainApi;
|
||||
|
||||
public class UrlApi {
|
||||
static public String URL_BALANCE = "http://10.0.2.2:8083/balance?name=";
|
||||
}
|
|
@ -22,7 +22,7 @@ public class HomepageActivity extends AppCompatActivity {
|
|||
setContentView(R.layout.activity_homepage);
|
||||
Button bRegister = findViewById(R.id.register);
|
||||
Button bLogin = findViewById(R.id.login);
|
||||
Button bDemo = findViewById(R.id.demo);
|
||||
//Button bDemo = findViewById(R.id.demo);
|
||||
|
||||
bRegister.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -36,11 +36,13 @@ public class HomepageActivity extends AppCompatActivity {
|
|||
launchLoginActivity();
|
||||
}
|
||||
});
|
||||
/*
|
||||
bDemo.setOnClickListener(new View.OnClickListener(){
|
||||
public void onClick(View view){
|
||||
launchDemoActivity();
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
public void launchRegisterActivity(){
|
||||
|
@ -51,8 +53,10 @@ public class HomepageActivity extends AppCompatActivity {
|
|||
Intent loginIntent = new Intent(HomepageActivity.this, LoginActivity.class);
|
||||
HomepageActivity.this.startActivity(loginIntent);
|
||||
}
|
||||
/*
|
||||
public void launchDemoActivity(){
|
||||
Intent demoIntent = new Intent(HomepageActivity.this, DemoActivity.class);
|
||||
HomepageActivity.this.startActivity(demoIntent);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.widget.Toast;
|
|||
|
||||
import com.example.monnthic.monnethicmobile.R;
|
||||
|
||||
import monnethic.mobile.user.UserAccountActivity;
|
||||
import monnethic.mobile.wallet.WalletActivity;
|
||||
|
||||
public class LoginActivity extends AppCompatActivity {
|
||||
|
@ -64,9 +65,9 @@ public class LoginActivity extends AppCompatActivity {
|
|||
}
|
||||
public void launchWalletActivity(int ldapId){
|
||||
//LAUNCH APP WALLET WITH ID USER
|
||||
Intent walletIntent = new Intent(LoginActivity.this, WalletActivity.class);
|
||||
walletIntent.putExtra("idUser", ldapId);
|
||||
LoginActivity.this.startActivity(walletIntent);
|
||||
Intent accountIntent = new Intent(LoginActivity.this, UserAccountActivity.class);
|
||||
accountIntent.putExtra("idUser", ldapId);
|
||||
LoginActivity.this.startActivity(accountIntent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package monnethic.mobile.user;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
@ -10,23 +11,34 @@ import android.widget.Toast;
|
|||
|
||||
import com.example.monnthic.monnethicmobile.R;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import monnethic.mobile.blockchainApi.UrlApi;
|
||||
import monnethic.mobile.transaction.MakePayementActivity;
|
||||
import monnethic.mobile.transaction.ReceivePayementActivity;
|
||||
|
||||
public class UserAccountActivity extends AppCompatActivity {
|
||||
private TextView solde;
|
||||
|
||||
private TextView balance;
|
||||
private String strUrl = UrlApi.URL_BALANCE+"b";
|
||||
private String result;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_user_account);
|
||||
|
||||
solde = findViewById(R.id.viewSolde);
|
||||
balance = findViewById(R.id.balanceView);
|
||||
Button buttonPayement = findViewById(R.id.buttonPayement);
|
||||
Button buttonReceive = findViewById(R.id.buttonReceive);
|
||||
Button buttonSettings = findViewById(R.id.buttonSettings);
|
||||
Button buttonRefresh = findViewById(R.id.buttonRefreshBalance);
|
||||
|
||||
|
||||
//refreshSolde();
|
||||
buttonPayement.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -45,13 +57,21 @@ public class UserAccountActivity extends AppCompatActivity {
|
|||
settings();
|
||||
}
|
||||
});
|
||||
buttonRefresh.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
refreshBalance("b");
|
||||
}
|
||||
});
|
||||
|
||||
new GetUserBalanceTask().execute(strUrl);
|
||||
}
|
||||
|
||||
public void sendPayement(){
|
||||
Intent payementIntent = new Intent(UserAccountActivity.this, MakePayementActivity.class);
|
||||
UserAccountActivity.this.startActivity(payementIntent);
|
||||
}
|
||||
public void receivePayement(){
|
||||
|
||||
Intent receivePayementIntent = new Intent(UserAccountActivity.this, ReceivePayementActivity.class);
|
||||
UserAccountActivity.this.startActivity(receivePayementIntent);
|
||||
}
|
||||
|
@ -59,7 +79,66 @@ public class UserAccountActivity extends AppCompatActivity {
|
|||
Toast.makeText(this, "Coming soon", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public void refreshSolde(){
|
||||
solde.setText("0.00");
|
||||
public void refreshBalance(String userHash){
|
||||
String url = UrlApi.URL_BALANCE+userHash;
|
||||
new GetUserBalanceTask().execute(url);
|
||||
}
|
||||
|
||||
public void setBalance(String value){
|
||||
balance.setText(value);
|
||||
}
|
||||
|
||||
|
||||
public class GetUserBalanceTask extends AsyncTask<String,String,String>
|
||||
{
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String s) {
|
||||
balance.setText(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(String... params) {
|
||||
System.out.println(params[0]);
|
||||
InputStream inputStream = null;
|
||||
HttpURLConnection conn = null;
|
||||
try{
|
||||
URL url = new URL(params[0]);
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
conn.connect();
|
||||
|
||||
int response = conn.getResponseCode();
|
||||
if(response != 200){
|
||||
return "Error response";
|
||||
}
|
||||
|
||||
inputStream = conn.getInputStream();
|
||||
if(inputStream == null){
|
||||
return "Error inputStream";
|
||||
}
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
String line;
|
||||
|
||||
while ((line = reader.readLine())!=null){
|
||||
buffer.append(line);
|
||||
}
|
||||
|
||||
String value = new String(buffer);
|
||||
|
||||
System.out.println("result is "+value);
|
||||
result = value;
|
||||
|
||||
} catch (Exception e){
|
||||
System.out.println("Exception : "+e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
android:layout_gravity="center"
|
||||
android:text="version v0.1"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<!--
|
||||
<Button
|
||||
android:id="@+id/demo"
|
||||
android:layout_width="200dp"
|
||||
|
@ -52,7 +52,7 @@
|
|||
android:layout_below="@+id/register"
|
||||
android:layout_marginTop="53dp"
|
||||
android:text="DEMO" />
|
||||
|
||||
-->
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="230dp"
|
||||
|
|
|
@ -27,12 +27,12 @@
|
|||
android:id="@+id/editTextPassword"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignStart="@+id/editTextEmail"
|
||||
android:layout_below="@+id/editTextEmail"
|
||||
android:layout_alignStart="@+id/editTextEmail"
|
||||
android:layout_marginTop="69dp"
|
||||
android:ems="10"
|
||||
android:hint="Password"
|
||||
android:inputType="textPersonName" />
|
||||
android:inputType="textPassword" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/forgetPassword"
|
||||
|
|
|
@ -8,14 +8,17 @@
|
|||
|
||||
<Button
|
||||
android:id="@+id/buttonScanQr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="141dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="148dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="148dp"
|
||||
android:layout_marginBottom="160dp"
|
||||
android:text="SCAN QR CODE"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
app:layout_constraintHorizontal_bias="0.502"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.905" />
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
|
||||
<Button
|
||||
android:id="@+id/buttonSettings"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:text="Settings" />
|
||||
|
@ -25,32 +25,61 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/buttonSettings"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginTop="13dp"
|
||||
android:text="User account" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/viewSolde"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/textView4"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="48dp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonPayement"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginBottom="202dp"
|
||||
android:text="Payement" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonReceive"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/buttonPayement"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="38dp"
|
||||
android:layout_marginBottom="142dp"
|
||||
android:text="Receive" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonRefreshBalance"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="82dp"
|
||||
android:text="Refresh" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/balanceView"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_below="@+id/textView4"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginStart="119dp"
|
||||
android:layout_marginTop="156dp"
|
||||
android:layout_marginEnd="113dp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="30sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView6"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="204dp"
|
||||
android:text="BALANCE"
|
||||
android:textAlignment="center"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<resources>
|
||||
<string name="app_name">Monnéthic Mobile</string>
|
||||
<string name="app_name">Monnethic Mobile</string>
|
||||
<string name="title_activity_login">Sign in</string>
|
||||
|
||||
<!-- Strings related to login -->
|
||||
|
|
Loading…
Reference in a new issue