create new instance of NoteSQLiteOpenHelper on SettingsChangedEvent

This commit is contained in:
Stefan Niedermann 2015-10-21 19:05:20 +02:00
parent 407407f6cd
commit e92f1156c2
6 changed files with 24 additions and 20 deletions

View file

@ -16,10 +16,4 @@ public class NoteTest extends TestCase {
note.setTitle("* Aufzählung"); note.setTitle("* Aufzählung");
assertTrue("Aufzählung".equals(note.getTitle())); assertTrue("Aufzählung".equals(note.getTitle()));
} }
public void testMarkDownRendering() {
Note note = new Note(0, Calendar.getInstance(), "", "**bold**");
System.out.println(note.getHtmlContent());
assertTrue(note.getHtmlContent().contains("<strong>bold</strong>"));
}
} }

View file

@ -26,7 +26,7 @@ public class NoteActivity extends AppCompatActivity implements View.OnClickListe
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// backToListViewIntent = new Intent(); Log.v("Note", "NoteActivity.onCreate()");
setContentView(R.layout.activity_single_note); setContentView(R.layout.activity_single_note);
note = (Note) getIntent().getSerializableExtra( note = (Note) getIntent().getSerializableExtra(
NotesListViewActivity.SELECTED_NOTE); NotesListViewActivity.SELECTED_NOTE);
@ -38,7 +38,7 @@ public class NoteActivity extends AppCompatActivity implements View.OnClickListe
actionBar.setTitle(note.getTitle()); actionBar.setTitle(note.getTitle());
actionBar.setSubtitle(note.getModified("dd.MM.yyyy HH:mm")); actionBar.setSubtitle(note.getModified("dd.MM.yyyy HH:mm"));
} }
noteContent = (TextView) findViewById(R.id.singleNoteContent); noteContent = (TextView) findViewById(R.id.single_note_content);
noteContent.setText(note.getSpannableContent()); noteContent.setText(note.getSpannableContent());
} }

View file

@ -9,7 +9,6 @@ import android.util.Log;
import android.widget.RemoteViews; import android.widget.RemoteViews;
import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.android.activity.NoteActivity;
import it.niedermann.owncloud.notes.android.activity.NotesListViewActivity; import it.niedermann.owncloud.notes.android.activity.NotesListViewActivity;
import it.niedermann.owncloud.notes.model.Note; import it.niedermann.owncloud.notes.model.Note;
@ -18,22 +17,28 @@ import it.niedermann.owncloud.notes.model.Note;
* Created by stefan on 08.10.15. * Created by stefan on 08.10.15.
*/ */
public class SingleNoteWidget extends AppWidgetProvider { public class SingleNoteWidget extends AppWidgetProvider {
public final static String ACTION_SHOW_NOTE = "ACTION_SHOW_NOTE";
public static void updateAppWidget(Note note, Context context, AppWidgetManager appWidgetManager, int appWidgetId) { public static void updateAppWidget(Note note, Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget_single_note); RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget_single_note);
if (note != null) { if (note != null) {
updateViews.setTextViewText(R.id.singleNoteContent, note.getSpannableContent()); updateViews.setTextViewText(R.id.single_note_content, note.getSpannableContent());
}
appWidgetManager.updateAppWidget(appWidgetId, updateViews);
//FIXME does not work! //FIXME does not work!
Intent intent = new Intent(context, NoteActivity.class); Intent intent = new Intent(context, SingleNoteWidget.class);
//intent.setAction(ACTION_SHOW_NOTE);
intent.putExtra(NotesListViewActivity.SELECTED_NOTE, note); intent.putExtra(NotesListViewActivity.SELECTED_NOTE, note);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
updateViews.setOnClickPendingIntent(R.id.singleNoteContent, pendingIntent); updateViews.setOnClickPendingIntent(R.id.single_note, pendingIntent);
}
appWidgetManager.updateAppWidget(appWidgetId, updateViews);
} }
@Override @Override
public void onEnabled(Context context) { public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
if (intent.getAction().equals(ACTION_SHOW_NOTE)) {
Log.v("SingleNoteWidget", "SingleNoteWidget.onReceive()");
}
} }
@Override @Override

View file

@ -10,7 +10,7 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
<TextView <TextView
android:id="@+id/singleNoteContent" android:id="@+id/single_note_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="10dp" android:padding="10dp"

View file

@ -7,5 +7,9 @@
<ListView <ListView
android:id="@+id/list_view" android:id="@+id/list_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"
android:background="@color/bg_transparent"
android:padding="10dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/fg_contrast" />
</FrameLayout> </FrameLayout>

View file

@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/single_note"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/singleNoteContent" android:id="@+id/single_note_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/bg_transparent" android:background="@color/bg_transparent"