Skip to content

Commit

Permalink
Version 1.1.2
Browse files Browse the repository at this point in the history
Bug fixes and improvements [Part 2]
  • Loading branch information
TheDorkKnightRises committed Aug 13, 2016
1 parent 0ab98ac commit 85ee88b
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 51 deletions.
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.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "thedorkknightrises.notes"
minSdkVersion 15
targetSdkVersion 23
versionCode 3
versionName "1.1.1"
versionCode 4
versionName "1.1.2"
}
buildTypes {
release {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/thedorkknightrises/notes/db/NotesDb.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package thedorkknightrises.notes.db;

import android.database.sqlite.SQLiteDatabase;
import android.provider.BaseColumns;

/**
Expand All @@ -12,7 +11,8 @@ public NotesDb() {
}

/* Inner class that defines the table contents */
public static abstract class Note implements BaseColumns {
public static abstract class Note {
public static final String _ID = "id";
public static final String TABLE_NAME = "notes";
public static final String COLUMN_NAME_TITLE = "title";
public static final String COLUMN_NAME_SUBTITLE = "subtitle";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.ContentValues;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
Expand Down Expand Up @@ -117,7 +116,7 @@ public ArrayList<NoteObj> getAllNotes() {
};

SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.query(NotesDb.Note.TABLE_NAME, projection, null, null, null, null, NotesDb.Note.COLUMN_NAME_TIME + " DESC");
Cursor cursor = db.query(NotesDb.Note.TABLE_NAME, projection, null, null, null, null, NotesDb.Note._ID + " DESC");

if (cursor.moveToFirst()) {
do {
Expand Down Expand Up @@ -148,7 +147,7 @@ public ArrayList<NoteObj> getAllNotesFromArchive() {
};

SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.query(NotesDb.Archive.TABLE_NAME, projection, null, null, null, null, NotesDb.Archive.COLUMN_NAME_TIME + " DESC");
Cursor cursor = db.query(NotesDb.Archive.TABLE_NAME, projection, null, null, null, null, NotesDb.Archive._ID + " DESC");

if (cursor.moveToFirst()) {
do {
Expand Down
31 changes: 10 additions & 21 deletions app/src/main/java/thedorkknightrises/notes/ui/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
package thedorkknightrises.notes.ui;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.PointF;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.LinearSmoothScroller;
import android.support.v7.widget.RecyclerView;
import android.transition.Slide;
import android.util.DisplayMetrics;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.logging.Handler;

import thedorkknightrises.notes.NoteObj;
import thedorkknightrises.notes.NotesAdapter;
Expand All @@ -40,17 +30,17 @@

public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
public static NotesAdapter notesAdapter;
public static boolean added = false;
static boolean changed = true;
static boolean themeChanged = false;
static boolean archive = false;
protected NotesDbHelper dbHelper;
ArrayList<NoteObj> noteObjArrayList;
RecyclerView recyclerView;
TextView blankText;
FloatingActionButton fab;
public static NotesAdapter notesAdapter;
public static boolean added = false;
SharedPreferences pref;
static boolean themeChanged = false;
static boolean archive = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -68,8 +58,7 @@ protected void onCreate(Bundle savedInstanceState) {
public void onClick(View view) {
Intent i = new Intent(getBaseContext(), NoteActivity.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat options = ActivityOptionsCompat.
makeSceneTransitionAnimation(MainActivity.this);
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this);
startActivity(i, options.toBundle());
} else startActivity(i);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public void onClick(View v) {
onPrepareOptionsMenu(menu);

toolbar.setVisibility(View.VISIBLE);
findViewById(R.id.note_update).setVisibility(View.VISIBLE);
timeText.setText(time);
editMode = false;
}
Expand All @@ -250,6 +251,7 @@ public void onClick(View v) {
fab.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_done_white_24dp));
onPrepareOptionsMenu(menu);
toolbar.setVisibility(View.GONE);
findViewById(R.id.note_update).setVisibility(View.GONE);
timeText.setText("");
editMode = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.support.v7.widget.SwitchCompat;
import android.view.MenuItem;
import android.view.View;
import android.widget.CompoundButton;

import thedorkknightrises.notes.R;

Expand Down Expand Up @@ -36,17 +37,22 @@ protected void onResume() {
pref= getSharedPreferences("Prefs", MODE_PRIVATE);

theme_switch.setChecked(pref.getBoolean("lightTheme", false));

theme_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
onCheckedChange(theme_switch);
}
});
}

public void onCheckedChange(View v)
{
if (v.equals(findViewById(R.id.theme_switch)) || v.equals(findViewById(R.id.theme_switch_row))) {
if (v.equals(theme_switch) || v.equals(findViewById(R.id.theme_switch_row))) {
Boolean b = pref.getBoolean("lightTheme", false);
SharedPreferences.Editor e = pref.edit();
e.putBoolean("lightTheme", !b);
e.commit();
if (!v.equals(theme_switch))
theme_switch.toggle();
MainActivity.themeChanged = true;
recreate();
}
Expand Down
32 changes: 25 additions & 7 deletions app/src/main/res/layout/activity_note.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,31 @@
android:textSize="18sp"
android:transitionName="content"/>

<TextView
android:id="@+id/note_date"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:maxLines="2"
android:transitionName="time"
tools:text="@string/updated" />
android:gravity="end">

<TextView
android:id="@+id/note_update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:maxLines="2"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="@string/updated" />

<TextView
android:id="@+id/note_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:maxLines="2"
android:transitionName="time"
tools:text="@string/updated" />

</LinearLayout>

</LinearLayout>

Expand Down Expand Up @@ -136,6 +153,7 @@
android:padding="0dp"
android:src="@drawable/ic_archive_white_24dp" />
<ImageButton
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
Expand Down
21 changes: 9 additions & 12 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
Expand All @@ -18,8 +16,8 @@
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:clickable="true"
app:cardElevation="4dp"
android:foreground="?android:attr/selectableItemBackground">
android:foreground="?android:attr/selectableItemBackground"
app:cardElevation="4dp">

<LinearLayout
android:layout_width="match_parent"
Expand All @@ -43,29 +41,29 @@
android:id="@+id/theme_switch_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="80dp"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:gravity="center_vertical"
android:minHeight="80dp"
android:onClick="onCheckedChange"
android:paddingBottom="@dimen/activity_horizontal_margin"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="@dimen/activity_horizontal_margin"
android:onClick="onCheckedChange">
android:paddingTop="@dimen/activity_horizontal_margin">

<LinearLayout
android:id="@+id/res_setting"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingTop="4dp"
android:text="Use light theme"
Expand All @@ -82,8 +80,7 @@
<android.support.v7.widget.SwitchCompat
android:id="@+id/theme_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onCheckedChange"/>
android:layout_height="wrap_content" />

</LinearLayout>

Expand Down

0 comments on commit 85ee88b

Please sign in to comment.