Merge "Fix ActionBar title for NFC sharing."
diff --git a/res/layout/preference_spellchecker.xml b/res/layout/preference_spellchecker.xml
new file mode 100644
index 0000000..e804f17
--- /dev/null
+++ b/res/layout/preference_spellchecker.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/pref_all"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:gravity="center_vertical">
+ <LinearLayout
+ android:id="@+id/pref_left_button"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:gravity="center_vertical"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?android:attr/selectableItemBackground">
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="15dip"
+ android:layout_marginRight="6dip"
+ android:layout_marginTop="6dip"
+ android:layout_marginBottom="6dip"
+ android:layout_weight="1">
+ <TextView
+ android:id="@+android:id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal"/>
+ <TextView
+ android:id="@android:id/summary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@android:id/title"
+ android:layout_alignLeft="@android:id/title"
+ android:visibility="gone"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textSize="13sp"
+ android:textColor="?android:attr/textColorSecondary"
+ android:maxLines="4" />
+ </RelativeLayout>
+ </LinearLayout>
+ <View
+ android:layout_width="2dip"
+ android:layout_height="match_parent"
+ android:layout_marginTop="5dip"
+ android:layout_marginBottom="5dip"
+ android:background="@android:drawable/divider_horizontal_dark" />
+ <ImageView
+ android:id="@+id/pref_right_button"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:paddingLeft="15dip"
+ android:paddingRight="?android:attr/scrollbarSize"
+ android:src="@drawable/ic_sysbar_quicksettings"
+ android:contentDescription="@string/input_method_settings_button"
+ android:layout_gravity="center"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?android:attr/selectableItemBackground" />
+</LinearLayout>
diff --git a/src/com/android/settings/deviceinfo/UsbSettings.java b/src/com/android/settings/deviceinfo/UsbSettings.java
index 8dea47f..538cde7 100644
--- a/src/com/android/settings/deviceinfo/UsbSettings.java
+++ b/src/com/android/settings/deviceinfo/UsbSettings.java
@@ -95,10 +95,11 @@
}
private void updateToggles() {
- if (mUsbManager.isFunctionEnabled(UsbManager.USB_FUNCTION_MTP)) {
+ String function = mUsbManager.getDefaultFunction();
+ if (UsbManager.USB_FUNCTION_MTP.equals(function)) {
mMtp.setChecked(true);
mPtp.setChecked(false);
- } else if (mUsbManager.isFunctionEnabled(UsbManager.USB_FUNCTION_PTP)) {
+ } else if (UsbManager.USB_FUNCTION_PTP.equals(function)) {
mMtp.setChecked(false);
mPtp.setChecked(true);
} else {
@@ -109,7 +110,6 @@
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
- Log.d(TAG, "onPreferenceTreeClick " + preference);
// temporary hack - using check boxes as radio buttons
// don't allow unchecking them
diff --git a/src/com/android/settings/inputmethod/SingleSpellCheckerPreference.java b/src/com/android/settings/inputmethod/SingleSpellCheckerPreference.java
new file mode 100644
index 0000000..98ca3af
--- /dev/null
+++ b/src/com/android/settings/inputmethod/SingleSpellCheckerPreference.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2011 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.settings.inputmethod;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+
+import android.content.Intent;
+
+import android.preference.Preference;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.textservice.SpellCheckerInfo;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+public class SingleSpellCheckerPreference extends Preference {
+ private static final float DISABLED_ALPHA = 0.4f;
+
+ private final SpellCheckerInfo mSpellCheckerInfo;
+
+ private SettingsPreferenceFragment mFragment;
+ private TextView mTitleText;
+ private TextView mSummaryText;
+ private View mPrefAll;
+ private View mPrefLeftButton;
+ private ImageView mSetingsButton;
+ private Intent mSettingsIntent;
+ private boolean mSelected;
+
+ public SingleSpellCheckerPreference(SettingsPreferenceFragment fragment, Intent settingsIntent,
+ SpellCheckerInfo sci) {
+ super(fragment.getActivity(), null, 0);
+ setLayoutResource(R.layout.preference_spellchecker);
+ mSpellCheckerInfo = sci;
+ mSelected = false;
+ }
+
+ @Override
+ protected void onBindView(View view) {
+ super.onBindView(view);
+ mPrefAll = view.findViewById(R.id.pref_all);
+ mPrefLeftButton = view.findViewById(R.id.pref_left_button);
+ mPrefLeftButton.setOnClickListener(
+ new OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ onLeftButtonClicked(arg0);
+ }
+ });
+ mSetingsButton = (ImageView)view.findViewById(R.id.pref_right_button);
+ mTitleText = (TextView)view.findViewById(android.R.id.title);
+ mSummaryText = (TextView)view.findViewById(android.R.id.summary);
+ mSetingsButton.setOnClickListener(
+ new OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ onSettingsButtonClicked(arg0);
+ }
+ });
+ updateSelectedState(mSelected);
+ }
+
+ private void onLeftButtonClicked(View arg0) {
+ final OnPreferenceClickListener listener = getOnPreferenceClickListener();
+ if (listener != null) {
+ listener.onPreferenceClick(this);
+ }
+ }
+
+ public SpellCheckerInfo getSpellCheckerInfo() {
+ return mSpellCheckerInfo;
+ }
+
+ public void updateSelectedState(boolean selected) {
+ if (mPrefAll != null) {
+ if (selected) {
+ // TODO: Use a color defined by the design guideline.
+ mPrefAll.setBackgroundColor(0x88006666);
+ } else {
+ mPrefAll.setBackgroundColor(0);
+ }
+ enableSettingsButton(selected);
+ }
+ }
+
+ public void setSelected(boolean selected) {
+ mSelected = selected;
+ }
+
+ protected void onSettingsButtonClicked(View arg0) {
+ if (mFragment != null && mSettingsIntent != null) {
+ mFragment.startActivity(mSettingsIntent);
+ }
+ }
+
+ private void enableSettingsButton(boolean enabled) {
+ if (mSetingsButton != null) {
+ if (mSettingsIntent == null) {
+ mSetingsButton.setVisibility(View.GONE);
+ } else {
+ mSetingsButton.setEnabled(enabled);
+ mSetingsButton.setClickable(enabled);
+ mSetingsButton.setFocusable(enabled);
+ if (!enabled) {
+ mSetingsButton.setAlpha(DISABLED_ALPHA);
+ }
+ }
+ }
+ }
+}
diff --git a/src/com/android/settings/inputmethod/SpellCheckersSettings.java b/src/com/android/settings/inputmethod/SpellCheckersSettings.java
index c8b3ca9..d6c0b1c 100644
--- a/src/com/android/settings/inputmethod/SpellCheckersSettings.java
+++ b/src/com/android/settings/inputmethod/SpellCheckersSettings.java
@@ -26,12 +26,16 @@
import android.view.textservice.SpellCheckerInfo;
import android.view.textservice.TextServicesManager;
+import java.util.ArrayList;
+
public class SpellCheckersSettings extends SettingsPreferenceFragment
- implements Preference.OnPreferenceChangeListener {
+ implements Preference.OnPreferenceClickListener {
private SpellCheckerInfo mCurrentSci;
private SpellCheckerInfo[] mEnabledScis;
private TextServicesManager mTsm;
+ private final ArrayList<SingleSpellCheckerPreference> mSpellCheckers =
+ new ArrayList<SingleSpellCheckerPreference>();
@Override
public void onCreate(Bundle icicle) {
@@ -42,11 +46,6 @@
}
@Override
- public boolean onPreferenceChange(Preference arg0, Object arg1) {
- return false;
- }
-
- @Override
public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
return false;
}
@@ -78,12 +77,28 @@
if (mCurrentSci == null || mEnabledScis == null) {
return;
}
- // TODO: implement here
+ mSpellCheckers.clear();
for (int i = 0; i < mEnabledScis.length; ++i) {
final SpellCheckerInfo sci = mEnabledScis[i];
- final PreferenceScreen scs = new PreferenceScreen(getActivity(), null);
- scs.setTitle(sci.getId());
- getPreferenceScreen().addPreference(scs);
+ final SingleSpellCheckerPreference scPref = new SingleSpellCheckerPreference(
+ this, null, sci);
+ mSpellCheckers.add(scPref);
+ scPref.setTitle(sci.getId());
+ scPref.setSelected(mCurrentSci != null && mCurrentSci.getId().equals(sci.getId()));
+ getPreferenceScreen().addPreference(scPref);
}
}
+
+ @Override
+ public boolean onPreferenceClick(Preference arg0) {
+ for (SingleSpellCheckerPreference scp : mSpellCheckers) {
+ if (arg0.equals(scp)) {
+ scp.setSelected(true);
+ mTsm.setCurrentSpellChecker(scp.getSpellCheckerInfo());
+ } else {
+ scp.setSelected(false);
+ }
+ }
+ return true;
+ }
}