Skip to content

Commit

Permalink
Release Version 1.0.2 (version code 4)
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsFo committed May 16, 2017
1 parent c551729 commit 3651325
Show file tree
Hide file tree
Showing 80 changed files with 296 additions and 85 deletions.
8 changes: 5 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "de.nilsfo.lsn"
minSdkVersion 17
targetSdkVersion 24
versionCode 3
versionName "1.0.1"
versionCode 4
versionName "1.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -27,6 +27,8 @@ dependencies {
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.jakewharton.timber:timber:4.5.1'
compile 'com.google.zxing:core:3.2.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha5'
compile 'com.amitshekhar.android:debug-db:1.0.0'
}
66 changes: 30 additions & 36 deletions app/src/main/java/de/nilsfo/lockscreennotes/LockScreenNotes.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

import android.app.Application;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.preference.PreferenceManager;
import android.util.Log;

import com.amitshekhar.DebugDB;

import java.util.Locale;

import de.nilsfo.lockscreennotes.util.VersionManager;
import de.nilsfo.lsn.BuildConfig;
import de.nilsfo.lsn.R;
import timber.log.Timber;
Expand All @@ -17,18 +21,21 @@

public class LockScreenNotes extends Application {

public static final String LOGTAG = "de.tos.lsn.";
public static final String APP_TAG = "de.tos.lsn.";
public static final String LOG_TAG = APP_TAG + "log.";
public static final String PREFS_TAG = APP_TAG + "prefs_";
public static final String PREFS_LAST_KNOWN_VERSION = PREFS_TAG + "last_known_version";

@Override
public void onCreate() {
super.onCreate();

if (BuildConfig.DEBUG) {
Timber.plant(new DebugTree());
Timber.i("Debug-DB URL: " + DebugDB.getAddressLog());
} else {
Timber.plant(new ReleaseTree());
}
Timber.i("Application started via TIMBER!");

Locale locale = Locale.getDefault();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
Expand All @@ -45,57 +52,44 @@ public void onCreate() {
PreferenceManager.setDefaultValues(this, R.xml.prefs_time, false);

Timber.i("Started the app. Locale used: " + locale.getISO3Country() + " - " + locale.getCountry() + " - " + locale.getDisplayLanguage() + " - " + locale.getDisplayCountry());

int lastVer = prefs.getInt(PREFS_LAST_KNOWN_VERSION, 0);
int currentVer = 0;
try {
currentVer = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
} catch (
PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if (lastVer != 0 && lastVer != currentVer) {
VersionManager.onVersionChange(this, lastVer, currentVer);
}

prefs.edit().putInt(PREFS_LAST_KNOWN_VERSION, currentVer).apply();
Timber.i("Application started. App version: " + currentVer);
}

public static boolean isDebugBuild() {
return BuildConfig.DEBUG;
}

@Override
public void onTerminate() {
super.onTerminate();
}

private class DebugTree extends Timber.DebugTree{
private class DebugTree extends Timber.DebugTree {
@Override
protected String createStackElementTag(StackTraceElement element) {
return LOGTAG + super.createStackElementTag(element) + ":" + element.getLineNumber();
return LOG_TAG + super.createStackElementTag(element) + ":" + element.getLineNumber();
}
}

private class ReleaseTree extends DebugTree {

@Override
protected boolean isLoggable(String tag, int priority) {
return !(priority == Log.VERBOSE || priority == Log.DEBUG || priority == Log.INFO);
}

//@Override
//protected void log(int priority, String tag, String message, Throwable t) {
// if (isLoggable(tag, priority)) {
//
// if (message.length() < MAX_LOG_LENGTH) {
// if (priority == Log.ASSERT) {
// Log.wtf(tag, message);
// } else {
// Log.println(priority, tag, message);
// }
// return;
// }
//
// for (int i = 0, length = message.length(); i < length; i++) {
// int newLine = message.indexOf('\n', i);
// newLine = newLine != -1 ? newLine : length;
// do {
// int end = Math.min(newLine, i + MAX_LOG_LENGTH);
// String part = message.substring(i, end);
//
// if (priority == Log.ASSERT) {
// Log.wtf(tag, part);
// } else {
// Log.println(priority, tag, part);
// }
// i = end;
// } while (i < newLine);
// }
// }
//}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.Snackbar;
Expand All @@ -16,20 +18,28 @@
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;

import java.util.Date;

import de.nilsfo.lockscreennotes.view.QRCodeView;
import de.nilsfo.lsn.R;
import de.nilsfo.lockscreennotes.data.Note;
import de.nilsfo.lockscreennotes.data.font.FontAwesomeDrawableBuilder;
import de.nilsfo.lockscreennotes.sql.DBAdapter;
import de.nilsfo.lockscreennotes.util.NotesNotificationManager;
import timber.log.Timber;

public class EditNoteActivity extends NotesActivity {

public static final String NOTE_ACTIVITY_NOTE_ID = "EditNoteActivity_note_id";
public static final int QR_IMAGE_SIZE = 512;
public static final long ILLEGAL_NOTE_ID = -1;

private Note myNote;
Expand Down Expand Up @@ -147,14 +157,7 @@ private void actionCopyText() {

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.edit_note_menu, menu);

menu.findItem(R.id.action_move_to_bottom).setIcon(FontAwesomeDrawableBuilder.getOptionsIcon(this, R.string.fa_icon_down));
menu.findItem(R.id.action_clear).setIcon(FontAwesomeDrawableBuilder.getOptionsIcon(this, R.string.fa_icon_clear));
menu.findItem(R.id.action_share).setIcon(FontAwesomeDrawableBuilder.getOptionsIcon(this, R.string.fa_icon_share));
menu.findItem(R.id.action_copy_note).setIcon(FontAwesomeDrawableBuilder.getOptionsIcon(this, R.string.fa_icon_copy));

return true;
}

Expand Down Expand Up @@ -216,6 +219,22 @@ public void onClick(DialogInterface dialog, int which) {
.show();
}

public void actionToQR() {
String qrcode = noteTF.getText().toString();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.app_name);
builder.setIcon(R.mipmap.ic_launcher);
builder.setPositiveButton(R.string.action_dismiss, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});

builder.setView(new QRCodeView(this, qrcode, QR_IMAGE_SIZE));
builder.show();
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
Expand Down Expand Up @@ -244,6 +263,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.action_cancel_edit:
actionCancelEdit();
return true;

case R.id.action_to_qr_code:
actionToQR();
return true;
}
return super.onOptionsItemSelected(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@
import de.nilsfo.lockscreennotes.data.Note;
import de.nilsfo.lockscreennotes.data.NoteAdapter;
import de.nilsfo.lockscreennotes.data.RelativeTimeTextfieldContainer;
import de.nilsfo.lockscreennotes.data.font.FontAwesomeDrawableBuilder;
import de.nilsfo.lockscreennotes.sql.DBAdapter;
import de.nilsfo.lockscreennotes.util.NotesNotificationManager;
import timber.log.Timber;

public class MainActivity extends NotesActivity implements Observer {

public static final int ONE_SECOND_IN_MS = 1000;
public static final String LOGTAG = "LockScreenNotes";
public static final String PREFS_HIDE_TUTORIAL = "prefs_hide_tutorial";
public static final int DEFAULT_SNACKBAR_PREVIEW_WORD_COUNT = 15;

Expand Down Expand Up @@ -92,7 +90,6 @@ public void onClick(View view) {
onFABClicked();
}
});
fab.setImageDrawable(FontAwesomeDrawableBuilder.get(this, R.string.fa_icon_plus, 48, Color.WHITE));

if (notesList.getCount() == 0)
tutorialView.animate().alpha(1f).setDuration(2000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ public void onCreate(Bundle savedInstanceState) {
bindPreferenceURLAsAction(findPreference("prefs_credits_font_awesome"));
bindPreferenceURLAsAction(findPreference("prefs_credits_text_drawable"));
bindPreferenceURLAsAction(findPreference("prefs_credits_timber"));
bindPreferenceURLAsAction(findPreference("prefs_credits_debug_db"));
bindPreferenceURLAsAction(findPreference("pref_view_on_play_store"), Uri.parse(getString(R.string.const_google_play_url)));

findPreference("pref_share_app").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import de.nilsfo.lockscreennotes.activity.MainActivity;
import de.nilsfo.lsn.R;
import de.nilsfo.lockscreennotes.data.font.FontAwesomeDrawableBuilder;
import timber.log.Timber;

/**
Expand Down Expand Up @@ -138,8 +137,6 @@ public void onClick(View view) {
}
}
});
Drawable drawable = FontAwesomeDrawableBuilder.get(getContext(), R.string.fa_icon_delete, DELETE_BT_SIZE, DELETE_BT_COLOR);
deleteBT.setImageDrawable(drawable);

if (preferences.getBoolean("prefs_time_relative", true) && note != null) {
long time = note.getTimestamp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Created by Nils on 03.01.2017.
*/

@Deprecated
public abstract class FontAwesomeDrawableBuilder {

public static final int DEFAULT__MENU_ICON_SCALE = 9;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
public class FontManager {

public static final String ROOT = "fonts/";
@Deprecated
public static final String FONTAWESOME = ROOT + "fontawesome-webfont.ttf";

public static Typeface getTypeface(Context context, String font) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

public class NotificationDismissedReceiver extends BroadcastReceiver {


@Override
public void onReceive(Context context, Intent intent) {
int notificationId = intent.getExtras().getInt(NotesNotificationManager.INTENT_EXTRA_NOTE_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
import de.nilsfo.lockscreennotes.LockScreenNotes;
import timber.log.Timber;

import static de.nilsfo.lockscreennotes.activity.MainActivity.LOGTAG;


// TO USE:
// Change the package (at top) to match your project.
// Search for "TODO", and make the appropriate changes.
Expand All @@ -41,16 +38,14 @@ public class DBAdapter extends Observable {
public static final String[] ALL_KEYS = new String[]{KEY_ROWID, KEY_NOTE_TEXT, KEY_NOTE_ENABLED, KEY_TIMESTAMP};

// DB info: it's name, and the table we are using (just one).
public static final String DATABASE_NAME = LockScreenNotes.LOGTAG+"notes_db";
public static final String DATABASE_NAME = LockScreenNotes.APP_TAG+"notes_db";
public static final String DATABASE_TABLE = "Notes";
// Track DB version if a new version of your app changes the format.
public static final int DATABASE_VERSION = 1;

/////////////////////////////////////////////////////////////////////
// Constants & Data
/////////////////////////////////////////////////////////////////////
// For logging:
private static final String TAG = LOGTAG;

private static final String DATABASE_CREATE_SQL =
"create table " + DATABASE_TABLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
public class NotesNotificationManager {

public static final String PREFERENCE_LOW_PRIORITY_NOTE = "prefs_low_priority_note";
public static final String INTENT_EXTRA_NOTE_ID = LockScreenNotes.LOGTAG+"notification_id";
public static final String PREFERENCE_HIGH_PRIORITY_NOTE = "prefs_high_priority_note";
public static final String INTENT_EXTRA_NOTE_ID = LockScreenNotes.APP_TAG+"notification_id";

public static final int DEFAULT_NOTIFICATION_ID = 1;
public static final int NOTE_PREVIEW_SIZE = -1;
Expand Down Expand Up @@ -189,9 +190,13 @@ public void hideNotifications() {
}

private int getNotificationPriority() {
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(PREFERENCE_LOW_PRIORITY_NOTE, true)) {
return NotificationCompat.PRIORITY_MIN;
int priority = NotificationCompat.PRIORITY_DEFAULT;
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(PREFERENCE_LOW_PRIORITY_NOTE, false)) {
priority= NotificationCompat.PRIORITY_MIN;
}
return NotificationCompat.PRIORITY_DEFAULT;
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(PREFERENCE_HIGH_PRIORITY_NOTE, false)) {
priority= NotificationCompat.PRIORITY_MAX;
}
return priority;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package de.nilsfo.lockscreennotes.util;

import android.content.Context;

import timber.log.Timber;

/**
* Created by Nils on 13.05.2017.
*/

public class VersionManager {

public static void onVersionChange(Context context, int oldVersion, int newVersion) {
Timber.i("App version changed! " + oldVersion + " -> " + newVersion);

switch (newVersion) {
default:
Timber.w("Unknown version change!");
break;
}
}

}
Loading

0 comments on commit 3651325

Please sign in to comment.