Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appearance improvements #2359

Merged
merged 5 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,6 @@ public void onNothingSelected(AdapterView<?> parent) {
.setView(scrollView)
.create();

final Window window = dialog.getWindow();
if (window != null) {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
}

final GsCallback.a0 submit = () -> {
final String query = searchEditText.getText().toString();
if (dialogCallback != null && !TextUtils.isEmpty(query)) {
Expand Down Expand Up @@ -187,5 +181,11 @@ public void onNothingSelected(AdapterView<?> parent) {
});

dialog.show();

final Window window = dialog.getWindow();
if (window != null) {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
window.setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be match_parent I guess for better usage? See latest issue

}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to be done after show().

(IMO bad design by the Android devs)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ public void afterTextChanged(final Editable arg0) {
.setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> dialogInterface.dismiss())
.create();

final Window window = dialog.getWindow();
if (window != null) {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
}

expandableListView.setOnGroupClickListener((parent, view, groupPosition, id) -> {
final FitFile groupItem = (FitFile) parent.getExpandableListAdapter().getGroup(groupPosition);
if (groupItem.children.isEmpty()) {
Expand Down Expand Up @@ -144,6 +138,11 @@ public void afterTextChanged(final Editable arg0) {
});

dialog.show();
final Window window = dialog.getWindow();
if (window != null) {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
}
}

private static List<FitFile> filter(final List<FitFile> searchResults, String query) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ public static void showMultiChoiceDialogWithSearchFilterUI(final Activity activi
});

dialog.show();

final Window win = dialog.getWindow();
if (win != null) {
if (dopt.isSearchEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ public void onViewCreated(final View root, final @Nullable Bundle savedInstanceS

root.setBackgroundColor(rcolor(_dopt.backgroundColor));

final LinearLayoutManager lam = (LinearLayoutManager) _recyclerList.getLayoutManager();
final DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activity, lam.getOrientation());
_recyclerList.addItemDecoration(dividerItemDecoration);
// final LinearLayoutManager lam = (LinearLayoutManager) _recyclerList.getLayoutManager();
// final DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activity, lam.getOrientation());
// _recyclerList.addItemDecoration(dividerItemDecoration);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Divider decoration not needed. The items do this themselves?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on how it's used. Generally the builtin Recyclerview decoration are better performant but in case there is a own one, of course bad to have multiple.

_recyclerList.setItemViewCacheSize(20);
gsantner marked this conversation as resolved.
Show resolved Hide resolved

_filesystemViewerAdapter = new GsFileBrowserListAdapter(_dopt, activity);
_recyclerList.setAdapter(_filesystemViewerAdapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,14 @@ public void onBindViewHolder(@NonNull FilesystemViewerViewHolder holder, int pos
}
}

holder.description.setTextColor(ContextCompat.getColor(_context, _dopt.secondaryTextColor));
final boolean isFile = file.isFile();

holder.image.postDelayed(() -> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gsantner You added this postDelayed in 2022. Do you remember why?

The code works well without it...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very likely because it was crashing on some devices without it.

holder.image.setImageResource(isSelected ? _dopt.selectedItemImage : (!file.isFile() ? _dopt.folderImage : _dopt.fileImage));
holder.description.setText(!_dopt.descModtimeInsteadOfParent || holder.title.getText().toString().equals("..")
holder.description.setText(!_dopt.descModtimeInsteadOfParent || holder.title.getText().toString().equals("..")
? descriptionFile.getAbsolutePath() : formatFileDescription(file, _prefApp.getString("pref_key__file_description_format", "")));
}, 60);
holder.description.setTextColor(ContextCompat.getColor(_context, _dopt.secondaryTextColor));
holder.image.setImageResource(isSelected ? _dopt.selectedItemImage : isFile ? _dopt.fileImage : _dopt.folderImage);
holder.image.setColorFilter(ContextCompat.getColor(_context,
isSelected ? _dopt.accentColor : (!file.isFile() ? _dopt.folderColor : _dopt.fileColor)),
isSelected ? _dopt.accentColor : isFile? _dopt.fileColor : _dopt.folderColor),
android.graphics.PorterDuff.Mode.SRC_ATOP);
if (!isSelected && isFavourite) {
holder.image.setColorFilter(0xFFE3B51B);
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/layout/expandable_list_group_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingStart="10dp"
android:paddingEnd="5dp"
android:paddingRight="5dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textAppearance="?android:attr/textAppearanceListItem" />
6 changes: 3 additions & 3 deletions app/src/main/res/layout/widget_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
android:layout_below="@id/widget_main"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/fab_circle"
Expand All @@ -75,7 +75,7 @@
android:layout_below="@+id/widget_new_note"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/fab_circle"
Expand All @@ -90,7 +90,7 @@
android:layout_below="@+id/widget_todo"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/fab_circle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import android.os.Build;
import android.widget.RemoteViews;

import androidx.annotation.ColorInt;
import androidx.core.content.ContextCompat;

import net.gsantner.markor.ApplicationObject;
import net.gsantner.markor.R;
import net.gsantner.markor.activity.MainActivity;
Expand All @@ -41,6 +44,7 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a

final int staticFlags = PendingIntent.FLAG_UPDATE_CURRENT | (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_IMMUTABLE : 0);
final int mutableFlags = PendingIntent.FLAG_UPDATE_CURRENT | (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ? PendingIntent.FLAG_MUTABLE : 0);
final @ColorInt int color = ContextCompat.getColor(context, R.color.white);

// Perform this loop procedure for each App Widget that belongs to this provider
for (final int appWidgetId : appWidgetIds) {
Expand All @@ -57,6 +61,7 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a
.setAction(Intent.ACTION_SEND)
.putExtra(Intent.EXTRA_TEXT, "");
views.setOnClickPendingIntent(R.id.widget_new_note, PendingIntent.getActivity(context, requestCode++, openShare, staticFlags));
views.setInt(R.id.widget_new_note, "setColorFilter", color);
gsantner marked this conversation as resolved.
Show resolved Hide resolved

// Open Folder
final Intent goToFolder = new Intent(context, MainActivity.class)
Expand All @@ -70,19 +75,22 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a
.putExtra(Document.EXTRA_FILE, appSettings.getTodoFile())
.putExtra(Document.EXTRA_FILE_LINE_NUMBER, Document.EXTRA_FILE_LINE_NUMBER_LAST);
views.setOnClickPendingIntent(R.id.widget_todo, PendingIntent.getActivity(context, requestCode++, openTodo, staticFlags));
views.setInt(R.id.widget_todo, "setColorFilter", color);

// Open QuickNote
final Intent openQuickNote = new Intent(context, OpenFromShortcutOrWidgetActivity.class)
.setAction(Intent.ACTION_EDIT)
.putExtra(Document.EXTRA_FILE, appSettings.getQuickNoteFile())
.putExtra(Document.EXTRA_FILE_LINE_NUMBER, Document.EXTRA_FILE_LINE_NUMBER_LAST);
views.setOnClickPendingIntent(R.id.widget_quicknote, PendingIntent.getActivity(context, requestCode++, openQuickNote, staticFlags));
views.setInt(R.id.widget_quicknote, "setColorFilter", color);

// Open Notebook
final Intent goHome = new Intent(context, MainActivity.class)
.setAction(Intent.ACTION_VIEW)
.putExtra(Document.EXTRA_FILE, appSettings.getNotebookDirectory());
views.setOnClickPendingIntent(R.id.widget_main, PendingIntent.getActivity(context, requestCode++, goHome, staticFlags));
views.setInt(R.id.widget_main, "setColorFilter", color);

// ListView
final Intent notesListIntent = new Intent(context, WrFilesWidgetService.class)
Expand Down
Loading