Loading app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidgetFactory.java +26 −11 Original line number Original line Diff line number Diff line package it.niedermann.owncloud.notes.widget.notelist; package it.niedermann.owncloud.notes.widget.notelist; import android.app.PendingIntent; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetManager; import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.net.Uri; import android.net.Uri; Loading @@ -9,6 +11,7 @@ import android.util.Log; import android.widget.RemoteViews; import android.widget.RemoteViews; import android.widget.RemoteViewsService; import android.widget.RemoteViewsService; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat; Loading @@ -19,6 +22,7 @@ import it.niedermann.android.util.ColorUtil; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.branding.BrandingUtil; import it.niedermann.owncloud.notes.branding.BrandingUtil; import it.niedermann.owncloud.notes.edit.EditNoteActivity; import it.niedermann.owncloud.notes.edit.EditNoteActivity; import it.niedermann.owncloud.notes.main.MainActivity; import it.niedermann.owncloud.notes.persistence.NotesDatabase; import it.niedermann.owncloud.notes.persistence.NotesDatabase; import it.niedermann.owncloud.notes.shared.model.Category; import it.niedermann.owncloud.notes.shared.model.Category; import it.niedermann.owncloud.notes.shared.model.DBNote; import it.niedermann.owncloud.notes.shared.model.DBNote; Loading Loading @@ -96,7 +100,20 @@ public class NoteListWidgetFactory implements RemoteViewsService.RemoteViewsFact if (position == 0) { if (position == 0) { final LocalAccount localAccount = db.getAccount(data.getAccountId()); final LocalAccount localAccount = db.getAccount(data.getAccountId()); final Intent fillInIntent = new Intent(); final Intent createIntent = new Intent(); // Launch application when user taps the header icon or app title final Intent openIntent = new Intent(Intent.ACTION_MAIN); openIntent.setComponent(new ComponentName(context.getPackageName(), MainActivity.class.getName())); // Open the main app if the user taps the widget header PendingIntent openAppI = PendingIntent.getActivity(context, 2, openIntent, PendingIntent.FLAG_UPDATE_CURRENT); final Bundle extras = new Bundle(); final Bundle extras = new Bundle(); String category = null; String category = null; Loading @@ -108,11 +125,11 @@ public class NoteListWidgetFactory implements RemoteViewsService.RemoteViewsFact extras.putSerializable(PARAM_CATEGORY, new Category(category, data.getMode() == MODE_DISPLAY_STARRED)); extras.putSerializable(PARAM_CATEGORY, new Category(category, data.getMode() == MODE_DISPLAY_STARRED)); extras.putLong(EditNoteActivity.PARAM_ACCOUNT_ID, data.getAccountId()); extras.putLong(EditNoteActivity.PARAM_ACCOUNT_ID, data.getAccountId()); fillInIntent.putExtras(extras); createIntent.putExtras(extras); fillInIntent.setData(Uri.parse(fillInIntent.toUri(Intent.URI_INTENT_SCHEME))); createIntent.setData(Uri.parse(createIntent.toUri(Intent.URI_INTENT_SCHEME))); note_content = new RemoteViews(context.getPackageName(), R.layout.widget_entry_add); note_content = new RemoteViews(context.getPackageName(), R.layout.widget_entry_add); note_content.setOnClickFillInIntent(R.id.widget_note_list_entry, fillInIntent); note_content.setOnClickFillInIntent(R.id.widget_entry_fav_icon, createIntent); note_content.setTextViewText(R.id.widget_entry_content_tv, getAddButtonText(context, data.getMode(), category)); note_content.setTextViewText(R.id.widget_entry_content_tv, getAddButtonText(context, data.getMode(), category)); note_content.setImageViewResource(R.id.widget_entry_fav_icon, R.drawable.ic_add_blue_24dp); note_content.setImageViewResource(R.id.widget_entry_fav_icon, R.drawable.ic_add_blue_24dp); note_content.setInt(R.id.widget_entry_fav_icon, "setColorFilter", NotesColorUtil.contrastRatioIsSufficient(ContextCompat.getColor(context, R.color.widget_background), localAccount.getColor()) note_content.setInt(R.id.widget_entry_fav_icon, "setColorFilter", NotesColorUtil.contrastRatioIsSufficient(ContextCompat.getColor(context, R.color.widget_background), localAccount.getColor()) Loading Loading @@ -150,16 +167,14 @@ public class NoteListWidgetFactory implements RemoteViewsService.RemoteViewsFact private static String getAddButtonText(@NonNull Context context, int displayMode, String category) { private static String getAddButtonText(@NonNull Context context, int displayMode, String category) { switch (displayMode) { switch (displayMode) { case MODE_DISPLAY_STARRED: case MODE_DISPLAY_STARRED: return context.getString(R.string.widget_note_list_add_favorite); return context.getString(R.string.label_favorites); case MODE_DISPLAY_CATEGORY: case MODE_DISPLAY_CATEGORY: if ("".equals(category)) { return "".equals(category) return context.getString(R.string.widget_note_list_add); ? context.getString(R.string.action_uncategorized) } else { : category; return context.getString(R.string.widget_note_list_add_to_category, category); } case MODE_DISPLAY_ALL: case MODE_DISPLAY_ALL: default: default: return context.getString(R.string.widget_note_list_add); return context.getString(R.string.app_name); } } } } Loading app/src/main/res/layout/widget_entry_add.xml +17 −16 Original line number Original line Diff line number Diff line Loading @@ -5,33 +5,34 @@ android:id="@+id/widget_note_list_entry" android:id="@+id/widget_note_list_entry" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:orientation="horizontal"> android:padding="@dimen/spacer_1x"> <ImageView android:id="@+id/widget_entry_fav_icon" android:layout_width="@dimen/widget_note_list_fav_icon_width" android:layout_height="@dimen/widget_note_list_fav_icon_height" android:layout_gravity="center_vertical" android:contentDescription="@string/widget_entry_fav_contentDescription" android:foregroundGravity="center_vertical" android:paddingStart="@dimen/widget_note_list_inner_padding" android:paddingEnd="@dimen/widget_note_list_outer_padding" app:srcCompat="@drawable/ic_add_blue_24dp" /> <TextView <TextView android:id="@+id/widget_entry_content_tv" android:id="@+id/widget_entry_content_tv" android:layout_width="0dp" android:layout_width="0dp" android:layout_height="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_gravity="center_vertical" android:layout_weight="1" android:layout_weight="1" android:ellipsize="middle" android:ellipsize="middle" android:gravity="center_vertical" android:paddingStart="38dp" android:paddingStart="@dimen/widget_note_list_inner_padding" android:paddingTop="@dimen/spacer_1x" android:paddingEnd="@dimen/widget_note_list_outer_padding" android:paddingEnd="@dimen/widget_note_list_outer_padding" android:paddingBottom="@dimen/spacer_1x" android:singleLine="true" android:singleLine="true" android:textColor="@color/widget_foreground" android:textColor="@color/widget_foreground" android:textSize="14sp" android:textSize="14sp" android:textStyle="bold" tools:text="@string/widget_note_list_add" /> tools:text="@string/widget_note_list_add" /> <ImageView android:id="@+id/widget_entry_fav_icon" android:layout_width="40dp" android:layout_height="match_parent" android:layout_gravity="center_vertical" android:contentDescription="@string/widget_entry_fav_contentDescription" android:foregroundGravity="center_vertical" android:paddingStart="@dimen/widget_note_list_inner_padding" android:paddingEnd="12dp" app:srcCompat="@drawable/ic_add_blue_24dp" /> </LinearLayout> </LinearLayout> app/src/main/res/layout/widget_note_list.xml +2 −2 Original line number Original line Diff line number Diff line Loading @@ -10,8 +10,8 @@ android:id="@+id/note_list_widget_lv" android:id="@+id/note_list_widget_lv" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:divider="@color/widget_divider" android:divider="@android:color/transparent" android:dividerHeight="@dimen/widget_divider" android:dividerHeight="@null" android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium" tools:listitem="@layout/widget_entry" /> tools:listitem="@layout/widget_entry" /> Loading app/src/main/res/values/dimens.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -42,6 +42,7 @@ <dimen name="widget_note_list_outer_padding">4dp</dimen> <dimen name="widget_note_list_outer_padding">4dp</dimen> <dimen name="widget_note_list_inner_padding">4dp</dimen> <dimen name="widget_note_list_inner_padding">4dp</dimen> <dimen name="widget_note_list_entry_add_button">34dp</dimen> <dimen name="widget_note_list_fav_icon_width">26dp</dimen> <dimen name="widget_note_list_fav_icon_width">26dp</dimen> <dimen name="widget_note_list_fav_icon_height">20dp</dimen> <dimen name="widget_note_list_fav_icon_height">20dp</dimen> </resources> </resources> Loading
app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidgetFactory.java +26 −11 Original line number Original line Diff line number Diff line package it.niedermann.owncloud.notes.widget.notelist; package it.niedermann.owncloud.notes.widget.notelist; import android.app.PendingIntent; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetManager; import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.net.Uri; import android.net.Uri; Loading @@ -9,6 +11,7 @@ import android.util.Log; import android.widget.RemoteViews; import android.widget.RemoteViews; import android.widget.RemoteViewsService; import android.widget.RemoteViewsService; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat; Loading @@ -19,6 +22,7 @@ import it.niedermann.android.util.ColorUtil; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.branding.BrandingUtil; import it.niedermann.owncloud.notes.branding.BrandingUtil; import it.niedermann.owncloud.notes.edit.EditNoteActivity; import it.niedermann.owncloud.notes.edit.EditNoteActivity; import it.niedermann.owncloud.notes.main.MainActivity; import it.niedermann.owncloud.notes.persistence.NotesDatabase; import it.niedermann.owncloud.notes.persistence.NotesDatabase; import it.niedermann.owncloud.notes.shared.model.Category; import it.niedermann.owncloud.notes.shared.model.Category; import it.niedermann.owncloud.notes.shared.model.DBNote; import it.niedermann.owncloud.notes.shared.model.DBNote; Loading Loading @@ -96,7 +100,20 @@ public class NoteListWidgetFactory implements RemoteViewsService.RemoteViewsFact if (position == 0) { if (position == 0) { final LocalAccount localAccount = db.getAccount(data.getAccountId()); final LocalAccount localAccount = db.getAccount(data.getAccountId()); final Intent fillInIntent = new Intent(); final Intent createIntent = new Intent(); // Launch application when user taps the header icon or app title final Intent openIntent = new Intent(Intent.ACTION_MAIN); openIntent.setComponent(new ComponentName(context.getPackageName(), MainActivity.class.getName())); // Open the main app if the user taps the widget header PendingIntent openAppI = PendingIntent.getActivity(context, 2, openIntent, PendingIntent.FLAG_UPDATE_CURRENT); final Bundle extras = new Bundle(); final Bundle extras = new Bundle(); String category = null; String category = null; Loading @@ -108,11 +125,11 @@ public class NoteListWidgetFactory implements RemoteViewsService.RemoteViewsFact extras.putSerializable(PARAM_CATEGORY, new Category(category, data.getMode() == MODE_DISPLAY_STARRED)); extras.putSerializable(PARAM_CATEGORY, new Category(category, data.getMode() == MODE_DISPLAY_STARRED)); extras.putLong(EditNoteActivity.PARAM_ACCOUNT_ID, data.getAccountId()); extras.putLong(EditNoteActivity.PARAM_ACCOUNT_ID, data.getAccountId()); fillInIntent.putExtras(extras); createIntent.putExtras(extras); fillInIntent.setData(Uri.parse(fillInIntent.toUri(Intent.URI_INTENT_SCHEME))); createIntent.setData(Uri.parse(createIntent.toUri(Intent.URI_INTENT_SCHEME))); note_content = new RemoteViews(context.getPackageName(), R.layout.widget_entry_add); note_content = new RemoteViews(context.getPackageName(), R.layout.widget_entry_add); note_content.setOnClickFillInIntent(R.id.widget_note_list_entry, fillInIntent); note_content.setOnClickFillInIntent(R.id.widget_entry_fav_icon, createIntent); note_content.setTextViewText(R.id.widget_entry_content_tv, getAddButtonText(context, data.getMode(), category)); note_content.setTextViewText(R.id.widget_entry_content_tv, getAddButtonText(context, data.getMode(), category)); note_content.setImageViewResource(R.id.widget_entry_fav_icon, R.drawable.ic_add_blue_24dp); note_content.setImageViewResource(R.id.widget_entry_fav_icon, R.drawable.ic_add_blue_24dp); note_content.setInt(R.id.widget_entry_fav_icon, "setColorFilter", NotesColorUtil.contrastRatioIsSufficient(ContextCompat.getColor(context, R.color.widget_background), localAccount.getColor()) note_content.setInt(R.id.widget_entry_fav_icon, "setColorFilter", NotesColorUtil.contrastRatioIsSufficient(ContextCompat.getColor(context, R.color.widget_background), localAccount.getColor()) Loading Loading @@ -150,16 +167,14 @@ public class NoteListWidgetFactory implements RemoteViewsService.RemoteViewsFact private static String getAddButtonText(@NonNull Context context, int displayMode, String category) { private static String getAddButtonText(@NonNull Context context, int displayMode, String category) { switch (displayMode) { switch (displayMode) { case MODE_DISPLAY_STARRED: case MODE_DISPLAY_STARRED: return context.getString(R.string.widget_note_list_add_favorite); return context.getString(R.string.label_favorites); case MODE_DISPLAY_CATEGORY: case MODE_DISPLAY_CATEGORY: if ("".equals(category)) { return "".equals(category) return context.getString(R.string.widget_note_list_add); ? context.getString(R.string.action_uncategorized) } else { : category; return context.getString(R.string.widget_note_list_add_to_category, category); } case MODE_DISPLAY_ALL: case MODE_DISPLAY_ALL: default: default: return context.getString(R.string.widget_note_list_add); return context.getString(R.string.app_name); } } } } Loading
app/src/main/res/layout/widget_entry_add.xml +17 −16 Original line number Original line Diff line number Diff line Loading @@ -5,33 +5,34 @@ android:id="@+id/widget_note_list_entry" android:id="@+id/widget_note_list_entry" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:orientation="horizontal"> android:padding="@dimen/spacer_1x"> <ImageView android:id="@+id/widget_entry_fav_icon" android:layout_width="@dimen/widget_note_list_fav_icon_width" android:layout_height="@dimen/widget_note_list_fav_icon_height" android:layout_gravity="center_vertical" android:contentDescription="@string/widget_entry_fav_contentDescription" android:foregroundGravity="center_vertical" android:paddingStart="@dimen/widget_note_list_inner_padding" android:paddingEnd="@dimen/widget_note_list_outer_padding" app:srcCompat="@drawable/ic_add_blue_24dp" /> <TextView <TextView android:id="@+id/widget_entry_content_tv" android:id="@+id/widget_entry_content_tv" android:layout_width="0dp" android:layout_width="0dp" android:layout_height="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_gravity="center_vertical" android:layout_weight="1" android:layout_weight="1" android:ellipsize="middle" android:ellipsize="middle" android:gravity="center_vertical" android:paddingStart="38dp" android:paddingStart="@dimen/widget_note_list_inner_padding" android:paddingTop="@dimen/spacer_1x" android:paddingEnd="@dimen/widget_note_list_outer_padding" android:paddingEnd="@dimen/widget_note_list_outer_padding" android:paddingBottom="@dimen/spacer_1x" android:singleLine="true" android:singleLine="true" android:textColor="@color/widget_foreground" android:textColor="@color/widget_foreground" android:textSize="14sp" android:textSize="14sp" android:textStyle="bold" tools:text="@string/widget_note_list_add" /> tools:text="@string/widget_note_list_add" /> <ImageView android:id="@+id/widget_entry_fav_icon" android:layout_width="40dp" android:layout_height="match_parent" android:layout_gravity="center_vertical" android:contentDescription="@string/widget_entry_fav_contentDescription" android:foregroundGravity="center_vertical" android:paddingStart="@dimen/widget_note_list_inner_padding" android:paddingEnd="12dp" app:srcCompat="@drawable/ic_add_blue_24dp" /> </LinearLayout> </LinearLayout>
app/src/main/res/layout/widget_note_list.xml +2 −2 Original line number Original line Diff line number Diff line Loading @@ -10,8 +10,8 @@ android:id="@+id/note_list_widget_lv" android:id="@+id/note_list_widget_lv" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:divider="@color/widget_divider" android:divider="@android:color/transparent" android:dividerHeight="@dimen/widget_divider" android:dividerHeight="@null" android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium" tools:listitem="@layout/widget_entry" /> tools:listitem="@layout/widget_entry" /> Loading
app/src/main/res/values/dimens.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -42,6 +42,7 @@ <dimen name="widget_note_list_outer_padding">4dp</dimen> <dimen name="widget_note_list_outer_padding">4dp</dimen> <dimen name="widget_note_list_inner_padding">4dp</dimen> <dimen name="widget_note_list_inner_padding">4dp</dimen> <dimen name="widget_note_list_entry_add_button">34dp</dimen> <dimen name="widget_note_list_fav_icon_width">26dp</dimen> <dimen name="widget_note_list_fav_icon_width">26dp</dimen> <dimen name="widget_note_list_fav_icon_height">20dp</dimen> <dimen name="widget_note_list_fav_icon_height">20dp</dimen> </resources> </resources>