diff --git a/app/build.gradle b/app/build.gradle index 175b137..4b9e4d5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,4 +23,6 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' + compile 'com.github.bumptech.glide:glide:3.6.1' + compile 'io.realm:realm-android:0.87.1' } diff --git a/app/src/main/java/slidenerd/vivz/bucketdrops/ActivityMain.java b/app/src/main/java/slidenerd/vivz/bucketdrops/ActivityMain.java index 44bf38b..e836fb2 100644 --- a/app/src/main/java/slidenerd/vivz/bucketdrops/ActivityMain.java +++ b/app/src/main/java/slidenerd/vivz/bucketdrops/ActivityMain.java @@ -1,13 +1,48 @@ package slidenerd.vivz.bucketdrops; -import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; + +import com.bumptech.glide.Glide; public class ActivityMain extends AppCompatActivity { + Toolbar mToolbar; + Button mBtnAdd; + private View.OnClickListener mBtnAddListener = new View.OnClickListener() { + + @Override + public void onClick(View v) { + showDialogAdd(); + } + }; + + private void showDialogAdd() { + DialogAdd dialog = new DialogAdd(); + dialog.show(getSupportFragmentManager(),"Add"); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + mToolbar = (Toolbar) findViewById(R.id.toolbar); + mBtnAdd = (Button) findViewById(R.id.btn_add); + + mBtnAdd.setOnClickListener(mBtnAddListener); + setSupportActionBar(mToolbar); + initBackgroundImage(); + } + + private void initBackgroundImage() { + ImageView background = (ImageView) findViewById(R.id.iv_background); + Glide.with(this) + .load(R.drawable.background) + .centerCrop() + .into(background); } } diff --git a/app/src/main/java/slidenerd/vivz/bucketdrops/DialogAdd.java b/app/src/main/java/slidenerd/vivz/bucketdrops/DialogAdd.java new file mode 100644 index 0000000..f78fb75 --- /dev/null +++ b/app/src/main/java/slidenerd/vivz/bucketdrops/DialogAdd.java @@ -0,0 +1,77 @@ +package slidenerd.vivz.bucketdrops; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v4.app.DialogFragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.DatePicker; +import android.widget.EditText; +import android.widget.ImageButton; + +import io.realm.Realm; +import io.realm.RealmConfiguration; +import slidenerd.vivz.bucketdrops.beans.Drop; + +/** + * Created by vivz on 28/12/15. + */ +public class DialogAdd extends DialogFragment { + + private ImageButton mBtnClose; + private EditText mInputWhat; + private DatePicker mInputWhen; + private Button mBtnAdd; + + private View.OnClickListener mBtnClickListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + int id =v.getId(); + switch (id){ + case R.id.btn_add_it: + addAction(); + break; + } + dismiss(); + } + }; + + private void addAction() { + //get the value of the 'goal' or 'to-do' + //get the time when it was added + String what=mInputWhat.getText().toString(); + long now = System.currentTimeMillis(); + RealmConfiguration configuration=new RealmConfiguration.Builder(getActivity()).build(); + Realm.setDefaultConfiguration(configuration); + Realm realm=Realm.getDefaultInstance(); + Drop drop= new Drop(what, now, 0, false); + realm.beginTransaction(); + realm.copyToRealm(drop); + realm.commitTransaction(); + realm.close(); + + } + + public DialogAdd() { + } + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + return inflater.inflate(R.layout.dialog_add, container, false); + } + + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + mBtnClose = (ImageButton) view.findViewById(R.id.btn_close); + mInputWhat = (EditText) view.findViewById(R.id.et_drop); + mInputWhen = (DatePicker) view.findViewById(R.id.bpv_date); + mBtnAdd = (Button) view.findViewById(R.id.btn_add_it); + + mBtnClose.setOnClickListener(mBtnClickListener); + mBtnAdd.setOnClickListener(mBtnClickListener); + } +} diff --git a/app/src/main/java/slidenerd/vivz/bucketdrops/beans/Drop.java b/app/src/main/java/slidenerd/vivz/bucketdrops/beans/Drop.java new file mode 100644 index 0000000..418802b --- /dev/null +++ b/app/src/main/java/slidenerd/vivz/bucketdrops/beans/Drop.java @@ -0,0 +1,57 @@ +package slidenerd.vivz.bucketdrops.beans; + +import io.realm.RealmObject; +import io.realm.annotations.PrimaryKey; + +/** + * Created by vivz on 30/12/15. + */ +public class Drop extends RealmObject { + public Drop(String what, long added, long when, boolean completed) { + this.what = what; + this.added = added; + this.when = when; + this.completed = completed; + } + + private String what; + @PrimaryKey + private long added; + private long when; + private boolean completed; + + public Drop() { + } + + public String getWhat() { + return what; + } + + public void setWhat(String what) { + this.what = what; + } + + public long getAdded() { + return added; + } + + public void setAdded(long added) { + this.added = added; + } + + public long getWhen() { + return when; + } + + public void setWhen(long when) { + this.when = when; + } + + public boolean isCompleted() { + return completed; + } + + public void setCompleted(boolean completed) { + this.completed = completed; + } +} diff --git a/app/src/main/res/color/btn_add_color.xml b/app/src/main/res/color/btn_add_color.xml new file mode 100644 index 0000000..bcfe559 --- /dev/null +++ b/app/src/main/res/color/btn_add_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-hdpi/ic_close.png b/app/src/main/res/drawable-hdpi/ic_close.png new file mode 100644 index 0000000..0d83919 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_close.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_close.png b/app/src/main/res/drawable-mdpi/ic_close.png new file mode 100644 index 0000000..385abea Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_close.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_close.png b/app/src/main/res/drawable-xhdpi/ic_close.png new file mode 100644 index 0000000..1b79d0b Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_close.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_close.png b/app/src/main/res/drawable-xxhdpi/ic_close.png new file mode 100644 index 0000000..783a624 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_close.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_close.png b/app/src/main/res/drawable-xxxhdpi/ic_close.png new file mode 100644 index 0000000..6e484ec Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_close.png differ diff --git a/app/src/main/res/drawable/android.png b/app/src/main/res/drawable/android.png new file mode 100644 index 0000000..799d0a1 Binary files /dev/null and b/app/src/main/res/drawable/android.png differ diff --git a/app/src/main/res/drawable/background.png b/app/src/main/res/drawable/background.png new file mode 100755 index 0000000..04b98d6 Binary files /dev/null and b/app/src/main/res/drawable/background.png differ diff --git a/app/src/main/res/drawable/bg_btn_add_it.xml b/app/src/main/res/drawable/bg_btn_add_it.xml new file mode 100644 index 0000000..8751a08 --- /dev/null +++ b/app/src/main/res/drawable/bg_btn_add_it.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/logo_large.png b/app/src/main/res/drawable/logo_large.png new file mode 100644 index 0000000..e0cd775 Binary files /dev/null and b/app/src/main/res/drawable/logo_large.png differ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 0e4bb05..e582ca3 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -3,14 +3,18 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingBottom="@dimen/activity_vertical_margin" - android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" tools:context="slidenerd.vivz.bucketdrops.ActivityMain"> - + + + + + + diff --git a/app/src/main/res/layout/dialog_add.xml b/app/src/main/res/layout/dialog_add.xml new file mode 100644 index 0000000..04bd9bc --- /dev/null +++ b/app/src/main/res/layout/dialog_add.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + +