mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2026-11-07 19:47:36 +00:00
Compare commits
41
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65c6ca77ed | ||
|
|
f02440348b | ||
|
|
1a80d00319 | ||
|
|
3f893fc580 | ||
|
|
225058f836 | ||
|
|
c23b92d386 | ||
|
|
41e5ab2349 | ||
|
|
580e79b03a | ||
|
|
301fab8024 | ||
|
|
281238a38e | ||
|
|
81fa259985 | ||
|
|
b2c6085933 | ||
|
|
caf3a0dd34 | ||
|
|
c4e10b9487 | ||
|
|
b05ee22c29 | ||
|
|
839433dbb1 | ||
|
|
153242ef66 | ||
|
|
05997eafe1 | ||
|
|
d6f4885b4a | ||
|
|
0b33c60a5a | ||
|
|
ad3a600e8c | ||
|
|
50dfb9be8b | ||
|
|
fafb996453 | ||
|
|
e1129bc009 | ||
|
|
5752e3285b | ||
|
|
a2ed78dfb8 | ||
|
|
0eadc3c3d5 | ||
|
|
6d0b24eb70 | ||
|
|
9da41e73aa | ||
|
|
01f28ecd4d | ||
|
|
2f3a331527 | ||
|
|
9496c3efbb | ||
|
|
93b833f7a9 | ||
|
|
3130be88be | ||
|
|
bb7b628d2f | ||
|
|
5f9ea732cf | ||
|
|
42f6bc17d3 | ||
|
|
1c6878c3fd | ||
|
|
b5beb7cc15 | ||
|
|
c6fb06ffe2 | ||
|
|
95d808dc75 |
No files matched your search
@@ -1,34 +1,33 @@
|
|||||||
package one.nem.lacerta;
|
package one.nem.lacerta;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.navigation.NavController;
|
import androidx.navigation.NavController;
|
||||||
import androidx.navigation.fragment.NavHostFragment;
|
import androidx.navigation.fragment.NavHostFragment;
|
||||||
import androidx.navigation.ui.NavigationUI;
|
import androidx.navigation.ui.NavigationUI;
|
||||||
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import one.nem.lacerta.model.FragmentNavigation;
|
||||||
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
|
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
|
||||||
import one.nem.lacerta.utils.FeatureSwitch;
|
import one.nem.lacerta.utils.FeatureSwitch;
|
||||||
|
|
||||||
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||||
|
|
||||||
|
|
||||||
import java.io.NotActiveException;
|
|
||||||
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint;
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
import one.nem.lacerta.utils.repository.SharedPrefUtils;
|
import one.nem.lacerta.utils.repository.SharedPrefUtils;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity implements FragmentNavigation {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SharedPrefUtils sharedPrefUtils;
|
SharedPrefUtils sharedPrefUtils;
|
||||||
@@ -68,6 +67,36 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
// Set status bar color
|
// Set status bar color
|
||||||
getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface));
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeApp() {
|
private void initializeApp() {
|
||||||
@@ -84,4 +113,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
boolean isEnabled = FeatureSwitch.Meta.canOverrideSwitch ? sharedPrefUtils.getFeatureSwitchOverride(featureSwitchOverride) : defaultValue;
|
boolean isEnabled = FeatureSwitch.Meta.canOverrideSwitch ? sharedPrefUtils.getFeatureSwitchOverride(featureSwitchOverride) : defaultValue;
|
||||||
if (!isEnabled) bottomNavigationView.getMenu().removeItem(menuId);
|
if (!isEnabled) bottomNavigationView.getMenu().removeItem(menuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void navigateToFragment(Fragment fragment) {
|
||||||
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
.replace(R.id.nav_host_fragment, fragment)
|
||||||
|
.addToBackStack(null)
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,61 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:theme="@style/Theme.Lacerta"
|
android:background="@color/colorSurface">
|
||||||
tools:context=".MainActivity">
|
|
||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
android:id="@+id/nav_host_fragment"
|
|
||||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="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_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
app:navGraph="@navigation/main_nav"
|
|
||||||
tools:layout="@layout/fragment_home_top" />
|
<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
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
android:id="@+id/bottom_nav"
|
android:id="@+id/bottom_nav"
|
||||||
@@ -31,6 +68,7 @@
|
|||||||
app:labelVisibilityMode="selected"
|
app:labelVisibilityMode="selected"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:menu="@menu/bottom_nav_menu" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -21,4 +21,7 @@ public interface LacertaLibrary {
|
|||||||
CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit);
|
CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit);
|
||||||
CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit, int offset);
|
CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit, int offset);
|
||||||
|
|
||||||
|
// Create Folder
|
||||||
|
CompletableFuture<String> createFolder(String path, String name);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
package one.nem.lacerta.data.impl;
|
package one.nem.lacerta.data.impl;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -12,10 +14,12 @@ import one.nem.lacerta.data.LacertaLibrary;
|
|||||||
import one.nem.lacerta.model.LibraryItemPage;
|
import one.nem.lacerta.model.LibraryItemPage;
|
||||||
import one.nem.lacerta.model.ListItem;
|
import one.nem.lacerta.model.ListItem;
|
||||||
import one.nem.lacerta.model.ListItemType;
|
import one.nem.lacerta.model.ListItemType;
|
||||||
|
import one.nem.lacerta.model.PublicPath;
|
||||||
import one.nem.lacerta.model.document.DocumentDetail;
|
import one.nem.lacerta.model.document.DocumentDetail;
|
||||||
import one.nem.lacerta.source.database.LacertaDatabase;
|
import one.nem.lacerta.source.database.LacertaDatabase;
|
||||||
import one.nem.lacerta.source.database.common.DateTypeConverter;
|
import one.nem.lacerta.source.database.common.DateTypeConverter;
|
||||||
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
||||||
|
import one.nem.lacerta.source.database.entity.FolderEntity;
|
||||||
import one.nem.lacerta.utils.LacertaLogger;
|
import one.nem.lacerta.utils.LacertaLogger;
|
||||||
|
|
||||||
public class LacertaLibraryImpl implements LacertaLibrary {
|
public class LacertaLibraryImpl implements LacertaLibrary {
|
||||||
@@ -60,10 +64,64 @@ public class LacertaLibraryImpl implements LacertaLibrary {
|
|||||||
return null; // TODO-rca: Implement
|
return null; // TODO-rca: Implement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Internal
|
||||||
|
private CompletableFuture<List<FolderEntity>> getFolderEntitiesByPublicPath(String publicPath) {
|
||||||
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
return database.folderDao().findByPublicPathWithLimit(publicPath, 10); // TODO-rca: ハードコーディングやめる
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private CompletableFuture<List<DocumentEntity>> getDocumentEntitiesByPublicPath(String publicPath) {
|
||||||
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
return database.documentDao().findByPublicPathWithLimit(publicPath, 10); // TODO-rca: ハードコーディングやめる
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<LibraryItemPage> getLibraryPage(int limit) {
|
public CompletableFuture<LibraryItemPage> getLibraryPage(int limit) {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
return null;
|
|
||||||
|
// 5秒フリーズさせる
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
LibraryItemPage libraryItemPage = new LibraryItemPage();
|
||||||
|
|
||||||
|
List<FolderEntity> folderEntities = getFolderEntitiesByPublicPath("/").join();
|
||||||
|
logger.debug("LacertaLibraryImpl", "folderEntities.size(): " + folderEntities.size());
|
||||||
|
List<DocumentEntity> documentEntities = getDocumentEntitiesByPublicPath("/").join();
|
||||||
|
logger.debug("LacertaLibraryImpl", "documentEntities.size(): " + documentEntities.size());
|
||||||
|
|
||||||
|
ArrayList<ListItem> listItems = new ArrayList<>();
|
||||||
|
for (FolderEntity folderEntity : folderEntities) {
|
||||||
|
logger.debug("LacertaLibraryImpl", "folderEntity.name: " + folderEntity.name);
|
||||||
|
ListItem listItem = new ListItem();
|
||||||
|
listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER);
|
||||||
|
listItem.setTitle(folderEntity.name);
|
||||||
|
listItem.setDescription("フォルダ"); // TODO-rca: ハードコーディングやめる
|
||||||
|
listItem.setItemId(folderEntity.id);
|
||||||
|
listItems.add(listItem);
|
||||||
|
}
|
||||||
|
for (DocumentEntity documentEntity : documentEntities) {
|
||||||
|
logger.debug("LacertaLibraryImpl", "documentEntity.title: " + documentEntity.title);
|
||||||
|
ListItem listItem = new ListItem();
|
||||||
|
listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
|
||||||
|
listItem.setTitle(documentEntity.title);
|
||||||
|
// listItem.setDescription(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm").format(documentEntity.updatedAt.toInstant()));
|
||||||
|
listItem.setItemId(documentEntity.id);
|
||||||
|
listItems.add(listItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
libraryItemPage.setPageTitle("/");
|
||||||
|
libraryItemPage.setPageId("root");
|
||||||
|
libraryItemPage.setListItems(listItems);
|
||||||
|
|
||||||
|
logger.debug("LacertaLibraryImpl", "libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
|
||||||
|
|
||||||
|
return libraryItemPage;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +135,52 @@ public class LacertaLibraryImpl implements LacertaLibrary {
|
|||||||
@Override
|
@Override
|
||||||
public CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit) {
|
public CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit) {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
return null;
|
LibraryItemPage libraryItemPage = new LibraryItemPage();
|
||||||
|
|
||||||
|
FolderEntity folderEntity = database.folderDao().findById(pageId);
|
||||||
|
if (folderEntity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
PublicPath publicPath = new PublicPath().parse(folderEntity.publicPath);
|
||||||
|
|
||||||
|
String resolvedPublicPath = publicPath.resolve(folderEntity.name).getStringPath();
|
||||||
|
|
||||||
|
logger.debug("LacertaLibraryImpl", "Resolved publicPath: " + resolvedPublicPath);
|
||||||
|
|
||||||
|
List<FolderEntity> folderEntities = getFolderEntitiesByPublicPath(resolvedPublicPath).join();
|
||||||
|
logger.debug("LacertaLibraryImpl", "folderEntities.size(): " + folderEntities.size());
|
||||||
|
List<DocumentEntity> documentEntities = getDocumentEntitiesByPublicPath(resolvedPublicPath).join();
|
||||||
|
logger.debug("LacertaLibraryImpl", "documentEntities.size(): " + documentEntities.size());
|
||||||
|
|
||||||
|
ArrayList<ListItem> listItems = new ArrayList<>();
|
||||||
|
for (FolderEntity childFolderEntity : folderEntities) {
|
||||||
|
logger.debug("LacertaLibraryImpl", "childFolderEntity.name: " + childFolderEntity.name);
|
||||||
|
ListItem listItem = new ListItem();
|
||||||
|
listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER);
|
||||||
|
listItem.setTitle(childFolderEntity.name);
|
||||||
|
listItem.setDescription("フォルダ"); // TODO-rca: ハードコーディングやめる
|
||||||
|
listItem.setItemId(childFolderEntity.id);
|
||||||
|
listItems.add(listItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DocumentEntity documentEntity : documentEntities) {
|
||||||
|
logger.debug("LacertaLibraryImpl", "documentEntity.title: " + documentEntity.title);
|
||||||
|
ListItem listItem = new ListItem();
|
||||||
|
listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
|
||||||
|
listItem.setTitle(documentEntity.title);
|
||||||
|
// listItem.setDescription(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm").format(documentEntity.updatedAt.toInstant()));
|
||||||
|
listItem.setItemId(documentEntity.id);
|
||||||
|
listItems.add(listItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
libraryItemPage.setPageTitle(folderEntity.name);
|
||||||
|
libraryItemPage.setPageId(folderEntity.id);
|
||||||
|
libraryItemPage.setListItems(listItems);
|
||||||
|
|
||||||
|
logger.debug("LacertaLibraryImpl", "libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
|
||||||
|
|
||||||
|
return libraryItemPage;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,4 +190,25 @@ public class LacertaLibraryImpl implements LacertaLibrary {
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<String> createFolder(String parentId, String name) {
|
||||||
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
|
||||||
|
FolderEntity parentFolderEntity = database.folderDao().findById(parentId);
|
||||||
|
PublicPath publicPath;
|
||||||
|
if (parentFolderEntity == null) {
|
||||||
|
publicPath = new PublicPath().resolve("/");
|
||||||
|
} else {
|
||||||
|
publicPath = new PublicPath().resolve(parentFolderEntity.publicPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
FolderEntity folderEntity = new FolderEntity();
|
||||||
|
folderEntity.id = UUID.randomUUID().toString();
|
||||||
|
folderEntity.name = name;
|
||||||
|
folderEntity.publicPath = publicPath.getStringPath();
|
||||||
|
database.folderDao().insert(folderEntity);
|
||||||
|
return folderEntity.id;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,12 +8,15 @@ import android.view.Menu;
|
|||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.core.view.MenuProvider;
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
@@ -70,58 +73,52 @@ public class HomeTopFragment extends Fragment {
|
|||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View view = inflater.inflate(R.layout.fragment_home_top, container, false);
|
View view = inflater.inflate(R.layout.fragment_home_top, container, false);
|
||||||
|
|
||||||
|
// setHasOptionsMenu(true);
|
||||||
|
Toolbar toolbar = view.findViewById(R.id.home_toolbar);
|
||||||
|
toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px);
|
||||||
|
toolbar.setNavigationOnClickListener(v -> {
|
||||||
|
Toast.makeText(getContext(), "Works!!!!!!!!!!!!", Toast.LENGTH_SHORT).show();
|
||||||
|
});
|
||||||
|
toolbar.inflateMenu(R.menu.drawer_menu);
|
||||||
|
toolbar.setOnMenuItemClickListener(item -> {
|
||||||
|
if (item.getItemId() == R.id.item_placeholder) {
|
||||||
|
Toast.makeText(getContext(), "Works!", Toast.LENGTH_SHORT).show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
// public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
// super.onViewCreated(view, savedInstanceState);
|
||||||
|
//
|
||||||
RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view);
|
// RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view);
|
||||||
|
//
|
||||||
|
//
|
||||||
ListItemAdapter listItemAdapter = new ListItemAdapter(documentId -> {
|
// ListItemAdapter listItemAdapter = new ListItemAdapter(documentId -> {
|
||||||
Log.d("HomeTopFragment", "onViewCreated: " + documentId);
|
// Log.d("HomeTopFragment", "onViewCreated: " + documentId);
|
||||||
Intent intent = new Intent(getContext(), ViewerMainActivity.class);
|
// Intent intent = new Intent(getContext(), ViewerMainActivity.class);
|
||||||
intent.putExtra("documentId", documentId);
|
// intent.putExtra("documentId", documentId);
|
||||||
startActivity(intent);
|
// startActivity(intent);
|
||||||
});
|
// });
|
||||||
recyclerView.setAdapter(listItemAdapter);
|
// recyclerView.setAdapter(listItemAdapter);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
// recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
//
|
||||||
lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> {
|
// lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> {
|
||||||
listItemAdapter.setListItems(listItems);
|
// listItemAdapter.setListItems(listItems);
|
||||||
getActivity().runOnUiThread(() -> {
|
// getActivity().runOnUiThread(() -> {
|
||||||
listItemAdapter.notifyItemRangeInserted(0, listItems.size());
|
// listItemAdapter.notifyItemRangeInserted(0, listItems.size());
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
|
// }
|
||||||
CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar);
|
//
|
||||||
Toolbar toolbar = view.findViewById(R.id.toolbar);
|
// @Override
|
||||||
|
// public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||||
// Set the Toolbar
|
// inflater.inflate(R.menu.drawer_menu, menu);
|
||||||
((AppCompatActivity)getActivity()).setSupportActionBar(toolbar);
|
// super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
// }
|
||||||
// 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/home_toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
app:layout_collapseMode="pin"
|
app:layout_collapseMode="pin"
|
||||||
|
|||||||
@@ -51,5 +51,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation project(':data')
|
implementation project(':data')
|
||||||
|
|
||||||
|
implementation project(':utils')
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
package one.nem.lacerta.feature.library;
|
||||||
|
|
||||||
|
public interface DocumentSelectListener {
|
||||||
|
void onFolderSelected(String folderId, String folderName);
|
||||||
|
void onDocumentSelected(String documentId, String documentName);
|
||||||
|
}
|
||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
package one.nem.lacerta.feature.library;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
// LibraryArchiveFragment.java
|
|
||||||
|
|
||||||
//画面変移用のコード
|
|
||||||
//Fragmentへのデータの受け渡し機能
|
|
||||||
public class LibraryArchiveFragment extends AppCompatActivity {
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.fragment_library_top);
|
|
||||||
|
|
||||||
// ここに入力された内容を表示する機能
|
|
||||||
TextView textView = findViewById(R.id.document_list);
|
|
||||||
|
|
||||||
textView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
// 文字をタップしたときの処理
|
|
||||||
|
|
||||||
// 移動先のアクティビティを指定
|
|
||||||
Intent intent = new Intent(LibraryArchiveFragment.this, LibraryDocFragment.class);
|
|
||||||
|
|
||||||
// データを付加する
|
|
||||||
intent.putExtra("key_name", "value_data");
|
|
||||||
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+186
@@ -0,0 +1,186 @@
|
|||||||
|
package one.nem.lacerta.feature.library;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
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.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
|
import one.nem.lacerta.data.LacertaLibrary;
|
||||||
|
import one.nem.lacerta.model.FragmentNavigation;
|
||||||
|
import one.nem.lacerta.utils.LacertaLogger;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple {@link Fragment} subclass.
|
||||||
|
* Use the {@link LibraryPageFragment#newInstance} factory method to
|
||||||
|
* create an instance of this fragment.
|
||||||
|
*/
|
||||||
|
@AndroidEntryPoint
|
||||||
|
public class LibraryPageFragment extends Fragment {
|
||||||
|
|
||||||
|
// Param
|
||||||
|
private String folderId;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
LacertaLibrary lacertaLibrary;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
LacertaLogger logger;
|
||||||
|
|
||||||
|
ListItemAdapter listItemAdapter;
|
||||||
|
|
||||||
|
int currentTotalItemCount = 0;
|
||||||
|
|
||||||
|
public LibraryPageFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
}
|
||||||
|
public static LibraryPageFragment newInstance(String folderId) {
|
||||||
|
LibraryPageFragment fragment = new LibraryPageFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString("folderId", folderId);
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LibraryPageFragment newInstance() {
|
||||||
|
LibraryPageFragment fragment = new LibraryPageFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString("folderId", null);
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
View view = inflater.inflate(R.layout.fragment_library_top, container, false);
|
||||||
|
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
|
RecyclerView recyclerView = view.findViewById(R.id.library_item_recycler_view);
|
||||||
|
|
||||||
|
this.listItemAdapter = new ListItemAdapter(new DocumentSelectListener() {
|
||||||
|
@Override
|
||||||
|
public void onFolderSelected(String folderId, String folderName) {
|
||||||
|
logger.debug("LibraryTopFragment", "Folder selected! folderId: " + folderId + ", folderName: " + folderName);
|
||||||
|
// 画面遷移
|
||||||
|
FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity();
|
||||||
|
assert fragmentNavigation != null;
|
||||||
|
fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDocumentSelected(String documentId, String documentName) {
|
||||||
|
Toast.makeText(getContext(), "Document selected! documentId: " + documentId + ", documentName: " + documentName, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
recyclerView.setAdapter(listItemAdapter);
|
||||||
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
|
if (getArguments() != null) {
|
||||||
|
this.folderId = getArguments().getString("folderId");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.folderId == null) { // Root
|
||||||
|
lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> {
|
||||||
|
logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
|
||||||
|
listItemAdapter.setLibraryItemPage(libraryItemPage);
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
|
// ActionBarのタイトルを変更する
|
||||||
|
getActivity().setTitle("ライブラリ");
|
||||||
|
// ActionBarに戻るボタンを非表示にする
|
||||||
|
// getActivity().getActionBar().setDisplayHomeAsUpEnabled(false);
|
||||||
|
listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1);
|
||||||
|
});
|
||||||
|
this.currentTotalItemCount = libraryItemPage.getListItems().size();
|
||||||
|
});
|
||||||
|
} else { // Root以外
|
||||||
|
lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> {
|
||||||
|
logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
|
||||||
|
listItemAdapter.setLibraryItemPage(libraryItemPage);
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
|
// ActionBarのタイトルを変更する
|
||||||
|
getActivity().setTitle(libraryItemPage.getPageTitle());
|
||||||
|
// ActionBarに戻るボタンを表示する
|
||||||
|
// getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1);
|
||||||
|
});
|
||||||
|
this.currentTotalItemCount = libraryItemPage.getListItems().size();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.dir_menu, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Selected
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
if (item.getItemId() == R.id.menu_item_create_new_folder) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
|
builder.setTitle("フォルダの作成");
|
||||||
|
builder.setMessage("フォルダ名を入力してください");
|
||||||
|
final android.widget.EditText input = new android.widget.EditText(getContext());
|
||||||
|
input.setText("フォルダ名");
|
||||||
|
builder.setView(input);
|
||||||
|
builder.setPositiveButton("作成", (dialog, which) -> {
|
||||||
|
lacertaLibrary.createFolder(null, input.getText().toString()).thenAccept(folderId -> {
|
||||||
|
logger.debug("LibraryTopFragment", "folderId: " + folderId);
|
||||||
|
});
|
||||||
|
// Refresh
|
||||||
|
updateItem();
|
||||||
|
});
|
||||||
|
builder.setNegativeButton("キャンセル", (dialog, which) -> {
|
||||||
|
dialog.cancel();
|
||||||
|
});
|
||||||
|
builder.show();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateItem() {
|
||||||
|
lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> {
|
||||||
|
logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
|
listItemAdapter.notifyItemRangeRemoved(0, this.currentTotalItemCount - 1);
|
||||||
|
});
|
||||||
|
listItemAdapter.setLibraryItemPage(libraryItemPage);
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
|
listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1);
|
||||||
|
});
|
||||||
|
this.currentTotalItemCount = libraryItemPage.getListItems().size();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
-106
@@ -1,106 +0,0 @@
|
|||||||
package one.nem.lacerta.feature.library;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint;
|
|
||||||
import one.nem.lacerta.data.Document;
|
|
||||||
import one.nem.lacerta.model.document.DocumentMeta;
|
|
||||||
import one.nem.lacerta.model.document.tag.DocumentTag;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple {@link Fragment} subclass.
|
|
||||||
* Use the {@link LibraryTopFragment#newInstance} factory method to
|
|
||||||
* create an instance of this fragment.
|
|
||||||
*/
|
|
||||||
@AndroidEntryPoint
|
|
||||||
public class LibraryTopFragment extends Fragment {
|
|
||||||
|
|
||||||
// @Inject
|
|
||||||
// Document document;
|
|
||||||
|
|
||||||
// TODO: Rename parameter arguments, choose names that match
|
|
||||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
|
||||||
private static final String ARG_PARAM1 = "param1";
|
|
||||||
private static final String ARG_PARAM2 = "param2";
|
|
||||||
|
|
||||||
// TODO: Rename and change types of parameters
|
|
||||||
private String mParam1;
|
|
||||||
private String mParam2;
|
|
||||||
|
|
||||||
public LibraryTopFragment() {
|
|
||||||
// Required empty public constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use this factory method to create a new instance of
|
|
||||||
* this fragment using the provided parameters.
|
|
||||||
*
|
|
||||||
* @param param1 Parameter 1.
|
|
||||||
* @param param2 Parameter 2.
|
|
||||||
* @return A new instance of fragment LibraryTopFragment.
|
|
||||||
*/
|
|
||||||
// TODO: Rename and change types and number of parameters
|
|
||||||
public static LibraryTopFragment newInstance(String param1, String param2) {
|
|
||||||
LibraryTopFragment fragment = new LibraryTopFragment();
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putString(ARG_PARAM1, param1);
|
|
||||||
args.putString(ARG_PARAM2, param2);
|
|
||||||
fragment.setArguments(args);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
if (getArguments() != null) {
|
|
||||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
|
||||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
View view = inflater.inflate(R.layout.fragment_library_top, container, false);
|
|
||||||
|
|
||||||
// Use view.findViewById instead of findViewById
|
|
||||||
RecyclerView documentRecyclerView = view.findViewById(R.id.document_list);
|
|
||||||
|
|
||||||
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
|
|
||||||
documentRecyclerView.setLayoutManager(layoutManager);
|
|
||||||
|
|
||||||
//データを取得
|
|
||||||
|
|
||||||
// List<DocumentMeta> metas = document.getAllDocumentMetas(100);
|
|
||||||
|
|
||||||
// Toast.makeText(getContext(), "Documents: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show();
|
|
||||||
|
|
||||||
// Create and set the adapter
|
|
||||||
// DocumentAdapter adapter = new DocumentAdapter(metas);
|
|
||||||
// documentRecyclerView.setAdapter(adapter);
|
|
||||||
|
|
||||||
// Use a LinearLayoutManager to specify the layout
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package one.nem.lacerta.feature.library;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import one.nem.lacerta.model.LibraryItemPage;
|
||||||
|
import one.nem.lacerta.model.ListItem;
|
||||||
|
import one.nem.lacerta.model.ListItemType;
|
||||||
|
|
||||||
|
public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListItemViewHolder>{
|
||||||
|
|
||||||
|
LibraryItemPage libraryItemPage;
|
||||||
|
|
||||||
|
DocumentSelectListener listener;
|
||||||
|
|
||||||
|
|
||||||
|
public ListItemAdapter(DocumentSelectListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLibraryItemPage(LibraryItemPage libraryItemPage) {
|
||||||
|
this.libraryItemPage = libraryItemPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public ListItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.common_list_item, parent, false);
|
||||||
|
return new ListItemViewHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull ListItemViewHolder holder, int position) {
|
||||||
|
ListItem listItem = libraryItemPage.getListItems().get(position);
|
||||||
|
holder.icon.setImageResource(listItem.getItemType().getIconId());
|
||||||
|
holder.icon.setColorFilter(one.nem.lacerta.shared.ui.R.color.colorOnSurface);
|
||||||
|
holder.title.setText(listItem.getTitle());
|
||||||
|
holder.description.setText(listItem.getDescription());
|
||||||
|
|
||||||
|
holder.itemView.setOnClickListener( v -> {
|
||||||
|
if (listItem.getItemType() == ListItemType.ITEM_TYPE_DOCUMENT) {
|
||||||
|
listener.onDocumentSelected(listItem.getItemId(), listItem.getTitle());
|
||||||
|
}
|
||||||
|
else if (listItem.getItemType() == ListItemType.ITEM_TYPE_FOLDER) {
|
||||||
|
listener.onFolderSelected(listItem.getItemId(), listItem.getTitle());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return this.libraryItemPage == null ? 0
|
||||||
|
: this.libraryItemPage.getListItems() == null ? 0 : this.libraryItemPage.getListItems().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ListItemViewHolder extends RecyclerView.ViewHolder{
|
||||||
|
|
||||||
|
ImageView icon;
|
||||||
|
TextView title;
|
||||||
|
TextView description;
|
||||||
|
public ListItemViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_icon);
|
||||||
|
title = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_title);
|
||||||
|
description = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,32 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:theme="@style/Theme.Lacerta"
|
|
||||||
tools:context=".LibraryTopFragment">
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.MaterialToolbar
|
|
||||||
android:id="@+id/tool_bar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="@color/colorPrimaryContainer"
|
|
||||||
android:minHeight="?attr/actionBarSize"
|
|
||||||
android:theme="?attr/actionBarTheme"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:title="Library"
|
|
||||||
app:titleTextColor="@color/colorOnPrimaryContainer" />
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/document_list"
|
android:id="@+id/library_item_recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="match_parent" />
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tool_bar" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</FrameLayout>
|
||||||
@@ -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>
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
app:startDestination="@id/feature_library_top_fragment">
|
app:startDestination="@id/feature_library_top_fragment">
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/feature_library_top_fragment"
|
android:id="@+id/feature_library_top_fragment"
|
||||||
android:name="one.nem.lacerta.feature.library.LibraryTopFragment"
|
android:name="one.nem.lacerta.feature.library.LibraryPageFragment"
|
||||||
android:label="fragment_library_top"
|
android:label="fragment_library_top"
|
||||||
tools:layout="@layout/fragment_library_top" />
|
tools:layout="@layout/fragment_library_top" />
|
||||||
</navigation>
|
</navigation>
|
||||||
@@ -1,50 +1,11 @@
|
|||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:background="@color/colorSurface">
|
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/setting_item_recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="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>
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package one.nem.lacerta.model;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
public interface FragmentNavigation {
|
||||||
|
void navigateToFragment(Fragment fragment);
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package one.nem.lacerta.model;
|
package one.nem.lacerta.model;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -29,11 +31,26 @@ public class PublicPath {
|
|||||||
private void resolveInternal(String path) {
|
private void resolveInternal(String path) {
|
||||||
if (path.equals("..")) {
|
if (path.equals("..")) {
|
||||||
this.path.remove(this.path.size() - 1);
|
this.path.remove(this.path.size() - 1);
|
||||||
|
} else if (path.equals(".")) {
|
||||||
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
add(path);
|
this.path.add(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PublicPath parse(String path) {
|
||||||
|
if (path.startsWith("/")) {
|
||||||
|
this.path.clear();
|
||||||
|
path = path.substring(1);
|
||||||
|
}
|
||||||
|
String[] pathArray = path.split("/");
|
||||||
|
for (String p : pathArray) {
|
||||||
|
Log.d("PublicPath", "parse: " + p);
|
||||||
|
resolveInternal(p);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public PublicPath resolve(String path) {
|
public PublicPath resolve(String path) {
|
||||||
resolveInternal(path);
|
resolveInternal(path);
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import androidx.room.Insert;
|
|||||||
import androidx.room.Query;
|
import androidx.room.Query;
|
||||||
import androidx.room.Update;
|
import androidx.room.Update;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import androidx.room.Dao;
|
|||||||
import androidx.room.Insert;
|
import androidx.room.Insert;
|
||||||
import androidx.room.Query;
|
import androidx.room.Query;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import one.nem.lacerta.source.database.entity.FolderEntity;
|
import one.nem.lacerta.source.database.entity.FolderEntity;
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
@@ -15,6 +18,9 @@ public interface FolderDao {
|
|||||||
@Query("SELECT * FROM Folder WHERE public_path = :publicPath")
|
@Query("SELECT * FROM Folder WHERE public_path = :publicPath")
|
||||||
FolderEntity findByPublicPath(String publicPath);
|
FolderEntity findByPublicPath(String publicPath);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM Folder WHERE public_path = :publicPath LIMIT :limit")
|
||||||
|
List<FolderEntity> findByPublicPathWithLimit(String publicPath, int limit);
|
||||||
|
|
||||||
@Insert
|
@Insert
|
||||||
void insert(FolderEntity folderEntity);
|
void insert(FolderEntity folderEntity);
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ package one.nem.lacerta.utils;
|
|||||||
public class FeatureSwitch {
|
public class FeatureSwitch {
|
||||||
|
|
||||||
public static class Meta {
|
public static class Meta {
|
||||||
public static boolean canOverrideSwitch = true;
|
public static boolean canOverrideSwitch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class FeatureMaster {
|
public static class FeatureMaster {
|
||||||
public static boolean enableSearch = true;
|
public static boolean enableSearch = false;
|
||||||
public static boolean enableDebugMenu = false;
|
public static boolean enableDebugMenu = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user