Update transfert tab in RecordTransactionActivity

- Prepare 'from' and 'to' fields
- Setup date field

- Update tab text colors
This commit is contained in:
Tanguy Herbron 2018-08-18 02:34:02 +02:00
parent de38e5dea4
commit 1d4324bec2
26 changed files with 250 additions and 36 deletions

View File

@ -76,7 +76,7 @@ public class Charts extends Fragment implements CurrencyInfoUpdateNotifierInterf
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
{
view = inflater.inflate(R.layout.fragment_charts_detailsactivity, container, false);
view = inflater.inflate(R.layout.detailsactivity_fragment_charts, container, false);
currency = getActivity().getIntent().getParcelableExtra("currency");

View File

@ -38,7 +38,7 @@ public class Informations extends Fragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
{
view = inflater.inflate(R.layout.fragment_informations_detailsactivity, container, false);
view = inflater.inflate(R.layout.detailsactivity_fragment_informations, container, false);
isSnapshotUpdated = false;
isTickerUpdated = false;

View File

@ -49,7 +49,7 @@ public class Transactions extends Fragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
view = inflater.inflate(R.layout.fragment_transactions_detailsactivity, container, false);
view = inflater.inflate(R.layout.detailsactivity_fragment_transactions, container, false);
PreferencesManager preferencesManager = new PreferencesManager(getActivity().getBaseContext());

View File

@ -67,7 +67,7 @@ public class MarketCapitalization extends Fragment implements CryptocompareNotif
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
view = inflater.inflate(R.layout.fragment_marketcap_homeactivity, container, false);
view = inflater.inflate(R.layout.homeactivity_fragment_marketcap, container, false);
preferencesManager = new PreferencesManager(getActivity().getBaseContext());
coinmarketCapAPIManager = CoinmarketCapAPIManager.getInstance(getActivity().getBaseContext());

View File

@ -10,7 +10,6 @@ import android.support.annotation.NonNull;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.graphics.Palette;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -53,7 +52,7 @@ public class Overview extends Fragment implements CoinmarketcapNotifierInterface
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View fragmentView = inflater.inflate(R.layout.fragment_overview_homeactivity, container, false);
View fragmentView = inflater.inflate(R.layout.homeactivity_fragment_overview, container, false);
coinmarketCapAPIManager = CoinmarketCapAPIManager.getInstance(getActivity().getBaseContext());
cryptocompareApiManager = CryptocompareApiManager.getInstance(getActivity().getBaseContext());

View File

@ -22,7 +22,6 @@ import android.support.v4.content.ContextCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.graphics.Palette;
import android.util.Log;
import android.view.Gravity;
@ -101,7 +100,7 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface,
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View fragmentView = inflater.inflate(R.layout.fragment_summary_homeactivity, container, false);
View fragmentView = inflater.inflate(R.layout.homeactivity_fragment_summary, container, false);
preferencesManager = new PreferencesManager(getActivity());
balanceManager = new BalanceManager(getActivity());

View File

@ -100,6 +100,7 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
exchange_autoCompleteTextView.setText("");
((LinearLayout) tabLayout.getChildAt(0)).getChildAt(2).setEnabled(false);
((TextView) tabLayout.getTabAt(2).getCustomView()).setTextColor(getResources().getColor(R.color.separationColor));
if(isGlobalLayoutVisible && globalTabLayouts.getAnimation().hasEnded())
{
@ -308,9 +309,9 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
globalTabLayouts = findViewById(R.id.globalTabLayouts);
tabLayout = findViewById(R.id.transactionsTabLayout);
tabLayout.addTab(0, "Buy");
tabLayout.addTab(1, "Sell");
tabLayout.addTab(2, "Transfer");
tabLayout.addTab(0, getResources().getString(R.string.buyText));
tabLayout.addTab(1, getResources().getString(R.string.sellText));
tabLayout.addTab(2, getResources().getString(R.string.transferText));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
viewPager = findViewById(R.id.transactionsViewPager);
@ -339,6 +340,7 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
for(int i = 0; i < tabLayoutChildren.getChildCount(); i++)
{
tabLayoutChildren.getChildAt(i).setEnabled(false);
((TextView) tabLayout.getTabAt(i).getCustomView()).setTextColor(getResources().getColor(R.color.separationColor));
}
revealAnimation = AnimationUtils.loadAnimation(this, R.anim.reveal);
@ -377,7 +379,9 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
public void onTextChanged(CharSequence s, int start, int before, int count) {
((LinearLayout) tabLayout.getChildAt(0)).getChildAt(0).setEnabled(false);
((TextView) tabLayout.getTabAt(0).getCustomView()).setTextColor(getResources().getColor(R.color.separationColor));
((LinearLayout) tabLayout.getChildAt(0)).getChildAt(1).setEnabled(false);
((TextView) tabLayout.getTabAt(1).getCustomView()).setTextColor(getResources().getColor(R.color.separationColor));
tabLayout.getTabAt(2).select();
}
@ -421,7 +425,9 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
updatePairData();
((LinearLayout) tabLayout.getChildAt(0)).getChildAt(0).setEnabled(true);
((TextView) tabLayout.getTabAt(0).getCustomView()).setTextColor(getResources().getColor(R.color.white));
((LinearLayout) tabLayout.getChildAt(0)).getChildAt(1).setEnabled(true);
((TextView) tabLayout.getTabAt(1).getCustomView()).setTextColor(getResources().getColor(R.color.white));
tabLayout.getTabAt(0).select();
}
});
@ -444,7 +450,9 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
pair_autoCompleteTextView.setText("");
((LinearLayout) tabLayout.getChildAt(0)).getChildAt(0).setEnabled(false);
((TextView) tabLayout.getTabAt(0).getCustomView()).setTextColor(getResources().getColor(R.color.separationColor));
((LinearLayout) tabLayout.getChildAt(0)).getChildAt(1).setEnabled(false);
((TextView) tabLayout.getTabAt(1).getCustomView()).setTextColor(getResources().getColor(R.color.separationColor));
tabLayout.getTabAt(2).select();
}
@ -554,8 +562,11 @@ public class RecordTransactionActivity extends AppCompatActivity implements Curr
iconDownloaderTask.execute();
((LinearLayout) tabLayout.getChildAt(0)).getChildAt(0).setEnabled(false);
((TextView) tabLayout.getTabAt(0).getCustomView()).setTextColor(getResources().getColor(R.color.separationColor));
((LinearLayout) tabLayout.getChildAt(0)).getChildAt(1).setEnabled(false);
((TextView) tabLayout.getTabAt(1).getCustomView()).setTextColor(getResources().getColor(R.color.separationColor));
((LinearLayout) tabLayout.getChildAt(0)).getChildAt(2).setEnabled(true);
((TextView) tabLayout.getTabAt(2).getCustomView()).setTextColor(getResources().getColor(R.color.white));
tabLayout.getTabAt(2).select();
updateCurrencyData();

