Implement V4 Toolbar for ComposeMessageActivity and AddAttachmentsActivity

MAILAND-1837
This commit is contained in:
Davide Farella 2021-05-07 17:13:53 +02:00 committed by Davide Giuseppe Farella
parent 7fa5a21b03
commit a72c7f9264
9 changed files with 119 additions and 76 deletions

View File

@ -242,7 +242,7 @@ public class AddAttachmentsActivity extends BaseStoragePermissionActivity implem
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.attachments_menu, menu);
getMenuInflater().inflate(R.menu.menu_attachments, menu);
return true;
}

View File

@ -631,6 +631,7 @@ public class ComposeMessageActivity
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.ic_close);
actionBar.setTitle("");
}
}
@ -1022,24 +1023,27 @@ public class ComposeMessageActivity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.compose_message_menu, menu);
getMenuInflater().inflate(R.menu.menu_compose_message, menu);
setMenuActionsListeners(menu);
this.menu = menu;
disableSendButton(true);
return true;
}
private void setMenuActionsListeners(Menu menu) {
MenuItem item = menu.findItem(R.id.send_message);
item.getActionView().findViewById(R.id.send_button).setOnClickListener((View view) -> {
if (!mSendingPressed)
onOptionSendHandler();
});
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
case R.id.send_message:
if (mSendingPressed) {
return true;
}
onOptionSendHandler();
return true;
}
return super.onOptionsItemSelected(item);
}
@ -2160,13 +2164,14 @@ public class ComposeMessageActivity
private void disableSendButton(boolean disable) {
// Find the menu item you want to style
if (menu != null) {
MenuItem item = menu.getItem(0);
MenuItem item = menu.findItem(R.id.send_message);
ImageButton imageButton = item.getActionView().findViewById(R.id.send_button);
if (disable) {
item.setEnabled(false);
item.getIcon().setColorFilter(getResources().getColor(R.color.white_30), PorterDuff.Mode.MULTIPLY);
imageButton.setBackgroundColor(R.color.white_30);
} else {
item.setEnabled(true);
item.getIcon().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.MULTIPLY);
imageButton.setBackgroundResource(R.drawable.selector_circle_background_interaction_strong);
}
}
}

View File

@ -835,7 +835,7 @@ class MailboxActivity :
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.mailbox_options_menu, menu)
menuInflater.inflate(R.menu.menu_mailbox_options, menu)
setUpMenuItems(menu.findItem(R.id.compose), menu.findItem(R.id.search))
val mailboxLocation = mailboxLocationMain.value
menu.findItem(R.id.empty).isVisible =
@ -845,7 +845,7 @@ class MailboxActivity :
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
menu.clear()
menuInflater.inflate(R.menu.mailbox_options_menu, menu)
menuInflater.inflate(R.menu.menu_mailbox_options, menu)
setUpMenuItems(menu.findItem(R.id.compose), menu.findItem(R.id.search))
val mailboxLocation = mailboxLocationMain.value
menu.findItem(R.id.empty).isVisible =

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2020 Proton Technologies AG
~
~ This file is part of ProtonMail.
~
~ ProtonMail is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ ProtonMail is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/toolbar_action_layout_size"
android:layout_height="@dimen/toolbar_action_layout_size">
<ImageButton
android:id="@+id/send_button"
android:layout_width="@dimen/button_nav_size"
android:layout_height="@dimen/button_nav_size"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_send"
android:tint="@color/icon_inverted"
android:background="@drawable/selector_circle_background_interaction_strong"
android:contentDescription="@string/send" />
</FrameLayout>

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2020 Proton Technologies AG
This file is part of ProtonMail.
ProtonMail is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ProtonMail is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/attach_file"
android:icon="@drawable/ic_menu_attach"
android:title="@string/attach_file"
app:showAsAction="ifRoom" />
<item
android:id="@+id/take_photo"
android:icon="@drawable/ic_menu_photo"
android:title="@string/take_photo"
app:showAsAction="ifRoom" />
</menu>

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2020 Proton Technologies AG
This file is part of ProtonMail.
ProtonMail is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ProtonMail is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/send_message"
android:icon="@drawable/ic_menu_send"
android:title="@string/send"
app:showAsAction="always" />
</menu>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2020 Proton Technologies AG
~
~ This file is part of ProtonMail.
~
~ ProtonMail is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ ProtonMail is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/attach_file"
android:icon="@drawable/ic_menu_attach"
app:iconTint="@color/icon_norm"
android:title="@string/attach_file"
app:showAsAction="ifRoom" />
<item
android:id="@+id/take_photo"
android:icon="@drawable/ic_menu_photo"
app:iconTint="@color/icon_norm"
android:title="@string/take_photo"
app:showAsAction="ifRoom" />
</menu>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2020 Proton Technologies AG
~
~ This file is part of ProtonMail.
~
~ ProtonMail is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ ProtonMail is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with ProtonMail. If not, see https://www.gnu.org/licenses/.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/send_message"
android:title="@string/send"
app:actionLayout="@layout/layout_send_action"
app:showAsAction="always" />
</menu>