diff options
4 files changed, 114 insertions, 92 deletions
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 05f4a5773..26625038b 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 @@ -17,6 +17,7 @@ import android.text.TextWatcher; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.inputmethod.InputMethodManager; import android.widget.PopupMenu; import androidx.annotation.ColorInt; @@ -77,7 +78,6 @@ import it.niedermann.nextcloud.deck.persistence.sync.adapters.db.util.WrappedLiv import it.niedermann.nextcloud.deck.ui.about.AboutActivity; import it.niedermann.nextcloud.deck.ui.accountswitcher.AccountSwitcherDialog; import it.niedermann.nextcloud.deck.ui.archivedboards.ArchivedBoardsActvitiy; -import it.niedermann.nextcloud.deck.ui.archivedcards.ArchivedCardsActvitiy; import it.niedermann.nextcloud.deck.ui.board.ArchiveBoardListener; import it.niedermann.nextcloud.deck.ui.board.DeleteBoardListener; import it.niedermann.nextcloud.deck.ui.board.EditBoardDialogFragment; @@ -203,7 +203,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener DrawableCompat.setTint(headerBinding.copyDebugLogs.getDrawable(), headerTextColor); }); - binding.currentBoardName.addTextChangedListener(new TextWatcher() { + binding.filterText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -402,7 +402,16 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener }); distinctUntilChanged(map(filterViewModel.getFilterInformation(), FilterInformation::hasActiveFilter)) .observe(this, (hasActiveFilter) -> binding.filterIndicator.setVisibility(hasActiveFilter ? View.VISIBLE : View.GONE)); - binding.archivedCards.setOnClickListener((v) -> startActivity(ArchivedCardsActvitiy.createIntent(this, mainViewModel.getCurrentAccount(), mainViewModel.getCurrentBoardLocalId(), mainViewModel.currentBoardHasEditPermission()))); +// binding.archivedCards.setOnClickListener((v) -> startActivity(ArchivedCardsActvitiy.createIntent(this, mainViewModel.getCurrentAccount(), mainViewModel.getCurrentBoardLocalId(), mainViewModel.currentBoardHasEditPermission()))); + binding.enableSearch.setOnClickListener((v) -> { + binding.toolbar.setVisibility(View.GONE); + binding.searchToolbar.setVisibility(View.VISIBLE); + binding.searchToolbar.setNavigationOnClickListener(v1 -> onBackPressed()); + binding.enableSearch.setVisibility(View.GONE); + binding.filterText.requestFocus(); + final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(binding.filterText, InputMethodManager.SHOW_IMPLICIT); + }); binding.swipeRefreshLayout.setOnRefreshListener(() -> { @@ -584,7 +593,8 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener } protected void clearCurrentBoard() { - binding.currentBoardName.setHint(R.string.app_name_short); + binding.toolbar.setTitle(R.string.app_name_short); + binding.filterText.setHint(R.string.app_name_short); binding.swipeRefreshLayout.setVisibility(View.GONE); binding.listMenuButton.setVisibility(View.GONE); binding.emptyContentViewStacks.setVisibility(View.GONE); @@ -603,7 +613,8 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener saveCurrentBoardId(this, mainViewModel.getCurrentAccount().getId(), mainViewModel.getCurrentBoardLocalId()); binding.navigationView.setCheckedItem(boardsList.indexOf(board)); - binding.currentBoardName.setHint(getString(R.string.search_in, board.getTitle())); + binding.toolbar.setTitle(board.getTitle()); + binding.filterText.setHint(getString(R.string.search_in, board.getTitle())); if (mainViewModel.currentBoardHasEditPermission()) { binding.fab.show(); @@ -933,10 +944,11 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener public void onBackPressed() { if (binding.drawerLayout.isDrawerOpen(GravityCompat.START)) { binding.drawerLayout.closeDrawer(GravityCompat.START); - } else if(binding.currentBoardName.hasFocus()) { - binding.currentBoardName.setText(null); - binding.currentBoardName.clearFocus(); - // TODO focus goes now to viewPager:first-child (recyclerview) + } else if (binding.searchToolbar.getVisibility() == View.VISIBLE) { + binding.filterText.setText(null); + binding.searchToolbar.setVisibility(View.GONE); + binding.enableSearch.setVisibility(View.VISIBLE); + binding.toolbar.setVisibility(View.VISIBLE); } else { super.onBackPressed(); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/sharetarget/ShareTargetActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/sharetarget/ShareTargetActivity.java index 1bae469dc..21aafed30 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/sharetarget/ShareTargetActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/sharetarget/ShareTargetActivity.java @@ -192,7 +192,7 @@ public class ShareTargetActivity extends MainActivity implements SelectCardListe super.setCurrentBoard(board); binding.listMenuButton.setVisibility(View.GONE); binding.fab.setVisibility(View.GONE); - binding.currentBoardName.setHint(R.string.simple_select); + binding.toolbar.setTitle(R.string.simple_select); } @Override diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/widget/singlecard/SelectCardForWidgetActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/widget/singlecard/SelectCardForWidgetActivity.java index 47dfbdf34..fe6e969e7 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/widget/singlecard/SelectCardForWidgetActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/widget/singlecard/SelectCardForWidgetActivity.java @@ -60,7 +60,7 @@ public class SelectCardForWidgetActivity extends MainActivity implements SelectC super.setCurrentBoard(board); binding.listMenuButton.setVisibility(View.GONE); binding.fab.setVisibility(View.GONE); - binding.currentBoardName.setHint(R.string.simple_select); + binding.toolbar.setTitle(R.string.simple_select); } @Override diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3df953318..f7f8101ba 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -112,107 +112,117 @@ android:elevation="@dimen/spacer_2x" app:cardCornerRadius="@dimen/spacer_2x"> - <androidx.appcompat.widget.Toolbar - android:id="@+id/toolbar" + + <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_gravity="center_vertical"> + android:layout_height="?attr/actionBarSize" + tools:title="Deck"> - <androidx.constraintlayout.widget.ConstraintLayout - android:layout_width="match_parent" - android:layout_height="?attr/actionBarSize" - tools:title="Deck"> + <androidx.appcompat.widget.Toolbar + android:id="@+id/toolbar" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@id/enableSearch" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <androidx.appcompat.widget.Toolbar + android:id="@+id/searchToolbar" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@id/enableSearch" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:navigationIcon="@drawable/ic_arrow_back_white_24dp"> <EditText - android:id="@+id/currentBoardName" - android:layout_width="0dp" + android:id="@+id/filter_text" + android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" android:inputType="text" android:maxLines="1" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@id/archivedCards" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" tools:hint="@string/app_name_short" /> + </androidx.appcompat.widget.Toolbar> + + <ImageView + android:id="@+id/enableSearch" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_gravity="center_vertical|end" + android:background="?attr/selectableItemBackgroundBorderless" + android:contentDescription="@string/action_archived_cards" + android:paddingStart="@dimen/spacer_1x" + android:paddingEnd="@dimen/spacer_1x" + android:tooltipText="@string/action_archived_cards" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@id/filterWrapper" + app:layout_constraintTop_toTopOf="parent" + app:srcCompat="@drawable/ic_baseline_search_24" + app:tint="?attr/colorAccent" + tools:targetApi="o" /> + + <FrameLayout + android:id="@+id/filterWrapper" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|end" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@id/accountSwitcher" + app:layout_constraintTop_toTopOf="parent"> <ImageView - android:id="@+id/archivedCards" + android:id="@+id/filter" android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_gravity="center_vertical|end" + android:layout_height="wrap_content" android:background="?attr/selectableItemBackgroundBorderless" - android:contentDescription="@string/action_archived_cards" + android:contentDescription="@string/simple_filter" android:paddingStart="@dimen/spacer_1x" + android:paddingTop="12dp" android:paddingEnd="@dimen/spacer_1x" - android:tooltipText="@string/action_archived_cards" - android:visibility="gone" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@id/filterWrapper" - app:layout_constraintTop_toTopOf="parent" - app:srcCompat="@drawable/ic_archive_white_24dp" + android:paddingBottom="12dp" + android:tooltipText="@string/simple_filter" + app:srcCompat="@drawable/ic_filter_list_white_24dp" app:tint="?attr/colorAccent" - tools:targetApi="o" - tools:visibility="visible" /> - + tools:targetApi="o" /> - <FrameLayout - android:id="@+id/filterWrapper" + <ImageView + android:id="@+id/filter_indicator" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center_vertical|end" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@id/accountSwitcher" - app:layout_constraintTop_toTopOf="parent"> - - <ImageView - android:id="@+id/filter" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:background="?attr/selectableItemBackgroundBorderless" - android:contentDescription="@string/simple_filter" - android:paddingTop="12dp" - android:paddingBottom="12dp" - android:paddingStart="@dimen/spacer_1x" - android:paddingEnd="@dimen/spacer_1x" - android:tooltipText="@string/simple_filter" - app:srcCompat="@drawable/ic_filter_list_white_24dp" - app:tint="?attr/colorAccent" - tools:targetApi="o" /> - - <ImageView - android:id="@+id/filter_indicator" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="bottom|end" - android:layout_marginEnd="@dimen/spacer_1x" - android:layout_marginBottom="12dp" - android:contentDescription="@null" - android:src="@drawable/circle_grey600_8dp" - android:visibility="gone" - app:tint="@color/defaultBrand" - tools:visibility="visible" /> - </FrameLayout> + android:layout_gravity="bottom|end" + android:layout_marginEnd="@dimen/spacer_1x" + android:layout_marginBottom="12dp" + android:contentDescription="@null" + android:src="@drawable/circle_grey600_8dp" + android:visibility="gone" + app:tint="@color/defaultBrand" + tools:visibility="visible" /> + </FrameLayout> - <ImageView - android:id="@+id/accountSwitcher" - android:layout_width="48dp" - android:layout_height="?attr/actionBarSize" - android:layout_gravity="center_vertical|end" - android:background="?attr/selectableItemBackgroundBorderless" - android:contentDescription="@string/choose_account" - android:paddingTop="12dp" - android:paddingBottom="12dp" - android:paddingStart="0dp" - android:paddingEnd="@dimen/spacer_1hx" - android:tooltipText="@string/choose_account" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toTopOf="parent" - app:srcCompat="@drawable/ic_baseline_account_circle_24" - tools:targetApi="o" /> - </androidx.constraintlayout.widget.ConstraintLayout> - </androidx.appcompat.widget.Toolbar> + <ImageView + android:id="@+id/accountSwitcher" + android:layout_width="48dp" + android:layout_height="?attr/actionBarSize" + android:layout_gravity="center_vertical|end" + android:background="?attr/selectableItemBackgroundBorderless" + android:contentDescription="@string/choose_account" + android:paddingStart="0dp" + android:paddingTop="12dp" + android:paddingEnd="@dimen/spacer_1hx" + android:paddingBottom="12dp" + android:tooltipText="@string/choose_account" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:srcCompat="@drawable/ic_baseline_account_circle_24" + tools:targetApi="o" /> + </androidx.constraintlayout.widget.ConstraintLayout> </com.google.android.material.card.MaterialCardView> <LinearLayout |