View File

@ -134,7 +134,7 @@ public class BuyFragment extends CustomRecordFragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_buy, container, false);
view = inflater.inflate(R.layout.record_transaction_fragment_buy, container, false);
context = getActivity().getApplicationContext();

View File

@ -10,7 +10,6 @@ import android.support.design.widget.TextInputEditText;
import android.support.v7.widget.AppCompatButton;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -135,7 +134,7 @@ public class SellFragment extends CustomRecordFragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_sell, container, false);
view = inflater.inflate(R.layout.record_transaction_fragment_sell, container, false);
context = getActivity().getApplicationContext();

View File

@ -1,28 +1,115 @@
package com.herbron.moodl.Activities.RecordTransactionFragments;
import android.app.DatePickerDialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.design.widget.TextInputEditText;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.DatePicker;
import android.widget.Spinner;
import android.widget.TimePicker;
import com.herbron.moodl.CustomLayouts.CustomRecordFragment;
import com.herbron.moodl.DataManagers.CurrencyData.Currency;
import com.herbron.moodl.R;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
public class TransferFragment extends CustomRecordFragment {
private static Currency fragmentCurrency;
private Spinner fromSpinner;
private Spinner toSpinner;
private TextInputEditText transferDateEditText;
private SimpleDateFormat sdf;
private Calendar calendar;
private View view;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_transfer, container, false);
view = inflater.inflate(R.layout.record_transaction_fragment_transfer, container, false);
calendar = Calendar.getInstance();
sdf = new SimpleDateFormat(" HH:mm dd/MM/yyyy", Locale.UK);
fromSpinner = view.findViewById(R.id.from_transfer_spinner);
toSpinner = view.findViewById(R.id.to_transfer_spinner);
ArrayAdapter<String> fromAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.from_transfer_options_string_array));
fromAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
ArrayAdapter<String> toAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.to_transfer_options_string_array));
toAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
fromSpinner.setAdapter(fromAdapter);
toSpinner.setAdapter(toAdapter);
transferDateEditText = view.findViewById(R.id.transfertDate_editText);
transferDateEditText.setText(sdf.format(calendar.getTime()));
transferDateEditText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
createDatePicker();
}
});
return view;
}
private void createDatePicker()
{
DatePickerDialog datePickerDialog = new DatePickerDialog(
getContext(),
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
transferDateEditText.setText(sdf.format(calendar.getTime()));
createTimePicker();
}
},
calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH)
);
datePickerDialog.getDatePicker().setMaxDate(Calendar.getInstance().getTimeInMillis());
datePickerDialog.show();
}
private void createTimePicker()
{
new android.app.TimePickerDialog(
getContext(),
new android.app.TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hour, int minute) {
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
transferDateEditText.setText(sdf.format(calendar.getTime()));
}
},
calendar.get(Calendar.HOUR_OF_DAY),
calendar.get(Calendar.MINUTE),
true
).show();
}
@Override
public void onCurrencyUpdated() {
fragmentCurrency = currency;
}
@Override

