Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App ui update #170

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ android {
proguardFile 'proguard-project.txt'
}
}
dataBinding {
enabled true
}
}

dependencies {
Expand All @@ -46,4 +49,6 @@ dependencies {
implementation 'com.razorpay:checkout:1.5.16'
implementation "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}
33 changes: 15 additions & 18 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.razorpay.sampleapp"
android:versionCode="20"
android:versionName="3.0"
>

android:versionName="3.0">

<application
android:icon="@mipmap/ic_launcher"
android:label="Razorpay Sample App"
android:theme="@style/AppTheme"
>
android:theme="@style/AppTheme">
<activity android:name=".java.ActivitySettings"></activity>
<activity android:name=".java.ActivityHomePage">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".java.PaymentActivity"
android:label="Razorpay Sample App"
>

</activity>
android:label="Razorpay Sample App" />
<activity android:name=".kotlin.PaymentActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<!-- Add your API key here -->
</activity> <!-- Add your API key here -->
<meta-data
android:name="com.razorpay.ApiKey"
android:value="rzp_live_ILgsfZCZoFIKMb"
/>

android:value="rzp_live_ILgsfZCZoFIKMb" />
</application>

</manifest>
</manifest>
110 changes: 110 additions & 0 deletions app/src/main/java/com/razorpay/sampleapp/java/ActivityHomePage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package com.razorpay.sampleapp.java;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.databinding.DataBindingUtil;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.widget.Toast;

import com.razorpay.Checkout;
import com.razorpay.PaymentResultListener;
import com.razorpay.sampleapp.R;
import com.razorpay.sampleapp.databinding.ActivityHomePageBinding;

import org.json.JSONObject;

public class ActivityHomePage extends AppCompatActivity implements PaymentResultListener {

private ActivityHomePageBinding binding;
private String imgUrl="https://s3.amazonaws.com/rzp-mobile/images/rzp.png";
private String companyName="Razorpay Online Store";
private String color= "#2B83EA";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
binding = DataBindingUtil.setContentView(this,R.layout.activity_home_page);
binding.btnSettings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ActivityHomePage.this,ActivitySettings.class);
startActivityForResult(intent, 100);
}
});
binding.btnCheckout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
binding.btnCheckout.setText("Processing");
startPayment();
}
});
}

private void startPayment() {

final Activity activity = this;

final Checkout co = new Checkout();

try {
JSONObject options = new JSONObject();
options.put("name", companyName);
options.put("description", "Final Charges");
//You can omit the image option to fetch the image from dashboard
options.put("image",imgUrl);
options.put("currency", "INR");
options.put("amount", "100");

JSONObject preFill = new JSONObject();
preFill.put("email", "[email protected]");
preFill.put("contact", "9876543210");

options.put("prefill", preFill);

JSONObject theme = new JSONObject();
theme.put("color",color);
options.put("theme",theme);

co.open(activity, options);
} catch (Exception e) {
Toast.makeText(activity, "Error in payment: " + e.getMessage(), Toast.LENGTH_SHORT)
.show();
e.printStackTrace();
}

}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == 1000) {
if (data!=null) {
imgUrl = data.getStringExtra("imageURL");
companyName = data.getStringExtra("companyName");
color = data.getStringExtra("color");
}
}
}



@Override
public void onPaymentSuccess(String s) {
binding.btnCheckout.setText("Pay now");
Toast.makeText(ActivityHomePage.this, "Payment succesfull "+s,Toast.LENGTH_LONG).show();
}

@Override
public void onPaymentError(int i, String s) {
binding.btnCheckout.setText("Pay now");
Toast.makeText(ActivityHomePage.this, "Payment unsuccessful "+s,Toast.LENGTH_LONG).show();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.razorpay.sampleapp.java;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.view.Window;
import android.widget.Toast;

import com.razorpay.sampleapp.R;
import com.razorpay.sampleapp.databinding.ActivitySettingsBinding;

public class ActivitySettings extends AppCompatActivity {

private ActivitySettingsBinding binding;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
binding = DataBindingUtil.setContentView(this, R.layout.activity_settings);
binding.ivBackArrow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
saveSettings();
}
});
binding.etColor.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

}

@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

}

@Override
public void afterTextChanged(Editable editable) {
if (editable.toString().length() >=6) {
String color = editable.toString();
color = "#"+color;
binding.ivColorEx.setBackgroundColor(Color.parseColor(color));
}
}
});
binding.btnSaveSettings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
saveSettings();
}
});
}

private void saveSettings() {
Intent intent = new Intent();
if (!TextUtils.isEmpty(binding.etImageurl.getText().toString())){
intent.putExtra("imageURL",binding.etImageurl.getText().toString());
}else{
intent.putExtra("imageURL","https://s3.amazonaws.com/rzp-mobile/images/rzp.png");
}
if (TextUtils.isEmpty(binding.etCompanyName.getText().toString())){
intent.putExtra("companyName","Razorpay Online Store");

}else{
intent.putExtra("companyName",binding.etCompanyName.getText().toString());
}
if (binding.etColor.getText().toString().length()!=6){
Toast.makeText(this,"Please enter a correct color hex value",Toast.LENGTH_LONG).show();
}else{
intent.putExtra("color","#"+binding.etColor.getText().toString());
setResult(1000,intent);
finish();
}

}
}
24 changes: 24 additions & 0 deletions app/src/main/res/drawable/bg_elevated.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">

<item >
<shape android:shape="rectangle">
<solid
android:color="#22000000"/>
<corners
android:radius="10dp"/>

</shape>
</item>
<item android:bottom="2dp">
<shape android:shape="rectangle">
<solid
android:color="#ffffff"/>
<corners
android:radius="10dp"/>

</shape>
</item>

</layer-list>
18 changes: 18 additions & 0 deletions app/src/main/res/drawable/bg_img.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">

<item
>
<shape android:shape="rectangle">
<solid
android:color="#44000000"/>
<corners
android:topLeftRadius="10dp"
android:bottomLeftRadius="10dp"
/>

</shape>
</item>

</layer-list>
16 changes: 16 additions & 0 deletions app/src/main/res/drawable/bg_warning_message.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
<shape android:shape="rectangle">
<solid
android:color="@color/note_fg"/>
<stroke
android:color="@color/note_bg"
android:width="2dp"
/>
</shape>
</item>


</layer-list>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_back_arrow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="8dp"
android:height="14dp"
android:viewportWidth="8"
android:viewportHeight="14">
<path
android:pathData="M7.7071,0.2929C8.0976,0.6834 8.0976,1.3166 7.7071,1.7071L2.4142,7L7.7071,12.2929C8.0976,12.6834 8.0976,13.3166 7.7071,13.7071C7.3166,14.0976 6.6834,14.0976 6.2929,13.7071L0.2929,7.7071C-0.0976,7.3166 -0.0976,6.6834 0.2929,6.2929L6.2929,0.2929C6.6834,-0.0976 7.3166,-0.0976 7.7071,0.2929Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
</vector>
14 changes: 14 additions & 0 deletions app/src/main/res/drawable/ic_rectangle_bg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="359dp"
android:height="108dp"
android:viewportWidth="359"
android:viewportHeight="108">
<path
android:pathData="M4,0H355V59V100H4V0Z"
android:fillColor="#ffffff"/>
<path
android:strokeWidth="1"
android:pathData="M4.5,0.5H354.5V59V99.5H4.5V0.5Z"
android:fillColor="#00000000"
android:strokeColor="#ffffff"/>
</vector>
Loading