Skip to content

Commit

Permalink
Version 2.0
Browse files Browse the repository at this point in the history
- App Shortcuts for Android 7.1+
- Changes to internal logic
- Other minor changes
  • Loading branch information
TheDorkKnightRises committed Jun 20, 2017
1 parent c61b374 commit 7e760a2
Show file tree
Hide file tree
Showing 21 changed files with 81 additions and 262 deletions.
7 changes: 7 additions & 0 deletions .idea/kotlinc.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.

18 changes: 9 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ android {
}
}
compileSdkVersion 25
buildToolsVersion "25.0.0"
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "thedorkknightrises.notes"
minSdkVersion 15
targetSdkVersion 25
versionCode 19
versionName "1.5.2"
versionCode 20
versionName "2.0"
}
buildTypes {
release {
Expand All @@ -35,13 +35,13 @@ dependencies {
compile('com.mikepenz:aboutlibraries:5.8.1@aar') {
transitive = true
}
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:cardview-v7:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.google.android.gms:play-services-drive:10.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.google.android.gms:play-services-drive:11.0.1'
compile 'com.google.firebase:firebase-crash:11.0.1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.google.firebase:firebase-crash:10.0.1'
compile 'com.heinrichreimersoftware:material-intro:1.6'
testCompile 'junit:junit:4.12'
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void merge(Context context) {

if (cursor.moveToFirst()) {
do {
notesDbHelper.addNote(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getInt(5), cursor.getInt(6));
notesDbHelper.addNote(cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getInt(5), cursor.getInt(6));
} while (cursor.moveToNext());
}

Expand Down
45 changes: 9 additions & 36 deletions app/src/main/java/thedorkknightrises/notes/data/NotesDbHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
onUpgrade(db, oldVersion, newVersion);
}

public void addNote(int id, String title, String subtitle, String content, String time, int archived, int notified) {
public void addNote(String title, String subtitle, String content, String time, int archived, int notified) {
SQLiteDatabase db = this.getWritableDatabase();

ContentValues values = new ContentValues();
values.put(NotesDb.Note._ID, id);
values.put(NotesDb.Note.COLUMN_NAME_TITLE, title);
values.put(NotesDb.Note.COLUMN_NAME_SUBTITLE, subtitle);
values.put(NotesDb.Note.COLUMN_NAME_CONTENT, content);
Expand All @@ -65,10 +64,15 @@ public void addNote(int id, String title, String subtitle, String content, Strin
db.close();
}

public void deleteNote(int id) {
public void deleteNote(String title, String subtitle, String content, String time, int archived) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(NotesDb.Note.TABLE_NAME, NotesDb.Note._ID + " = ?",
new String[]{Long.toString(id)});
db.delete(NotesDb.Note.TABLE_NAME,
NotesDb.Note.COLUMN_NAME_TITLE + " = ? AND "
+ NotesDb.Note.COLUMN_NAME_SUBTITLE + " = ? AND "
+ NotesDb.Note.COLUMN_NAME_CONTENT + " = ? AND "
+ NotesDb.Note.COLUMN_NAME_TIME + " = ? AND "
+ NotesDb.Note.COLUMN_NAME_ARCHIVED + " = ? ",
new String[]{title, subtitle, content, time, Integer.toString(archived)});
Log.d("DB", "Deleted");
db.close();
}
Expand Down Expand Up @@ -111,35 +115,4 @@ public int deleteAllNotes(int archive) {
Log.d("DB", "All notes deleted");
return result;
}

public ArrayList<NoteObj> searchDB(String query, int archive) {
ArrayList<NoteObj> mList = new ArrayList<NoteObj>();
SQLiteDatabase db = this.getReadableDatabase();
String[] projection = {
NotesDb.Note._ID,
NotesDb.Note.COLUMN_NAME_TITLE,
NotesDb.Note.COLUMN_NAME_SUBTITLE,
NotesDb.Note.COLUMN_NAME_CONTENT,
NotesDb.Note.COLUMN_NAME_TIME,
NotesDb.Note.COLUMN_NAME_ARCHIVED,
NotesDb.Note.COLUMN_NAME_NOTIFIED
};
Cursor cursor = db.query(NotesDb.Note.TABLE_NAME, projection,
NotesDb.Note.COLUMN_NAME_ARCHIVED + " LIKE " + archive
+ " AND ( " + NotesDb.Note.COLUMN_NAME_TITLE + " LIKE " + "'%" + query
+ "%' OR " + NotesDb.Note.COLUMN_NAME_SUBTITLE + " LIKE " + "'%" + query
+ "%' OR " + NotesDb.Note.COLUMN_NAME_CONTENT + " LIKE " + "'%" + query + "%')",
null, null, null, null, null);

if (cursor.moveToFirst()) {
do {
NoteObj noteObj = new NoteObj(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getInt(5), cursor.getInt(6));
mList.add(noteObj);
} while (cursor.moveToNext());
}

cursor.close();
db.close();
return mList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
public void onLinkClick(View v) {
String text = (String) ((Button) v).getText();
String uri;
if (text.equals(getString(R.string.gplus))) {
uri = "https://plus.google.com/u/0/+SamriddhaBasu";
} else if (text.equals(getString(R.string.github))) {
if (text.equals(getString(R.string.github))) {
uri = "https://github.com/TheDorkKnightRises";
} else if (text.equals(getString(R.string.website))) {
uri = "https://thedorkknightrises.github.io";
uri = "https://samriddhabasu.github.io";
} else if (text.equals(getString(R.string.source))) {
uri = "https://github.com/TheDorkKnightRises/Notes-App";
} else {
Expand Down
46 changes: 25 additions & 21 deletions app/src/main/java/thedorkknightrises/notes/ui/NoteActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public class NoteActivity extends AppCompatActivity {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private Menu menu;
private int id = -1;
private String title;
private String subtitle;
private String content;
private String time;
private int archived = 0;
private String title, oldTitle;
private String subtitle, oldSubtitle;
private String content, oldContent;
private String time, oldTime;
private int archived = 0, oldArchived;
private int notified = 0;
private boolean backPressFlag = false;

Expand Down Expand Up @@ -190,17 +190,13 @@ private void setupWindowAnimations() {
}

public void close(View v) {
if (MainActivity.added) {
SharedPreferences.Editor editor = pref.edit();
editor.putInt(NotesDb.Note._ID, id + 1);
editor.commit();
}
if (subtitleText.getText().toString().isEmpty()) subtitleText.setVisibility(View.INVISIBLE);
backPressFlag = true;
onBackPressed();
}

public void delete(View v) {
dbHelper.deleteNote(id);
dbHelper.deleteNote(title, subtitle, content, time, archived);
MainActivity.changed = true;
// Gets an instance of the NotificationManager service
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Expand All @@ -217,15 +213,12 @@ public void onClick(View v) {
Snackbar.make(coordinatorLayout, R.string.incomplete, Snackbar.LENGTH_LONG).show();
else {
Calendar c = Calendar.getInstance();
if (id == -1) {
id = pref.getInt(NotesDb.Note._ID, 1);
MainActivity.added = true;
} else dbHelper.deleteNote(id);
//get date and time, specifically in 24-hr format suitable for sorting
time = sdf.format(c.getTime());
Log.d("TIME", time);
archived = 0;
dbHelper.addNote(id, title, subtitle, content, time, archived, notified);
dbHelper.deleteNote(oldTitle, oldSubtitle, oldContent, oldTime, oldArchived);
dbHelper.addNote(title, subtitle, content, time, archived, notified);
editMode = false;
MainActivity.changed = true;
titleText.setEnabled(false);
Expand Down Expand Up @@ -260,10 +253,10 @@ public void onClick(View v) {
notif();
}
} else {
saveOldData();
titleText.setEnabled(true);
subtitleText.setEnabled(true);
contentText.setEnabled(true);
contentText.requestFocus();
contentText.setSelection(contentText.getText().length());
subtitleText.setVisibility(View.VISIBLE);
fab.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_done_white_24dp));
Expand All @@ -272,11 +265,20 @@ public void onClick(View v) {
findViewById(R.id.note_update).setVisibility(View.GONE);
timeText.setText("");
editMode = true;
contentText.requestFocusFromTouch();
}
onResume();

}

private void saveOldData() {
oldTitle = title;
oldSubtitle = subtitle;
oldContent = content;
oldTime = time;
oldArchived = archived;
}

public void share(View v) {
Intent share = new Intent(Intent.ACTION_SEND);
if (subtitle.equals(""))
Expand All @@ -287,14 +289,15 @@ public void share(View v) {
}

public void notifBtn(View v) {
dbHelper.deleteNote(title, subtitle, content, time, archived);
if (notified == 1) {
notified = 0;
dbHelper.addNote(id, title, subtitle, content, time, archived, notified);
dbHelper.addNote(title, subtitle, content, time, archived, notified);
MainActivity.changed = true;
notif();
} else {
notified = 1;
dbHelper.addNote(id, title, subtitle, content, time, archived, notified);
dbHelper.addNote(title, subtitle, content, time, archived, notified);
MainActivity.changed = true;
notif();
}
Expand Down Expand Up @@ -348,17 +351,18 @@ public void notif() {
}

public void archive(View v) {
dbHelper.deleteNote(title, subtitle, content, time, archived);
if (archived == 1) {
Toast.makeText(this, R.string.removed_archive, Toast.LENGTH_SHORT).show();
archived = 0;
dbHelper.addNote(id, title, subtitle, content, time, archived, notified);
dbHelper.addNote(title, subtitle, content, time, archived, notified);
MainActivity.changed = true;
notif();
finish();
} else {
Toast.makeText(this, R.string.added_archive, Toast.LENGTH_SHORT).show();
archived = 1;
dbHelper.addNote(id, title, subtitle, content, time, archived, notified);
dbHelper.addNote(title, subtitle, content, time, archived, notified);
MainActivity.changed = true;
notif();
finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.google.android.gms.drive.DriveContents;
import com.google.android.gms.drive.DriveFile;
import com.google.android.gms.drive.DriveFolder;
import com.google.android.gms.drive.DriveId;
import com.google.android.gms.drive.MetadataChangeSet;
import com.google.android.gms.drive.query.Filters;
import com.google.android.gms.drive.query.Query;
Expand Down Expand Up @@ -196,11 +195,6 @@ public void onResult(@NonNull DriveApi.DriveContentsResult result) {

}

public void fetchFile(DriveId driveId) {

}


@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7e760a2

Please sign in to comment.