Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 3e1384e

Browse files
committed
- DrawerLayout, ToolbarLayout, AboutPage, SwitchBarLayout rendering in preview
- EdgeEffect color fix
1 parent c9cc06d commit 3e1384e

File tree

10 files changed

+74
-58
lines changed

10 files changed

+74
-58
lines changed

yanndroid/oneui/src/main/java/de/dlyt/yanndroid/oneui/layout/AboutPage.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ public void onClick(View view) {
115115
}
116116

117117
try {
118-
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
119-
version.setText(context.getString(R.string.sesl_version) + " " + packageInfo.versionName);
118+
if (!isInEditMode()) {
119+
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
120+
version.setText(context.getString(R.string.sesl_version) + " " + packageInfo.versionName);
121+
}
120122
} catch (PackageManager.NameNotFoundException e) {
121123
e.printStackTrace();
122124
}

yanndroid/oneui/src/main/java/de/dlyt/yanndroid/oneui/layout/DrawerLayout.java

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -90,58 +90,13 @@ public DrawerLayout(Context context, @Nullable AttributeSet attrs) {
9090
drawerButton.setImageTintList(ColorStateList.valueOf(getResources().getColor(R.color.drawer_icon_color)));
9191
setDrawerButtonIcon(mDrawerIcon);
9292

93-
94-
onBackPressedCallback = new OnBackPressedCallback(true) {
95-
@Override
96-
public void handleOnBackPressed() {
97-
if (drawerLayout.isDrawerOpen(drawer)) {
98-
drawerLayout.closeDrawer(drawer, true);
99-
return;
100-
}
101-
this.setEnabled(false);
102-
mActivity.onBackPressed();
103-
this.setEnabled(true);
104-
}
105-
};
106-
mActivity.getOnBackPressedDispatcher().addCallback(onBackPressedCallback);
107-
108-
/*drawer logic*/
109-
View translationView = findViewById(R.id.drawer_custom_translation);
110-
if (translationView == null)
111-
translationView = toolbarLayout;
112-
113-
View content = translationView;
114-
11593
drawerLayout = findViewById(R.id.drawerLayout);
11694
drawer = findViewById(R.id.drawer);
11795

11896
drawerLayout.setScrimColor(ContextCompat.getColor(getContext(), R.color.drawer_dim_color));
11997
drawerLayout.setDrawerElevation(0);
120-
12198
setDrawerWidth();
12299

123-
Boolean isRtl = getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
124-
Window window = mActivity.getWindow();
125-
126-
ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(mActivity, drawerLayout, R.string.opened, R.string.closed) {
127-
@Override
128-
public void onDrawerSlide(View drawerView, float slideOffset) {
129-
super.onDrawerSlide(drawerView, slideOffset);
130-
float slideX = drawerView.getWidth() * slideOffset;
131-
if (isRtl) slideX *= -1;
132-
content.setTranslationX(slideX);
133-
134-
float[] hsv = new float[3];
135-
Color.colorToHSV(ContextCompat.getColor(getContext(), R.color.background_color), hsv);
136-
hsv[2] *= 1f - (slideOffset * 0.2f);
137-
window.setStatusBarColor(Color.HSVToColor(hsv));
138-
window.setNavigationBarColor(Color.HSVToColor(hsv));
139-
140-
}
141-
};
142-
drawerLayout.addDrawerListener(actionBarDrawerToggle);
143-
toolbarLayout.setNavigationButtonOnClickListener(v -> drawerLayout.openDrawer(drawer, true));
144-
145100
drawer.setOutlineProvider(new ViewOutlineProvider() {
146101
@Override
147102
public void getOutline(View view, Outline outline) {
@@ -151,6 +106,51 @@ public void getOutline(View view, Outline outline) {
151106
}
152107
});
153108
drawer.setClipToOutline(true);
109+
110+
if (!isInEditMode()) {
111+
onBackPressedCallback = new OnBackPressedCallback(true) {
112+
@Override
113+
public void handleOnBackPressed() {
114+
if (drawerLayout.isDrawerOpen(drawer)) {
115+
drawerLayout.closeDrawer(drawer, true);
116+
return;
117+
}
118+
this.setEnabled(false);
119+
mActivity.onBackPressed();
120+
this.setEnabled(true);
121+
}
122+
};
123+
mActivity.getOnBackPressedDispatcher().addCallback(onBackPressedCallback);
124+
125+
/*drawer logic*/
126+
Boolean isRtl = getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
127+
128+
View translationView = findViewById(R.id.drawer_custom_translation);
129+
if (translationView == null) translationView = toolbarLayout;
130+
View content = translationView;
131+
132+
Window window = mActivity.getWindow();
133+
134+
ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(mActivity, drawerLayout, R.string.opened, R.string.closed) {
135+
@Override
136+
public void onDrawerSlide(View drawerView, float slideOffset) {
137+
super.onDrawerSlide(drawerView, slideOffset);
138+
float slideX = drawerView.getWidth() * slideOffset;
139+
if (isRtl) slideX *= -1;
140+
content.setTranslationX(slideX);
141+
142+
float[] hsv = new float[3];
143+
Color.colorToHSV(ContextCompat.getColor(getContext(), R.color.background_color), hsv);
144+
hsv[2] *= 1f - (slideOffset * 0.2f);
145+
window.setStatusBarColor(Color.HSVToColor(hsv));
146+
window.setNavigationBarColor(Color.HSVToColor(hsv));
147+
148+
}
149+
};
150+
drawerLayout.addDrawerListener(actionBarDrawerToggle);
151+
toolbarLayout.setNavigationButtonOnClickListener(v -> drawerLayout.openDrawer(drawer, true));
152+
153+
}
154154
}
155155

156156
private void setDrawerWidth() {

yanndroid/oneui/src/main/java/de/dlyt/yanndroid/oneui/layout/ToolbarLayout.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,6 @@ public ToolbarLayout(Context context, @Nullable AttributeSet attrs) {
205205
search_action_button = findViewById(R.id.search_view_action_button);
206206
search_edittext = findViewById(R.id.toolbar_layout_search_field);
207207

208-
mActivity.setSupportActionBar(toolbar);
209-
mActivity.getSupportActionBar().setDisplayShowTitleEnabled(false);
210-
mActivity.getSupportActionBar().setDisplayHomeAsUpEnabled(false);
211208
setNavigationButtonIcon(mNavigationIcon);
212209
setTitle(mTitleExpanded);
213210
setSubtitle(mSubtitle);
@@ -225,10 +222,15 @@ public void handleOnBackPressed() {
225222
if (mSearchMode) dismissSearchMode();
226223
}
227224
};
228-
mActivity.getOnBackPressedDispatcher().addCallback(onBackPressedCallback);
229225

230-
refreshLayout(getResources().getConfiguration());
226+
if (!isInEditMode()){
227+
mActivity.setSupportActionBar(toolbar);
228+
mActivity.getSupportActionBar().setDisplayShowTitleEnabled(false);
229+
mActivity.getSupportActionBar().setDisplayHomeAsUpEnabled(false);
230+
mActivity.getOnBackPressedDispatcher().addCallback(onBackPressedCallback);
231+
}
231232

233+
refreshLayout(getResources().getConfiguration());
232234
}
233235

234236
void syncWithDrawer(DrawerLayout drawerLayout) {
@@ -327,7 +329,7 @@ private int getWindowHeight() {
327329
}
328330

329331
private void refreshLayout(Configuration newConfig) {
330-
WindowManagerSupport.hideStatusBarForLandscape(mActivity, newConfig.orientation);
332+
if (!isInEditMode()) WindowManagerSupport.hideStatusBarForLandscape(mActivity, newConfig.orientation);
331333

332334
ViewSupport.updateListBothSideMargin(mActivity, mainContainer);
333335
ViewSupport.updateListBothSideMargin(mActivity, findViewById(R.id.toolbar_layout_bottom_corners));

yanndroid/oneui/src/main/java/de/dlyt/yanndroid/oneui/sesl/appbar/SamsungCollapsingToolbarLayout.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,12 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
504504
if (mDrawCollapsingTitle) {
505505
final boolean isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
506506

507-
final int maxOffset = getMaxOffsetForPinChild(mToolbarDirectChild != null ? mToolbarDirectChild : mToolbar);
507+
final int maxOffset;
508+
if (mToolbarDirectChild != null) {
509+
maxOffset = getMaxOffsetForPinChild(mToolbarDirectChild);
510+
} else {
511+
maxOffset = getMaxOffsetForPinChild(mToolbar);
512+
}
508513
ViewGroupUtils.getDescendantRect(this, mDummyView, mTmpRect);
509514
mCollapsingTextHelper.setCollapsedBounds(mTmpRect.left + (isRtl ? mToolbar.getTitleMarginEnd() : mToolbar.getTitleMarginStart()), mTmpRect.top + maxOffset + mToolbar.getTitleMarginTop(), mTmpRect.right + (isRtl ? mToolbar.getTitleMarginStart() : mToolbar.getTitleMarginEnd()), mTmpRect.bottom + maxOffset - mToolbar.getTitleMarginBottom());
510515

@@ -1024,9 +1029,12 @@ final int getMaxOffsetForPinChild(View child) {
10241029

10251030
public static class LayoutParams extends FrameLayout.LayoutParams {
10261031
private static final float DEFAULT_PARALLAX_MULTIPLIER = 0.5f;
1032+
10271033
@IntDef({COLLAPSE_MODE_OFF, COLLAPSE_MODE_PIN, COLLAPSE_MODE_PARALLAX})
10281034
@Retention(RetentionPolicy.SOURCE)
1029-
@interface CollapseMode {}
1035+
@interface CollapseMode {
1036+
}
1037+
10301038
public static final int COLLAPSE_MODE_OFF = 0;
10311039
public static final int COLLAPSE_MODE_PIN = 1;
10321040
public static final int COLLAPSE_MODE_PARALLAX = 2;

yanndroid/oneui/src/main/java/de/dlyt/yanndroid/oneui/sesl/utils/SamsungEdgeEffect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public SamsungEdgeEffect(Context context) {
113113
int color = obtainStyledAttributes.getColor(0, -10066330);
114114
obtainStyledAttributes.recycle();
115115
if (mIsOneUI4)
116-
this.mPaint.setColor(color & 0x33000000);
116+
this.mPaint.setColor(color);
117117
else
118118
mPaint.setColor((0xFFFFFF & color) | 0x33000000);
119119
this.mPaint.setStyle(Paint.Style.FILL);

yanndroid/oneui/src/main/res/layout/samsung_switchbarlayout.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
android:layout_width="match_parent"
3131
android:layout_height="match_parent">
3232

33-
<!--switchbar content-->
33+
<!--content-->
3434

3535
</FrameLayout>
3636

yanndroid/oneui/src/main/res/values-night/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
<color name="sesl_scrollbar_handle_tint">#ff595959</color>
8181
<color name="sesl_list_subheader_text_color">#ff999999</color>
8282
<color name="about_info_button_tint">#ffd9d9d9</color>
83+
<color name="sesl_edge_effect_device_default">#14fafafa</color>
8384

8485

8586
<!--ColorPicker-->

yanndroid/oneui/src/main/res/values/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
<color name="sesl_scrollbar_handle_tint">#ffdedede</color>
145145
<color name="sesl_list_subheader_text_color">#ff8c8c8c</color>
146146
<color name="about_info_button_tint">#ff454545</color>
147+
<color name="sesl_edge_effect_device_default">#0d000000</color>
147148

148149

149150
<!--ColorPicker-->

yanndroid/oneui/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<resources>
22
<string name="closed" translatable="false">closed</string>
33
<string name="opened" translatable="false">opened</string>
4-
<string name="sesl_font_family_regular" translatable="false">sec-roboto-light</string>
4+
<string name="sesl_font_family_regular" translatable="false">sans-serif-light</string> <!--sec-roboto-light--> <!--preview render problem-->
55
<string name="app_name" translatable="false" />
66
<string name="sesl_appbar_scrolling_view_behavior" translatable="false">de.dlyt.yanndroid.oneui.sesl.appbar.SamsungAppBarLayout$ScrollingViewBehavior</string>
77

yanndroid/oneui/src/main/res/values/styles.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,8 @@
922922
<item name="toolbarSubtitleStyle">@style/OneUI4.CollapsedActionBarSubtitleTextStyle</item>
923923

924924
<item name="bottomNaviViewStyle">@style/OneUI4.BaseTabLayoutStyle</item>
925+
926+
<item name="android:colorEdgeEffect">@color/sesl_edge_effect_device_default</item>
925927
</style>
926928

927929

0 commit comments

Comments
 (0)