Skip to content

Commit 167d5e9

Browse files
committed
Rounded widget corners, hide text actions bar
1 parent bce6cb2 commit 167d5e9

5 files changed

Lines changed: 134 additions & 122 deletions

File tree

app/src/main/java/net/gsantner/markor/activity/DocumentEditAndViewFragment.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,34 @@ public void applyTextFormat(final int textFormatId) {
669669
.setUiReferences(activity, _hlEditor, _webView)
670670
.recreateActionButtons(_textActionsBar, _isPreviewVisible ? ActionButtonBase.ActionItem.DisplayMode.VIEW : ActionButtonBase.ActionItem.DisplayMode.EDIT);
671671
updateMenuToggleStates(_format.getFormatId());
672+
showHideActionBar();
673+
}
674+
675+
private void showHideActionBar() {
676+
final Activity activity = getActivity();
677+
if (activity != null) {
678+
final View bar = activity.findViewById(R.id.document__fragment__edit__text_actions_bar);
679+
final View parent = activity.findViewById(R.id.document__fragment__edit__text_actions_bar__scrolling_parent);
680+
final View editScroll = activity.findViewById(R.id.document__fragment__edit__content_editor__scrolling_parent);
681+
final View viewScroll = activity.findViewById(R.id.document__fragment_view_webview);
682+
683+
if (bar != null && parent != null && editScroll != null && viewScroll != null) {
684+
final boolean hide = _textActionsBar.getChildCount() == 0;
685+
parent.setVisibility(hide ? View.GONE : View.VISIBLE);
686+
final int marginBottom = hide ? 0 : (int) getResources().getDimension(R.dimen.textactions_bar_height);
687+
setMarginBottom(editScroll, marginBottom);
688+
setMarginBottom(viewScroll, marginBottom);
689+
690+
}
691+
}
692+
}
693+
694+
private void setMarginBottom(final View view, final int marginBottom) {
695+
final ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
696+
if (params != null) {
697+
params.setMargins(params.leftMargin, params.topMargin, params.rightMargin, marginBottom);
698+
view.setLayoutParams(params);
699+
}
672700
}
673701