View File

@ -68,6 +68,7 @@ public class CustomTabLayout extends TabLayout {
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView.setText(label);
textView.setGravity(GRAVITY_CENTER);
textView.setTextColor(getResources().getColor(R.color.separationColor));
addTab(newTab().setCustomView(textView));
View tabView = linearLayout.getChildAt(linearLayout.getChildCount() - 1);

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/record_transaction_layout_background_transfer">
<TextView
android:text="transfer fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>
</RelativeLayout>

View File

@ -20,7 +20,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:hint="@string/activity_add_amount"/>
android:hint="@string/activity_amount"/>
</android.support.design.widget.TextInputLayout>

View File

@ -20,7 +20,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:hint="@string/activity_add_amount"/>
android:hint="@string/activity_amount"/>
</android.support.design.widget.TextInputLayout>

View File

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/record_transaction_layout_background_transfer">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin"
android:orientation="vertical">
<Spinner
android:id="@+id/from_transfer_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_amount_transfert"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/amount_editText_transfert"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:hint="@string/activity_amount"/>
</android.support.design.widget.TextInputLayout>
<Spinner
android:id="@+id/to_transfer_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_transfertDate"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/transfertDate_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/activity_transfert_date"
android:focusable="false"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_fees_transfert"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/fees_editText_transfert"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:hint="@string/activity_fees"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_note_transfert"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/note_editText_transfert"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/notes"
android:maxLines="4"
android:lines="4"
android:gravity="top"/>
</android.support.design.widget.TextInputLayout>
<android.support.v7.widget.AppCompatButton
android:id="@+id/saveTransfertButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:text="@string/save"
android:layout_marginBottom="@dimen/mdtp_minimum_margin_top_bottom"
android:layout_gravity="end"
style="@style/Widget.AppCompat.Button.Colored"/>
</LinearLayout>
</ScrollView>

View File

@ -15,7 +15,7 @@
<string name="pref_title_enable_synchronization_gdax">Activer la synchronisation</string>
<string name="pref_title_gdax_publickey">Clé public</string>
<string name="pref_title_gdax_privatekey">Clé privée</string>
<string name="activity_add_amount">Montant</string>
<string name="activity_amount">Montant</string>
<string name="activity_purchase_price">Prix d\'achat</string>
<string name="activity_purchase_date">Date d\'achat</string>
<string name="activity_fees">Frais</string>
@ -116,6 +116,24 @@
<item>6 mois</item>
<item>1 année</item>
</string-array>
<string-array name="from_transfer_options_string_array">
<item>Site d'échange</item>
<item>Mon portefeuille</item>
<item>Minage</item>
<item>Le portefeuille de quelqu'un d'autre</item>
<item>Airdrop</item>
<item>Autre / Inconnu</item>
<item>Fork</item>
</string-array>
<string-array name="to_transfer_options_string_array">
<item>Site d'échange</item>
<item>Mon portefeuille</item>
<item>Le portefeuille de quelqu'un d'autre</item>
<item>Autre / Inconnu</item>
</string-array>
<string name="emitedPlaceholder">Pourcentage de coin émis : %1$s%%</string>
<string name="edit_transaction">Edition d\'une transaction de %1$s</string>
<string name="new_transaction">Nouvelle transaction</string>

View File

@ -126,7 +126,7 @@
<string name="pref_title_exchange_kraken" translatable="false">Kraken</string>
<!--Add transaction activity-->
<string name="activity_add_amount">Amount</string>
<string name="activity_amount">Amount</string>
<string name="activity_purchase_price">Purchase price</string>
<string name="activity_purchase_date">Purchase date</string>
<string name="activity_fees">Fees</string>
@ -157,6 +157,23 @@
<item>API keys</item>
</string-array>
<string-array name="from_transfer_options_string_array">
<item>Exchange</item>
<item>My wallet</item>
<item>Mining</item>
<item>Someone else\'s wallet</item>
<item>Airdrop</item>
<item>Other / Unknown</item>
<item>Fork</item>
</string-array>
<string-array name="to_transfer_options_string_array">
<item>Exchange</item>
<item>My wallet</item>
<item>Someone else\'s wallet</item>
<item>Other / Unknown</item>
</string-array>
<!--Cardview placeholders-->
<string name="currencySymbolPlaceholder" translatable="false">(%1$s)</string>
<string name="currencyBalancePlaceholder" translatable="false">%1$s%2$s</string>
@ -273,5 +290,6 @@
<string name="percentageFee">%1$s fixed</string>
<string name="activity_sell_price">Sell price</string>
<string name="activity_sell_date">Sell date</string>
<string name="activity_transfert_date">Date of transfert</string>
</resources>