From 83f40c6f4473d157f4837ad37ab6a803dbd280c9 Mon Sep 17 00:00:00 2001 From: Quang Anh Luong Date: Wed, 5 Jul 2023 16:16:35 +0900 Subject: Fix P2P dialog time remaining text being cut off P2P dialog time remaining text is set as a message in the AlertDialog, separately from the ScrollView containing the rest of the P2P dialog text. If the screen size is too small to fit the dialog and the keyboard, the dialog will get squished and push the message underneath the Title, cutting it off. To prevent this, move the time remaining text to the ScrollView with the rest of the P2P text so the text is more compact and is able to be scrolled together if the dialog is too small. Updated-Overlayable: Not applicable - changing default value Bug: 288179496 Test: manually verify timeleft text appears in rest of the ScrollView using adb shell cmd wifi launch-p2p-dialog-invitation-received DeviceName -c 15000 -p Change-Id: Ic2cf4dd0cbf5e33ff38023e89b3e1388cf4d1fdb --- .../src/com/android/wifi/dialog/WifiDialogActivity.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'WifiDialog') diff --git a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java index 34fc8e3d28..43d7d92e1e 100644 --- a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java +++ b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java @@ -406,9 +406,12 @@ public class WifiDialogActivity extends Activity { // Round up to the nearest whole second. secondsRemaining++; } - dialog.setMessage(MessageFormat.format( + TextView timeRemaining = dialog.getWindow().findViewById( + getWifiViewId("time_remaining")); + timeRemaining.setText(MessageFormat.format( getWifiString("wifi_p2p_invitation_seconds_remaining"), secondsRemaining)); + timeRemaining.setVisibility(View.VISIBLE); } } @@ -586,15 +589,15 @@ public class WifiDialogActivity extends Activity { @Nullable final String deviceName, final boolean isPinRequested, @Nullable final String displayPin) { - final View textEntryView = getWifiLayoutInflater() - .inflate(getWifiLayoutId("wifi_p2p_dialog"), null); - ViewGroup group = textEntryView.findViewById(getWifiViewId("info")); if (TextUtils.isEmpty(deviceName)) { Log.w(TAG, "P2P Invitation Received dialog device name is null or empty." + " id=" + dialogId + " deviceName=" + deviceName + " displayPin=" + displayPin); } + final View textEntryView = getWifiLayoutInflater() + .inflate(getWifiLayoutId("wifi_p2p_dialog"), null); + ViewGroup group = textEntryView.findViewById(getWifiViewId("info")); addRowToP2pDialog(group, getWifiString("wifi_p2p_from_message"), deviceName); final EditText pinEditText; @@ -612,8 +615,6 @@ public class WifiDialogActivity extends Activity { AlertDialog dialog = getWifiAlertDialogBuilder("wifi_p2p_invitation_received_dialog") .setTitle(getWifiString("wifi_p2p_invitation_to_connect_title")) - // Set the message to "" to allow us to modify it after building (b/36913966). - .setMessage("") .setView(textEntryView) .setPositiveButton(getWifiString("accept"), (dialogPositive, which) -> { String pin = null; -- cgit v1.2.3-59-g8ed1b