Skip to content

Commit

Permalink
release cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
shakiz committed May 6, 2020
1 parent f16d129 commit 235e9e6
Show file tree
Hide file tree
Showing 62 changed files with 342 additions and 902 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.dailysaver.shadowhite.dailysaver"
minSdkVersion 21// 5.0
targetSdkVersion 28
versionCode 1
versionName "1.0"
versionCode 4
versionName "1.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private void setMenu() {
.setAnimation(MenuAnimation.SHOW_UP_CENTER)
.setMenuRadius(16f) // sets the corner radius.
.setMenuShadow(16f) // sets the shadow.
.setWidth(448)
.setWidth(688)
.setCircularEffect(CircularEffect.INNER)
.setOnMenuItemClickListener(onMenuItemClickListener)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,57 +185,86 @@ public void onClick(View v) {
//Save expense into DB with validation
private void saveRecord(){
if (!recordTypeStr.isEmpty()){
if (ux.validation(new int[]{R.id.Amount, R.id.Currency, R.id.Wallet, R.id.Note, R.id.ExpenseDate})){
if (!walletTitleStr.equals("No Data") && !walletTitleStr.equals("Select Wallet")) {
Record record = new Record(Integer.parseInt(Amount.getText().toString()), currencyValue, recordTypeStr, categoryTitle.getText().toString(), walletTitleStr,
walletValue, Note.getText().toString(), ExpenseDate.getText().toString());
if (record.getRecordType().equals(getText(R.string.expense))){
if (getRemainingBalance()){
new SaveRecord(record).execute();
if (!TextUtils.isEmpty(Amount.getText().toString())){
if (!TextUtils.isEmpty(Note.getText().toString())){
if (!walletTitleStr.equals("No Data") && !walletTitleStr.equals("Select Wallet")) {
if (!TextUtils.isEmpty(ExpenseDate.getText().toString())){
Record record = new Record(Integer.parseInt(Amount.getText().toString()), currencyValue, recordTypeStr, categoryTitle.getText().toString(), walletTitleStr,
walletValue, Note.getText().toString(), ExpenseDate.getText().toString());
if (record.getRecordType().equals(getText(R.string.expense))){
if (getRemainingBalance()){
new SaveRecord(record).execute();
}
else{
Snackbar.make(mainLayout,getResources().getString(R.string.wallet_amount_exceeds), Snackbar.LENGTH_SHORT).show();
}
}
else {
new SaveRecord(record).execute();
}
}
else{
Snackbar.make(mainLayout,getResources().getString(R.string.wallet_amount_exceeds), Snackbar.LENGTH_SHORT).show();
else {
ExpenseDate.requestFocus();
ExpenseDate.setError(getText(R.string.input_validation));
}
}
else {
new SaveRecord(record).execute();

} else {
Snackbar.make(mainLayout,R.string.select_wallet, Snackbar.LENGTH_LONG).show();
}
}
else{
Snackbar.make(mainLayout,R.string.select_wallet, BaseTransientBottomBar.LENGTH_SHORT).show();
else {
Note.requestFocus();
Note.setError(getText(R.string.input_validation));
}
}
}
else Snackbar.make(mainLayout,getResources().getString(R.string.select_record_type_error_message),Snackbar.LENGTH_SHORT).show();
else {
Amount.requestFocus();
Amount.setError(getText(R.string.input_validation));
}
}else Snackbar.make(mainLayout,getResources().getString(R.string.select_record_type_error_message),Snackbar.LENGTH_SHORT).show();

}
//end

//Update expense
private void updateRecord() {

if (!recordTypeStr.isEmpty()){
if (ux.validation(new int[]{R.id.Amount, R.id.Currency, R.id.Wallet, R.id.Note, R.id.ExpenseDate})){
if (!walletTitleStr.equals("No Data") && !walletTitleStr.equals("Select Wallet")) {
Record updatableRecord = new Record(Integer.parseInt(Amount.getText().toString()), currencyValue, recordTypeStr, categoryTitle.getText().toString(), walletTitleStr,
walletValue, Note.getText().toString(), ExpenseDate.getText().toString());
if (record.getRecordType().equals(getText(R.string.expense))){
if (getRemainingBalance()){
new UpdateRecord(updatableRecord,record.getId()).execute();
if (!TextUtils.isEmpty(Amount.getText().toString())){
if (!TextUtils.isEmpty(Note.getText().toString())){
if (!walletTitleStr.equals("No Data") && !walletTitleStr.equals("Select Wallet")) {
if (!TextUtils.isEmpty(ExpenseDate.getText().toString())){
Record updatableRecord = new Record(Integer.parseInt(Amount.getText().toString()), currencyValue, recordTypeStr, categoryTitle.getText().toString(), walletTitleStr,
walletValue, Note.getText().toString(), ExpenseDate.getText().toString());
if (record.getRecordType().equals(getText(R.string.expense))){
if (getRemainingBalance()){
new UpdateRecord(updatableRecord,record.getId()).execute();
}
else{
Snackbar.make(mainLayout,R.string.wallet_amount_exceeds, Snackbar.LENGTH_LONG).show();
}
}
else{
new UpdateRecord(updatableRecord,record.getId()).execute();
}
}
else{
Snackbar.make(mainLayout,R.string.wallet_amount_exceeds, Snackbar.LENGTH_LONG).show();
else {
ExpenseDate.requestFocus();
ExpenseDate.setError(getText(R.string.input_validation));
}
} else {
Snackbar.make(mainLayout,R.string.select_wallet, Snackbar.LENGTH_LONG).show();
}
else{
new UpdateRecord(updatableRecord,record.getId()).execute();
}

} else {
Snackbar.make(mainLayout,R.string.select_wallet, Snackbar.LENGTH_LONG).show();
}
else {
Note.requestFocus();
Note.setError(getText(R.string.input_validation));
}
}
}
else Snackbar.make(mainLayout,getResources().getString(R.string.select_record_type_error_message),Snackbar.LENGTH_SHORT).show();
else {
Amount.requestFocus();
Amount.setError(getText(R.string.input_validation));
}
}else Snackbar.make(mainLayout,getResources().getString(R.string.select_record_type_error_message),Snackbar.LENGTH_SHORT).show();
}
//end

Expand All @@ -246,12 +275,7 @@ private boolean getRemainingBalance(){
}
int remaining = databaseHelper.getWalletBalance(walletValue) - databaseHelper.singleWalletTotalCost(walletTitleStr);
if (!TextUtils.isEmpty(Amount.getText().toString())){
if (Integer.parseInt(Amount.getText().toString()) < remaining){
return true;
}
else{
return false;
}
return Integer.parseInt(Amount.getText().toString()) < remaining;
}
else {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private void setMenu() {
.setAnimation(MenuAnimation.SHOW_UP_CENTER)
.setMenuRadius(16f) // sets the corner radius.
.setMenuShadow(16f) // sets the shadow.
.setWidth(448)
.setWidth(688)
.setCircularEffect(CircularEffect.INNER)
.setOnMenuItemClickListener(onMenuItemClickListener)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
Expand All @@ -14,6 +15,8 @@
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.Toast;

import com.google.android.material.snackbar.BaseTransientBottomBar;
import com.sakhawat.expense.tracker.R;
import com.sakhawat.expense.tracker.activities.newrecord.AddNewRecordActivity;
import com.sakhawat.expense.tracker.activities.dashboard.DashboardActivity;
Expand Down Expand Up @@ -166,30 +169,62 @@ public void onCheckedChanged(RadioGroup group, int checkedId) {

//save wallet
private void saveWallet() {
if (ux.validation(new int[]{R.id.Amount, R.id.Currency, R.id.WalletName, R.id.Note, R.id.ExpiresOn})){
if (!budgetTypeStr.isEmpty()){
Wallet wallet = new Wallet(WalletName.getText().toString(), Integer.parseInt(Amount.getText().toString()), currencyValue, ExpiresOn.getText().toString(), budgetTypeStr,
Note.getText().toString());
new SaveWallet(wallet).execute();
if (!TextUtils.isEmpty(Amount.getText().toString())){
if (!TextUtils.isEmpty(WalletName.getText().toString())){
if (!TextUtils.isEmpty(Note.getText().toString())){
if (!budgetTypeStr.isEmpty()){
Wallet wallet = new Wallet(WalletName.getText().toString(), Integer.parseInt(Amount.getText().toString()), currencyValue, ExpiresOn.getText().toString(), budgetTypeStr,
Note.getText().toString());
new SaveWallet(wallet).execute();
}
else {
Snackbar.make(mainLayout,getText(R.string.select_wallet_type),Snackbar.LENGTH_SHORT).show();
}
}
else {
Note.requestFocus();
Note.setError(getText(R.string.input_validation));
}
}
else {
Snackbar.make(mainLayout,getText(R.string.select_wallet_type),Snackbar.LENGTH_SHORT).show();
WalletName.requestFocus();
WalletName.setError(getText(R.string.input_validation));
}
}
else {
Amount.requestFocus();
Amount.setError(getText(R.string.input_validation));
}
}

//Update expense
private void updateWallet() {
if (ux.validation(new int[]{R.id.Amount, R.id.Currency, R.id.WalletName, R.id.Note, R.id.ExpiresOn})){
if (!budgetTypeStr.isEmpty()){
Wallet updatableWallet = new Wallet(WalletName.getText().toString(), Integer.parseInt(Amount.getText().toString()), currencyValue, ExpiresOn.getText().toString(), budgetTypeStr,
Note.getText().toString());
new UpdateWallet(updatableWallet, wallet.getId()).execute();
if (!TextUtils.isEmpty(Amount.getText().toString())){
if (!TextUtils.isEmpty(WalletName.getText().toString())){
if (!TextUtils.isEmpty(Note.getText().toString())){
if (!budgetTypeStr.isEmpty()){
Wallet updatableWallet = new Wallet(WalletName.getText().toString(), Integer.parseInt(Amount.getText().toString()), currencyValue, ExpiresOn.getText().toString(), budgetTypeStr,
Note.getText().toString());
new UpdateWallet(updatableWallet, wallet.getId()).execute();
}
else {
Snackbar.make(mainLayout,getText(R.string.select_wallet_type),Snackbar.LENGTH_SHORT).show();
}
}
else {
Note.requestFocus();
Note.setError(getText(R.string.input_validation));
}
}
else {
Snackbar.make(mainLayout,getText(R.string.select_wallet_type),Snackbar.LENGTH_SHORT).show();
WalletName.requestFocus();
WalletName.setError(getText(R.string.input_validation));
}
}
else {
Amount.requestFocus();
Amount.setError(getText(R.string.input_validation));
}
}
//end

Expand Down Expand Up @@ -250,10 +285,10 @@ public void onClick(View view) {

@Override
public void onBackPressed() {
if (getIntent().getStringExtra("from").equals("record")) startActivity(new Intent(AddNewWalletActivity.this, RecordsActivity.class));
else if (getIntent().getStringExtra("from").equals("newRecord")) startActivity(new Intent(this, AddNewRecordActivity.class));
else if (getIntent().getStringExtra("from").equals("main")) startActivity(new Intent(AddNewWalletActivity.this, DashboardActivity.class));
else if (getIntent().getStringExtra("from").equals("walletDetails")) startActivity(new Intent(AddNewWalletActivity.this, WalletDetailsActivity.class).putExtra("wallet",wallet));
if (getIntent().getStringExtra("from").equals("record")) startActivity(new Intent(this, RecordsActivity.class));
else if (getIntent().getStringExtra("from").equals("newRecord")) startActivity(new Intent(this, AddNewRecordActivity.class).putExtra("from","wallet"));
else if (getIntent().getStringExtra("from").equals("main")) startActivity(new Intent(this, DashboardActivity.class));
else if (getIntent().getStringExtra("from").equals("walletDetails")) startActivity(new Intent(this, WalletDetailsActivity.class).putExtra("wallet",wallet));
overridePendingTransition(R.anim.fadein,R.anim.push_up_out);
}

Expand Down
78 changes: 0 additions & 78 deletions app/src/main/java/com/sakhawat/expense/tracker/utills/Tools.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.icu.text.DateFormat;
import android.icu.text.SimpleDateFormat;
import android.net.Uri;
import android.os.Build;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import com.sakhawat.expense.tracker.R;
import java.text.ParseException;
import java.util.Date;
import java.util.Locale;

public class Tools {
private Context context;
Expand All @@ -32,78 +26,6 @@ public void setAnimation(View view){
view.startAnimation(a);
}

/**
* This method will provide the date formatter
*/
private DateFormat getAndroidDateFormat(){
DateFormat dateFormatter = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
dateFormatter = new SimpleDateFormat("dd-MMM-yyyy", Locale.US);
}
return dateFormatter;
}

/**
* This method will convert string to a date value
*
* @param strDate
*/
public Date convertStrToDate(String strDate){
Date date = null;
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
date = getAndroidDateFormat().parse(strDate);
System.out.println("Current Date Time : " + date);
}
System.out.println(date);
} catch (ParseException e) {
e.printStackTrace();
}

return date;
}

/**
* This method will convert date to a string value
*
* @param date
*/
public String dateToStr(Date date){
String dateStr = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
dateStr = getAndroidDateFormat().format(date);
}
System.out.println("Current Date Time : " + dateStr);

return dateStr;
}

/**
* This method will convert date to a long value
*
* @param date
*/
public Long convertDateToLong(Date date) {
if (date != null) {
return date.getTime();
}
return null;
}

/**
* This method will convert long to a date value
*
* @param dateInLong
*/
public String longToDateString(long dateInLong){
// or you already have long value of date, use this instead of milliseconds variable.
String dateString = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
dateString = getAndroidDateFormat().format(new Date(dateInLong));
}
return dateString;
}

/**
* This method will exit the app
*/
Expand Down
Loading

0 comments on commit 235e9e6

Please sign in to comment.