diff options
author | 2022-01-25 16:07:21 -0800 | |
---|---|---|
committer | 2022-01-28 13:25:50 -0800 | |
commit | c9f9a7967adf600e47d5f2f96667821926f93aca (patch) | |
tree | 8c57c8b827723c90b6706aee04a5003b1b090729 | |
parent | 7dd9241b2a06d92b9fd93662916d8ecc20cf8cd9 (diff) |
Add Gravity overlay for wifi dialogs
Add an overlayable value to indicate the Gravity of all wifi dialogs.
Bug: 201723053
Test: modify overlay value and adb shell cmd wifi
launch-dialog-p2p-invitation-received <ssid> and verify dialog gravity
changes.
Change-Id: I3a6407c96a89d229d0d2c4a79a09f3ebacf527c7
3 files changed, 17 insertions, 0 deletions
diff --git a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java index 409c08e2d0..d02ae0a979 100644 --- a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java +++ b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java @@ -33,6 +33,7 @@ import android.text.TextUtils; import android.util.ArraySet; import android.util.Log; import android.util.SparseArray; +import android.view.Gravity; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; @@ -57,6 +58,7 @@ public class WifiDialogActivity extends Activity { private @Nullable WifiContext mWifiContext; private @Nullable WifiManager mWifiManager; private boolean mIsVerboseLoggingEnabled; + private int mGravity = Gravity.NO_GRAVITY; private @NonNull SparseArray<Intent> mIntentsPerId = new SparseArray<>(); private @NonNull SparseArray<Dialog> mActiveDialogsPerId = new SparseArray<>(); @@ -100,6 +102,12 @@ public class WifiDialogActivity extends Activity { name, "string", getWifiContext().getWifiOverlayApkPkgName()); } + private int getIntegerId(@NonNull String name) { + Resources res = getResources(); + return res.getIdentifier( + name, "integer", getWifiContext().getWifiOverlayApkPkgName()); + } + private int getLayoutId(@NonNull String name) { Resources res = getResources(); return res.getIdentifier( @@ -128,6 +136,7 @@ public class WifiDialogActivity extends Activity { if (mIsVerboseLoggingEnabled) { Log.v(TAG, "Creating WifiDialogActivity."); } + mGravity = getResources().getInteger(getIntegerId("config_wifiDialogGravity")); List<Intent> receivedIntents = new ArrayList<>(); if (savedInstanceState != null) { if (mIsVerboseLoggingEnabled) { @@ -270,6 +279,9 @@ public class WifiDialogActivity extends Activity { return false; } mActiveDialogsPerId.put(dialogId, dialog); + if (mGravity != Gravity.NO_GRAVITY) { + dialog.getWindow().setGravity(mGravity); + } dialog.show(); if (mIsVerboseLoggingEnabled) { Log.v(TAG, "Showing dialog " + dialogId); diff --git a/service/ServiceWifiResources/res/values/config.xml b/service/ServiceWifiResources/res/values/config.xml index 713de3c4c8..c5a897c3b5 100644 --- a/service/ServiceWifiResources/res/values/config.xml +++ b/service/ServiceWifiResources/res/values/config.xml @@ -775,4 +775,8 @@ <!-- Wifi driver supports Opportunistic Wireless Encryption (OWE) Transition aka Enhanced Open for Soft-AP --> <bool translatable="false" name="config_wifiSoftapOweTransitionSupported">false</bool> + + <!-- Indicate the gravity of Wifi dialogs. Must be an integer corresponding to a + android.view.Gravity.GravityFlags constant. Default = Gravity.NO_GRAVITY (0) --> + <integer translatable="false" name="config_wifiDialogGravity">0</integer> </resources> diff --git a/service/ServiceWifiResources/res/values/overlayable.xml b/service/ServiceWifiResources/res/values/overlayable.xml index 55451d8abb..342bc88ccc 100644 --- a/service/ServiceWifiResources/res/values/overlayable.xml +++ b/service/ServiceWifiResources/res/values/overlayable.xml @@ -217,6 +217,7 @@ <item type="string" name="config_wifiCertInstallationHelpLink" /> <item type="integer" name="config_wifiConfigurationRestoreNetworksBatchNum" /> <item type="bool" name="config_wifiSoftapOweTransitionSupported" /> + <item type="integer" name="config_wifiDialogGravity" /> <!-- Params from config.xml that can be overlayed --> <!-- Params from strings.xml that can be overlayed --> |