diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index c5e64de..539eba9 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/app/src/main/java/com/herbron/moodl/Activities/CurrencySelectionActivity.java b/app/src/main/java/com/herbron/moodl/Activities/CurrencySelectionActivity.java index caa2cd1..fe59f75 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/CurrencySelectionActivity.java +++ b/app/src/main/java/com/herbron/moodl/Activities/CurrencySelectionActivity.java @@ -21,7 +21,7 @@ import com.herbron.moodl.DataManagers.CurrencyData.Currency; import com.herbron.moodl.DataManagers.CurrencyData.CurrencyDetailsList; import com.herbron.moodl.DataManagers.DatabaseManager; import com.herbron.moodl.DataManagers.PreferencesManager; -import com.herbron.moodl.LayoutManagers.CurrencyListAdapter; +import com.herbron.moodl.LayoutManagers.CoinWatchlistAdapter; import com.herbron.moodl.R; import java.util.ArrayList; @@ -29,7 +29,7 @@ import java.util.List; public class CurrencySelectionActivity extends AppCompatActivity implements SearchView.OnQueryTextListener{ - private CurrencyListAdapter adapter; + private CoinWatchlistAdapter adapter; private ListView listView; private android.widget.Filter filter; private CurrencyDetailsList currencyDetailsList; @@ -77,7 +77,7 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear currencyArrayList.add(new Currency(currencyNames.get(i), currencySymbols.get(i))); } - adapter = new CurrencyListAdapter(this, currencyArrayList); + adapter = new CoinWatchlistAdapter(this, currencyArrayList); } private void setupList() diff --git a/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Watchlist.java b/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Watchlist.java index d7af59d..d9d9ffd 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Watchlist.java +++ b/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Watchlist.java @@ -19,8 +19,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.LinearLayout; import com.herbron.moodl.Activities.CurrencySelectionActivity; import com.herbron.moodl.Activities.HomeActivity; @@ -42,7 +40,6 @@ import org.json.JSONObject; import static com.herbron.moodl.MoodlBox.collapseW; import static com.herbron.moodl.MoodlBox.expandW; import static com.herbron.moodl.MoodlBox.getColor; -import static java.lang.Math.abs; /** * Created by Tiji on 13/04/2018. diff --git a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionActivity.java b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionActivity.java index b904cee..bd47fd0 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionActivity.java +++ b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionActivity.java @@ -1,34 +1,60 @@ package com.herbron.moodl.Activities; +import android.app.Activity; import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.AsyncTask; import android.os.Bundle; +import android.support.design.widget.TabLayout; import android.support.design.widget.TextInputLayout; +import android.support.v4.view.PagerAdapter; +import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; +import android.support.v7.graphics.Palette; import android.support.v7.widget.SearchView; import android.support.v7.widget.Toolbar; +import android.text.Editable; +import android.text.TextWatcher; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; +import android.view.inputmethod.InputMethodManager; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.AutoCompleteTextView; import android.widget.Button; import android.widget.DatePicker; import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.TabWidget; import android.widget.TextView; import android.widget.TimePicker; import com.herbron.moodl.DataManagers.CurrencyData.Currency; +import com.herbron.moodl.DataManagers.CurrencyData.CurrencyDetailsList; import com.herbron.moodl.DataManagers.CurrencyData.Transaction; import com.herbron.moodl.DataManagers.DatabaseManager; import com.herbron.moodl.DataManagers.PreferencesManager; +import com.herbron.moodl.LayoutManagers.CoinSummaryListAdapter; +import com.herbron.moodl.LayoutManagers.CustomTabLayout; +import com.herbron.moodl.LayoutManagers.RecordTransactionPageAdapter; +import com.herbron.moodl.MoodlBox; import com.herbron.moodl.PlaceholderManager; import com.herbron.moodl.R; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Calendar; import java.util.Locale; +import static com.herbron.moodl.MoodlBox.getColor; + public class RecordTransactionActivity extends AppCompatActivity { private String coin; @@ -49,14 +75,12 @@ public class RecordTransactionActivity extends AppCompatActivity { private Currency currency; private int transactionId; - private SearchView mainSearchView; + private Toolbar toolbar; + private ImageView currencyIconImageView; - @Override - public boolean onCreateOptionsMenu(Menu menu) { - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.menu_record_action, menu); - return true; - } + private CurrencyDetailsList currencyDetailsList; + + private SearchView mainSearchView; /*@Override public boolean onOptionsItemSelected(MenuItem item) { @@ -171,10 +195,134 @@ public class RecordTransactionActivity extends AppCompatActivity { transactionId = intent.getIntExtra("transactionId", -1); - Toolbar toolbar = findViewById(R.id.searchCurrencyToolbar); + toolbar = findViewById(R.id.toolbar); + + currencyIconImageView = findViewById(R.id.currencyIconImageView); setSupportActionBar(toolbar); + setupAutoCompleteTextView(); + + setupBackButton(); + + CustomTabLayout tabLayout = findViewById(R.id.transactionsTabLayout); + tabLayout.addTab(0, "Buy"); + tabLayout.addTab(1, "Sell"); + tabLayout.addTab(2, "Transfer"); + tabLayout.setTabGravity(TabLayout.GRAVITY_FILL); + + final ViewPager viewPager = findViewById(R.id.transactionsViewPager); + final RecordTransactionPageAdapter pageAdapter = new RecordTransactionPageAdapter(getSupportFragmentManager(), tabLayout.getTabCount()); + viewPager.setAdapter(pageAdapter); + viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); + tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { + @Override + public void onTabSelected(TabLayout.Tab tab) { + viewPager.setCurrentItem(tab.getPosition()); + } + + @Override + public void onTabUnselected(TabLayout.Tab tab) { + + } + + @Override + public void onTabReselected(TabLayout.Tab tab) { + + } + }); + } + + private void setupAutoCompleteTextView() + { + currencyDetailsList = CurrencyDetailsList.getInstance(this); + + CoinSummaryListAdapter adapter = new CoinSummaryListAdapter(this, R.layout.custom_summary_coin_row, new ArrayList<>(currencyDetailsList.getCurrenciesDenomination())); + + AutoCompleteTextView coin_autoCompleteTextView = findViewById(R.id.coin_autoCompleteTextView); + coin_autoCompleteTextView.setThreshold(0); + coin_autoCompleteTextView.setAdapter(adapter); + coin_autoCompleteTextView.setTextColor(getResources().getColor(R.color.white)); + coin_autoCompleteTextView.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + currencyIconImageView.setImageBitmap(null); + } + + @Override + public void afterTextChanged(Editable s) { + + } + }); + coin_autoCompleteTextView.setOnFocusChangeListener(new View.OnFocusChangeListener() { + @Override + public void onFocusChange(View v, boolean hasFocus) { + if(hasFocus) + { + coin_autoCompleteTextView.showDropDown(); + } + else + { + coin_autoCompleteTextView.dismissDropDown(); + } + } + }); + + coin_autoCompleteTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + Currency currency = (Currency) coin_autoCompleteTextView.getAdapter().getItem(position); + + coin_autoCompleteTextView.setText(PlaceholderManager.getDenomination(currency.getName(), currency.getSymbol(), getBaseContext())); + toolbar.requestFocus(); + hideSoftKeyboard(RecordTransactionActivity.this); + + RecordTransactionActivity.this.currency = currency; + + IconDownloaderTask iconDownloaderTask = new IconDownloaderTask(); + iconDownloaderTask.execute(); + } + }); + } + + private class IconDownloaderTask extends AsyncTask { + + @Override + protected Void doInBackground(Void... voids) { + String iconUrl = MoodlBox.getIconUrl(currency.getSymbol(), 500, currencyDetailsList); + + if(iconUrl != null) + { + MoodlBox.getBitmapFromURL(iconUrl, currency.getSymbol(), getResources(), getBaseContext(), new HomeActivity.IconCallBack() { + @Override + public void onSuccess(Bitmap bitmapIcon) { + runOnUiThread(new Runnable() { + @Override + public void run() { + currencyIconImageView.setImageBitmap(bitmapIcon); + } + }); + } + }); + } + else + { + runOnUiThread(new Runnable() { + @Override + public void run() { + currencyIconImageView.setBackground(getResources().getDrawable(R.mipmap.ic_launcher_moodl)); + } + }); + } + return null; + } + } + /*if(transactionId != -1) { setTitle(PlaceholderManager.getEditTransactionString(coin, getBaseContext())); @@ -222,6 +370,13 @@ public class RecordTransactionActivity extends AppCompatActivity { purchasedPriceEditText.setText(price); } }, calendar.getTimeInMillis() / 1000);*/ + + public static void hideSoftKeyboard(Activity activity) { + InputMethodManager inputMethodManager = + (InputMethodManager) activity.getSystemService( + Activity.INPUT_METHOD_SERVICE); + inputMethodManager.hideSoftInputFromWindow( + activity.getCurrentFocus().getWindowToken(), 0); } /*private void initializeButtons() @@ -272,6 +427,17 @@ public class RecordTransactionActivity extends AppCompatActivity { transferButton = findViewById(R.id.transfertButton); }*/ + private void setupBackButton() + { + ImageButton backButton = findViewById(R.id.back_button); + backButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + } + private void createDatePicker() { new android.app.DatePickerDialog( diff --git a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java new file mode 100644 index 0000000..7ea78b1 --- /dev/null +++ b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java @@ -0,0 +1,21 @@ +package com.herbron.moodl.Activities.RecordTransactionFragments; + +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.herbron.moodl.R; + +public class BuyFragment extends Fragment { + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_buy, container, false); + return view; + } +} diff --git a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/SellFragment.java b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/SellFragment.java new file mode 100644 index 0000000..fd3a83f --- /dev/null +++ b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/SellFragment.java @@ -0,0 +1,21 @@ +package com.herbron.moodl.Activities.RecordTransactionFragments; + +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.herbron.moodl.R; + +public class SellFragment extends Fragment { + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_sell, container, false); + return view; + } +} diff --git a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/TransferFragment.java b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/TransferFragment.java new file mode 100644 index 0000000..49f2b2b --- /dev/null +++ b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/TransferFragment.java @@ -0,0 +1,21 @@ +package com.herbron.moodl.Activities.RecordTransactionFragments; + +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.herbron.moodl.R; + +public class TransferFragment extends Fragment { + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_transfer, container, false); + return view; + } +} diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyDetailsList.java b/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyDetailsList.java index c3d9aab..2b0e016 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyDetailsList.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyDetailsList.java @@ -167,6 +167,23 @@ public class CurrencyDetailsList { return currenciesName; } + public List getCurrenciesDenomination() + { + List currencies = new ArrayList<>(); + + for(String symbol : coinInfosHashmap.keySet()) + { + try { + JSONObject jsonObject = new JSONObject(coinInfosHashmap.get(symbol)); + currencies.add(new Currency(jsonObject.getString("CoinName"), symbol)); + } catch (JSONException e) { + e.printStackTrace(); + } + } + + return currencies; + } + public Currency getCurrencyDetailsFromSymbol(String symbol) { //Currency currency = new Currency(); diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/BinanceManager.java b/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/BinanceManager.java index 937b2cb..152d21f 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/BinanceManager.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/BinanceManager.java @@ -56,7 +56,8 @@ public class BinanceManager extends Exchange { { if(Double.parseDouble(assets.get(i).getFree()) > 0 || Double.parseDouble(assets.get(i).getLocked()) > 0) { - if(!assets.get(i).getAsset().equals("VET")) + //balance.add(new Currency(assets.get(i).getAsset(), Double.parseDouble(assets.get(i).getFree()) + Double.parseDouble(assets.get(i).getLocked()))); + if(!assets.get(i).getAsset().equals("VEN")) { balance.add(new Currency(assets.get(i).getAsset(), Double.parseDouble(assets.get(i).getFree()) + Double.parseDouble(assets.get(i).getLocked()))); } diff --git a/app/src/main/java/com/herbron/moodl/LayoutManagers/CoinSummaryListAdapter.java b/app/src/main/java/com/herbron/moodl/LayoutManagers/CoinSummaryListAdapter.java new file mode 100644 index 0000000..4f5285d --- /dev/null +++ b/app/src/main/java/com/herbron/moodl/LayoutManagers/CoinSummaryListAdapter.java @@ -0,0 +1,120 @@ +package com.herbron.moodl.LayoutManagers; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.Filter; +import android.widget.TextView; + +import com.herbron.moodl.DataManagers.CurrencyData.Currency; +import com.herbron.moodl.R; + +import java.util.ArrayList; + +public class CoinSummaryListAdapter extends ArrayAdapter { + + private CustomFilter filter; + private ArrayList currencies, suggestions; + + public CoinSummaryListAdapter(@NonNull Context context, int resource, @NonNull ArrayList currencies) { + super(context, resource, currencies); + + this.currencies = currencies; + this.suggestions = currencies; + } + + @Override + public int getCount() { + return currencies.size(); + } + + @Override + public Currency getItem(int position) { + return currencies.get(position); + } + + @Override + public long getItemId(int position) { + return currencies.indexOf(getItem(position)); + } + + @NonNull + @Override + public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + Currency currency = getItem(position); + + if(convertView == null) + { + convertView = LayoutInflater.from(getContext()).inflate(R.layout.custom_summary_coin_row, parent, false); + } + + TextView nameTxtview = convertView.findViewById(R.id.currencyName); + TextView symbolTxtView = convertView.findViewById(R.id.currencySymbol); + + nameTxtview.setText(currency.getName()); + symbolTxtView.setText(currency.getSymbol()); + + return convertView; + } + + @NonNull + @Override + public Filter getFilter() { + if(filter == null) + { + filter = new CustomFilter(); + } + + return filter; + } + + class CustomFilter extends Filter + { + + @Override + protected FilterResults performFiltering(CharSequence constraint) { + FilterResults results = new FilterResults(); + + if(constraint != null && constraint.length() > 0) + { + constraint = constraint.toString().toLowerCase(); + + ArrayList filters = new ArrayList<>(); + + for(int i = 0; i < suggestions.size(); i++) + { + if(suggestions.get(i).getName().toLowerCase().contains(constraint) || suggestions.get(i).getSymbol().toLowerCase().contains(constraint)) + { + Currency currency = new Currency(suggestions.get(i).getName(), suggestions.get(i).getSymbol()); + + filters.add(currency); + } + } + + results.count = filters.size(); + results.values = filters; + } + else + { + results.count = suggestions.size(); + results.values = suggestions; + } + + return results; + } + + @Override + protected void publishResults(CharSequence constraint, FilterResults results) { + if(results != null) + { + currencies = (ArrayList) results.values; + } + + notifyDataSetChanged(); + } + } +} diff --git a/app/src/main/java/com/herbron/moodl/LayoutManagers/CurrencyListAdapter.java b/app/src/main/java/com/herbron/moodl/LayoutManagers/CoinWatchlistAdapter.java similarity index 93% rename from app/src/main/java/com/herbron/moodl/LayoutManagers/CurrencyListAdapter.java rename to app/src/main/java/com/herbron/moodl/LayoutManagers/CoinWatchlistAdapter.java index cf18847..a191f43 100644 --- a/app/src/main/java/com/herbron/moodl/LayoutManagers/CurrencyListAdapter.java +++ b/app/src/main/java/com/herbron/moodl/LayoutManagers/CoinWatchlistAdapter.java @@ -19,13 +19,13 @@ import java.util.ArrayList; * Created by Guitoune on 17/01/2018. */ -public class CurrencyListAdapter extends BaseAdapter implements Filterable { +public class CoinWatchlistAdapter extends BaseAdapter implements Filterable { private ArrayList currencies, suggestions; private Context context; private CustomFilter filter; - public CurrencyListAdapter(Context context, ArrayList currencies) { + public CoinWatchlistAdapter(Context context, ArrayList currencies) { this.context = context; this.currencies = currencies; this.suggestions = currencies; @@ -53,7 +53,7 @@ public class CurrencyListAdapter extends BaseAdapter implements Filterable { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (convertView == null) { - convertView = inflater.inflate(R.layout.custom_currency_row, parent, false); + convertView = inflater.inflate(R.layout.custom_watchlist_coin_row, parent, false); } TextView currencyName = convertView.findViewById(R.id.currencyName); diff --git a/app/src/main/java/com/herbron/moodl/LayoutManagers/CustomTabLayout.java b/app/src/main/java/com/herbron/moodl/LayoutManagers/CustomTabLayout.java new file mode 100644 index 0000000..5eb3791 --- /dev/null +++ b/app/src/main/java/com/herbron/moodl/LayoutManagers/CustomTabLayout.java @@ -0,0 +1,86 @@ +package com.herbron.moodl.LayoutManagers; + +import android.content.Context; +import android.graphics.drawable.StateListDrawable; +import android.support.design.widget.TabLayout; +import android.support.v4.content.ContextCompat; +import android.util.AttributeSet; +import android.util.TypedValue; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.herbron.moodl.R; + +public class CustomTabLayout extends TabLayout { + + private LinearLayout linearLayout; + private Context context; + + public CustomTabLayout(Context context, AttributeSet attrs) { + super(context, attrs); + linearLayout = (LinearLayout) getChildAt(0); + this.context = context; + } + + private StateListDrawable getSellStateListDrawable() { + StateListDrawable sld = new StateListDrawable(); + sld.addState(new int[] {android.R.attr.state_pressed}, + ContextCompat.getDrawable(context, R.drawable.record_transaction_tab_background_sell)); + sld.addState(new int[] {android.R.attr.state_selected}, + ContextCompat.getDrawable(context, R.drawable.record_transaction_tab_background_sell)); + sld.addState(new int[] { }, + ContextCompat.getDrawable(context, R.drawable.unselected_tab_background)); + return sld; + } + + private StateListDrawable getBuyStateListDrawable() { + StateListDrawable sld = new StateListDrawable(); + sld.addState(new int[] {android.R.attr.state_pressed}, + ContextCompat.getDrawable(context, R.drawable.record_transaction_tab_background_buy)); + sld.addState(new int[] {android.R.attr.state_selected}, + ContextCompat.getDrawable(context, R.drawable.record_transaction_tab_background_buy)); + sld.addState(new int[] { }, + ContextCompat.getDrawable(context, R.drawable.unselected_tab_background)); + return sld; + } + + private StateListDrawable getTransferStateListDrawable() { + StateListDrawable sld = new StateListDrawable(); + sld.addState(new int[] {android.R.attr.state_pressed}, + ContextCompat.getDrawable(context, R.drawable.record_transaction_tab_background_transfer)); + sld.addState(new int[] {android.R.attr.state_selected}, + ContextCompat.getDrawable(context, R.drawable.record_transaction_tab_background_transfer)); + sld.addState(new int[] { }, + ContextCompat.getDrawable(context, R.drawable.unselected_tab_background)); + return sld; + } + + public void addTab(int index, String label) { + TextView textView = new TextView(context); + textView.setTextColor(getResources().getColor(R.color.white)); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + textView.setText(label); + textView.setGravity(GRAVITY_CENTER); + addTab(newTab().setCustomView(textView)); + + View tabView = linearLayout.getChildAt(linearLayout.getChildCount() - 1); + LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) tabView.getLayoutParams(); + params.setMargins(2, 0, 2, 0); + tabView.setLayoutParams(params); + + switch (index) + { + case 0: + tabView.setBackground(getBuyStateListDrawable()); + break; + case 1: + tabView.setBackground(getSellStateListDrawable()); + break; + case 2: + tabView.setBackground(getTransferStateListDrawable()); + break; + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/herbron/moodl/LayoutManagers/RecordTransactionPageAdapter.java b/app/src/main/java/com/herbron/moodl/LayoutManagers/RecordTransactionPageAdapter.java new file mode 100644 index 0000000..5554c61 --- /dev/null +++ b/app/src/main/java/com/herbron/moodl/LayoutManagers/RecordTransactionPageAdapter.java @@ -0,0 +1,44 @@ +package com.herbron.moodl.LayoutManagers; + +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentStatePagerAdapter; + +import com.herbron.moodl.Activities.RecordTransactionFragments.BuyFragment; +import com.herbron.moodl.Activities.RecordTransactionFragments.SellFragment; +import com.herbron.moodl.Activities.RecordTransactionFragments.TransferFragment; + +public class RecordTransactionPageAdapter extends FragmentStatePagerAdapter { + + private int tabsNumber; + + public RecordTransactionPageAdapter(FragmentManager fm, int tabsNumber) { + super(fm); + + this.tabsNumber = tabsNumber; + } + + @Override + public Fragment getItem(int position) { + + switch (position) + { + case 0: + BuyFragment buyFragment = new BuyFragment(); + return buyFragment; + case 1: + SellFragment sellFragment = new SellFragment(); + return sellFragment; + case 2: + TransferFragment transferFragment = new TransferFragment(); + return transferFragment; + default: + return null; + } + } + + @Override + public int getCount() { + return tabsNumber; + } +} diff --git a/app/src/main/java/com/herbron/moodl/PlaceholderManager.java b/app/src/main/java/com/herbron/moodl/PlaceholderManager.java index dba42a1..8bcb242 100644 --- a/app/src/main/java/com/herbron/moodl/PlaceholderManager.java +++ b/app/src/main/java/com/herbron/moodl/PlaceholderManager.java @@ -34,6 +34,11 @@ public class PlaceholderManager { return formattedString; } + public static String getDenomination(String coinName, String coinSymbol, Context context) + { + return context.getResources().getString(R.string.denomincationPlaceholder, coinName, coinSymbol); + } + public static String getEditTransactionString(String coinName, Context context) { return context.getResources().getString(R.string.edit_transaction, coinName); diff --git a/app/src/main/res/drawable/record_transaction_layout_background_buy.xml b/app/src/main/res/drawable/record_transaction_layout_background_buy.xml new file mode 100644 index 0000000..f64f8a4 --- /dev/null +++ b/app/src/main/res/drawable/record_transaction_layout_background_buy.xml @@ -0,0 +1,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/record_transaction_layout_background_sell.xml b/app/src/main/res/drawable/record_transaction_layout_background_sell.xml new file mode 100644 index 0000000..3b4ba96 --- /dev/null +++ b/app/src/main/res/drawable/record_transaction_layout_background_sell.xml @@ -0,0 +1,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/record_transaction_layout_background_transfer.xml b/app/src/main/res/drawable/record_transaction_layout_background_transfer.xml new file mode 100644 index 0000000..18b93e4 --- /dev/null +++ b/app/src/main/res/drawable/record_transaction_layout_background_transfer.xml @@ -0,0 +1,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/record_transaction_tab_background_buy.xml b/app/src/main/res/drawable/record_transaction_tab_background_buy.xml new file mode 100644 index 0000000..6ebf3dd --- /dev/null +++ b/app/src/main/res/drawable/record_transaction_tab_background_buy.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/record_transaction_tab_background_sell.xml b/app/src/main/res/drawable/record_transaction_tab_background_sell.xml new file mode 100644 index 0000000..68b6de1 --- /dev/null +++ b/app/src/main/res/drawable/record_transaction_tab_background_sell.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/record_transaction_tab_background_transfer.xml b/app/src/main/res/drawable/record_transaction_tab_background_transfer.xml new file mode 100644 index 0000000..7811beb --- /dev/null +++ b/app/src/main/res/drawable/record_transaction_tab_background_transfer.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/spinner_background.xml b/app/src/main/res/drawable/spinner_background.xml index 66a69c8..af41d11 100644 --- a/app/src/main/res/drawable/spinner_background.xml +++ b/app/src/main/res/drawable/spinner_background.xml @@ -1,6 +1,5 @@ - + diff --git a/app/src/main/res/drawable/unselected_tab_background.xml b/app/src/main/res/drawable/unselected_tab_background.xml new file mode 100644 index 0000000..ce071fd --- /dev/null +++ b/app/src/main/res/drawable/unselected_tab_background.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_record_transaction.xml b/app/src/main/res/layout/activity_record_transaction.xml index 998c41a..0e140c4 100644 --- a/app/src/main/res/layout/activity_record_transaction.xml +++ b/app/src/main/res/layout/activity_record_transaction.xml @@ -1,135 +1,104 @@ + android:background="@drawable/gradient_background" + style="@style/InputActivityTheme"> - - - - - - + \ No newline at end of file diff --git a/app/src/main/res/layout/custom_summary_coin_row.xml b/app/src/main/res/layout/custom_summary_coin_row.xml new file mode 100644 index 0000000..f8e9709 --- /dev/null +++ b/app/src/main/res/layout/custom_summary_coin_row.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/custom_currency_row.xml b/app/src/main/res/layout/custom_watchlist_coin_row.xml similarity index 100% rename from app/src/main/res/layout/custom_currency_row.xml rename to app/src/main/res/layout/custom_watchlist_coin_row.xml diff --git a/app/src/main/res/layout/exchange_cell.xml b/app/src/main/res/layout/exchange_cell.xml index 7ae26fe..9080a43 100644 --- a/app/src/main/res/layout/exchange_cell.xml +++ b/app/src/main/res/layout/exchange_cell.xml @@ -2,7 +2,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_sell.xml b/app/src/main/res/layout/fragment_sell.xml new file mode 100644 index 0000000..88d790e --- /dev/null +++ b/app/src/main/res/layout/fragment_sell.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_transfer.xml b/app/src/main/res/layout/fragment_transfer.xml new file mode 100644 index 0000000..8c13214 --- /dev/null +++ b/app/src/main/res/layout/fragment_transfer.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2f96301..4a6581c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -178,6 +178,8 @@ %1$s¥ %1$s¥ (%2$s%%) + %1$s (%2$s) + Date\n%1$s Percentage of coin emitted : %1$s%% @@ -256,5 +258,9 @@ API Key Secret Key Informations + Choose a coin + + + Hello blank fragment