diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 9b9448c..b761e37 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/ExchangeListActivity.java b/app/src/main/java/com/herbron/moodl/Activities/ExchangeListActivity.java new file mode 100644 index 0000000..053a6f6 --- /dev/null +++ b/app/src/main/java/com/herbron/moodl/Activities/ExchangeListActivity.java @@ -0,0 +1,70 @@ +package com.herbron.moodl.Activities; + +import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.MenuItem; +import android.view.View; +import android.widget.ListView; + +import com.herbron.moodl.DataManagers.DatabaseManager; +import com.herbron.moodl.DataManagers.ExchangeManager.Exchange; +import com.herbron.moodl.LayoutManagers.ExchangeListAdapter; +import com.herbron.moodl.R; + +import java.util.ArrayList; +import java.util.List; + +import static com.herbron.moodl.DataManagers.DatabaseManager.BINANCE_TYPE; +import static com.herbron.moodl.DataManagers.DatabaseManager.HITBTC_TYPE; + +public class ExchangeListActivity extends AppCompatActivity { + + private DatabaseManager databaseManager; + private ListView exchangeListView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_exchange_list); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayShowHomeEnabled(true); + + databaseManager = new DatabaseManager(this); + + ArrayList exchangeList = new ArrayList<>(); + exchangeList.add(new Exchange(0, "Main account", BINANCE_TYPE, "Account with main balance & trading bot", "0000", "0000")); + exchangeList.add(new Exchange(1, "Hit account", HITBTC_TYPE, "BCN account and HIT", "0001", "0001")); + + ExchangeListAdapter exchangeListAdapter = new ExchangeListAdapter(getApplicationContext(), exchangeList); + + exchangeListView = findViewById(R.id.exchange_listView); + exchangeListView.setAdapter(exchangeListAdapter); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if (id == android.R.id.home) { + finish(); + return true; + } + + return super.onOptionsItemSelected(item); + } + +} diff --git a/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java b/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java index a08fd4f..ec09c8b 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java +++ b/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java @@ -6,6 +6,7 @@ import android.app.AlertDialog; import android.app.KeyguardManager; import android.content.Context; import android.content.DialogInterface; +import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.Configuration; @@ -234,7 +235,9 @@ public class SettingsActivity extends AppCompatPreferenceActivity { @Override public boolean onPreferenceChange(Preference preference, Object o) { - return false; + Log.d("moodl", "> " + o + " " + preference); + + return (boolean) o; } }); @@ -777,6 +780,17 @@ public class SettingsActivity extends AppCompatPreferenceActivity { } }); + findPreference("exchange").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + + Intent exchangeListIntent = new Intent(getContext(), ExchangeListActivity.class); + startActivity(exchangeListIntent); + + return false; + } + }); + EditTextPreference editTextPreference = (EditTextPreference) findPreference("minimum_value_displayed"); editTextPreference.setPositiveButtonText(getString(R.string.save)); editTextPreference.setNegativeButtonText(getString(R.string.cancel)); @@ -832,6 +846,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity { //startActivity(new Intent(getActivity(), SettingsActivity.class)); return true; } + return super.onOptionsItemSelected(item); } } diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/Exchange.java b/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/Exchange.java new file mode 100644 index 0000000..173a316 --- /dev/null +++ b/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/Exchange.java @@ -0,0 +1,31 @@ +package com.herbron.moodl.DataManagers.ExchangeManager; + +public class Exchange { + + protected int id; + protected String name; + protected int type; + protected String description; + protected String publicKey; + protected String privateKey; + + public Exchange(int id, String name, int type, String description, String publicKey, String privateKey) + { + this.id = id; + this.name = name; + this.type = type; + this.description = description; + this.publicKey = publicKey; + this.privateKey = privateKey; + } + + public String getName() + { + return name; + } + + public String getDescription() + { + return description; + } +} diff --git a/app/src/main/java/com/herbron/moodl/LayoutManagers/ExchangeListAdapter.java b/app/src/main/java/com/herbron/moodl/LayoutManagers/ExchangeListAdapter.java new file mode 100644 index 0000000..5c7bfe3 --- /dev/null +++ b/app/src/main/java/com/herbron/moodl/LayoutManagers/ExchangeListAdapter.java @@ -0,0 +1,53 @@ +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.BaseAdapter; +import android.widget.Filter; +import android.widget.Filterable; +import android.widget.TextView; + +import com.herbron.moodl.DataManagers.CurrencyData.Currency; +import com.herbron.moodl.DataManagers.CurrencyData.Trade; +import com.herbron.moodl.DataManagers.ExchangeManager.Exchange; +import com.herbron.moodl.R; + +import java.util.ArrayList; + +import static com.herbron.moodl.MoodlBox.getDateFromTimestamp; + +public class ExchangeListAdapter extends ArrayAdapter { + + private Context context; + + public ExchangeListAdapter(Context context, ArrayList exchanges) + { + super(context, android.R.layout.simple_list_item_1, exchanges); + this.context = context; + } + + @NonNull + @Override + public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + Exchange exchange = getItem(position); + + if(convertView == null) + { + convertView = LayoutInflater.from(getContext()).inflate(R.layout.exchange_cell, parent, false); + } + + TextView exchangeNameTextView = convertView.findViewById(R.id.exchange_name); + TextView exchangeDescriptionTextView = convertView.findViewById(R.id.exchange_description); + + exchangeNameTextView.setText(exchange.getName()); + exchangeDescriptionTextView.setText(exchange.getDescription()); + + return convertView; + } + +} diff --git a/app/src/main/res/layout/activity_exchange_list.xml b/app/src/main/res/layout/activity_exchange_list.xml new file mode 100644 index 0000000..191ec64 --- /dev/null +++ b/app/src/main/res/layout/activity_exchange_list.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/content_exchange_list.xml b/app/src/main/res/layout/content_exchange_list.xml new file mode 100644 index 0000000..be2d1e7 --- /dev/null +++ b/app/src/main/res/layout/content_exchange_list.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/exchange_cell.xml b/app/src/main/res/layout/exchange_cell.xml new file mode 100644 index 0000000..e7ffe0e --- /dev/null +++ b/app/src/main/res/layout/exchange_cell.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml index bd9495e..7772bd9 100644 --- a/app/src/main/res/xml/pref_main.xml +++ b/app/src/main/res/xml/pref_main.xml @@ -39,7 +39,6 @@ android:title="@string/pref_title_category_synchronization">