Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4bffaef
Added the Dialog Add class in java and initialized all views from the…
slidenerd Dec 28, 2015
ef7e465
Added a drop to realm through DialogAdd and used the RealmBrowser to …
slidenerd Dec 30, 2015
f86a373
Added the RecyclerView in XML
slidenerd Dec 30, 2015
5e8d0f0
Added the row_drop.xml and the selector bg_row_drop
slidenerd Dec 30, 2015
4415824
Added the implementation of RecyclerView.Adapter with dummy items ins…
slidenerd Dec 30, 2015
fdb8347
Displayed the data from the Realm Database inside the RecyclerView an…
slidenerd Dec 30, 2015
e90c201
Fixed the error 'plugin is too old' by updating gradle version from a…
slidenerd Dec 31, 2015
5fb65fb
Added an Adapter Data Observer to display an empty view when the Recy…
slidenerd Dec 31, 2015
787aede
Fixed a bug where an Image was not taking full screen width and heigh…
slidenerd Jan 2, 2016
51ec48f
Override the getItemViewType method and change the code inside onCrea…
slidenerd Jan 2, 2016
c4b73d7
Added a divider to the RecyclerView which is drawn on top of every it…
slidenerd Jan 3, 2016
751e1da
Added the AddListener interface that can be used to communicate betwe…
slidenerd Jan 3, 2016
e7428d1
Added Swipe to delete support with ItemTouchHelper.Callback and fixed…
slidenerd Jan 4, 2016
9b1b13e
Added the XML file for the Dialog Mark and changed the background col…
slidenerd Jan 4, 2016
e32d75c
Added the Dialog Mark in code and triggered it when an item from the …
slidenerd Jan 4, 2016
484e304
Marked the item as complete in the database by setting a different ba…
slidenerd Jan 4, 2016
8c9053b
Added the menu in XML and overriden the onCreateOptionsMenu and onOpt…
slidenerd Jan 5, 2016
8d9ce51
Displaying and storing dates in our App
slidenerd Jan 5, 2016
717fc6d
Added the code to sort data inside the RecyclerView on the basis of t…
slidenerd Jan 5, 2016
6d251f8
Added SharedPreferences to store user choice on how they want their d…
slidenerd Jan 5, 2016
5fbeb20
Added the NoItemsHolder to the Adapter to display "No Items to Displa…
slidenerd Jan 6, 2016
36b4c16
Override the getItemId to return a unique id for each item and call s…
slidenerd Jan 6, 2016
28322cf
Added code to disable Swipe on the Footer and the special "No Items t…
slidenerd Jan 6, 2016
fa14ae3
Added the reset listener to the app to maintain consistent ux when th…
slidenerd Jan 6, 2016
2f92273
Made the dialog full screen by adding a custom style for it and chang…
slidenerd Jan 9, 2016
7b0bdf1
Added the reset filter to keep the UX consistent
slidenerd Jan 10, 2016
08d49b5
Added a custom style for the Dialog and Toolbar
slidenerd Jan 10, 2016
2311552
Added the DatePickerWidget in XML with its essential drawables
slidenerd Jan 10, 2016
0f52fea
Added the code to link the custom widget in XML to code and display c…
slidenerd Jan 10, 2016
33aac92
Added a touch listener to process motion events on our textviews
slidenerd Jan 12, 2016
b72994a
Increment or Decrement values inside the Date Picker
slidenerd Jan 13, 2016
3ab4aaa
Continuously Increment and Decrement values with the Handler
slidenerd Jan 13, 2016
70b8f37
Toggle Compound Drawables when the buttons are in the normal or press…
slidenerd Jan 13, 2016
96ef723
Added onSaveInstanceState and onRestoreInstanceState on the custom wi…
slidenerd Jan 13, 2016
55891e5
Polish the app with custom fonts wherever we need them
slidenerd Jan 13, 2016
0808617
Added a notification service for notifying the user about those drops…
slidenerd Jan 14, 2016
90a730d
Display notifications using the pug notification library for those go…
slidenerd Jan 15, 2016
7329073
Added a Boot Receiver to start the alarms when the phone reboots
slidenerd Jan 15, 2016
fd67310
Added a Boot Receiver to start the alarms when the phone reboots
slidenerd Jan 16, 2016
3aa848a
Updated the dependencies to match with the latest version of Realm an…
slidenerd Mar 8, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 18 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
apply plugin: 'com.android.application'

