diff options
Diffstat (limited to 'app/src')
7 files changed, 48 insertions, 22 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/Board.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/Board.java index e116286b4..36ceae564 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/Board.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/Board.java @@ -22,6 +22,15 @@ import it.niedermann.nextcloud.deck.model.interfaces.AbstractRemoteEntity; ) public class Board extends AbstractRemoteEntity { + public Board() { + + } + + public Board(String title, String color) { + this.title = title; + this.color = color; + } + private String title; private long ownerId; private String color; diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java index 0beeed0be..026f363c4 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java @@ -360,10 +360,7 @@ public class MainActivity extends AppCompatActivity implements EditStackListener @Override public void onCreateBoard(String title, String color) { - Board b = new Board(); - b.setTitle(title); - String colorToSet = color.startsWith("#") ? color.substring(1) : color; - b.setColor(colorToSet); + Board b = new Board(title, color.startsWith("#") ? color.substring(1) : color); observeOnce(syncManager.createBoard(currentAccount.getId(), b), this, board -> { if (board == null) { Snackbar.make(binding.coordinatorLayout, "Open Deck in web interface first!", Snackbar.LENGTH_LONG); @@ -406,11 +403,15 @@ public class MainActivity extends AppCompatActivity implements EditStackListener boardsList = boards; - for (int i = 0; i < boardsList.size(); i++) { - if (currentBoardId == boardsList.get(i).getLocalId() || currentBoardId == NO_BOARDS) { - setCurrentBoard(boardsList.get(i)); - break; + if (boardsList.size() > 0) { + for (int i = 0; i < boardsList.size(); i++) { + if (currentBoardId == boardsList.get(i).getLocalId() || currentBoardId == NO_BOARDS) { + setCurrentBoard(boardsList.get(i)); + break; + } } + } else { + clearCurrentBoard(); } inflateBoardMenu(); }; @@ -423,6 +424,15 @@ public class MainActivity extends AppCompatActivity implements EditStackListener binding.drawerLayout.closeDrawer(GravityCompat.START); } + protected void clearCurrentBoard() { + binding.toolbar.setTitle(R.string.app_name_short); + binding.swipeRefreshLayout.setVisibility(View.GONE); + binding.addStackButton.setVisibility(View.GONE); + binding.stackLayout.setVisibility(View.GONE); + binding.emptyContentViewStacks.setVisibility(View.GONE); + binding.emptyContentViewBoards.setVisibility(View.VISIBLE); + } + protected void setCurrentBoard(@NonNull Board board) { this.currentBoardId = board.getLocalId(); @@ -440,9 +450,10 @@ public class MainActivity extends AppCompatActivity implements EditStackListener } else { binding.fab.hide(); binding.addStackButton.setVisibility(View.GONE); - binding.emptyContentView.hideDescription(); + binding.emptyContentViewStacks.hideDescription(); } + binding.emptyContentViewBoards.setVisibility(View.GONE); binding.stackLayout.setVisibility(View.VISIBLE); binding.swipeRefreshLayout.setVisibility(View.VISIBLE); syncManager.getStacksForBoard(this.currentAccount.getId(), board.getLocalId()).observe(MainActivity.this, (List<FullStack> fullStacks) -> { @@ -452,10 +463,10 @@ public class MainActivity extends AppCompatActivity implements EditStackListener currentBoardHasStacks = true; if (fullStacks.size() == 0) { - binding.emptyContentView.setVisibility(View.VISIBLE); + binding.emptyContentViewStacks.setVisibility(View.VISIBLE); currentBoardHasStacks = false; } else { - binding.emptyContentView.setVisibility(View.GONE); + binding.emptyContentViewStacks.setVisibility(View.GONE); currentBoardHasStacks = true; } @@ -489,7 +500,6 @@ public class MainActivity extends AppCompatActivity implements EditStackListener } protected void inflateBoardMenu() { - binding.navigationView.setItemIconTintList(null); Menu menu = binding.navigationView.getMenu(); menu.clear(); @@ -522,12 +532,10 @@ public class MainActivity extends AppCompatActivity implements EditStackListener } else { switch (item.getItemId()) { case MENU_ID_ABOUT: - Intent aboutIntent = new Intent(getApplicationContext(), AboutActivity.class); - startActivityForResult(aboutIntent, MainActivity.ACTIVITY_ABOUT); + startActivityForResult(new Intent(getApplicationContext(), AboutActivity.class), MainActivity.ACTIVITY_ABOUT); break; case MENU_ID_SETTINGS: - Intent settingsIntent = new Intent(getApplicationContext(), SettingsActivity.class); - startActivityForResult(settingsIntent, MainActivity.ACTIVITY_SETTINGS); + startActivityForResult(new Intent(getApplicationContext(), SettingsActivity.class), MainActivity.ACTIVITY_SETTINGS); break; case MENU_ID_ADD_BOARD: EditBoardDialogFragment.newInstance().show(getSupportFragmentManager(), addBoard); @@ -623,7 +631,6 @@ public class MainActivity extends AppCompatActivity implements EditStackListener default: try { AccountImporter.onActivityResult(requestCode, resultCode, data, this, (account) -> { - final WrappedLiveData<Account> accountLiveData = this.syncManager.createAccount(new Account(account.name, account.userId, account.url)); accountLiveData.observe(this, (Account createdAccount) -> { if (accountLiveData.hasError()) { @@ -761,7 +768,7 @@ public class MainActivity extends AppCompatActivity implements EditStackListener @Override public void onLastBoardDeleted() { - binding.toolbar.setTitle(R.string.app_name_short); + clearCurrentBoard(); EditBoardDialogFragment.newInstance().show(getSupportFragmentManager(), addBoard); } }
\ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 09b162e0d..a0015c2ed 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -19,7 +19,15 @@ app:layout_behavior="@string/appbar_scrolling_view_behavior"> <it.niedermann.nextcloud.deck.ui.helper.emptycontentview.EmptyContentView - android:id="@+id/empty_content_view" + android:id="@+id/empty_content_view_boards" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:visibility="gone" + app:description="@string/add_a_new_board_using_the_button" + app:title="@string/no_boards" /> + + <it.niedermann.nextcloud.deck.ui.helper.emptycontentview.EmptyContentView + android:id="@+id/empty_content_view_stacks" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" diff --git a/app/src/main/res/layout/fragment_card_edit_tab_activities.xml b/app/src/main/res/layout/fragment_card_edit_tab_activities.xml index 2fe7bed0b..33e9809a1 100644 --- a/app/src/main/res/layout/fragment_card_edit_tab_activities.xml +++ b/app/src/main/res/layout/fragment_card_edit_tab_activities.xml @@ -16,7 +16,7 @@ tools:listitem="@layout/item_activity" /> <it.niedermann.nextcloud.deck.ui.helper.emptycontentview.EmptyContentView - android:id="@+id/empty_content_view" + android:id="@+id/empty_content_view_stacks" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" diff --git a/app/src/main/res/layout/fragment_card_edit_tab_attachments.xml b/app/src/main/res/layout/fragment_card_edit_tab_attachments.xml index 87898d4dd..0d07e8f51 100644 --- a/app/src/main/res/layout/fragment_card_edit_tab_attachments.xml +++ b/app/src/main/res/layout/fragment_card_edit_tab_attachments.xml @@ -26,7 +26,7 @@ tools:visibility="visible" /> <it.niedermann.nextcloud.deck.ui.helper.emptycontentview.EmptyContentView - android:id="@+id/empty_content_view" + android:id="@+id/empty_content_view_stacks" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" diff --git a/app/src/main/res/layout/fragment_stack.xml b/app/src/main/res/layout/fragment_stack.xml index 02199fdc7..8f8bc2b5f 100644 --- a/app/src/main/res/layout/fragment_stack.xml +++ b/app/src/main/res/layout/fragment_stack.xml @@ -7,7 +7,7 @@ android:orientation="vertical"> <it.niedermann.nextcloud.deck.ui.helper.emptycontentview.EmptyContentView - android:id="@+id/empty_content_view" + android:id="@+id/empty_content_view_stacks" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cf1e9be4c..d4751012a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -164,4 +164,6 @@ <string name="share_success">Successfully added %1$s to %2$s</string> <string name="could_not_copy_to_clipboard">Could not copy to clipboard</string> <string name="shared_error">Sharing content from 3rd-party apps is not yet fully supported. Please try to download it first and then share it from you native file manager or gallery.</string> + <string name="no_boards">No boards yet</string> + <string name="add_a_new_board_using_the_button">Add a new board using the + button</string> </resources> |