Add assistant to header

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-03-13 09:53:38 +01:00
parent f12657d420
commit ffe19232dc
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF
6 changed files with 37 additions and 27 deletions

View file

@ -53,7 +53,6 @@ class ComposeActivity : DrawerActivity() {
companion object {
const val DESTINATION = "DESTINATION"
const val TITLE = "TITLE"
const val MENU_ITEM = "MENU_ITEM"
}
override fun onCreate(savedInstanceState: Bundle?) {
@ -63,13 +62,10 @@ class ComposeActivity : DrawerActivity() {
val destination = intent.getSerializableArgument(DESTINATION, ComposeDestination::class.java)
val titleId = intent.getIntExtra(TITLE, R.string.empty)
val menuItemId = intent.getIntExtra(MENU_ITEM, R.id.nav_assistant)
setupToolbar()
updateActionBarTitleAndHomeButtonByString(getString(titleId))
setupDrawer(menuItemId)
binding.composeView.setContent {
MaterialTheme(
colorScheme = viewThemeUtils.getColorScheme(this),
@ -80,11 +76,6 @@ class ComposeActivity : DrawerActivity() {
}
}
override fun onResume() {
super.onResume()
setDrawerMenuItemChecked(R.id.nav_assistant)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
android.R.id.home -> {

View file

@ -362,12 +362,14 @@ public abstract class DrawerActivity extends ToolbarActivity
LinearLayout[] views = {
ecosystemApps.findViewById(R.id.drawer_ecosystem_notes),
ecosystemApps.findViewById(R.id.drawer_ecosystem_talk),
ecosystemApps.findViewById(R.id.drawer_ecosystem_more)
ecosystemApps.findViewById(R.id.drawer_ecosystem_more),
ecosystemApps.findViewById(R.id.drawer_ecosystem_assistant),
};
views[0].setOnClickListener(v -> openAppOrStore("it.niedermann.owncloud.notes"));
views[1].setOnClickListener(v -> openAppOrStore("com.nextcloud.talk2"));
views[2].setOnClickListener(v -> openAppStore("Nextcloud", true));
views[3].setOnClickListener(v -> startComposeActivity(ComposeDestination.AssistantScreen, R.string.assistant_screen_top_bar_title));
int iconColor;
if (Hct.fromInt(primaryColor).getTone() < 80.0) {
@ -468,7 +470,6 @@ public abstract class DrawerActivity extends ToolbarActivity
DrawerMenuUtil.filterSearchMenuItems(menu, user, getResources());
DrawerMenuUtil.filterTrashbinMenuItem(menu, capability);
DrawerMenuUtil.filterActivityMenuItem(menu, capability);
DrawerMenuUtil.filterAssistantMenuItem(menu, capability);
DrawerMenuUtil.filterGroupfoldersMenuItem(menu, capability);
DrawerMenuUtil.setupHomeMenuItem(menu, getResources());
@ -545,8 +546,6 @@ public abstract class DrawerActivity extends ToolbarActivity
intent.setAction(FileDisplayActivity.LIST_GROUPFOLDERS);
intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItem.getItemId());
startActivity(intent);
} else if (itemId == R.id.nav_assistant) {
startComposeActivity(ComposeDestination.AssistantScreen, R.string.assistant_screen_top_bar_title, itemId);
} else {
if (menuItem.getItemId() >= MENU_ITEM_EXTERNAL_LINK &&
menuItem.getItemId() <= MENU_ITEM_EXTERNAL_LINK + 100) {
@ -558,11 +557,10 @@ public abstract class DrawerActivity extends ToolbarActivity
}
}
private void startComposeActivity(ComposeDestination destination, int titleId, int menuItemId) {
private void startComposeActivity(ComposeDestination destination, int titleId) {
Intent composeActivity = new Intent(getApplicationContext(), ComposeActivity.class);
composeActivity.putExtra(ComposeActivity.DESTINATION, destination);
composeActivity.putExtra(ComposeActivity.TITLE, titleId);
composeActivity.putExtra(ComposeActivity.MENU_ITEM, menuItemId);
startActivity(composeActivity);
}

View file

@ -64,12 +64,6 @@ public final class DrawerMenuUtil {
}
}
public static void filterAssistantMenuItem(Menu menu, @Nullable OCCapability capability) {
if (capability != null && !capability.getAssistant().isTrue()) {
filterMenuItems(menu, R.id.nav_assistant);
}
}
public static void filterGroupfoldersMenuItem(Menu menu, @Nullable OCCapability capability) {
if (capability != null && !capability.getGroupfolders().isTrue()) {
filterMenuItems(menu, R.id.nav_groupfolders);

View file

@ -71,6 +71,37 @@
android:layout_marginBottom="@dimen/standard_half_margin"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/drawer_ecosystem_assistant"
android:layout_width="wrap_content"
android:layout_marginEnd="40dp"
android:layout_height="wrap_content"
android:gravity="center"
android:background="?android:selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:orientation="vertical">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="4dp"
android:background="@drawable/white_outline"
android:contentDescription="@string/ecosystem_apps_talk"
android:padding="8dp"
android:src="@drawable/ic_assistant"
app:tint="@color/white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/ecosystem_apps_display_assistant"
android:textColor="@color/white"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/drawer_ecosystem_talk"
android:layout_width="wrap_content"

View file

@ -25,12 +25,6 @@
<group
android:id="@+id/drawer_menu_standard"
android:checkableBehavior="single">
<item
android:id="@+id/nav_assistant"
android:icon="@drawable/ic_assistant"
android:orderInCategory="0"
android:title="@string/drawer_item_assistant" />
<item
android:id="@+id/nav_all_files"
android:icon="@drawable/all_files"

View file

@ -18,6 +18,8 @@
<string name="menu_item_sort_by_size_biggest_first">Biggest first</string>
<string name="menu_item_sort_by_size_smallest_first">Smallest first</string>
<string name="ecosystem_apps_display_assistant">Assistant</string>
<string name="assistant_screen_top_bar_title">Assistant</string>
<string name="assistant_screen_loading">Task List are loading, please wait</string>
<string name="assistant_screen_no_task_available_for_all_task_filter_text">No task available. Select a task type to create a new task.</string>