mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
commit
839433dbb1
|
@ -1,6 +1,7 @@
|
|||
package one.nem.lacerta;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.navigation.NavController;
|
||||
|
@ -17,6 +18,7 @@ import android.widget.Toast;
|
|||
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
|
||||
import one.nem.lacerta.utils.FeatureSwitch;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
|
||||
|
||||
|
@ -68,6 +70,40 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
// Set status bar color
|
||||
getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface));
|
||||
|
||||
// Set app bar color
|
||||
AppBarLayout appBarLayout = findViewById(R.id.app_bar_layout);
|
||||
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
|
||||
@Override
|
||||
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
|
||||
if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) {
|
||||
// Collapsed
|
||||
getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
|
||||
} else if (verticalOffset == 0) {
|
||||
// Expanded
|
||||
getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(), one.nem.lacerta.shared.ui.R.color.colorSurface));
|
||||
} else {
|
||||
// Somewhere in between
|
||||
// Here you can add a color transition if you want
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
}
|
||||
|
||||
// Public
|
||||
public void setActionBarTitle(String title) {
|
||||
getSupportActionBar().setTitle(title);
|
||||
}
|
||||
|
||||
public void setActionBarBackButton(boolean isEnabled) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(isEnabled);
|
||||
}
|
||||
|
||||
public void setActionBarMenuItem(int itemId, boolean isEnabled) {
|
||||
|
||||
}
|
||||
|
||||
private void initializeApp() {
|
||||
|
|
|
@ -1,24 +1,61 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:theme="@style/Theme.Lacerta"
|
||||
tools:context=".MainActivity">
|
||||
android:background="@color/colorSurface">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/nav_host_fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:defaultNavHost="true"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bottom_nav"
|
||||
app:layout_constraintBottom_toTopOf="@id/bottom_nav"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navGraph="@navigation/main_nav"
|
||||
tools:layout="@layout/fragment_home_top" />
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="160dp"
|
||||
android:background="@color/colorSurface"
|
||||
android:fitsSystemWindows="true"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:collapsedTitleGravity="start|center_vertical"
|
||||
app:contentScrim="@color/colorSecondaryContainer"
|
||||
app:expandedTitleGravity="start|bottom"
|
||||
app:expandedTitleMarginBottom="16dp"
|
||||
app:expandedTitleMarginStart="16dp"
|
||||
app:expandedTitleTextAppearance="@style/TextAppearance.MaterialComponents.Headline4"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:title="HOGE" />
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
|
||||
android:id="@+id/nav_host_fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/main_nav"
|
||||
tools:layout="@layout/fragment_home_top"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottom_nav"
|
||||
|
|
|
@ -78,6 +78,14 @@ public class LacertaLibraryImpl implements LacertaLibrary {
|
|||
@Override
|
||||
public CompletableFuture<LibraryItemPage> getLibraryPage(int limit) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
|
||||
// 5秒フリーズさせる
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
LibraryItemPage libraryItemPage = new LibraryItemPage();
|
||||
|
||||
List<FolderEntity> folderEntities = getFolderEntitiesByPublicPath("/").join();
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
@ -70,6 +71,7 @@ public class HomeTopFragment extends Fragment {
|
|||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_home_top, container, false);
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -95,32 +97,12 @@ public class HomeTopFragment extends Fragment {
|
|||
listItemAdapter.notifyItemRangeInserted(0, listItems.size());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar);
|
||||
Toolbar toolbar = view.findViewById(R.id.toolbar);
|
||||
|
||||
// Set the Toolbar
|
||||
((AppCompatActivity)getActivity()).setSupportActionBar(toolbar);
|
||||
|
||||
// Set the title of the CollapsingToolbarLayout
|
||||
collapsingToolbarLayout.setTitle("Lacerta");
|
||||
|
||||
AppBarLayout appBarLayout = view.findViewById(R.id.app_bar_layout);
|
||||
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
|
||||
@Override
|
||||
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
|
||||
if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) {
|
||||
// Collapsed
|
||||
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getActivity(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
|
||||
} else if (verticalOffset == 0) {
|
||||
// Expanded
|
||||
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getActivity(), one.nem.lacerta.shared.ui.R.color.colorSurface));
|
||||
} else {
|
||||
// Somewhere in between
|
||||
// Here you can add a color transition if you want
|
||||
}
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.drawer_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,50 +1,11 @@
|
|||
<FrameLayout 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="match_parent"
|
||||
android:background="@color/colorSurface">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/home_item_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
app:contentScrim="@color/colorSecondaryContainer"
|
||||
android:background="@color/colorSurface"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="160dp"
|
||||
android:fitsSystemWindows="true"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:collapsedTitleGravity="start|center_vertical"
|
||||
app:expandedTitleGravity="start|bottom"
|
||||
app:expandedTitleMarginBottom="16dp"
|
||||
app:expandedTitleMarginStart="16dp"
|
||||
app:expandedTitleTextAppearance="@style/TextAppearance.MaterialComponents.Headline4"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:title="HOGE" />
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/home_item_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</FrameLayout>
|
|
@ -11,6 +11,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
@ -70,6 +72,8 @@ public class LibraryTopFragment extends Fragment {
|
|||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_library_top, container, false);
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -92,31 +96,11 @@ public class LibraryTopFragment extends Fragment {
|
|||
listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar);
|
||||
Toolbar toolbar = view.findViewById(R.id.toolbar);
|
||||
|
||||
// Set the Toolbar
|
||||
((AppCompatActivity)getActivity()).setSupportActionBar(toolbar);
|
||||
|
||||
// Set the title of the CollapsingToolbarLayout
|
||||
collapsingToolbarLayout.setTitle("Library");
|
||||
|
||||
AppBarLayout appBarLayout = view.findViewById(R.id.app_bar_layout);
|
||||
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
|
||||
@Override
|
||||
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
|
||||
if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) {
|
||||
// Collapsed
|
||||
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getActivity(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
|
||||
} else if (verticalOffset == 0) {
|
||||
// Expanded
|
||||
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getActivity(), one.nem.lacerta.shared.ui.R.color.colorSurface));
|
||||
} else {
|
||||
// Somewhere in between
|
||||
// Here you can add a color transition if you want
|
||||
}
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.dir_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,50 +1,11 @@
|
|||
<FrameLayout 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="match_parent"
|
||||
android:background="@color/colorSurface">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/library_item_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
app:contentScrim="@color/colorSecondaryContainer"
|
||||
android:background="@color/colorSurface"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="160dp"
|
||||
android:fitsSystemWindows="true"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:collapsedTitleGravity="start|center_vertical"
|
||||
app:expandedTitleGravity="start|bottom"
|
||||
app:expandedTitleMarginBottom="16dp"
|
||||
app:expandedTitleMarginStart="16dp"
|
||||
app:expandedTitleTextAppearance="@style/TextAppearance.MaterialComponents.Headline4"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:title="HOGE" />
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/library_item_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</FrameLayout>
|
11
feature/library/src/main/res/menu/dir_menu.xml
Normal file
11
feature/library/src/main/res/menu/dir_menu.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_item_create_new_folder"
|
||||
android:icon="@drawable/developer_mode_24px"
|
||||
android:title="@string/app_name"
|
||||
app:showAsAction="ifRoom"/> <!-- TODO-rca: change this -->
|
||||
|
||||
</menu>
|
|
@ -1,50 +1,11 @@
|
|||
<FrameLayout 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="match_parent"
|
||||
android:background="@color/colorSurface">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/setting_item_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
app:contentScrim="@color/colorSecondaryContainer"
|
||||
android:background="@color/colorSurface"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="160dp"
|
||||
android:fitsSystemWindows="true"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:collapsedTitleGravity="start|center_vertical"
|
||||
app:expandedTitleGravity="start|bottom"
|
||||
app:expandedTitleMarginBottom="16dp"
|
||||
app:expandedTitleMarginStart="16dp"
|
||||
app:expandedTitleTextAppearance="@style/TextAppearance.MaterialComponents.Headline4"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:title="@string/setting_title" />
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/setting_item_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</FrameLayout>
|
Loading…
Reference in New Issue
Block a user