Commit 59275085 authored by Bhavesh Yadav's avatar Bhavesh Yadav

Added wallet topup feature - offline

parent 14d37d61
......@@ -11,7 +11,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
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
android:name="com.example.infiniteLoop.parkingo.SplashActivity"
android:theme="@style/splash_screen">
......
......@@ -142,7 +142,8 @@ public class login_activity extends Activity {
progress.dismiss();
uinfo.setU_name(user.get("name").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();
startActivity(new Intent(login_activity.this,dashboard.class));
......
......@@ -14,6 +14,7 @@ public class userInfo {
Log.d("ins","called");
return u_instance;
}
private int balance= 0;
public String getName() {
return u_name;
......@@ -30,4 +31,8 @@ public class userInfo {
public void setUsername(String username) {
this.username = username;
}
public int getBalance(){return this.balance;}
public void setBalance(int newBalance){this.balance = newBalance;}
}
package com.example.infiniteLoop.parkingo;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
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 androidx.appcompat.app.AlertDialog;
import androidx.cardview.widget.CardView;
import io.opencensus.internal.StringUtils;
public class wallets extends Activity {
String top_up_text;
TextView wdraw;
TextView balance;
CardView topupButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
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();
balance.setText("\u20B9 "+uinfo.getBalance());
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 @@
</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
android:id="@+id/topup"
......@@ -125,7 +83,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="25dp"
android:text="\u2022 Top-Up"
android:text="\u2022 Top-up"
android:textColor="#000"
android:paddingLeft="25dp"
android:textColorHighlight="#00f"
......@@ -148,50 +106,92 @@
></TextView>
</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>
<!-- <androidx.cardview.widget.CardView-->
<!-- android:id="@+id/topup"-->
<!-- 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 Top-Up"-->
<!-- 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-->
<!-- 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