674702
private void updateMenuToggleStates(final int selectedFormatActionId) {
@@ -813,6 +841,7 @@ public void setViewModeVisibility(boolean show, final boolean animate) {
813841
show |= _document.isBinaryFileNoTextLoading();
814842

815843
_format.getActions().recreateActionButtons(_textActionsBar, show ? ActionButtonBase.ActionItem.DisplayMode.VIEW : ActionButtonBase.ActionItem.DisplayMode.EDIT);
844+
showHideActionBar();
816845
if (show) {
817846
updateViewModeText();
818847
_cu.showSoftKeyboard(activity, false, _hlEditor);

app/src/main/java/net/gsantner/markor/activity/MarkorBaseActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected boolean onReceiveKeyPress(GsFragmentBase fragment, int keyCode, KeyEve
3939

4040
@Override
4141
public Integer getNewNavigationBarColor() {
42-
return null; // Set by style
42+
return _appSettings.getAppThemeName().contains("black") ? Color.BLACK : null;
4343
}
4444

4545
@Override

app/src/main/java/net/gsantner/markor/format/ActionButtonBase.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@
1414
import android.content.Context;
1515
import android.content.DialogInterface;
1616
import android.content.SharedPreferences;
17-
import android.os.Build;
1817
import android.os.Handler;
1918
import android.text.Editable;
20-
import android.text.Spannable;
21-
import android.text.SpannableStringBuilder;
2219
import android.text.TextUtils;
2320
import android.view.HapticFeedbackConstants;
2421
import android.view.KeyEvent;
@@ -33,7 +30,6 @@
3330
import androidx.annotation.DrawableRes;
3431
import androidx.annotation.NonNull;
3532
import androidx.annotation.Nullable;
36-
import androidx.annotation.RequiresApi;
3733
import androidx.annotation.StringRes;
3834
import androidx.appcompat.widget.TooltipCompat;
3935

@@ -292,13 +288,12 @@ public List<String> getActionOrder() {
292288
}
293289

294290
@SuppressWarnings("ConstantConditions")
295-
public void recreateActionButtons(ViewGroup barLayout, ActionItem.DisplayMode displayMode) {
291+
public void recreateActionButtons(final ViewGroup barLayout, final ActionItem.DisplayMode displayMode) {
296292
barLayout.removeAllViews();
297-
setBarVisible(barLayout, true);
298-
299293
final Map<String, ActionItem> map = getActiveActionMap();
300294
final List<String> orderedKeys = getActionOrder();
301295
final Set<String> disabledKeys = new HashSet<>(getDisabledActions());
296+
302297
for (final String key : orderedKeys) {
303298
final ActionItem action = map.get(key);
304299
if (!disabledKeys.contains(key) && (action.displayMode == displayMode || action.displayMode == ActionItem.DisplayMode.ANY)) {
@@ -374,12 +369,6 @@ protected void appendActionButtonToBar(final ViewGroup barLayout, final @NonNull
374369
barLayout.addView(btn);
375370
}
376371

377-
protected void setBarVisible(ViewGroup barLayout, boolean visible) {
378-
if (barLayout.getId() == R.id.document__fragment__edit__text_actions_bar && barLayout.getParent() instanceof HorizontalScrollView) {
379-
((HorizontalScrollView) barLayout.getParent()).setVisibility(visible ? View.VISIBLE : View.GONE);
380-
}
381-
}
382-
383372
protected void runRegularPrefixAction(String action) {
384373
runRegularPrefixAction(action, null, false);
385374
}

app/src/main/res/drawable/rounded_corner_background.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
android:insetTop="8dp">
77
<shape>
88
<corners android:radius="@dimen/dialog_corner_radius"/>
9-
<solid android:color="?attr/colorBackgroundFloating" />
9+
<solid android:color="@color/background_2" />
1010
</shape>
1111
</inset>

app/src/main/res/layout/widget_layout.xml

Lines changed: 101 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -9,126 +9,120 @@
99
* https://opensource.org/licenses/MIT
1010
###########################################################*/
1111
-->
12-
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
12+
<RelativeLayout
13+
xmlns:android="http://schemas.android.com/apk/res/android"
1314
xmlns:app="http://schemas.android.com/apk/res-auto"
14-
xmlns:tools="http://schemas.android.com/tools"
1515
android:layout_width="match_parent"
16-
android:layout_height="match_parent"
16+
android:layout_height="wrap_content"
17+
android:clipToOutline="true"
18+
android:outlineProvider="background"
1719
android:background="@drawable/rounded_corner_background">
1820

19-
<RelativeLayout
21+
<LinearLayout
22+
android:id="@+id/widget_header"
2023
android:layout_width="match_parent"
21-
android:layout_height="wrap_content"
22-
android:background="@color/background_2"
23-
tools:ignore="UselessParent">
24+
android:layout_height="36sp"
25+
android:background="@color/primary">
2426

25-
<LinearLayout
26-
android:id="@+id/widget_header"
27+
<TextView
28+
android:id="@+id/widget_header_title"
2729
android:layout_width="match_parent"
28-
android:layout_height="36sp"
29-
android:background="@color/primary">
30+
android:layout_height="match_parent"
31+
android:gravity="center|start"
32+
android:paddingStart="15sp"
33+
android:paddingLeft="15sp"
34+
android:paddingEnd="0sp"
35+
android:paddingRight="0sp"
36+
android:text="@string/app_name"
37+
android:textColor="@color/white"
38+
android:textSize="16sp"
39+
android:textStyle="bold" />
40+
</LinearLayout>
41+
42+
<ImageButton
43+
android:id="@+id/widget_main"
44+
android:layout_width="40dp"
45+
android:layout_height="40dp"
46+
android:layout_alignParentEnd="true"
47+
android:layout_alignParentRight="true"
48+
android:layout_marginTop="8dp"
49+
android:layout_marginEnd="10dp"
50+
android:layout_marginRight="10dp"
51+
android:background="@drawable/fab_circle"
52+
android:elevation="2dp"
53+
android:src="@drawable/ic_home_black_24dp"
54+
app:tint="@color/white" />
3055

31-
<TextView
32-
android:id="@+id/widget_header_title"
33-
android:layout_width="match_parent"
34-
android:layout_height="match_parent"
35-
android:gravity="center|start"
36-
android:paddingStart="15sp"
37-
android:paddingLeft="15sp"
38-
android:paddingEnd="0sp"
39-
android:paddingRight="0sp"
40-
android:text="@string/app_name"
41-
android:textColor="@color/white"
42-
android:textSize="16sp"
43-
android:textStyle="bold" />
44-
</LinearLayout>
56+
<ImageButton
57+
android:id="@+id/widget_new_note"
58+
android:layout_width="40dp"
59+
android:layout_height="40dp"
60+
android:layout_below="@id/widget_main"
61+
android:layout_alignParentEnd="true"
62+
android:layout_alignParentRight="true"
63+
android:layout_marginTop="4dp"
64+
android:layout_marginEnd="10dp"
65+
android:layout_marginRight="10dp"
66+
android:background="@drawable/fab_circle"
67+
android:elevation="2dp"
68+
android:src="@drawable/ic_add_white_24dp"
69+
app:tint="@color/white" />
4570

46-
<ImageButton
47-
android:id="@+id/widget_main"
48-
android:layout_width="40dp"
49-
android:layout_height="40dp"
50-
android:layout_alignParentEnd="true"
51-
android:layout_alignParentRight="true"
52-
android:layout_marginTop="8dp"
53-
android:layout_marginEnd="10dp"
54-
android:layout_marginRight="10dp"
55-
android:background="@drawable/fab_circle"
56-
android:elevation="2dp"
57-
android:src="@drawable/ic_home_black_24dp"
58-
app:tint="@color/white" />
71+
<ImageButton
72+
android:id="@+id/widget_todo"
73+
android:layout_width="40dp"
74+
android:layout_height="40dp"
75+
android:layout_below="@+id/widget_new_note"
76+
android:layout_alignParentEnd="true"
77+
android:layout_alignParentRight="true"
78+
android:layout_marginTop="4dp"
79+
android:layout_marginEnd="10dp"
80+
android:layout_marginRight="10dp"
81+
android:background="@drawable/fab_circle"
82+
android:elevation="2dp"
83+
android:src="@drawable/ic_assignment_turned_in_black_24dp"
84+
app:tint="@color/white" />
5985

60-
<ImageButton
61-
android:id="@+id/widget_new_note"
62-
android:layout_width="40dp"
63-
android:layout_height="40dp"
64-
android:layout_below="@id/widget_main"
65-
android:layout_alignParentEnd="true"
66-
android:layout_alignParentRight="true"
67-
android:layout_marginTop="4dp"
68-
android:layout_marginEnd="10dp"
69-
android:layout_marginRight="10dp"
70-
android:background="@drawable/fab_circle"
71-
android:elevation="2dp"
72-
android:src="@drawable/ic_add_white_24dp"
73-
app:tint="@color/white" />
86+
<ImageButton
87+
android:id="@+id/widget_quicknote"
88+
android:layout_width="40dp"
89+
android:layout_height="40dp"
90+
android:layout_below="@+id/widget_todo"
91+
android:layout_alignParentEnd="true"
92+
android:layout_alignParentRight="true"
93+
android:layout_marginTop="4dp"
94+
android:layout_marginEnd="10dp"
95+
android:layout_marginRight="10dp"
96+
android:background="@drawable/fab_circle"
97+
android:elevation="2dp"
98+
android:src="@drawable/ic_lightning_black_24dp"
99+
app:tint="@color/white" />
74100

75-
<ImageButton
76-
android:id="@+id/widget_todo"
77-
android:layout_width="40dp"
78-
android:layout_height="40dp"
79-
android:layout_below="@+id/widget_new_note"
80-
android:layout_alignParentEnd="true"
81-
android:layout_alignParentRight="true"
82-
android:layout_marginTop="4dp"
83-
android:layout_marginEnd="10dp"
84-
android:layout_marginRight="10dp"
85-
android:background="@drawable/fab_circle"
86-
android:elevation="2dp"
87-
android:src="@drawable/ic_assignment_turned_in_black_24dp"
88-
app:tint="@color/white" />
101+
<RelativeLayout
102+
android:id="@+id/widget_list_container"
103+
android:layout_width="match_parent"
104+
android:layout_height="wrap_content"
105+
android:layout_below="@id/widget_header"
106+
android:background="@color/background_2">
89107

90-
<ImageButton
91-
android:id="@+id/widget_quicknote"
92-
android:layout_width="40dp"
93-
android:layout_height="40dp"
94-
android:layout_below="@+id/widget_todo"
95-
android:layout_alignParentEnd="true"
96-
android:layout_alignParentRight="true"
97-
android:layout_marginTop="4dp"
98-
android:layout_marginEnd="10dp"
99-
android:layout_marginRight="10dp"
100-
android:background="@drawable/fab_circle"
101-
android:elevation="2dp"
102-
android:src="@drawable/ic_lightning_black_24dp"
103-
app:tint="@color/white" />
108+
<TextView
109+
android:id="@+id/widget_empty_hint"
110+
android:layout_width="match_parent"
111+
android:layout_height="match_parent"
112+
android:gravity="center"
113+
android:paddingLeft="@dimen/activity_horizontal_margin"
114+
android:paddingRight="@dimen/activity_horizontal_margin"
115+
android:textColor="@color/light_grey"
116+
android:textSize="24sp"
117+
android:textStyle="bold" />
104118

105-
<RelativeLayout
106-
android:id="@+id/widget_list_container"
119+
<ListView
120+
android:id="@+id/widget_notes_list"
107121
android:layout_width="match_parent"
108122
android:layout_height="wrap_content"
109-
android:layout_below="@id/widget_header"
110-
android:background="@color/background_2">
111-
112-
<TextView
113-
android:id="@+id/widget_empty_hint"
114-
android:layout_width="match_parent"
115-
android:layout_height="match_parent"
116-
android:gravity="center"
117-
android:paddingLeft="@dimen/activity_horizontal_margin"
118-
android:paddingRight="@dimen/activity_horizontal_margin"
119-
android:textColor="@color/light_grey"
120-
android:textSize="24sp"
121-
android:textStyle="bold" />
122-
123-
<ListView
124-
android:id="@+id/widget_notes_list"
125-
android:layout_width="match_parent"
126-
android:layout_height="wrap_content"
127-
android:layout_gravity="start"
128-
android:background="@color/background"
129-
android:divider="@color/grey"
130-
android:dividerHeight="0.5dp" />
131-
</RelativeLayout>
123+
android:layout_gravity="start"
124+
android:background="@color/background"
125+
android:divider="@color/grey"
126+
android:dividerHeight="0.5dp" />
132127
</RelativeLayout>
133-
134-
</FrameLayout>
128+
</RelativeLayout>

0 commit comments

Comments
 (0)