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

Commit 865a1756 authored by Victoria Lease's avatar Victoria Lease Committed by Android (Google) Code Review
Browse files

Merge "Set text locale in language settings panel." into jb-mr1-dev

parents 1caca0a1 0203341a
Loading
Loading
Loading
Loading
+28 −3
Original line number Diff line number Diff line
@@ -28,9 +28,12 @@ import android.content.res.Resources;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import java.text.Collator;
import java.util.Arrays;
@@ -86,7 +89,7 @@ public class LocalePicker extends ListFragment {
    }

    public static ArrayAdapter<LocaleInfo> constructAdapter(Context context,
            int layoutId, int fieldId) {
            final int layoutId, final int fieldId) {
        final Resources resources = context.getResources();
        final String[] locales = Resources.getSystem().getAssets().getLocales();
        final String[] specialLocaleCodes = resources.getStringArray(R.array.special_locale_codes);
@@ -154,7 +157,29 @@ public class LocalePicker extends ListFragment {
            localeInfos[i] = preprocess[i];
        }
        Arrays.sort(localeInfos);
        return new ArrayAdapter<LocaleInfo>(context, layoutId, fieldId, localeInfos);

        final LayoutInflater inflater =
                (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        return new ArrayAdapter<LocaleInfo>(context, layoutId, fieldId, localeInfos) {
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View view;
                TextView text;
                if (convertView == null) {
                    view = inflater.inflate(layoutId, parent, false);
                    text = (TextView) view.findViewById(fieldId);
                    view.setTag(text);
                } else {
                    view = convertView;
                    text = (TextView) view.getTag();
                }
                LocaleInfo item = getItem(position);
                text.setText(item.toString());
                text.setTextLocale(item.getLocale());

                return view;
            }
        };
    }

    private static String toTitleCase(String s) {