OneUIProject / oneui-core

Samsung's One UI core libraries for Android apps.
MIT License
122 stars 15 forks source link

Round corner issue? #7

Closed long266 closed 2 years ago

long266 commented 2 years ago

Hello, I have used this library for one of my projects, but when using it I found some inadequacies.

  1. Is there a way to round the 4 corners of the PreferenceFragment(Compat), as I marked in red (screenshot in light mode)
  2. when I add a PreferenceCategory with elements inside, the preference background color error(I think so) (dark mode screenshot)

    Edit2 : I found that i need to use seslSetFillBottomEnabled(true); but how i can use RecycleView in PreferenceFragmentCompat, as PreferenceFragmentCompat created its own RecycleView, Thanks

    LIGHT DARK

salvogiangri commented 2 years ago

Samsung's PreferenceFragment enables by default rounded corners/fillBottom as long as you add or set a preference xml in the onCreatePreferences method, you can enable/disable these features with the PreferenceFragmentCompat.seslSetRoundedCorner(boolean) method.

To set rounded corners, you can either add a PreferenceCategory in your xmls (they have enabled rounded corners by default) or handle them manually per-Preference with the Preference.seslSetRoundedBg(int) (sets the corners inside the choosen Preference) or Preference.seslSetSubheaderRoundedBackground(int) (sets the corners in-between the choosen Preference) methods.

For setting up the RecyclerView of the PreferenceFragment I suggest you to override the onViewCreated method of the fragment like here:

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    getListView().seslSetLastRoundedCorner(true);
}

Regarding the bottom rounded corners, these are handled in system frameworks by Samsung and are drawn in the decor view of the window, a flag in the manifest of the app is checked to see whether or not to draw them:

<meta-data
    android:name="SamsungBasicInteraction"
    android:value="SEP10" />

For non-Samsung devices, I suggest you to draw them using a custom LinearLayout as parent of your layout to emulate the behavior of Samsung's frameworks:

<dev.oneuiproject.oneui.widget.RoundLinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="vertical"
    app:roundedCorners="bottom_left|bottom_right">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <!-- ... -->

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

</dev.oneuiproject.oneui.widget.RoundLinearLayout>
long266 commented 2 years ago

Thanks for your reply But

salvogiangri commented 2 years ago

Just tested myself with the latest 1.1.0 artifact and the default fillBottom works as expected:

Make sure you're using "Theme.AppCompat" as your app theme and not "MaterialComponents". For the LinearLayout you can just use the one in the design lib repo (the lib has still not been released so you can't use it unless you compile it yourself) by downloading the class and adding it in your app, you'll also need to add the attrs resources for the widget.

long266 commented 2 years ago

I made some changes, added RoundedLinearLayout but the problem is still here ( tested on samsung and non-samsung devices ) IMG Also, my project is open-srced, Can you take a look at this https://github.com/long266/Lumi-Constellation Thanks !

salvogiangri commented 2 years ago

The issue is in your layout: avoid using both NestedScrollView and RecyclerView since they both have nested scrolling, remove the NestedScrollView from your layout and move the layout_behavior attr in the fragment FrameLayout

long266 commented 2 years ago

Thank you very much! Problem solved But I still have one question CollapsingToolbarLayout will show the correct title when expanded But in collapsed mode it shows my app name, instead of title i set in app:title

salvogiangri commented 2 years ago

Glad you solved! Try to use getSupportActionBar(). setDisplayShowTitleEnabled(false), but I'm not sure it will work anyway due to how Samsung's CollapsingToolbar works, you may have to set the title on both CollapsingToolbar and Toolbar programmatically

long266 commented 2 years ago

Thanks for help. Have a nice day !