android {
signingConfigs {
config {
keyAlias 'Bucket Drops'
keyPassword 'appCOURSE'
storeFile file('/Users/vivz/Desktop/Examples/AndroidExamples/BucketDrops/bucketdrops.jks')
storePassword 'bucketDROPS'
}
}
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "slidenerd.vivz.bucketdrops"
applicationId "appcourse.vivz.bucketdrops"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'io.realm:realm-android:0.87.5'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.github.halysongoncalves:pugnotification:1.8.1'
}
15 changes: 15 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,18 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep class io.realm.annotations.RealmModule
-keep @io.realm.annotations.RealmModule class *
-keep class io.realm.internal.Keep
-keep @io.realm.internal.Keep class * { *; }
-dontwarn javax.**
-dontwarn io.realm.**
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
-dontwarn com.squareup.okhttp.**
-dontwarn android.support.v7.**
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package slidenerd.vivz.bucketdrops;
package appcourse.vivz.bucketdrops;

import android.app.Application;
import android.test.ApplicationTestCase;
Expand Down
18 changes: 16 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="slidenerd.vivz.bucketdrops">
package="appcourse.vivz.bucketdrops">

<application
android:name="appcourse.vivz.bucketdrops.AppBucketDrops"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ActivityMain">
<activity android:name="appcourse.vivz.bucketdrops.ActivityMain">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<service
android:name="appcourse.vivz.bucketdrops.services.NotificationService"
android:exported="false" />

<receiver
android:name="appcourse.vivz.bucketdrops.receivers.BootReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application>

</manifest>
Binary file added app/src/main/assets/fonts/raleway_thin.ttf
Binary file not shown.
211 changes: 211 additions & 0 deletions app/src/main/java/appcourse/vivz/bucketdrops/ActivityMain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
package appcourse.vivz.bucketdrops;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.Toolbar;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

import io.realm.Realm;
import io.realm.RealmChangeListener;
import io.realm.RealmResults;
import io.realm.Sort;
import appcourse.vivz.bucketdrops.adapters.AdapterDrops;
import appcourse.vivz.bucketdrops.adapters.AddListener;
import appcourse.vivz.bucketdrops.adapters.CompleteListener;
import appcourse.vivz.bucketdrops.adapters.Divider;
import appcourse.vivz.bucketdrops.adapters.Filter;
import appcourse.vivz.bucketdrops.adapters.MarkListener;
import appcourse.vivz.bucketdrops.adapters.ResetListener;
import appcourse.vivz.bucketdrops.adapters.SimpleTouchCallback;
import appcourse.vivz.bucketdrops.beans.Drop;
import appcourse.vivz.bucketdrops.extras.Util;
import appcourse.vivz.bucketdrops.widgets.BucketRecyclerView;

