Commit 59275085 authored by Bhavesh Yadav's avatar Bhavesh Yadav

Added wallet topup feature - offline

parent 14d37d61
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/appTheme"> android:theme="@style/appTheme">
<activity android:name="com.example.infiniteLoop.parkingo.wallets"></activity> <activity android:name="com.example.infiniteLoop.parkingo.wallets"
android:theme="@style/Theme.AppCompat"></activity>
<activity <activity
android:name="com.example.infiniteLoop.parkingo.SplashActivity" android:name="com.example.infiniteLoop.parkingo.SplashActivity"
android:theme="@style/splash_screen"> android:theme="@style/splash_screen">
......
...@@ -142,7 +142,8 @@ public class login_activity extends Activity { ...@@ -142,7 +142,8 @@ public class login_activity extends Activity {
progress.dismiss(); progress.dismiss();
uinfo.setU_name(user.get("name").toString()); uinfo.setU_name(user.get("name").toString());
uinfo.setUsername(user.get("username").toString()); uinfo.setUsername(user.get("username").toString());
if(user.get("balance")!=null)
uinfo.setBalance(Integer.parseInt(user.get("balance").toString()));
Toast.makeText(login_activity.this,"Login_Success",Toast.LENGTH_SHORT).show(); Toast.makeText(login_activity.this,"Login_Success",Toast.LENGTH_SHORT).show();
startActivity(new Intent(login_activity.this,dashboard.class)); startActivity(new Intent(login_activity.this,dashboard.class));
......
...@@ -14,6 +14,7 @@ public class userInfo { ...@@ -14,6 +14,7 @@ public class userInfo {
Log.d("ins","called"); Log.d("ins","called");
return u_instance; return u_instance;
} }
private int balance= 0;
public String getName() { public String getName() {
return u_name; return u_name;
...@@ -30,4 +31,8 @@ public class userInfo { ...@@ -30,4 +31,8 @@ public class userInfo {
public void setUsername(String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
public int getBalance(){return this.balance;}
public void setBalance(int newBalance){this.balance = newBalance;}
} }
package com.example.infiniteLoop.parkingo; package com.example.infiniteLoop.parkingo;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.cardview.widget.CardView;
import io.opencensus.internal.StringUtils; import io.opencensus.internal.StringUtils;
public class wallets extends Activity { public class wallets extends Activity {
String top_up_text;
TextView wdraw;
TextView balance;
CardView topupButton;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wallets); setContentView(R.layout.activity_wallets);
TextView wdraw= findViewById(R.id.uname); wdraw= findViewById(R.id.uname);
balance=findViewById(R.id.balance_amount);
topupButton =findViewById(R.id.topup);
userInfo uinfo=userInfo.getInstance(); userInfo uinfo=userInfo.getInstance();
balance.setText("\u20B9 "+uinfo.getBalance());
wdraw.setText("Hello ".toUpperCase()+uinfo.getName().toUpperCase()); wdraw.setText("Hello ".toUpperCase()+uinfo.getName().toUpperCase());
topupButton.setOnClickListener(new View.OnClickListener(){
@Override public void onClick(View v) {
top_up();
}
});
}
private void top_up() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Enter amount to top up with");
final EditText input = new EditText(this);
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_CLASS_NUMBER);
builder.setView(input);
builder.setPositiveButton("ADD", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
top_up_text = input.getText().toString();
userInfo uinfo = userInfo.getInstance();
int newBalance = Integer.parseInt(top_up_text)+uinfo.getBalance();
uinfo.setBalance(newBalance);
balance.setText("\u20B9 "+uinfo.getBalance());
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
} }
} }
...@@ -63,48 +63,6 @@ ...@@ -63,48 +63,6 @@
</TextView> </TextView>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/transactions"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_column="1"
android:layout_margin="10dp"
android:layout_marginTop="50dp"
android:paddingLeft="10dp"
android:paddingTop="0dp"
android:paddingRight="10dp"
android:paddingBottom="5dp"
app:cardBackgroundColor="#fff"
app:cardElevation="15dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="25dp"
android:text="\u2022 Transactions"
android:textColor="#000"
android:paddingLeft="25dp"
android:textColorHighlight="#00f"
android:textColorLink="@color/black"
android:shadowColor="#000"
android:outlineSpotShadowColor="#000"
>
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:text="view"
android:layout_marginEnd="20dp"
android:background="#fff"
android:padding="10dp"
android:textSize="20dp"
></TextView>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:id="@+id/topup" android:id="@+id/topup"
...@@ -125,7 +83,7 @@ ...@@ -125,7 +83,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:textSize="25dp" android:textSize="25dp"
android:text="\u2022 Top-Up" android:text="\u2022 Top-up"
android:textColor="#000" android:textColor="#000"
android:paddingLeft="25dp" android:paddingLeft="25dp"
android:textColorHighlight="#00f" android:textColorHighlight="#00f"
...@@ -148,50 +106,92 @@ ...@@ -148,50 +106,92 @@
></TextView> ></TextView>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView <!-- <androidx.cardview.widget.CardView-->
android:id="@+id/withdraw" <!-- android:id="@+id/topup"-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="70dp" <!-- android:layout_height="70dp"-->
android:layout_column="1" <!-- android:layout_column="1"-->
android:layout_margin="10dp" <!-- android:layout_margin="10dp"-->
android:layout_marginTop="50dp" <!-- android:layout_marginTop="50dp"-->
android:paddingLeft="10dp" <!-- android:paddingLeft="10dp"-->
android:paddingTop="0dp" <!-- android:paddingTop="0dp"-->
android:paddingRight="10dp" <!-- android:paddingRight="10dp"-->
android:paddingBottom="5dp" <!-- android:paddingBottom="5dp"-->
app:cardBackgroundColor="#fff" <!-- app:cardBackgroundColor="#fff"-->
app:cardElevation="15dp" <!-- app:cardElevation="15dp"-->
> <!-- >-->
<TextView <!-- <TextView-->
android:id="@+id/wdraw_txt" <!-- android:layout_width="wrap_content"-->
android:layout_width="wrap_content" <!-- android:layout_height="wrap_content"-->
android:layout_height="wrap_content" <!-- android:layout_gravity="center_vertical"-->
android:layout_gravity="center_vertical" <!-- android:textSize="25dp"-->
android:textSize="25dp" <!-- android:text="\u2022 Top-Up"-->
android:text="\u2022 Withdraw Money" <!-- android:textColor="#000"-->
android:textColor="#000" <!-- android:paddingLeft="25dp"-->
android:paddingLeft="25dp" <!-- android:textColorHighlight="#00f"-->
android:textColorHighlight="#00f" <!-- android:textColorLink="@color/black"-->
android:textColorLink="@color/black" <!-- android:shadowColor="#000"-->
android:shadowColor="#000" <!-- android:outlineSpotShadowColor="#000"-->
android:outlineSpotShadowColor="#000"
<!-- >-->
>
<!-- </TextView>-->
</TextView> <!-- <TextView-->
<TextView <!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
android:layout_width="wrap_content" <!-- android:layout_gravity="right|center_vertical"-->
android:layout_height="wrap_content" <!-- android:text="view"-->
android:layout_gravity="right|center_vertical" <!-- android:layout_marginEnd="20dp"-->
android:text="view" <!-- android:background="#fff"-->
android:layout_marginEnd="20dp" <!-- android:padding="10dp"-->
android:background="#fff" <!-- android:textSize="20dp"-->
android:padding="10dp" <!-- ></TextView>-->
android:textSize="20dp"
></TextView> <!-- </androidx.cardview.widget.CardView>-->
<!-- <androidx.cardview.widget.CardView-->
</androidx.cardview.widget.CardView> <!-- android:id="@+id/withdraw"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="70dp"-->
<!-- android:layout_column="1"-->
<!-- android:layout_margin="10dp"-->
<!-- android:layout_marginTop="50dp"-->
<!-- android:paddingLeft="10dp"-->
<!-- android:paddingTop="0dp"-->
<!-- android:paddingRight="10dp"-->
<!-- android:paddingBottom="5dp"-->
<!-- app:cardBackgroundColor="#fff"-->
<!-- app:cardElevation="15dp"-->
<!-- >-->
<!-- <TextView-->
<!-- android:id="@+id/wdraw_txt"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="center_vertical"-->
<!-- android:textSize="25dp"-->
<!-- android:text="\u2022 Withdraw Money"-->
<!-- android:textColor="#000"-->
<!-- android:paddingLeft="25dp"-->
<!-- android:textColorHighlight="#00f"-->
<!-- android:textColorLink="@color/black"-->
<!-- android:shadowColor="#000"-->
<!-- android:outlineSpotShadowColor="#000"-->
<!-- >-->
<!-- </TextView>-->
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="right|center_vertical"-->
<!-- android:text="view"-->
<!-- android:layout_marginEnd="20dp"-->
<!-- android:background="#fff"-->
<!-- android:padding="10dp"-->
<!-- android:textSize="20dp"-->
<!-- ></TextView>-->
<!-- </androidx.cardview.widget.CardView>-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment