diff --git a/app/build.gradle b/app/build.gradle index 2041774..60f8f7a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,4 +29,5 @@ dependencies { implementation 'com.android.support.constraint:constraint-layout:1.0.2' implementation 'com.android.support:design:25.4.0' compile 'com.getbase:floatingactionbutton:1.10.1' + implementation 'com.android.support:cardview-v7:25.4.0' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ae36000..1b40fe2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -4,7 +4,9 @@ - + - + + + + + + + - + + + + diff --git a/app/src/main/java/com/codigoparallevar/minicards/CanvasView.java b/app/src/main/java/com/codigoparallevar/minicards/CanvasView.java index e808942..03d78d8 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/CanvasView.java +++ b/app/src/main/java/com/codigoparallevar/minicards/CanvasView.java @@ -34,7 +34,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; -import java.io.ObjectStreamException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -63,7 +62,7 @@ class CanvasView extends View implements PartGrid { private String name = "default"; private final static float touchTimeForLongTouchInMillis = 500; private boolean _isDragging = false; - private MainActivity parentActivity = null; + private CardActivity parentActivity = null; private Tuple4 _dropToRemoveZone = new Tuple4<>(0, 0, 0, 0); private boolean _devMode = false; @@ -458,7 +457,7 @@ class CanvasView extends View implements PartGrid { return _isDragging; } - public void setParentActivity(MainActivity parentActivity) { + public void setParentActivity(CardActivity parentActivity) { this.parentActivity = parentActivity; } diff --git a/app/src/main/java/com/codigoparallevar/minicards/MainActivity.java b/app/src/main/java/com/codigoparallevar/minicards/CardActivity.java similarity index 77% rename from app/src/main/java/com/codigoparallevar/minicards/MainActivity.java rename to app/src/main/java/com/codigoparallevar/minicards/CardActivity.java index 390660a..320fc68 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/MainActivity.java +++ b/app/src/main/java/com/codigoparallevar/minicards/CardActivity.java @@ -1,17 +1,17 @@ package com.codigoparallevar.minicards; -import android.app.Dialog; -import android.content.DialogInterface; +import android.content.Intent; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.ActionBar; -import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.MotionEvent; import android.view.View; -public class MainActivity extends AppCompatActivity { +public class CardActivity extends AppCompatActivity { + + public final static String INTENT = "com.codigoparallevar.minicards.CARD"; CanvasView canvasView; com.getbase.floatingactionbutton.AddFloatingActionButton AddPartButton; @@ -21,6 +21,8 @@ public class MainActivity extends AppCompatActivity { com.getbase.floatingactionbutton.FloatingActionsMenu devFabMenu; com.getbase.floatingactionbutton.FloatingActionsMenu userFabMenu; + com.getbase.floatingactionbutton.FloatingActionButton ShowDeckFromDevModeButton; + com.getbase.floatingactionbutton.FloatingActionButton ShowDeckFromUserModeButton; boolean devMode = false; FloatingActionButton removePartFab; @@ -78,7 +80,27 @@ public class MainActivity extends AppCompatActivity { SetDevModeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - MainActivity.this.setDevMode(true); + CardActivity.this.setDevMode(true); + } + }); + + ShowDeckFromDevModeButton = (com.getbase.floatingactionbutton.FloatingActionButton) + findViewById(R.id.show_deck_from_dev_mode_button); + ShowDeckFromDevModeButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent i = new Intent(DeckPreviewActivity.INTENT); + CardActivity.this.startActivity(i); + } + }); + + ShowDeckFromUserModeButton = (com.getbase.floatingactionbutton.FloatingActionButton) + findViewById(R.id.show_deck_from_user_mode_button); + ShowDeckFromUserModeButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent i = new Intent(DeckPreviewActivity.INTENT); + CardActivity.this.startActivity(i); } }); @@ -87,7 +109,7 @@ public class MainActivity extends AppCompatActivity { SetUserModeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - MainActivity.this.setDevMode(false); + CardActivity.this.setDevMode(false); } }); @@ -120,7 +142,7 @@ public class MainActivity extends AppCompatActivity { return canvasView.onTouchEvent(event); } - Log.e("MainActivity", "CanvasView is null"); + Log.e("CardActivity", "CanvasView is null"); return super.onTouchEvent(event); } diff --git a/app/src/main/java/com/codigoparallevar/minicards/CardPreviewArrayAdapter.java b/app/src/main/java/com/codigoparallevar/minicards/CardPreviewArrayAdapter.java new file mode 100644 index 0000000..bde2739 --- /dev/null +++ b/app/src/main/java/com/codigoparallevar/minicards/CardPreviewArrayAdapter.java @@ -0,0 +1,49 @@ +package com.codigoparallevar.minicards; + +import android.content.Context; +import android.content.Intent; +import android.support.annotation.NonNull; +import android.support.v7.widget.CardView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.TextView; + +class CardPreviewArrayAdapter extends ArrayAdapter { + private final PreviewCard[] cards; + + public CardPreviewArrayAdapter(@NonNull Context context, PreviewCard[] cards) { + super(context, R.layout.card_preview); + + this.cards = cards; + } + + @Override + public int getCount() { + return this.cards.length; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + View row = inflater.inflate(R.layout.card_preview, parent, false); + PreviewCard card = this.cards[position]; + + row.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent i = new Intent(CardActivity.INTENT); + CardPreviewArrayAdapter.this.getContext().startActivity(i); + } + }); + CardView cardView = (CardView) row.findViewById(R.id.card_preview_card); + TextView nameView = (TextView) row.findViewById(R.id.card_preview_name); + + cardView.setBackgroundColor(card.getColor()); + nameView.setText(card.getName()); + nameView.setTextColor(0xFFFFFF ^ card.getColor()); + + return row; + } +} diff --git a/app/src/main/java/com/codigoparallevar/minicards/DeckPreviewActivity.java b/app/src/main/java/com/codigoparallevar/minicards/DeckPreviewActivity.java new file mode 100644 index 0000000..783c1f4 --- /dev/null +++ b/app/src/main/java/com/codigoparallevar/minicards/DeckPreviewActivity.java @@ -0,0 +1,46 @@ +package com.codigoparallevar.minicards; + +import android.graphics.Color; +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.View; +import android.widget.ListView; + +public class DeckPreviewActivity extends AppCompatActivity { + + public static final String INTENT = "com.codigoparallevar.minicards.DECK"; + private ListView listView; + private CardPreviewArrayAdapter cardArrayAdapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_deck_preview); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.create_new_card_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(); + } + }); + + listView = (ListView) findViewById(R.id.card_deck_list); + + cardArrayAdapter = new CardPreviewArrayAdapter(getApplicationContext(), new PreviewCard[]{ + new PreviewCard("Default", 0, PreviewCard.DEFAULT_COLOR), + new PreviewCard("Second", 1, Color.parseColor("#FF00FF")), + new PreviewCard("Greenie", 2, Color.parseColor("#00FF00")), + }); + + listView.setAdapter(cardArrayAdapter); + + } + +} diff --git a/app/src/main/java/com/codigoparallevar/minicards/PreviewCard.java b/app/src/main/java/com/codigoparallevar/minicards/PreviewCard.java new file mode 100644 index 0000000..1e198b5 --- /dev/null +++ b/app/src/main/java/com/codigoparallevar/minicards/PreviewCard.java @@ -0,0 +1,28 @@ +package com.codigoparallevar.minicards; + +import android.graphics.Color; + +class PreviewCard { + public static final int DEFAULT_COLOR = Color.parseColor("#044563"); + private final String name; + private final int cardId; + private final int color; + + public PreviewCard(String name, int cardId, int color) { + this.name = name; + this.cardId = cardId; + this.color = color; + } + + public String getName() { + return name; + } + + public int getCardId() { + return cardId; + } + + public int getColor() { + return color; + } +} diff --git a/app/src/main/res/drawable-hdpi/ic_add_black.png b/app/src/main/res/drawable-hdpi/ic_add_black.png new file mode 100644 index 0000000..a84106b Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_add_black.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_add_black.png b/app/src/main/res/drawable-mdpi/ic_add_black.png new file mode 100644 index 0000000..3191d52 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_add_black.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_add_black.png b/app/src/main/res/drawable-xhdpi/ic_add_black.png new file mode 100644 index 0000000..3cb1092 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_add_black.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_add_black.png b/app/src/main/res/drawable-xxhdpi/ic_add_black.png new file mode 100644 index 0000000..60cbd9c Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_add_black.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_add_black.png b/app/src/main/res/drawable-xxxhdpi/ic_add_black.png new file mode 100644 index 0000000..1e1e4d6 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_add_black.png differ diff --git a/app/src/main/res/layout/activity_deck_preview.xml b/app/src/main/res/layout/activity_deck_preview.xml new file mode 100644 index 0000000..8b41796 --- /dev/null +++ b/app/src/main/res/layout/activity_deck_preview.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index aed2bfe..99f5b30 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -6,7 +6,7 @@ xmlns:fab="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context="com.codigoparallevar.minicards.MainActivity"> + tools:context="com.codigoparallevar.minicards.CardActivity">