Skip to content

Commit

Permalink
Improvements to display of file browser dialog / fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 committed Aug 17, 2024
1 parent 287c271 commit 00eae25
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public void onBackPressed() {
// Exit confirmed with 2xBack
if (_doubleBackToExitPressedOnce) {
super.onBackPressed();
_appSettings.setFileBrowserLastBrowsedFolder(_appSettings.getNotebookDirectory());
_appSettings.setFileBrowserLastBrowsedFolder(_notebook.getCurrentFolder());
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -127,7 +128,7 @@ public void onViewCreated(final View root, final @Nullable Bundle savedInstanceS
_toolBar.setTitleTextColor(rcolor(_dopt.titleTextColor));
_toolBar.setTitle(_dopt.titleText);
_toolBar.setSubtitleTextColor(rcolor(_dopt.secondaryTextColor));
_toolBar.setSubtitleTextAppearance(activity, R.style.TextAppearance_AppCompat_Subhead_Ellipsize);
setSubtitleApprearance(_toolBar);

_homeButton.setImageResource(_dopt.homeButtonImage);
_homeButton.setVisibility(_dopt.homeButtonEnable ? View.VISIBLE : View.GONE);
Expand Down Expand Up @@ -302,4 +303,30 @@ public void onStart() {
w.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
}
}

private static void setSubtitleApprearance(final Toolbar toolbar) {
final String test = "__%%SUBTITLE%%__";
toolbar.setSubtitle(test);

for (int i = 0; i < toolbar.getChildCount(); i++) {
final View child = toolbar.getChildAt(i);
if (child instanceof TextView) {
final TextView tv = (TextView) child;
if (test.contentEquals(tv.getText())) {

tv.setEllipsize(TextUtils.TruncateAt.START);
tv.setSingleLine(true);
final Toolbar.LayoutParams params = new Toolbar.LayoutParams(
Toolbar.LayoutParams.MATCH_PARENT,
Toolbar.LayoutParams.WRAP_CONTENT
);
tv.setLayoutParams(params);

break;
}
}
}

toolbar.setSubtitle("");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ public boolean goBack() {
}

public boolean canGoBack() {
return !_backStack.empty();
return !_backStack.isEmpty();
}

public boolean goUp() {
Expand Down Expand Up @@ -666,7 +666,7 @@ private void loadFolder(final File folder, final File show) {
if (GO_BACK_SIGNIFIER == folder) {
toLoad = _backStack.pop();
} else {
if (folderChanged) {
if (folderChanged && _currentFolder != null) {
_backStack.push(_currentFolder);
}
toLoad = folder;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/opoc_filesystem_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="middle"
android:ellipsize="start"
android:importantForAccessibility="no"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,4 @@
<item name="android:backgroundDimEnabled">true</item>
<item name="colorAccent">@color/accent</item>
</style>

<style name="TextAppearance.AppCompat.Subhead.Ellipsize" parent="TextAppearance.AppCompat.Subhead">
<item name="android:ellipsize">end</item>
<item name="android:cursorVisible">false</item>
</style>
</resources>

0 comments on commit 00eae25

Please sign in to comment.