Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetConfigurationActivity.java')
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetConfigurationActivity.java74
1 files changed, 74 insertions, 0 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetConfigurationActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetConfigurationActivity.java
new file mode 100644
index 00000000..ef3bbbe6
--- /dev/null
+++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetConfigurationActivity.java
@@ -0,0 +1,74 @@
+package it.niedermann.owncloud.notes.widget.singlenote;
+
+import android.app.Activity;
+import android.appwidget.AppWidgetManager;
+import android.content.Intent;
+import android.database.SQLException;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Toast;
+
+import androidx.appcompat.widget.Toolbar;
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
+
+import it.niedermann.owncloud.notes.R;
+import it.niedermann.owncloud.notes.exception.ExceptionHandler;
+import it.niedermann.owncloud.notes.main.MainActivity;
+import it.niedermann.owncloud.notes.shared.model.DBNote;
+import it.niedermann.owncloud.notes.NotesApplication;
+
+public class SingleNoteWidgetConfigurationActivity extends MainActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this));
+ setResult(Activity.RESULT_CANCELED);
+
+ fabCreate.setVisibility(View.GONE);
+ Toolbar toolbar = binding.activityNotesListView.toolbar;
+ SwipeRefreshLayout swipeRefreshLayout = binding.activityNotesListView.swiperefreshlayout;
+ toolbar.setTitle(R.string.activity_select_single_note);
+ swipeRefreshLayout.setEnabled(false);
+ swipeRefreshLayout.setRefreshing(false);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ return true;
+ }
+
+ @Override
+ public void onNoteClick(int position, View v) {
+ final DBNote note = (DBNote) adapter.getItem(position);
+ final Bundle extras = getIntent().getExtras();
+
+ if (extras == null) {
+ finish();
+ return;
+ }
+
+ int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
+
+ try {
+ db.createOrUpdateSingleNoteWidgetData(
+ new SingleNoteWidgetData(
+ appWidgetId,
+ note.getAccountId(),
+ note.getId(),
+ NotesApplication.getAppTheme(this).getModeId()
+ )
+ );
+ final Intent updateIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE, null,
+ getApplicationContext(), SingleNoteWidget.class)
+ .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
+ setResult(RESULT_OK, updateIntent);
+ getApplicationContext().sendBroadcast(updateIntent);
+ } catch (SQLException e) {
+ Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
+ }
+
+ finish();
+ }
+}