Skip to content

Commit

Permalink
Version 3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sepulzera authored Aug 11, 2023
2 parents 795aaec + 056cd46 commit 1254f2d
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ This app fits your needs. Doesn't? Change it right to your needs.

### System Requirements

* OS: Android 7.0
* OS: Android 10.0
* Display: 480x800, hdpi
* Touch Input

Expand Down
11 changes: 8 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ android {
buildToolsVersion '32.0.0'
defaultConfig {
applicationId "de.sepulzera.notes"
minSdkVersion 24
minSdkVersion 29
targetSdkVersion 32
versionCode 25
versionName "3.0.0"
versionCode 26
versionName "3.0.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.debug
}
Expand All @@ -21,6 +21,11 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
dex {
useLegacyPackaging true
}
}
testOptions {
unitTests.returnDefaultValues = true
}
Expand Down
13 changes: 8 additions & 5 deletions app/src/main/java/de/sepulzera/notes/bf/helper/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
import android.util.Log;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
Expand Down Expand Up @@ -252,10 +250,15 @@ private static void setNightMode(@NonNull final Context context) {
* @param mode {@code AppCompatDelegate.MODE_NIGHT_NO}, {@code AppCompatDelegate.MODE_NIGHT_YES} or {@code AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM}
*/
public static void setNightMode(int mode) {
int systemMode;
switch (mode) {
case 0: AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); break;
case 1: AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); break;
default: AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); break;
case 0: systemMode = AppCompatDelegate.MODE_NIGHT_NO; break;
case 1: systemMode = AppCompatDelegate.MODE_NIGHT_YES; break;
default: systemMode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM; break;
}

