summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Quang Anh Luong <qal@google.com> 2023-07-05 16:16:35 +0900
committer Quang Anh Luong <qal@google.com> 2023-07-13 16:44:05 +0900
commit83f40c6f4473d157f4837ad37ab6a803dbd280c9 (patch)
tree426f8ffa76945121a9c8594e470391f3970c1ad2
parent34c6be8515d20d963df658989d51670f0f0bd97b (diff)
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
-rw-r--r--WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java13
-rw-r--r--service/ServiceWifiResources/res/layout/wifi_p2p_dialog.xml4
-rw-r--r--service/ServiceWifiResources/res/values/styles.xml2
3 files changed, 13 insertions, 6 deletions
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;
diff --git a/service/ServiceWifiResources/res/layout/wifi_p2p_dialog.xml b/service/ServiceWifiResources/res/layout/wifi_p2p_dialog.xml
index 85794936d4..947f976fcc 100644
--- a/service/ServiceWifiResources/res/layout/wifi_p2p_dialog.xml
+++ b/service/ServiceWifiResources/res/layout/wifi_p2p_dialog.xml
@@ -23,6 +23,10 @@
android:layout_height="wrap_content"
android:orientation="vertical">
+ <TextView android:id="@+id/time_remaining"
+ style="@style/wifi_p2p_dialog_timeout"
+ android:visibility="gone"/>
+
<LinearLayout android:id="@+id/info"
style="@style/wifi_section" />
diff --git a/service/ServiceWifiResources/res/values/styles.xml b/service/ServiceWifiResources/res/values/styles.xml
index e3ad1619a5..714d10fe0f 100644
--- a/service/ServiceWifiResources/res/values/styles.xml
+++ b/service/ServiceWifiResources/res/values/styles.xml
@@ -46,6 +46,8 @@
<style name="wifi_dialog" parent="@android:style/Theme.DeviceDefault.Light.Dialog.Alert" />
<style name="wifi_p2p_invitation_received_dialog" parent="@android:style/Theme.DeviceDefault.Light.Dialog.Alert" />
+ <style name="wifi_p2p_dialog_timeout" parent="@style/wifi_item" />
+
<style name="wifi_p2p_dialog_row_label" parent="@style/wifi_item_label" />
<style name="wifi_p2p_dialog_row_content" parent="@style/wifi_item_content">