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

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

Merge "Redesign app language selection page" into main

parents 58447850 0f1ce599
Loading
Loading
Loading
Loading
+47 −22
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.Filterable;
import android.widget.LinearLayout;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.TextView;


import com.android.internal.R;
import com.android.internal.R;
@@ -242,11 +243,7 @@ public class SuggestedLocaleAdapter extends BaseAdapter implements Filterable {
                break;
                break;
            case TYPE_SYSTEM_LANGUAGE_FOR_APP_LANGUAGE_PICKER:
            case TYPE_SYSTEM_LANGUAGE_FOR_APP_LANGUAGE_PICKER:
                TextView title;
                TextView title;
                LocaleStore.LocaleInfo info = (LocaleStore.LocaleInfo) getItem(position);
                if (mHasSpecificAppPackageName) {
                if (info == null) {
                    throw new NullPointerException("Non header locale cannot be null.");
                }
                if (info.isAppCurrentLocale()) {
                    title = itemView.findViewById(R.id.language_picker_item);
                    title = itemView.findViewById(R.id.language_picker_item);
                } else {
                } else {
                    title = itemView.findViewById(R.id.locale);
                    title = itemView.findViewById(R.id.locale);
@@ -254,11 +251,22 @@ public class SuggestedLocaleAdapter extends BaseAdapter implements Filterable {
                title.setText(R.string.system_locale_title);
                title.setText(R.string.system_locale_title);
                break;
                break;
            case TYPE_CURRENT_LOCALE:
            case TYPE_CURRENT_LOCALE:
                updateTextView(itemView,
                updateTextView(
                        itemView.findViewById(R.id.language_picker_item), position);
                        itemView, itemView.findViewById(R.id.language_picker_item), position);
                break;
                break;
            default:
            default:
                LocaleStore.LocaleInfo localeInfo = (LocaleStore.LocaleInfo) getItem(position);
                if (localeInfo == null) {
                    throw new NullPointerException("Non header locale cannot be null.");
                }
                if (mHasSpecificAppPackageName && localeInfo.isSuggested() && !mCountryMode) {
                    updateTextView(
                            itemView,
                            itemView.findViewById(R.id.language_picker_item),
                            position);
                } else {
                    updateTextView(itemView, itemView.findViewById(R.id.locale), position);
                    updateTextView(itemView, itemView.findViewById(R.id.locale), position);
                }
                break;
                break;
        }
        }
        return itemView;
        return itemView;
@@ -280,20 +288,21 @@ public class SuggestedLocaleAdapter extends BaseAdapter implements Filterable {
                }
                }
                break;
                break;
            case TYPE_SYSTEM_LANGUAGE_FOR_APP_LANGUAGE_PICKER:
            case TYPE_SYSTEM_LANGUAGE_FOR_APP_LANGUAGE_PICKER:
                if (((LocaleStore.LocaleInfo) getItem(position)).isAppCurrentLocale()) {
                if (mHasSpecificAppPackageName) {
                    shouldReuseView = convertView instanceof LinearLayout
                            && convertView.findViewById(R.id.language_picker_item) != null;
                    if (!shouldReuseView) {
                    updatedView = mInflater.inflate(
                    updatedView = mInflater.inflate(
                                R.layout.app_language_picker_current_locale_item,
                        R.layout.app_language_picker_locale_item, parent, false);
                                parent, false);
                    RadioButton option = updatedView.findViewById(R.id.checkbox);
                    if (((LocaleStore.LocaleInfo) getItem(position)).isAppCurrentLocale()) {
                        option.setChecked(true);
                    } else {
                        option.setChecked(false);
                    }
                    }
                } else {
                } else {
                    shouldReuseView = convertView instanceof TextView
                    shouldReuseView = convertView instanceof TextView
                        && convertView.findViewById(R.id.locale) != null;
                        && convertView.findViewById(R.id.locale) != null;
                    if (!shouldReuseView) {
                    if (!shouldReuseView) {
                        updatedView = mInflater.inflate(
                        updatedView =
                                R.layout.language_picker_item, parent, false);
                            mInflater.inflate(R.layout.language_picker_item, parent, false);
                    }
                    }
                }
                }
                break;
                break;
@@ -302,14 +311,30 @@ public class SuggestedLocaleAdapter extends BaseAdapter implements Filterable {
                        && convertView.findViewById(R.id.language_picker_item) != null;
                        && convertView.findViewById(R.id.language_picker_item) != null;
                if (!shouldReuseView) {
                if (!shouldReuseView) {
                    updatedView = mInflater.inflate(
                    updatedView = mInflater.inflate(
                            R.layout.app_language_picker_current_locale_item, parent, false);
                            R.layout.app_language_picker_locale_item, parent, false);
                    RadioButton option = updatedView.findViewById(R.id.checkbox);
                    option.setChecked(true);
                }
                }
                break;
                break;
            default:
            default:
                LocaleStore.LocaleInfo localeInfo = (LocaleStore.LocaleInfo) getItem(position);
                if (mHasSpecificAppPackageName
                        && localeInfo.isSuggested() && !mCountryMode) {
                    shouldReuseView = convertView instanceof LinearLayout
                        && convertView.findViewById(R.id.language_picker_item) != null;
                    if ((!shouldReuseView)) {
                        updatedView = mInflater.inflate(
                            R.layout.app_language_picker_locale_item, parent, false);
                        RadioButton option = updatedView.findViewById(R.id.checkbox);
                        option.setChecked(false);
                    }
                } else {
                    shouldReuseView = convertView instanceof TextView
                    shouldReuseView = convertView instanceof TextView
                        && convertView.findViewById(R.id.locale) != null;
                        && convertView.findViewById(R.id.locale) != null;
                if (!shouldReuseView) {
                    if ((!shouldReuseView)) {
                    updatedView = mInflater.inflate(R.layout.language_picker_item, parent, false);
                        updatedView = mInflater.inflate(
                            R.layout.language_picker_item, parent, false);
                    }
                }
                }
                break;
                break;
        }
        }