if (systemMode != AppCompatDelegate.getDefaultNightMode()) {
AppCompatDelegate.setDefaultNightMode(systemMode);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.net.Uri;
import androidx.annotation.NonNull;

import java.io.File;
import java.util.List;

import de.sepulzera.notes.ds.model.Note;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@
import android.content.ContentValues;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;

import androidx.annotation.NonNull;

import org.json.JSONArray;
import org.json.JSONException;

import java.io.File;
import java.nio.file.FileStore;
import java.sql.SQLIntegrityConstraintViolationException;
import java.text.DateFormat;
import java.util.ArrayList;
Expand All @@ -25,7 +20,6 @@
import java.util.Locale;

import de.sepulzera.notes.R;
import de.sepulzera.notes.bf.helper.DateUtil;
import de.sepulzera.notes.bf.helper.Helper;
import de.sepulzera.notes.bf.helper.StringUtil;
import de.sepulzera.notes.bf.helper.vlog.VLog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ private void restoreState(@NonNull final Bundle savedInstanceState) {

FragmentManager fragmentManager = getChildFragmentManager();
final List<Fragment> frags = fragmentManager.getFragments();
if (frags.size() == 0) {
throw new IllegalStateException("RunDo Fragment is lost");
}
// may have additional frags, but only the RunDo is needed
for (final Fragment frag : frags) {
if (frag instanceof RunDoSupport && String.valueOf(mIndex).equals(((RunDoSupport)frag).getIdent())) {
mRunDo = (RunDoSupport)frag;
break;
if (frags.size() > 0) {
// may have additional frags, but only the RunDo is needed
for (final Fragment frag : frags) {
if (frag instanceof RunDoSupport && String.valueOf(mIndex).equals(((RunDoSupport) frag).getIdent())) {
mRunDo = (RunDoSupport) frag;
break;
}
}
if (mRunDo == null) {
throw new IllegalStateException("RunDo Fragment is lost");
}
}
}
Expand All @@ -112,10 +114,10 @@ public void onSaveInstanceState(@NonNull final Bundle outState) {
outState.putBoolean(KEY_EDITABLE, mIsEditable);
}

public void initialize(int index, @NonNull final Note note) {
public void initialize(int index, @NonNull final Note note, boolean openNotesReadonly) {
mIndex = index;
mNote = note;
mIsEditable = note.getId() == 0L || !NoteTabViewerActivity.mOpenNotesReadonly;
mIsEditable = note.getId() == 0L || !openNotesReadonly;
}
public Note getNote() { return mNote; }
public int getIndex() { return mIndex; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ protected void onCreate(Bundle savedInstanceState) {

VLog.d(ACTIVITY_IDENT, "Creating activity.");

Helper.localize(getApplicationContext());
Helper.updatePreferences(this);

Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

Expand Down Expand Up @@ -107,6 +110,11 @@ protected void onCreate(Bundle savedInstanceState) {
return;
}
noteFrag.setEditable(true);
if (note.getDraft()) {
mIsDraftFragEditable = true;
} else {
mIsNoteFragEditable = true;
}
invalidateFloatingActionButton(true, true);
invalidateOptionsMenu();
}
Expand All @@ -128,7 +136,7 @@ protected void onCreate(Bundle savedInstanceState) {
invalidateOptionsMenu();
});

invalidateFloatingActionButton(mNoteFrags.get(0).getFragment());
invalidateFloatingActionButton();
invalidateOptionsMenu();
}

Expand All @@ -145,6 +153,8 @@ private void createState(final Intent intent) {
if (mNote == null) {
throw new IllegalArgumentException("note must not be null!");
}
mIsDraftFragEditable = !mOpenNotesReadonly;
mIsNoteFragEditable = !mOpenNotesReadonly;
}

final NoteService srv = NoteServiceImpl.getInstance();
Expand Down Expand Up @@ -188,6 +198,8 @@ private void restoreState(@NonNull final Bundle outState) {
mNote = (Note)outState.getSerializable(Note.TAG_NOTE);
mDraft = (Note)outState.getSerializable(KEY_DRAFT);
mDisplayedNote = (Note)outState.getSerializable(KEY_DISPLAYED_NOTE);
mIsDraftFragEditable = outState.getBoolean(KEY_DRAFT_EDITABLE);
mIsNoteFragEditable = outState.getBoolean(KEY_NOTE_EDITABLE);
mShowsRevisions = outState.getBoolean(KEY_SHOW_REVS);
mShowToolbarEdit = outState.getBoolean(KEY_SHOW_TB_EDIT);
mInvalidateList = outState.getBoolean(KEY_INVALID_LIST);
Expand Down Expand Up @@ -226,8 +238,6 @@ private void restoreState(@NonNull final Bundle outState) {

@Override
public void onSaveInstanceState(@NonNull final Bundle outState) {
mPager.setCurrentItem(0);

super.onSaveInstanceState(outState);

if (mNote != null) {
Expand All @@ -239,6 +249,8 @@ public void onSaveInstanceState(@NonNull final Bundle outState) {
if (mDisplayedNote != null) {
outState.putSerializable(KEY_DISPLAYED_NOTE, mDisplayedNote);
}
outState.putBoolean(KEY_DRAFT_EDITABLE, mIsDraftFragEditable);
outState.putBoolean(KEY_NOTE_EDITABLE, mIsNoteFragEditable);
outState.putString(KEY_TITLE, getTitle().toString());
outState.putBoolean(KEY_SHOW_REVS , mShowsRevisions);
outState.putBoolean(KEY_SHOW_TB_EDIT, mShowToolbarEdit);
Expand All @@ -253,9 +265,10 @@ public static void readPreferences(@NonNull final Context context) {
, context.getResources().getString(R.string.PREF_NOTE_OPEN_READONLY_KEY), Boolean.parseBoolean(context.getResources().getString(R.string.pref_note_open_readonly_default)));
}

private void invalidateFloatingActionButton(@NonNull final NoteEditFragment frag) {
private void invalidateFloatingActionButton() {
final boolean isCurrRev = mDisplayedNote != null && mDisplayedNote.getCurrRev() && mDisplayedNote.getCurr();
invalidateFloatingActionButton(isCurrRev, frag.isEditable());
final boolean isEditable = mDisplayedNote != null && mDisplayedNote.getDraft() ? mIsDraftFragEditable : mIsNoteFragEditable;
invalidateFloatingActionButton(isCurrRev, isEditable);
}

private void invalidateFloatingActionButton(boolean isCurrRev, boolean isEditable) {
Expand Down Expand Up @@ -693,17 +706,14 @@ private void saveNote(@NonNull final NoteEditFragment frag) {
final String newTitle = getTitle().toString();
if (!note.getDraft()
&& StringUtil.equals(newMsg, note.getMsg()) && StringUtil.equals(newTitle, note.getTitle())) {
VLog.d(ACTIVITY_IDENT, "Closing note=\"" + note + "\". (no changes)");
// no changes made -> just go back
executeDone();
return;
}

VLog.d(ACTIVITY_IDENT, "Saving note=\"" + note + "\". (title=\"" + newTitle + "\", msg=\"" + newMsg + "\"");

final Note saveNote = NoteServiceImpl.getInstance().clone(note);
saveNote.setMsg(newMsg);
saveNote.setTitle(StringUtil.equals(getResources().getString(R.string.new_note_title), newTitle)? "" : newTitle);
saveNote.setTitle(StringUtil.equals(getResources().getString(R.string.new_note_title), newTitle) ? "" : newTitle);

final boolean wasDraft = note.getDraft();
if (wasDraft) {
Expand Down Expand Up @@ -743,7 +753,6 @@ private void saveNote(@NonNull final NoteEditFragment frag) {
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
dialog.show();

}

private void executeDone() {
Expand Down Expand Up @@ -800,7 +809,7 @@ private void updatePage() {
NoteEditFragment noteFrag = getActiveNoteFragment(getSupportFragmentManager(), mPager);
if (noteFrag != null) {
mDisplayedNote = noteFrag.getNote();
invalidateFloatingActionButton(noteFrag);
invalidateFloatingActionButton();
invalidateOptionsMenu();
}
}
Expand Down Expand Up @@ -934,7 +943,7 @@ private static class NoteFragmentAdapter {

void add(@NonNull final Note note, @NonNull final String fragmentTitle) {
final NoteEditFragment frag = new NoteEditFragment();
frag.initialize(mNoteFrags.size(), note);
frag.initialize(mNoteFrags.size(), note, mOpenNotesReadonly || !note.getCurrRev());
// The fragment's instances should not be destroyed to not invalidate the references to them
frag.setRetainInstance(true);

Expand Down Expand Up @@ -1026,6 +1035,8 @@ private static Fragment getActiveFragment(@NonNull final FragmentManager fragmen
private boolean mInvalidateList = false;

private final NoteFragmentAdapter mNoteFrags = new NoteFragmentAdapter();
private boolean mIsNoteFragEditable = false;
private boolean mIsDraftFragEditable = false;

private NoteFragmentPagerAdapter mAdapter;
private ViewPager mPager;
Expand All @@ -1047,6 +1058,8 @@ private static Fragment getActiveFragment(@NonNull final FragmentManager fragmen
private static final String KEY_DRAFT = "notetabvieweract_draft";
private static final String KEY_TITLE = "notetabvieweract_title";
private static final String KEY_DISPLAYED_NOTE = "notetabvieweract_displayednote";
private static final String KEY_DRAFT_EDITABLE = "notetabvieweract_drafteditable";
private static final String KEY_NOTE_EDITABLE = "notetabvieweract_noteeditable";
private static final String KEY_SHOW_REVS = "notetabvieweract_showrevs";
private static final String KEY_SHOW_TB_EDIT = "notetabvieweract_showtoolbaredit";
private static final String KEY_INVALID_LIST = "notetabvieweract_invalidatelist";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.List;

import de.sepulzera.notes.R;
import de.sepulzera.notes.bf.helper.Helper;
import de.sepulzera.notes.bf.helper.vlog.VLog;
import de.sepulzera.notes.bf.service.NoteService;
import de.sepulzera.notes.bf.service.impl.NoteServiceImpl;
Expand All @@ -40,6 +41,9 @@ protected void onCreate(Bundle savedInstanceState) {

VLog.d(ACTIVITY_IDENT, "Creating activity.");

Helper.localize(getApplicationContext());
Helper.updatePreferences(this);

// SETUP APPLICATION

if (null != savedInstanceState) {
Expand Down

0 comments on commit 1254f2d

Please sign in to comment.