Merge "Polish print settings accessibility." into klp-dev
This commit is contained in:
@@ -28,7 +28,6 @@
|
|||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/icon"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="12dip"
|
android:layout_marginBottom="12dip"
|
||||||
@@ -41,7 +40,8 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:textColor="?android:attr/textColorSecondary">
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:importantForAccessibility="no">
|
||||||
</TextView>
|
</TextView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@@ -3483,6 +3483,18 @@
|
|||||||
<!-- Template for the label of the state for a blocked print job. [CHAR LIMIT=25] -->
|
<!-- Template for the label of the state for a blocked print job. [CHAR LIMIT=25] -->
|
||||||
<string name="print_blocked_state_title_template">Printer blocked <xliff:g id="print_job_name" example="foo.jpg">%1$s</xliff:g></string>
|
<string name="print_blocked_state_title_template">Printer blocked <xliff:g id="print_job_name" example="foo.jpg">%1$s</xliff:g></string>
|
||||||
|
|
||||||
|
<!-- Utterance to announce that the search box is shown. This is spoken to a blind user. [CHAR LIMIT=none] -->
|
||||||
|
<string name="print_search_box_shown_utterance">Search box shown</string>
|
||||||
|
|
||||||
|
<!-- Utterance to announce that the search box is hidden. This is spoken to a blind user. [CHAR LIMIT=none] -->
|
||||||
|
<string name="print_search_box_hidden_utterance">Search box hidden</string>
|
||||||
|
|
||||||
|
<!-- Utterance to announce a change in the number of matches during a search. This is spoken to a blind user. [CHAR LIMIT=none] -->
|
||||||
|
<plurals name="print_search_result_count_utterance">
|
||||||
|
<item quantity="one"><xliff:g id="count" example="1">%1$s</xliff:g> printer found</item>
|
||||||
|
<item quantity="other"><xliff:g id="count" example="2">%1$s</xliff:g> printers found</item>
|
||||||
|
</plurals>
|
||||||
|
|
||||||
<!-- App Fuel Gauge strings -->
|
<!-- App Fuel Gauge strings -->
|
||||||
<skip />
|
<skip />
|
||||||
|
|
||||||
|
@@ -48,10 +48,6 @@ public abstract class ToggleFeaturePreferenceFragment
|
|||||||
protected CharSequence mSettingsTitle;
|
protected CharSequence mSettingsTitle;
|
||||||
protected Intent mSettingsIntent;
|
protected Intent mSettingsIntent;
|
||||||
|
|
||||||
// TODO: Showing sub-sub fragment does not handle the activity title
|
|
||||||
// so we do it but this is wrong. Do a real fix when there is time.
|
|
||||||
private CharSequence mOldActivityTitle;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -100,9 +96,6 @@ public abstract class ToggleFeaturePreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
getActivity().getActionBar().setCustomView(null);
|
getActivity().getActionBar().setCustomView(null);
|
||||||
if (mOldActivityTitle != null) {
|
|
||||||
getActivity().getActionBar().setTitle(mOldActivityTitle);
|
|
||||||
}
|
|
||||||
mToggleSwitch.setOnBeforeCheckedChangeListener(null);
|
mToggleSwitch.setOnBeforeCheckedChangeListener(null);
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
@@ -144,9 +137,8 @@ public abstract class ToggleFeaturePreferenceFragment
|
|||||||
// Title.
|
// Title.
|
||||||
PreferenceActivity activity = (PreferenceActivity) getActivity();
|
PreferenceActivity activity = (PreferenceActivity) getActivity();
|
||||||
if (!activity.onIsMultiPane() || activity.onIsHidingHeaders()) {
|
if (!activity.onIsMultiPane() || activity.onIsHidingHeaders()) {
|
||||||
mOldActivityTitle = getActivity().getTitle();
|
|
||||||
String title = arguments.getString(AccessibilitySettings.EXTRA_TITLE);
|
String title = arguments.getString(AccessibilitySettings.EXTRA_TITLE);
|
||||||
getActivity().getActionBar().setTitle(title);
|
getActivity().setTitle(title);
|
||||||
}
|
}
|
||||||
// Summary.
|
// Summary.
|
||||||
CharSequence summary = arguments.getCharSequence(AccessibilitySettings.EXTRA_SUMMARY);
|
CharSequence summary = arguments.getCharSequence(AccessibilitySettings.EXTRA_SUMMARY);
|
||||||
|
@@ -78,7 +78,7 @@ public class PrintJobSettingsFragment extends SettingsPreferenceFragment {
|
|||||||
Context.PRINT_SERVICE)).getGlobalPrintManagerForUser(
|
Context.PRINT_SERVICE)).getGlobalPrintManagerForUser(
|
||||||
ActivityManager.getCurrentUser());
|
ActivityManager.getCurrentUser());
|
||||||
|
|
||||||
getActivity().getActionBar().setTitle(R.string.print_print_job);
|
getActivity().setTitle(R.string.print_print_job);
|
||||||
|
|
||||||
processArguments();
|
processArguments();
|
||||||
|
|
||||||
|
@@ -55,6 +55,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@@ -71,8 +72,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
|
||||||
/**
|
/**
|
||||||
* Fragment with print service settings.
|
* Fragment with print service settings.
|
||||||
*/
|
*/
|
||||||
@@ -130,14 +129,12 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
private PrintersAdapter mPrintersAdapter;
|
private PrintersAdapter mPrintersAdapter;
|
||||||
|
|
||||||
// TODO: Showing sub-sub fragment does not handle the activity title
|
|
||||||
// so we do it but this is wrong. Do a real fix when there is time.
|
|
||||||
private CharSequence mOldActivityTitle;
|
|
||||||
|
|
||||||
private int mLastUnfilteredItemCount;
|
private int mLastUnfilteredItemCount;
|
||||||
|
|
||||||
private boolean mServiceEnabled;
|
private boolean mServiceEnabled;
|
||||||
|
|
||||||
|
private AnnounceFilterResult mAnnounceFilterResult;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -149,6 +146,9 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
mSettingsContentObserver.unregister(getContentResolver());
|
mSettingsContentObserver.unregister(getContentResolver());
|
||||||
|
if (mAnnounceFilterResult != null) {
|
||||||
|
mAnnounceFilterResult.remove();
|
||||||
|
}
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,9 +162,6 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
getActivity().getActionBar().setCustomView(null);
|
getActivity().getActionBar().setCustomView(null);
|
||||||
if (mOldActivityTitle != null) {
|
|
||||||
getActivity().getActionBar().setTitle(mOldActivityTitle);
|
|
||||||
}
|
|
||||||
mToggleSwitch.setOnBeforeCheckedChangeListener(null);
|
mToggleSwitch.setOnBeforeCheckedChangeListener(null);
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
@@ -235,8 +232,7 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
|||||||
if (emptyView == null) {
|
if (emptyView == null) {
|
||||||
emptyView = getActivity().getLayoutInflater().inflate(
|
emptyView = getActivity().getLayoutInflater().inflate(
|
||||||
R.layout.empty_print_state, contentRoot, false);
|
R.layout.empty_print_state, contentRoot, false);
|
||||||
ImageView iconView = (ImageView) emptyView.findViewById(R.id.icon);
|
emptyView.setContentDescription(getString(R.string.print_service_disabled));
|
||||||
iconView.setContentDescription(getString(R.string.print_service_disabled));
|
|
||||||
TextView textView = (TextView) emptyView.findViewById(R.id.message);
|
TextView textView = (TextView) emptyView.findViewById(R.id.message);
|
||||||
textView.setText(R.string.print_service_disabled);
|
textView.setText(R.string.print_service_disabled);
|
||||||
contentRoot.addView(emptyView);
|
contentRoot.addView(emptyView);
|
||||||
@@ -262,8 +258,7 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
|||||||
if (emptyView == null) {
|
if (emptyView == null) {
|
||||||
emptyView = getActivity().getLayoutInflater().inflate(
|
emptyView = getActivity().getLayoutInflater().inflate(
|
||||||
R.layout.empty_print_state, contentRoot, false);
|
R.layout.empty_print_state, contentRoot, false);
|
||||||
ImageView iconView = (ImageView) emptyView.findViewById(R.id.icon);
|
emptyView.setContentDescription(getString(R.string.print_no_printers_found));
|
||||||
iconView.setContentDescription(getString(R.string.print_no_printers_found));
|
|
||||||
TextView textView = (TextView) emptyView.findViewById(R.id.message);
|
TextView textView = (TextView) emptyView.findViewById(R.id.message);
|
||||||
textView.setText(R.string.print_no_printers_found);
|
textView.setText(R.string.print_no_printers_found);
|
||||||
contentRoot.addView(emptyView);
|
contentRoot.addView(emptyView);
|
||||||
@@ -331,9 +326,11 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
|||||||
// Title.
|
// Title.
|
||||||
PreferenceActivity activity = (PreferenceActivity) getActivity();
|
PreferenceActivity activity = (PreferenceActivity) getActivity();
|
||||||
if (!activity.onIsMultiPane() || activity.onIsHidingHeaders()) {
|
if (!activity.onIsMultiPane() || activity.onIsHidingHeaders()) {
|
||||||
mOldActivityTitle = getActivity().getTitle();
|
// PreferenceActivity allows passing as an extra only title by its
|
||||||
|
// resource id but we do not have the resource id for the print
|
||||||
|
// service label. Therefore, we do it ourselves.
|
||||||
String title = arguments.getString(PrintSettingsFragment.EXTRA_TITLE);
|
String title = arguments.getString(PrintSettingsFragment.EXTRA_TITLE);
|
||||||
getActivity().getActionBar().setTitle(title);
|
getActivity().setTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Settings title and intent.
|
// Settings title and intent.
|
||||||
@@ -425,6 +422,18 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
searchView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onViewAttachedToWindow(View view) {
|
||||||
|
view.announceForAccessibility(getString(
|
||||||
|
R.string.print_search_box_shown_utterance));
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onViewDetachedFromWindow(View view) {
|
||||||
|
view.announceForAccessibility(getString(
|
||||||
|
R.string.print_search_box_hidden_utterance));
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
menu.removeItem(R.id.print_menu_item_search);
|
menu.removeItem(R.id.print_menu_item_search);
|
||||||
}
|
}
|
||||||
@@ -463,6 +472,39 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
|||||||
public abstract void onChange(boolean selfChange, Uri uri);
|
public abstract void onChange(boolean selfChange, Uri uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final class AnnounceFilterResult implements Runnable {
|
||||||
|
private static final int SEARCH_RESULT_ANNOUNCEMENT_DELAY = 1000; // 1 sec
|
||||||
|
|
||||||
|
public void post() {
|
||||||
|
remove();
|
||||||
|
getListView().postDelayed(this, SEARCH_RESULT_ANNOUNCEMENT_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove() {
|
||||||
|
getListView().removeCallbacks(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
final int count = getListView().getAdapter().getCount();
|
||||||
|
final String text;
|
||||||
|
if (count <= 0) {
|
||||||
|
text = getString(R.string.print_no_printers_found);
|
||||||
|
} else {
|
||||||
|
text = getActivity().getResources().getQuantityString(
|
||||||
|
R.plurals.print_search_result_count_utterance, count, count);
|
||||||
|
}
|
||||||
|
getListView().announceForAccessibility(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void announceSearchResult() {
|
||||||
|
if (mAnnounceFilterResult == null) {
|
||||||
|
mAnnounceFilterResult = new AnnounceFilterResult();
|
||||||
|
}
|
||||||
|
mAnnounceFilterResult.post();
|
||||||
|
}
|
||||||
|
|
||||||
private final class PrintersAdapter extends BaseAdapter
|
private final class PrintersAdapter extends BaseAdapter
|
||||||
implements LoaderManager.LoaderCallbacks<List<PrinterInfo>>, Filterable {
|
implements LoaderManager.LoaderCallbacks<List<PrinterInfo>>, Filterable {
|
||||||
private final Object mLock = new Object();
|
private final Object mLock = new Object();
|
||||||
@@ -514,7 +556,9 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||||
|
final boolean resultCountChanged;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
|
final int oldPrinterCount = mFilteredPrinters.size();
|
||||||
mLastSearchString = constraint;
|
mLastSearchString = constraint;
|
||||||
mFilteredPrinters.clear();
|
mFilteredPrinters.clear();
|
||||||
if (results == null) {
|
if (results == null) {
|
||||||
@@ -523,6 +567,10 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
|||||||
List<PrinterInfo> printers = (List<PrinterInfo>) results.values;
|
List<PrinterInfo> printers = (List<PrinterInfo>) results.values;
|
||||||
mFilteredPrinters.addAll(printers);
|
mFilteredPrinters.addAll(printers);
|
||||||
}
|
}
|
||||||
|
resultCountChanged = (oldPrinterCount != mFilteredPrinters.size());
|
||||||
|
}
|
||||||
|
if (resultCountChanged) {
|
||||||
|
announceSearchResult();
|
||||||
}
|
}
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user