public class ActivityMain extends AppCompatActivity {

public static final String TAG_DIALOG_ADD = "add";
public static final String TAG_DIALOG_MARK = "mark";
public static final String FIELD_WHEN = "when";
public static final String FIELD_COMPLETED = "completed";
Toolbar mToolbar;
Button mBtnAdd;
BucketRecyclerView mRecycler;
Realm mRealm;
RealmResults<Drop> mResults;
View mEmptyView;
AdapterDrops mAdapter;
private View.OnClickListener mBtnAddListener = new View.OnClickListener() {

@Override
public void onClick(View v) {
showDialogAdd();
}
};
private AddListener mAddListener = new AddListener() {
@Override
public void add() {
showDialogAdd();
}
};

private RealmChangeListener mChangeListener = new RealmChangeListener() {
@Override
public void onChange() {
mAdapter.update(mResults);
}
};

private MarkListener mMarkListener = new MarkListener() {
@Override
public void onMark(int position) {
showDialogMark(position);
}
};

private CompleteListener mCompleteListener = new CompleteListener() {
@Override
public void onComplete(int position) {
mAdapter.markComplete(position);
}
};
private ResetListener mResetListener = new ResetListener() {
@Override
public void onReset() {
AppBucketDrops.save(ActivityMain.this, Filter.NONE);
loadResults(Filter.NONE);
}
};

private void showDialogAdd() {
DialogAdd dialog = new DialogAdd();
dialog.show(getSupportFragmentManager(), TAG_DIALOG_ADD);
}

private void showDialogMark(int position) {
DialogMark dialog = new DialogMark();
Bundle bundle = new Bundle();
bundle.putInt(DialogMark.EXTRA_POSITION, position);
dialog.setArguments(bundle);
dialog.setCompleteListener(mCompleteListener);
dialog.show(getSupportFragmentManager(), TAG_DIALOG_MARK);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRealm = Realm.getDefaultInstance();
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
mBtnAdd = (Button) findViewById(R.id.btn_add);
mBtnAdd.setOnClickListener(mBtnAddListener);

int filterOption = AppBucketDrops.load(this);
loadResults(filterOption);
mEmptyView = findViewById(R.id.empty_drops);
mRecycler = (BucketRecyclerView) findViewById(R.id.rv_drops);
mRecycler.addItemDecoration(new Divider(this, LinearLayoutManager.VERTICAL));
mRecycler.setItemAnimator(new DefaultItemAnimator());
mRecycler.hideIfEmpty(mToolbar);
mRecycler.showIfEmpty(mEmptyView);
mAdapter = new AdapterDrops(this, mRealm, mResults, mAddListener, mMarkListener, mResetListener);
mAdapter.setHasStableIds(true);
mRecycler.setAdapter(mAdapter);
SimpleTouchCallback callback = new SimpleTouchCallback(mAdapter);
ItemTouchHelper helper = new ItemTouchHelper(callback);
helper.attachToRecyclerView(mRecycler);
initBackgroundImage();
Util.scheduleAlarm(this);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
boolean handled = true;
int filterOption = Filter.NONE;
switch (id) {
case R.id.action_add:
showDialogAdd();
break;
case R.id.action_sort_none:
filterOption = Filter.NONE;
break;
case R.id.action_sort_ascending_date:
filterOption = Filter.LEAST_TIME_LEFT;
break;
case R.id.action_sort_descending_date:
filterOption = Filter.MOST_TIME_LEFT;
break;
case R.id.action_show_complete:
filterOption = Filter.COMPLETE;
break;
case R.id.action_show_incomplete:
filterOption = Filter.INCOMPLETE;
break;
default:
handled = false;
break;
}
loadResults(filterOption);
AppBucketDrops.save(this, filterOption);
return handled;
}

private void loadResults(int filterOption) {
switch (filterOption) {
case Filter.NONE:
mResults = mRealm.where(Drop.class).findAllAsync();
break;
case Filter.LEAST_TIME_LEFT:
mResults = mRealm.where(Drop.class).findAllSortedAsync(FIELD_WHEN);
break;
case Filter.MOST_TIME_LEFT:
mResults = mRealm.where(Drop.class).findAllSortedAsync(FIELD_WHEN, Sort.DESCENDING);
break;
case Filter.COMPLETE:
mResults = mRealm.where(Drop.class).equalTo(FIELD_COMPLETED, true).findAllAsync();
break;
case Filter.INCOMPLETE:
mResults = mRealm.where(Drop.class).equalTo(FIELD_COMPLETED, false).findAllAsync();
break;
}
mResults.addChangeListener(mChangeListener);
}


@Override
protected void onStart() {
super.onStart();
mResults.addChangeListener(mChangeListener);
}

@Override
protected void onStop() {
super.onStop();
mResults.removeChangeListener(mChangeListener);
}

private void initBackgroundImage() {
ImageView background = (ImageView) findViewById(R.id.iv_background);
Glide.with(this)
.load(R.drawable.background)
.centerCrop()
.into(background);
}

}
54 changes: 54 additions & 0 deletions app/src/main/java/appcourse/vivz/bucketdrops/AppBucketDrops.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package appcourse.vivz.bucketdrops;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.preference.PreferenceManager;
import android.widget.TextView;

import io.realm.Realm;
import io.realm.RealmConfiguration;
import appcourse.vivz.bucketdrops.adapters.Filter;

/**
* Created by vivz on 30/12/15.
* TODO change to custom fonts wherever appropriate
*/
public class AppBucketDrops extends Application {

static String FILTER_OPTION = "filter";

@Override
public void onCreate() {
super.onCreate();
RealmConfiguration configuration = new RealmConfiguration.Builder(this).build();
Realm.setDefaultConfiguration(configuration);
}

public static void save(Context context, int filterOption) {

SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = pref.edit();
editor.putInt(FILTER_OPTION, filterOption);
editor.apply();
}

public static int load(Context context) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
int filterOption = pref.getInt(FILTER_OPTION, Filter.NONE);
return filterOption;
}

public static void setRalewayRegular(Context context, TextView textView) {
Typeface typeface = Typeface.createFromAsset(context.getAssets(), "fonts/raleway_thin.ttf");
textView.setTypeface(typeface);
}

public static void setRalewayRegular(Context context, TextView... textViews) {
Typeface typeface = Typeface.createFromAsset(context.getAssets(), "fonts/raleway_thin.ttf");
for (TextView textView : textViews) {
textView.setTypeface(typeface);
}
}
}
Loading