Merge "Remove unused battery strings"
diff --git a/res/drawable-hdpi/lock_anim_0.png b/res/drawable-hdpi/lock_anim_0.png
deleted file mode 100644
index 08732e4..0000000
--- a/res/drawable-hdpi/lock_anim_0.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_1.png b/res/drawable-hdpi/lock_anim_1.png
deleted file mode 100644
index 74a0628..0000000
--- a/res/drawable-hdpi/lock_anim_1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_10.png b/res/drawable-hdpi/lock_anim_10.png
deleted file mode 100644
index adb981d..0000000
--- a/res/drawable-hdpi/lock_anim_10.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_11.png b/res/drawable-hdpi/lock_anim_11.png
deleted file mode 100644
index f8976a2..0000000
--- a/res/drawable-hdpi/lock_anim_11.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_12.png b/res/drawable-hdpi/lock_anim_12.png
deleted file mode 100644
index 3ccdc85..0000000
--- a/res/drawable-hdpi/lock_anim_12.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_13.png b/res/drawable-hdpi/lock_anim_13.png
deleted file mode 100644
index ccd38d5..0000000
--- a/res/drawable-hdpi/lock_anim_13.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_14.png b/res/drawable-hdpi/lock_anim_14.png
deleted file mode 100644
index 2f40d9e..0000000
--- a/res/drawable-hdpi/lock_anim_14.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_2.png b/res/drawable-hdpi/lock_anim_2.png
deleted file mode 100644
index 495b2da..0000000
--- a/res/drawable-hdpi/lock_anim_2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_3.png b/res/drawable-hdpi/lock_anim_3.png
deleted file mode 100644
index fa37813..0000000
--- a/res/drawable-hdpi/lock_anim_3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_4.png b/res/drawable-hdpi/lock_anim_4.png
deleted file mode 100644
index 8201fd9..0000000
--- a/res/drawable-hdpi/lock_anim_4.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_5.png b/res/drawable-hdpi/lock_anim_5.png
deleted file mode 100644
index b08932d..0000000
--- a/res/drawable-hdpi/lock_anim_5.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_6.png b/res/drawable-hdpi/lock_anim_6.png
deleted file mode 100644
index dac09e1..0000000
--- a/res/drawable-hdpi/lock_anim_6.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_7.png b/res/drawable-hdpi/lock_anim_7.png
deleted file mode 100644
index f06c9d6..0000000
--- a/res/drawable-hdpi/lock_anim_7.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_8.png b/res/drawable-hdpi/lock_anim_8.png
deleted file mode 100644
index 07f7e34..0000000
--- a/res/drawable-hdpi/lock_anim_8.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_9.png b/res/drawable-hdpi/lock_anim_9.png
deleted file mode 100644
index 551bafa..0000000
--- a/res/drawable-hdpi/lock_anim_9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_0.png b/res/drawable-mdpi/lock_anim_0.png
deleted file mode 100644
index afdda8b..0000000
--- a/res/drawable-mdpi/lock_anim_0.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_1.png b/res/drawable-mdpi/lock_anim_1.png
deleted file mode 100644
index 6cae8e5..0000000
--- a/res/drawable-mdpi/lock_anim_1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_10.png b/res/drawable-mdpi/lock_anim_10.png
deleted file mode 100644
index 5de840e..0000000
--- a/res/drawable-mdpi/lock_anim_10.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_11.png b/res/drawable-mdpi/lock_anim_11.png
deleted file mode 100644
index 35db815..0000000
--- a/res/drawable-mdpi/lock_anim_11.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_12.png b/res/drawable-mdpi/lock_anim_12.png
deleted file mode 100644
index 8778d98..0000000
--- a/res/drawable-mdpi/lock_anim_12.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_13.png b/res/drawable-mdpi/lock_anim_13.png
deleted file mode 100644
index d0b8cf0..0000000
--- a/res/drawable-mdpi/lock_anim_13.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_14.png b/res/drawable-mdpi/lock_anim_14.png
deleted file mode 100644
index ea1aa31..0000000
--- a/res/drawable-mdpi/lock_anim_14.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_2.png b/res/drawable-mdpi/lock_anim_2.png
deleted file mode 100644
index 0542b1d..0000000
--- a/res/drawable-mdpi/lock_anim_2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_3.png b/res/drawable-mdpi/lock_anim_3.png
deleted file mode 100644
index 7e2ba9a..0000000
--- a/res/drawable-mdpi/lock_anim_3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_4.png b/res/drawable-mdpi/lock_anim_4.png
deleted file mode 100644
index a3ca629..0000000
--- a/res/drawable-mdpi/lock_anim_4.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_5.png b/res/drawable-mdpi/lock_anim_5.png
deleted file mode 100644
index 17e3839..0000000
--- a/res/drawable-mdpi/lock_anim_5.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_6.png b/res/drawable-mdpi/lock_anim_6.png
deleted file mode 100644
index 90205a6..0000000
--- a/res/drawable-mdpi/lock_anim_6.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_7.png b/res/drawable-mdpi/lock_anim_7.png
deleted file mode 100644
index 1d94a47..0000000
--- a/res/drawable-mdpi/lock_anim_7.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_8.png b/res/drawable-mdpi/lock_anim_8.png
deleted file mode 100644
index af7cd28..0000000
--- a/res/drawable-mdpi/lock_anim_8.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_9.png b/res/drawable-mdpi/lock_anim_9.png
deleted file mode 100644
index d401624..0000000
--- a/res/drawable-mdpi/lock_anim_9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_0.png b/res/drawable-xhdpi/lock_anim_0.png
deleted file mode 100644
index 5e8e6dc..0000000
--- a/res/drawable-xhdpi/lock_anim_0.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_1.png b/res/drawable-xhdpi/lock_anim_1.png
deleted file mode 100644
index 96fbd03..0000000
--- a/res/drawable-xhdpi/lock_anim_1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_10.png b/res/drawable-xhdpi/lock_anim_10.png
deleted file mode 100644
index e2e83b1..0000000
--- a/res/drawable-xhdpi/lock_anim_10.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_11.png b/res/drawable-xhdpi/lock_anim_11.png
deleted file mode 100644
index 68de396..0000000
--- a/res/drawable-xhdpi/lock_anim_11.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_12.png b/res/drawable-xhdpi/lock_anim_12.png
deleted file mode 100644
index 11e51c7..0000000
--- a/res/drawable-xhdpi/lock_anim_12.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_13.png b/res/drawable-xhdpi/lock_anim_13.png
deleted file mode 100644
index 86a6115..0000000
--- a/res/drawable-xhdpi/lock_anim_13.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_14.png b/res/drawable-xhdpi/lock_anim_14.png
deleted file mode 100644
index 5bff2fa..0000000
--- a/res/drawable-xhdpi/lock_anim_14.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_2.png b/res/drawable-xhdpi/lock_anim_2.png
deleted file mode 100644
index 68e59c8..0000000
--- a/res/drawable-xhdpi/lock_anim_2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_3.png b/res/drawable-xhdpi/lock_anim_3.png
deleted file mode 100644
index 16272ed..0000000
--- a/res/drawable-xhdpi/lock_anim_3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_4.png b/res/drawable-xhdpi/lock_anim_4.png
deleted file mode 100644
index af6fbc4..0000000
--- a/res/drawable-xhdpi/lock_anim_4.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_5.png b/res/drawable-xhdpi/lock_anim_5.png
deleted file mode 100644
index 1e631b5..0000000
--- a/res/drawable-xhdpi/lock_anim_5.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_6.png b/res/drawable-xhdpi/lock_anim_6.png
deleted file mode 100644
index 93fcf39..0000000
--- a/res/drawable-xhdpi/lock_anim_6.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_7.png b/res/drawable-xhdpi/lock_anim_7.png
deleted file mode 100644
index b5c5277..0000000
--- a/res/drawable-xhdpi/lock_anim_7.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_8.png b/res/drawable-xhdpi/lock_anim_8.png
deleted file mode 100644
index bcaec0d..0000000
--- a/res/drawable-xhdpi/lock_anim_8.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_9.png b/res/drawable-xhdpi/lock_anim_9.png
deleted file mode 100644
index c481d1a..0000000
--- a/res/drawable-xhdpi/lock_anim_9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/lock_anim.xml b/res/drawable/lock_anim.xml
deleted file mode 100644
index 8ec31a6..0000000
--- a/res/drawable/lock_anim.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 2008, 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.
-*/
--->
-<animation-list
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:oneshot="false">
- <item android:drawable="@drawable/lock_anim_0" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_1" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_2" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_3" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_4" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_5" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_6" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_7" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_8" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_9" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_10" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_11" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_12" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_13" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_14" android:duration="200" />
-</animation-list>
diff --git a/res/layout/preference_list_fragment.xml b/res/layout/preference_list_fragment.xml
index eeea9c4..852ef6d 100644
--- a/res/layout/preference_list_fragment.xml
+++ b/res/layout/preference_list_fragment.xml
@@ -37,19 +37,6 @@
android:paddingStart="@dimen/settings_side_margin"
android:paddingEnd="@dimen/settings_side_margin">
- <ListView android:id="@+id/backup_list"
- style="@style/PreferenceFragmentListSinglePane"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingTop="@dimen/dashboard_padding_top"
- android:paddingBottom="@dimen/dashboard_padding_bottom"
- android:scrollbarStyle="@*android:integer/preference_fragment_scrollbarStyle"
- android:clipToPadding="false"
- android:drawSelectorOnTop="false"
- android:elevation="@dimen/dashboard_category_elevation"
- android:visibility="gone"
- android:scrollbarAlwaysDrawVerticalTrack="true" />
-
<include layout="@layout/loading_container" />
</FrameLayout>
@@ -74,8 +61,7 @@
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_alignParentStart="true"
- android:text="@*android:string/back_button_label"
- />
+ android:text="@*android:string/back_button_label" />
<LinearLayout
android:orientation="horizontal"
@@ -89,16 +75,14 @@
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:text="@*android:string/skip_button_label"
- android:visibility="gone"
- />
+ android:visibility="gone" />
<Button android:id="@+id/next_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dip"
- android:text="@*android:string/next_button_label"
- />
+ android:text="@*android:string/next_button_label" />
</LinearLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 02d3182..2341728 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -97,9 +97,6 @@
<dimen name="dashboard_category_padding_start">0dp</dimen>
<dimen name="dashboard_category_padding_end">0dp</dimen>
- <!-- Dashboard category panel elevation -->
- <dimen name="dashboard_category_elevation">2dp</dimen>
-
<!-- Dashboard tile minimum height -->
<dimen name="dashboard_tile_minimum_height">72dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index aee9860..4453e2c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -588,9 +588,6 @@
<!-- Title for the locale picker activity -->
<string name="language_picker_title">Languages</string>
- <!-- Title for the language selection screen [CHAR LIMIT=25] -->
- <string name="pref_title_lang_selection">Language preferences</string>
-
<!-- Menu item in the locale menu. Will remove the selected locales. [CHAR LIMIT=30] -->
<string name="locale_remove_menu">Remove</string>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 2674d2f..b3de0ae 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -46,7 +46,7 @@
<item name="preferenceBackgroundColor">@drawable/preference_background</item>
<!-- For all androidx version of AlertDialogs -->
- <item name="alertDialogTheme">@style/Theme.AppCompat.Light.Dialog.Alert</item>
+ <item name="alertDialogTheme">@style/Theme.AppCompat.DayNight.Dialog.Alert</item>
<item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
diff --git a/src/com/android/settings/language/PhoneLanguagePreferenceController.java b/src/com/android/settings/language/PhoneLanguagePreferenceController.java
index 0f9b419..8045fc0 100644
--- a/src/com/android/settings/language/PhoneLanguagePreferenceController.java
+++ b/src/com/android/settings/language/PhoneLanguagePreferenceController.java
@@ -75,7 +75,7 @@
new SubSettingLauncher(mContext)
.setDestination(LocaleListEditor.class.getName())
.setSourceMetricsCategory(MetricsProto.MetricsEvent.SETTINGS_LANGUAGE_CATEGORY)
- .setTitleRes(R.string.pref_title_lang_selection)
+ .setTitleRes(R.string.language_picker_title)
.launch();
return true;
}
diff --git a/src/com/android/settings/print/PrintServiceSettingsFragment.java b/src/com/android/settings/print/PrintServiceSettingsFragment.java
index 4629360..1311be0 100644
--- a/src/com/android/settings/print/PrintServiceSettingsFragment.java
+++ b/src/com/android/settings/print/PrintServiceSettingsFragment.java
@@ -22,9 +22,6 @@
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
import android.content.pm.ResolveInfo;
-import android.database.DataSetObserver;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.print.PrintManager;
@@ -44,13 +41,10 @@
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
-import android.widget.AdapterView;
-import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ImageView;
import android.widget.LinearLayout;
-import android.widget.ListView;
import android.widget.SearchView;
import android.widget.Switch;
import android.widget.TextView;
@@ -67,8 +61,11 @@
import java.util.List;
import java.util.Map;
+import androidx.annotation.NonNull;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.Loader;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
/**
* Fragment with print service settings.
@@ -77,23 +74,18 @@
implements SwitchBar.OnSwitchChangeListener,
LoaderManager.LoaderCallbacks<List<PrintServiceInfo>> {
- private static final String LOG_TAG = "PrintServiceSettingsFragment";
+ private static final String LOG_TAG = "PrintServiceSettings";
private static final int LOADER_ID_PRINTERS_LOADER = 1;
private static final int LOADER_ID_PRINT_SERVICE_LOADER = 2;
- private final DataSetObserver mDataObserver = new DataSetObserver() {
+ private final AdapterDataObserver mDataObserver = new AdapterDataObserver() {
@Override
public void onChanged() {
invalidateOptionsMenuIfNeeded();
updateEmptyView();
}
- @Override
- public void onInvalidated() {
- invalidateOptionsMenuIfNeeded();
- }
-
private void invalidateOptionsMenuIfNeeded() {
final int unfilteredItemCount = mPrintersAdapter.getUnfilteredCount();
if ((mLastUnfilteredItemCount <= 0 && unfilteredItemCount > 0)
@@ -173,8 +165,6 @@
super.onViewCreated(view, savedInstanceState);
initComponents();
updateUiForArguments();
- getListView().setVisibility(View.GONE);
- getBackupListView().setVisibility(View.VISIBLE);
}
@Override
@@ -189,15 +179,11 @@
.setPrintServiceEnabled(mComponentName, enabled);
}
- private ListView getBackupListView() {
- return (ListView) getView().findViewById(R.id.backup_list);
- }
-
private void updateEmptyView() {
ViewGroup contentRoot = (ViewGroup) getListView().getParent();
- View emptyView = getBackupListView().getEmptyView();
+ View emptyView = getEmptyView();
if (!mToggleSwitch.isChecked()) {
- if (emptyView != null && emptyView.getId() != R.id.empty_print_state) {
+ if (emptyView != null) {
contentRoot.removeView(emptyView);
emptyView = null;
}
@@ -209,11 +195,10 @@
TextView textView = (TextView) emptyView.findViewById(R.id.message);
textView.setText(R.string.print_service_disabled);
contentRoot.addView(emptyView);
- getBackupListView().setEmptyView(emptyView);
+ setEmptyView(emptyView);
}
} else if (mPrintersAdapter.getUnfilteredCount() <= 0) {
- if (emptyView != null
- && emptyView.getId() != R.id.empty_printers_list_service_enabled) {
+ if (emptyView != null) {
contentRoot.removeView(emptyView);
emptyView = null;
}
@@ -221,10 +206,10 @@
emptyView = getActivity().getLayoutInflater().inflate(
R.layout.empty_printers_list_service_enabled, contentRoot, false);
contentRoot.addView(emptyView);
- getBackupListView().setEmptyView(emptyView);
+ setEmptyView(emptyView);
}
- } else if (mPrintersAdapter.getCount() <= 0) {
- if (emptyView != null && emptyView.getId() != R.id.empty_print_state) {
+ } else if (mPrintersAdapter.getItemCount() <= 0) {
+ if (emptyView != null) {
contentRoot.removeView(emptyView);
emptyView = null;
}
@@ -236,7 +221,11 @@
TextView textView = (TextView) emptyView.findViewById(R.id.message);
textView.setText(R.string.print_no_printers_found);
contentRoot.addView(emptyView);
- getBackupListView().setEmptyView(emptyView);
+ setEmptyView(emptyView);
+ }
+ } else if (mPrintersAdapter.getItemCount() > 0) {
+ if (emptyView != null) {
+ contentRoot.removeView(emptyView);
}
}
}
@@ -254,7 +243,7 @@
private void initComponents() {
mPrintersAdapter = new PrintersAdapter();
- mPrintersAdapter.registerDataSetObserver(mDataObserver);
+ mPrintersAdapter.registerAdapterDataObserver(mDataObserver);
final SettingsActivity activity = (SettingsActivity) getActivity();
@@ -263,31 +252,12 @@
mSwitchBar.show();
mToggleSwitch = mSwitchBar.getSwitch();
- mToggleSwitch.setOnBeforeCheckedChangeListener(new ToggleSwitch.OnBeforeCheckedChangeListener() {
- @Override
- public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
- onPreferenceToggled(mPreferenceKey, checked);
- return false;
- }
+ mToggleSwitch.setOnBeforeCheckedChangeListener((toggleSwitch, checked) -> {
+ onPreferenceToggled(mPreferenceKey, checked);
+ return false;
});
- getBackupListView().setSelector(new ColorDrawable(Color.TRANSPARENT));
- getBackupListView().setAdapter(mPrintersAdapter);
- getBackupListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- PrinterInfo printer = (PrinterInfo) mPrintersAdapter.getItem(position);
-
- if (printer.getInfoIntent() != null) {
- try {
- getActivity().startIntentSender(printer.getInfoIntent().getIntentSender(),
- null, 0, 0, 0);
- } catch (SendIntentException e) {
- Log.e(LOG_TAG, "Could not execute info intent: %s", e);
- }
- }
- }
- });
+ getListView().setAdapter(mPrintersAdapter);
}
@@ -446,8 +416,17 @@
}
}
- private final class PrintersAdapter extends BaseAdapter
+ public static class ViewHolder extends RecyclerView.ViewHolder {
+
+ public ViewHolder(@NonNull View itemView) {
+ super(itemView);
+ }
+ }
+
+
+ private final class PrintersAdapter extends RecyclerView.Adapter<ViewHolder>
implements LoaderManager.LoaderCallbacks<List<PrinterInfo>>, Filterable {
+
private final Object mLock = new Object();
private final List<PrinterInfo> mPrinters = new ArrayList<PrinterInfo>();
@@ -509,19 +488,19 @@
}
}
notifyDataSetChanged();
+
}
};
}
@Override
- public int getCount() {
+ public int getItemCount() {
synchronized (mLock) {
return mFilteredPrinters.size();
}
}
- @Override
- public Object getItem(int position) {
+ private Object getItem(int position) {
synchronized (mLock) {
return mFilteredPrinters.get(position);
}
@@ -543,24 +522,27 @@
return printer.getStatus() != PrinterInfo.STATUS_UNAVAILABLE;
}
+ @NonNull
@Override
- public View getView(int position, View convertView, ViewGroup parent) {
- if (convertView == null) {
- convertView = getActivity().getLayoutInflater().inflate(
- R.layout.printer_dropdown_item, parent, false);
- }
+ public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ final View view = LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.printer_dropdown_item, parent, false);
+ return new ViewHolder(view);
+ }
- convertView.setEnabled(isActionable(position));
+ @Override
+ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
+ holder.itemView.setEnabled(isActionable(position));
final PrinterInfo printer = (PrinterInfo) getItem(position);
CharSequence title = printer.getName();
CharSequence subtitle = printer.getDescription();
Drawable icon = printer.loadIcon(getActivity());
- TextView titleView = (TextView) convertView.findViewById(R.id.title);
+ TextView titleView = holder.itemView.findViewById(R.id.title);
titleView.setText(title);
- TextView subtitleView = (TextView) convertView.findViewById(R.id.subtitle);
+ TextView subtitleView = holder.itemView.findViewById(R.id.subtitle);
if (!TextUtils.isEmpty(subtitle)) {
subtitleView.setText(subtitle);
subtitleView.setVisibility(View.VISIBLE);
@@ -569,7 +551,7 @@
subtitleView.setVisibility(View.GONE);
}
- LinearLayout moreInfoView = (LinearLayout) convertView.findViewById(R.id.more_info);
+ LinearLayout moreInfoView = holder.itemView.findViewById(R.id.more_info);
if (printer.getInfoIntent() != null) {
moreInfoView.setVisibility(View.VISIBLE);
moreInfoView.setOnClickListener(new OnClickListener() {
@@ -587,7 +569,7 @@
moreInfoView.setVisibility(View.GONE);
}
- ImageView iconView = (ImageView) convertView.findViewById(R.id.icon);
+ ImageView iconView = holder.itemView.findViewById(R.id.icon);
if (icon != null) {
iconView.setVisibility(View.VISIBLE);
if (!isActionable(position)) {
@@ -603,7 +585,18 @@
iconView.setVisibility(View.GONE);
}
- return convertView;
+ holder.itemView.setOnClickListener(v -> {
+ PrinterInfo pi = (PrinterInfo) getItem(position);
+
+ if (pi.getInfoIntent() != null) {
+ try {
+ getActivity().startIntentSender(pi.getInfoIntent().getIntentSender(),
+ null, 0, 0, 0);
+ } catch (SendIntentException e) {
+ Log.e(LOG_TAG, "Could not execute info intent: %s", e);
+ }
+ }
+ });
}
@Override
@@ -642,7 +635,7 @@
mFilteredPrinters.clear();
mLastSearchString = null;
}
- notifyDataSetInvalidated();
+ notifyDataSetChanged();
}
}