Transaction deletion / Coin menu
Quick add of the upcoming coin menu comporting 3 tabs Possibility to remove a manual transaction from the transaction tab in the coin menu
This commit is contained in:
parent
7997ffb42d
commit
97c625efa7
@ -12,7 +12,7 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
<activity
|
<activity
|
||||||
android:name="com.nauk.coinfolio.Activities.HomeActivity"
|
android:name=".Activities.HomeActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@ -22,10 +22,13 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="com.nauk.coinfolio.Activities.SettingsActivity"
|
android:name=".Activities.SettingsActivity"
|
||||||
android:label="@string/title_activity_settings" />
|
android:label="@string/title_activity_settings" />
|
||||||
<activity android:name="com.nauk.coinfolio.Activities.CurrencySelectionActivity" />
|
<activity android:name=".Activities.CurrencySelectionActivity" />
|
||||||
<activity android:name="com.nauk.coinfolio.Activities.RecordTransactionActivity"></activity>
|
<activity android:name=".Activities.RecordTransactionActivity" />
|
||||||
|
<activity
|
||||||
|
android:name=".Activities.CurrencyDetailsActivity"
|
||||||
|
android:label="@string/title_activity_currency_details"></activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -0,0 +1,102 @@
|
|||||||
|
package com.nauk.coinfolio.Activities;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.design.widget.BottomNavigationView;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.ViewFlipper;
|
||||||
|
|
||||||
|
import com.nauk.coinfolio.DataManagers.DatabaseManager;
|
||||||
|
import com.nauk.coinfolio.R;
|
||||||
|
|
||||||
|
import org.w3c.dom.Text;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
public class CurrencyDetailsActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private ViewFlipper viewFlipper;
|
||||||
|
private LinearLayout transactionLayout;
|
||||||
|
private DatabaseManager databaseManager;
|
||||||
|
private String symbol;
|
||||||
|
|
||||||
|
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
|
||||||
|
= new BottomNavigationView.OnNavigationItemSelectedListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.navigation_home:
|
||||||
|
viewFlipper.setDisplayedChild(0);
|
||||||
|
return true;
|
||||||
|
case R.id.navigation_dashboard:
|
||||||
|
viewFlipper.setDisplayedChild(1);
|
||||||
|
return true;
|
||||||
|
case R.id.navigation_notifications:
|
||||||
|
viewFlipper.setDisplayedChild(2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_currency_details);
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
|
||||||
|
symbol = intent.getStringExtra("symbol");
|
||||||
|
|
||||||
|
databaseManager = new DatabaseManager(this);
|
||||||
|
|
||||||
|
viewFlipper = findViewById(R.id.vfCurrencyDetails);
|
||||||
|
transactionLayout = findViewById(R.id.transactionsLinearLayout);
|
||||||
|
|
||||||
|
drawTransactionList();
|
||||||
|
|
||||||
|
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
|
||||||
|
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawTransactionList()
|
||||||
|
{
|
||||||
|
transactionLayout.removeAllViews();
|
||||||
|
|
||||||
|
HashMap<Integer, Double> transactionList = databaseManager.getCurrencyTransactions(symbol);
|
||||||
|
|
||||||
|
Iterator transactionsIterator = transactionList.keySet().iterator();
|
||||||
|
|
||||||
|
while(transactionsIterator.hasNext())
|
||||||
|
{
|
||||||
|
final TextView txtView = new TextView(this);
|
||||||
|
Integer key = (Integer) transactionsIterator.next();
|
||||||
|
|
||||||
|
txtView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
txtView.setTag(key);
|
||||||
|
txtView.setText("Amount : " + transactionList.get(key));
|
||||||
|
|
||||||
|
txtView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
TextView thisTxtView = (TextView) view;
|
||||||
|
databaseManager.deleteTransactionFromId(Integer.parseInt(thisTxtView.getTag().toString()));
|
||||||
|
Log.d(CurrencyDetailsActivity.this.getResources().getString(R.string.debug), "Id : " + thisTxtView.getTag());
|
||||||
|
drawTransactionList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
transactionLayout.addView(txtView);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -10,6 +10,7 @@ import android.util.Log;
|
|||||||
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,4 +109,33 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
|
|
||||||
return currencyList;
|
return currencyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashMap<Integer, Double> getCurrencyTransactions(String symbol)
|
||||||
|
{
|
||||||
|
String searchQuerry = "SELECT * FROM " + TABLE_MANUAL_CURRENCIES + " WHERE symbol='" + symbol.toUpperCase() + "'";
|
||||||
|
SQLiteDatabase db = this.getWritableDatabase();
|
||||||
|
Cursor resultatList = db.rawQuery(searchQuerry, null);
|
||||||
|
|
||||||
|
HashMap<Integer, Double> transactionList = new HashMap<>();
|
||||||
|
|
||||||
|
while(resultatList.moveToNext())
|
||||||
|
{
|
||||||
|
transactionList.put(resultatList.getInt(0), resultatList.getDouble(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
resultatList.close();
|
||||||
|
|
||||||
|
db.close();
|
||||||
|
|
||||||
|
return transactionList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteTransactionFromId(int id)
|
||||||
|
{
|
||||||
|
SQLiteDatabase db = this.getWritableDatabase();
|
||||||
|
|
||||||
|
db.delete(TABLE_MANUAL_CURRENCIES, KEY_CURRENCY_ID + "=" + id, null);
|
||||||
|
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.nauk.coinfolio.LayoutManagers;
|
|||||||
import android.animation.AnimatorInflater;
|
import android.animation.AnimatorInflater;
|
||||||
import android.animation.StateListAnimator;
|
import android.animation.StateListAnimator;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
@ -16,6 +17,8 @@ import android.widget.TextView;
|
|||||||
import com.db.chart.model.LineSet;
|
import com.db.chart.model.LineSet;
|
||||||
import com.db.chart.renderer.AxisRenderer;
|
import com.db.chart.renderer.AxisRenderer;
|
||||||
import com.db.chart.view.LineChartView;
|
import com.db.chart.view.LineChartView;
|
||||||
|
import com.nauk.coinfolio.Activities.CurrencyDetailsActivity;
|
||||||
|
import com.nauk.coinfolio.Activities.HomeActivity;
|
||||||
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
||||||
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDataChart;
|
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDataChart;
|
||||||
import com.nauk.coinfolio.R;
|
import com.nauk.coinfolio.R;
|
||||||
@ -39,7 +42,7 @@ public class HomeLayoutGenerator {
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardView getInfoLayout(Currency currency, int chartColor)
|
public CardView getInfoLayout(final Currency currency, int chartColor)
|
||||||
{
|
{
|
||||||
CardView mainCard = new CardView(context);
|
CardView mainCard = new CardView(context);
|
||||||
LinearLayout mainLinear = new LinearLayout(context);
|
LinearLayout mainLinear = new LinearLayout(context);
|
||||||
@ -63,8 +66,9 @@ public class HomeLayoutGenerator {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
view.animate();
|
view.animate();
|
||||||
Snackbar.make(view, "This feature is not yet available...", Snackbar.LENGTH_LONG)
|
Intent intent = new Intent(context.getApplicationContext(), CurrencyDetailsActivity.class);
|
||||||
.show();
|
intent.putExtra("symbol", currency.getSymbol());
|
||||||
|
context.getApplicationContext().startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mainCard.setClickable(true);
|
mainCard.setClickable(true);
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M21,18v1c0,1.1 -0.9,2 -2,2L5,21c-1.11,0 -2,-0.9 -2,-2L3,5c0,-1.1 0.89,-2 2,-2h14c1.1,0 2,0.9 2,2v1h-9c-1.11,0 -2,0.9 -2,2v8c0,1.1 0.89,2 2,2h9zM12,16h10L22,8L12,8v8zM16,13.5c-0.83,0 -1.5,-0.67 -1.5,-1.5s0.67,-1.5 1.5,-1.5 1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5z"/>
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/ic_dashboard_black_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_dashboard_black_24dp.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportHeight="24.0"
|
||||||
|
android:viewportWidth="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M3,13h8L11,3L3,3v10zM3,21h8v-6L3,15v6zM13,21h8L21,11h-8v10zM13,3v6h8L21,3h-8z" />
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/ic_home_black_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_home_black_24dp.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportHeight="24.0"
|
||||||
|
android:viewportWidth="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z" />
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/ic_show_chart_black_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_show_chart_black_24dp.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M3.5,18.49l6,-6.01 4,4L22,6.92l-1.41,-1.41 -7.09,7.97 -4,-4L2,16.99z"/>
|
||||||
|
</vector>
|
91
app/src/main/res/layout/activity_currency_details.xml
Normal file
91
app/src/main/res/layout/activity_currency_details.xml
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
tools:context="com.nauk.coinfolio.Activities.CurrencyDetailsActivity">
|
||||||
|
|
||||||
|
<ViewFlipper
|
||||||
|
android:id="@+id/vfCurrencyDetails"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:id="@+id/svCharts"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Charts"/>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:id="@+id/svInfos"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Infos"/>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:id="@+id/svTransactions"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/transactionsLinearLayout"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</ViewFlipper>
|
||||||
|
|
||||||
|
<android.support.design.widget.BottomNavigationView
|
||||||
|
android:id="@+id/navigation"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="0dp"
|
||||||
|
android:layout_marginStart="0dp"
|
||||||
|
android:background="?android:attr/windowBackground"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:menu="@menu/navigation"
|
||||||
|
android:layout_alignParentBottom="true"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
<!--<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="com.nauk.coinfolio.Activities.CurrencyDetailsActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/message"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
||||||
|
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||||
|
android:text="@string/title_home"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
</android.support.constraint.ConstraintLayout>
|
||||||
|
-->
|
19
app/src/main/res/menu/navigation.xml
Normal file
19
app/src/main/res/menu/navigation.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/navigation_home"
|
||||||
|
android:icon="@drawable/ic_show_chart_black_24dp"
|
||||||
|
android:title="@string/title_charts" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/navigation_dashboard"
|
||||||
|
android:icon="@drawable/ic_dashboard_black_24dp"
|
||||||
|
android:title="@string/title_infos" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/navigation_notifications"
|
||||||
|
android:icon="@drawable/ic_account_balance_wallet_black_24dp"
|
||||||
|
android:title="@string/title_transactions" />
|
||||||
|
|
||||||
|
</menu>
|
@ -4,4 +4,7 @@
|
|||||||
<dimen name="text_margin">16dp</dimen>
|
<dimen name="text_margin">16dp</dimen>
|
||||||
<dimen name="mainText">6dp</dimen>
|
<dimen name="mainText">6dp</dimen>
|
||||||
<dimen name="secondaryText">5dp</dimen>
|
<dimen name="secondaryText">5dp</dimen>
|
||||||
|
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||||
|
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||||
|
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -116,4 +116,8 @@
|
|||||||
<!--Add transaction activity-->
|
<!--Add transaction activity-->
|
||||||
<string name="activity_add_amount">Amount</string>
|
<string name="activity_add_amount">Amount</string>
|
||||||
<string name="activity_purchased_price">Purchased price</string>
|
<string name="activity_purchased_price">Purchased price</string>
|
||||||
|
<string name="title_activity_currency_details">CurrencyDetailsActivity</string>
|
||||||
|
<string name="title_charts">Charts</string>
|
||||||
|
<string name="title_infos">Infos</string>
|
||||||
|
<string name="title_transactions">Transactions</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user