Fix the “screen lock option” and password restriction view are

in the wrong position on PIN/Password/Pattern in the landscape mode.

1. Move the description position under the GlifLayout header
2. Move the position "Screen lock options" button under the
GlifLayout header

Bug: 272676038
Bug: 285271342

Test: manully test with reproducible steps:
STEPS TO REPRODUCE:
1. Go through the setup flow
2. Continue steps until “set pin” page
3. The “screen lock option” is in the wrong position

Test: make RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings
.password.SetupChooseLockPasswordTest"

Change-Id: I24464e6b7e93f20abbeb59426919ed7fec5c7cbb
This commit is contained in:
Jason Chang
2023-06-15 16:09:06 +00:00
parent cc1fe61339
commit c0f0b0ca1a
12 changed files with 112 additions and 39 deletions

View File

@@ -27,7 +27,13 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.Utils;
public final class PasswordUtils extends com.android.settingslib.Utils {
@@ -97,4 +103,25 @@ public final class PasswordUtils extends com.android.settingslib.Utils {
Log.v(TAG, "Could not talk to activity manager.", e);
}
}
/** Setup screen lock options button under the Glif Header. */
public static void setupScreenLockOptionsButton(Context context, View view, Button optButton) {
final LinearLayout headerLayout = view.findViewById(
R.id.sud_layout_header);
final TextView sucTitleView = headerLayout.findViewById(R.id.suc_layout_title);
if (headerLayout != null && sucTitleView != null) {
final ViewGroup.MarginLayoutParams layoutTitleParams =
(ViewGroup.MarginLayoutParams) sucTitleView.getLayoutParams();
final ViewGroup.MarginLayoutParams lp = new ViewGroup.MarginLayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
lp.leftMargin = layoutTitleParams.leftMargin;
lp.topMargin = (int) context.getResources().getDimensionPixelSize(
R.dimen.screen_lock_options_button_margin_top);
optButton.setPadding(0, 0, 0, 0);
optButton.setLayoutParams(lp);
optButton.setText(context.getString(R.string.setup_lock_settings_options_button_label));
headerLayout.addView(optButton);
}
}
}