+19 −18
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--
<!--
  ~ Copyright (C) 2022 The Android Open Source Project
  ~ Copyright (C) 2024 The Android Open Source Project
  ~
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ you may not use this file except in compliance with the License.
@@ -20,10 +20,27 @@
    android:layout_width="match_parent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_vertical">
    android:gravity="center_vertical">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="center"
        android:minHeight="?android:attr/listPreferredItemHeight"
        android:layout_marginStart="20dip">

      <RadioButton
          android:id="@+id/checkbox"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:background="@null"
          android:focusable="false"
          android:clickable="false" />

    </LinearLayout>

    <RelativeLayout
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="6dip"
        android:layout_marginTop="6dip"
        android:layout_marginTop="6dip"
        android:layout_marginBottom="6dip"
        android:layout_marginBottom="6dip"
        android:layout_weight="1">
        android:layout_weight="1">
@@ -31,20 +48,4 @@
            android:id="@+id/language_picker_item"
            android:id="@+id/language_picker_item"
            layout="@layout/language_picker_item" />
            layout="@layout/language_picker_item" />
    </RelativeLayout>
    </RelativeLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="center"
        android:minHeight="?android:attr/listPreferredItemHeight">
        <ImageView
            android:id="@+id/imageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginHorizontal="16dp"
            android:src="@drawable/ic_check_24dp"
            app:tint="?attr/colorAccentPrimaryVariant"
            android:contentDescription="@*android:string/checked"/>
    </LinearLayout>
</LinearLayout>
</LinearLayout>
+1 −1
Original line number Original line Diff line number Diff line
@@ -5264,7 +5264,7 @@
  <java-symbol type="string" name="system_locale_title" />
  <java-symbol type="string" name="system_locale_title" />
  <java-symbol type="layout" name="app_language_picker_system_default" />
  <java-symbol type="layout" name="app_language_picker_system_default" />
  <java-symbol type="layout" name="app_language_picker_system_current" />
  <java-symbol type="layout" name="app_language_picker_system_current" />
  <java-symbol type="layout" name="app_language_picker_current_locale_item" />
  <java-symbol type="layout" name="app_language_picker_locale_item" />
  <java-symbol type="id" name="system_locale_subtitle" />
  <java-symbol type="id" name="system_locale_subtitle" />
  <java-symbol type="id" name="language_picker_item" />
  <java-symbol type="id" name="language_picker_item" />
  <java-symbol type="id" name="language_picker_header" />
  <java-symbol type="id" name="language_picker_header" />