BlueWhaleYT / OneUI-Sample

This is an open source project showcase using OneUI design library on android.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OneUI Sample

This is a simple project which demonstrates how to utilize OneUI design library on Android.

Github Repositories

Quick notes

Here are some notes that for you getting started on using OneUI library.

Dependencies

Warning: You need to first remove the original appcompat and material dependencies generated in Android Studio.

- implementation 'androidx.appcompat:appcompat:1.6.1'
- implementation 'com.google.android.material:material:1.9.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'io.github.oneuiproject.sesl:appcompat:1.4.0'
implementation 'io.github.oneuiproject.sesl:material:1.5.0'
implementation 'io.github.oneuiproject:design:1.2.3'

// OneUI Preferences
implementation 'io.github.oneuiproject.sesl:preference:1.1.0'

// OneUI Icons
implementation 'io.github.oneuiproject:icons:1.0.1'

you need to add following code belowdependencies block.

dependencies {
    ...
}

configurations.all {
    exclude group: 'androidx.appcompat', module: 'appcompat'
    exclude group: 'androidx.core', module: 'core'
}

Theme settings

<application
    ...
    android:theme="@style/OneUITheme" />

Widgets

Drawer

Define a DrawerLayout as the parent layout.

<dev.oneuiproject.oneui.layout.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:expanded="false"
    app:title="@string/app_name">

Now, set the items for the DrawerLayout, you need to define a RecyclerView.

Note: You need to set app:layout_location="drawer_panel, this is to set the RecyclerView locates in the DrawerLayout.

<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/drawer_list_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical"
    app:layout_location="drawer_panel" />
Setup fragment list

Note: add(null) means add a separator line

private void setupFragmentList() {
    listFragment.add(new HomeFragment());
    listFragment.add(null);
    listFragment.add(new PreferencesFragment());
}
Setup fragments
private void setupFragments() {
    fragmentManager = getSupportFragmentManager();
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    for (Fragment fragment : listFragment) {
        if (fragment != null) transaction.add(R.id.frame_layout, fragment);
    }
    transaction.commit();
    fragmentManager.executePendingTransactions();
}
Setup drawer
private void setupDrawer() {
    drawerListView.setLayoutManager(new LinearLayoutManager(this));
    drawerListView.setItemAnimator(null);
    drawerListView.setHasFixedSize(true);
    drawerListView.seslSetLastRoundedCorner(false);
    drawerListView.setAdapter(new DrawerListAdapter(this, listFragment, this));
}

Finally, in your onCreate() method:

setupFragmentList();
setupFragments();
setupDrawer();

Preferences Widgets

Warning: Make sure you've imported OneUI preferences library.

OneUI provides innovative preference widgets.

<dev.oneuiproject.oneui.preference.XXX ... />
Preference widgets
TipsCardPreference ColorPickerPreference LayoutPreference
SwitchBarPreference DescriptionPreference HorizontalRadioPreference

more..

Use OneUI icons

Warning: Make sure you've imported OneUI icons library.

you need to use the R class from OneUI icons library:

dev.oneuiproject.oneui.R

e.g. use home outline icon

dev.oneuiproject.oneui.R.drawable.ic_oui_home_outline

About

This is an open source project showcase using OneUI design library on android.


Languages

Language:Java 100.0%