Display tooltips when long-pressing the menu actions
This commit is contained in:
parent
59e0658299
commit
85762d5ec7
1 changed files with 24 additions and 2 deletions
|
@ -17,6 +17,7 @@ import android.widget.Toast;
|
|||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.appcompat.widget.TooltipCompat;
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.DI;
|
||||
import com.fsck.k9.FontSizes;
|
||||
|
@ -96,11 +97,12 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
|
|||
|
||||
menuPrimaryActionView = findViewById(R.id.menu_primary_action);
|
||||
menuPrimaryActionView.setOnClickListener(this);
|
||||
menuPrimaryActionView.setOnLongClickListener(this);
|
||||
|
||||
View menuOverflowView = findViewById(R.id.menu_overflow);
|
||||
menuOverflowView.setOnClickListener(this);
|
||||
menuOverflowView.setOnLongClickListener(this);
|
||||
String menuOverflowDescription =
|
||||
getContext().getString(androidx.appcompat.R.string.abc_action_menu_overflow_description);
|
||||
TooltipCompat.setTooltipText(menuOverflowView, menuOverflowDescription);
|
||||
|
||||
findViewById(R.id.participants_container).setOnClickListener(this);
|
||||
}
|
||||
|
@ -246,6 +248,10 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
|
|||
} else {
|
||||
int replyIconResource = getReplyImageResource(defaultAction);
|
||||
menuPrimaryActionView.setImageResource(replyIconResource);
|
||||
|
||||
String replyActionName = getReplyActionName(defaultAction);
|
||||
TooltipCompat.setTooltipText(menuPrimaryActionView, replyActionName);
|
||||
|
||||
menuPrimaryActionView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
@ -265,6 +271,22 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
|
|||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private String getReplyActionName(@NonNull ReplyAction replyAction) {
|
||||
Context context = getContext();
|
||||
switch (replyAction) {
|
||||
case REPLY: {
|
||||
return context.getString(R.string.reply_action);
|
||||
}
|
||||
case REPLY_ALL: {
|
||||
return context.getString(R.string.reply_all_action);
|
||||
}
|
||||
default: {
|
||||
throw new IllegalStateException("Unknown reply action: " + replyAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setAdditionalReplyActions(PopupMenu popupMenu) {
|
||||
List<ReplyAction> additionalActions = replyActions.getAdditionalActions();
|
||||
if (!additionalActions.contains(ReplyAction.REPLY)) {
|
||||
|
|
Loading…
Reference in a new issue