- Revamped the list UI: replaced the long-press actions by some stateful buttons. Uses the listview's single choice mode. - Added a broadcast receiver to be able to change the system locale using an intent, e.g. sent by adb shell am. This is convenient for automated testing scripts. - Changed package namespace to v2. This makes it easier for an automated testing script to figure that an emulator has the old version and install the new one side-by-side. Change-Id: I1849d2b9d55441490b013cfefcca5d8fa48e22bd
74 lines
2.3 KiB
Java
74 lines
2.3 KiB
Java
/*
|
|
* Copyright (C) 2009 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.
|
|
*/
|
|
|
|
package com.android.customlocale2;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.util.Log;
|
|
import android.view.View;
|
|
import android.widget.Button;
|
|
import android.widget.EditText;
|
|
|
|
/**
|
|
* Dialog to ask the user for a new locale. <p/> Returns the locale code (e.g.
|
|
* "en_US") via an intent with a "locale" extra string and a "select" extra
|
|
* boolean.
|
|
*/
|
|
public class NewLocaleDialog extends Activity implements View.OnClickListener {
|
|
|
|
public static final String INTENT_EXTRA_LOCALE = "locale";
|
|
public static final String INTENT_EXTRA_SELECT = "select";
|
|
|
|
private static final String TAG = "NewLocale";
|
|
private static final boolean DEBUG = true;
|
|
private Button mButtonAdd;
|
|
private Button mButtonAddSelect;
|
|
private EditText mEditText;
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.new_locale);
|
|
|
|
mEditText = (EditText) findViewById(R.id.value);
|
|
|
|
mButtonAdd = (Button) findViewById(R.id.add);
|
|
mButtonAdd.setOnClickListener(this);
|
|
|
|
mButtonAddSelect = (Button) findViewById(R.id.add_and_select);
|
|
mButtonAddSelect.setOnClickListener(this);
|
|
}
|
|
|
|
public void onClick(View v) {
|
|
String locale = mEditText.getText().toString();
|
|
boolean select = v == mButtonAddSelect;
|
|
|
|
if (DEBUG) {
|
|
Log.d(TAG, "New Locale: " + locale + (select ? " + select" : ""));
|
|
}
|
|
|
|
Intent data = new Intent(NewLocaleDialog.this, NewLocaleDialog.class);
|
|
data.putExtra(INTENT_EXTRA_LOCALE, locale);
|
|
data.putExtra(INTENT_EXTRA_SELECT, select);
|
|
setResult(RESULT_OK, data);
|
|
|
|
finish();
|
|
}
|
|
}
|