Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b41e016f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Moves layout code from java files to layout xml"

parents b46df69a 3742ccf8
Loading
Loading
Loading
Loading
+57 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<!-- TODO(b/33197203) remove hardcoded color once color is final -->
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingStart="16dip"
    android:paddingEnd="16dip"
    android:paddingTop="16dip"
    android:paddingBottom="16dip"
    android:background="#FDF8C8">

  <!-- TODO(b/33197203) use.R.string once final wording is done -->
  <TextView
      android:id="@+id/autofill_save_title"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="Save for autofill?"
      android:singleLine="true"/>

  <TextView
      android:id="@+id/autofill_save_no"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/autofill_save_title"
      android:layout_toLeftOf="@+id/autofill_save_yes"
      android:layout_marginRight="16dip"
      android:text="No thanks"
      android:textAllCaps="true"
      android:singleLine="true"/>

    <TextView
      android:id="@+id/autofill_save_yes"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/autofill_save_title"
      android:layout_alignParentRight="true"
      android:text="Save"
      android:textAllCaps="true"
      android:singleLine="true"/>

</RelativeLayout>
+6 −0
Original line number Diff line number Diff line
@@ -2828,4 +2828,10 @@
  <java-symbol type="dimen" name="item_touch_helper_max_drag_scroll_per_frame"/>
  <java-symbol type="dimen" name="item_touch_helper_swipe_escape_velocity"/>
  <java-symbol type="dimen" name="item_touch_helper_swipe_escape_max_velocity"/>

  <!-- com.android.server.autofill -->
  <java-symbol type="layout" name="autofill_save"/>
  <java-symbol type="id" name="autofill_save_title" />
  <java-symbol type="id" name="autofill_save_no" />
  <java-symbol type="id" name="autofill_save_yes" />
</resources>
+8 −40
Original line number Diff line number Diff line
@@ -21,19 +21,20 @@ import android.graphics.Color;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import android.view.LayoutInflater;
import android.view.View;

import com.android.internal.R;

/**
 * Autofill Save Prompt
 */
final class SavePrompt extends RelativeLayout {
    public interface OnSaveListener {
        void onSaveClick();

        void onCancelClick();
    }

    private final TextView mTextView;
    private final TextView mNoButton;
    private final TextView mYesButton;
    private final OnSaveListener mListener;
@@ -41,52 +42,19 @@ final class SavePrompt extends RelativeLayout {
    SavePrompt(Context context, OnSaveListener listener) {
        super(context);
        mListener = listener;
        setBackgroundColor(Color.YELLOW);
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.autofill_save, this);

        // TODO(b/33197203): move layout to XML
        mTextView = new TextView(context);
        final LayoutParams textParams = new LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        textParams.setMargins(50, 25, 50, 0);
        mTextView.setLayoutParams(textParams);
        // TODO(b/33197203): use R.string once final wording is done
        mTextView.setText("Save for autofill?");
        mTextView.setId(View.generateViewId());

        mNoButton = new TextView(context);
        // TODO(b/33197203): use R.string once final wording is done
        mNoButton.setText("No thanks");
        mNoButton.setBackgroundColor(Color.TRANSPARENT);
        mNoButton.setAllCaps(true);
        mNoButton = (TextView) view.findViewById(R.id.autofill_save_no);
        mNoButton.setOnClickListener((v) -> {
            mListener.onCancelClick();
        });

        mYesButton = new TextView(context);
        // TODO(b/33197203): use R.string once final wording is done
        mYesButton.setText("Save");
        mYesButton.setBackgroundColor(Color.TRANSPARENT);
        mYesButton.setId(View.generateViewId());
        mYesButton.setAllCaps(true);
        mYesButton = (TextView) view.findViewById(R.id.autofill_save_yes);
        mYesButton.setOnClickListener((v) -> {
            mListener.onSaveClick();
        });

        addView(mTextView);
        addView(mNoButton);
        addView(mYesButton);

        final LayoutParams yesLayoutParams = new LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        yesLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        yesLayoutParams.addRule(RelativeLayout.BELOW, mTextView.getId());
        yesLayoutParams.setMargins(25, 25, 50, 25);
        mYesButton.setLayoutParams(yesLayoutParams);
        final LayoutParams noLayoutParams = new LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        noLayoutParams.addRule(RelativeLayout.LEFT_OF, mYesButton.getId());
        noLayoutParams.addRule(RelativeLayout.BELOW, mTextView.getId());
        noLayoutParams.setMargins(50, 25, 25, 25);
        mNoButton.setLayoutParams(noLayoutParams);
        //addView(view);
    }
}