Before Width: | Height: | Size: 942 B |
After Width: | Height: | Size: 191 B |
Before Width: | Height: | Size: 154 B After Width: | Height: | Size: 154 B |
Before Width: | Height: | Size: 159 B After Width: | Height: | Size: 159 B |
Before Width: | Height: | Size: 159 B After Width: | Height: | Size: 159 B |
Before Width: | Height: | Size: 189 B After Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 189 B After Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 942 B |
Before Width: | Height: | Size: 578 B |
After Width: | Height: | Size: 171 B |
Before Width: | Height: | Size: 151 B After Width: | Height: | Size: 151 B |
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 158 B |
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 158 B |
Before Width: | Height: | Size: 172 B After Width: | Height: | Size: 172 B |
Before Width: | Height: | Size: 171 B After Width: | Height: | Size: 171 B |
Before Width: | Height: | Size: 632 B After Width: | Height: | Size: 578 B |
Before Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 203 B |
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 158 B |
Before Width: | Height: | Size: 163 B After Width: | Height: | Size: 163 B |
Before Width: | Height: | Size: 163 B After Width: | Height: | Size: 163 B |
Before Width: | Height: | Size: 190 B After Width: | Height: | Size: 190 B |
Before Width: | Height: | Size: 188 B After Width: | Height: | Size: 188 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.2 KiB |
@ -1,23 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<!-- |
|
||||||
Copyright 2010-2013 Eric Kok et al. |
|
||||||
|
|
||||||
Transdroid is free software: you can redistribute it and/or modify |
|
||||||
it under the terms of the GNU General Public License as published by |
|
||||||
the Free Software Foundation, either version 3 of the License, or |
|
||||||
(at your option) any later version. |
|
||||||
|
|
||||||
Transdroid is distributed in the hope that it will be useful, |
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
GNU General Public License for more details. |
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License |
|
||||||
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. |
|
||||||
--> |
|
||||||
<resources> |
|
||||||
|
|
||||||
<!-- Used to enable the scrolling widget on Honeycomb (API 11) and higher only --> |
|
||||||
<bool name="widget_available">true</bool> |
|
||||||
|
|
||||||
</resources> |
|
@ -1,67 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<!-- File created by the Android Action Bar Style Generator |
|
||||||
|
|
||||||
Copyright (C) 2012 readyState Software Ltd |
|
||||||
|
|
||||||
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. |
|
||||||
--> |
|
||||||
|
|
||||||
<resources> |
|
||||||
|
|
||||||
<style name="Theme.Transdroid.Dark" parent="@style/Theme.Sherlock"> |
|
||||||
<item name="actionBarItemBackground">@drawable/selectable_background_transdroid</item> |
|
||||||
<item name="popupMenuStyle">@style/PopupMenu.Transdroid.Dark</item> |
|
||||||
<item name="dropDownListViewStyle">@style/DropDownListView.Transdroid.Dark</item> |
|
||||||
<item name="actionBarTabStyle">@style/ActionBarTabStyle.Transdroid.Dark</item> |
|
||||||
<item name="actionDropDownStyle">@style/DropDownNav.Transdroid.Dark</item> |
|
||||||
<item name="actionBarStyle">@style/ActionBar.Solid.Transdroid.Dark</item> |
|
||||||
|
|
||||||
<item name="android:popupMenuStyle">@style/PopupMenu.Transdroid.Dark</item> |
|
||||||
<item name="android:dropDownListViewStyle">@style/DropDownListView.Transdroid.Dark</item> |
|
||||||
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Transdroid.Dark</item> |
|
||||||
<item name="android:actionDropDownStyle">@style/ActionBarTabStyle.Transdroid.Dark</item> |
|
||||||
<item name="android:actionBarStyle">@style/ActionBar.Solid.Transdroid.Dark</item> |
|
||||||
<item name="android:panelBackground">@drawable/menu_hardkey_panel_transdroid</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
<style name="ActionBar.Solid.Transdroid.Dark" parent="@style/Widget.Sherlock.ActionBar.Solid"> |
|
||||||
<item name="background">@drawable/ab_solid_transdroid</item> |
|
||||||
<item name="backgroundStacked">@drawable/ab_stacked_solid_transdroid</item> |
|
||||||
<item name="backgroundSplit">@drawable/ab_bottom_solid_transdroid</item> |
|
||||||
|
|
||||||
<item name="android:background">@drawable/ab_solid_transdroid</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
<style name="PopupMenu.Transdroid.Dark" parent="@style/Widget.Sherlock.ListPopupWindow"> |
|
||||||
<item name="android:popupBackground">@drawable/menu_dropdown_panel_transdroid</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
<style name="DropDownListView.Transdroid.Dark" parent="@style/Widget.Sherlock.ListView.DropDown"> |
|
||||||
<item name="android:listSelector">@drawable/selectable_background_transdroid</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
<style name="ActionBarTabStyle.Transdroid.Dark" parent="@style/Widget.Sherlock.ActionBar.TabView"> |
|
||||||
<item name="background">@drawable/tab_indicator_ab_transdroid</item> |
|
||||||
|
|
||||||
<item name="android:background">@drawable/tab_indicator_ab_transdroid</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
<style name="DropDownNav.Transdroid.Dark" parent="@style/Widget.Sherlock.Spinner.DropDown.ActionBar"> |
|
||||||
<item name="background">@drawable/spinner_background_ab_transdroid</item> |
|
||||||
|
|
||||||
<item name="android:background">@drawable/spinner_background_ab_transdroid</item> |
|
||||||
<item name="android:popupBackground">@drawable/menu_dropdown_panel_transdroid</item> |
|
||||||
<item name="android:dropDownSelector">@drawable/selectable_background_transdroid</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
</resources> |
|
@ -1,42 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<!-- File created by the Android Action Bar Style Generator |
|
||||||
|
|
||||||
Copyright (C) 2011 The Android Open Source Project |
|
||||||
Copyright (C) 2012 readyState Software Ltd |
|
||||||
|
|
||||||
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. |
|
||||||
--> |
|
||||||
|
|
||||||
<resources xmlns:android="http://schemas.android.com/apk/res/android"> |
|
||||||
|
|
||||||
<style name="Theme.Transdroid.Light" parent="@style/Theme.Sherlock.Light"> |
|
||||||
<item name="android:popupMenuStyle">@style/PopupMenu.Transdroid2</item> |
|
||||||
<item name="android:dropDownListViewStyle">@style/DropDownListView.Transdroid.Light</item> |
|
||||||
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Transdroid.Light</item> |
|
||||||
<item name="android:actionDropDownStyle">@style/DropDownNav.Transdroid.Light</item> |
|
||||||
<item name="android:actionBarStyle">@style/ActionBar.Solid.Transdroid.Light</item> |
|
||||||
<item name="android:actionModeBackground">@drawable/cab_background_top_transdroid2</item> |
|
||||||
<item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Transdroid.Light</item> |
|
||||||
|
|
||||||
|
|
||||||
</style> |
|
||||||
|
|
||||||
<style name="ActionBar.Solid.Transdroid.Light" parent="@style/Widget.Sherlock.Light.ActionBar.Solid"> |
|
||||||
<item name="android:background">@drawable/ab_solid_transdroid2</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
<style name="ActionBar.Transparent.Transdroid.Light" parent="@style/Widget.Sherlock.Light.ActionBar"> |
|
||||||
<item name="android:background">@drawable/ab_transparent_transdroid2</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
</resources> |
|
@ -1,21 +0,0 @@ |
|||||||
<!-- |
|
||||||
Copyright 2010-2013 Eric Kok et al. |
|
||||||
|
|
||||||
Transdroid is free software: you can redistribute it and/or modify |
|
||||||
it under the terms of the GNU General Public License as published by |
|
||||||
the Free Software Foundation, either version 3 of the License, or |
|
||||||
(at your option) any later version. |
|
||||||
|
|
||||||
Transdroid is distributed in the hope that it will be useful, |
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
GNU General Public License for more details. |
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License |
|
||||||
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. |
|
||||||
--> |
|
||||||
<resources> |
|
||||||
|
|
||||||
<dimen name="margin_widget">0dp</dimen> |
|
||||||
|
|
||||||
</resources> |
|
@ -1,70 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<!-- File created by the Android Action Bar Style Generator |
|
||||||
|
|
||||||
Copyright (C) 2012 readyState Software Ltd |
|
||||||
|
|
||||||
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. |
|
||||||
--> |
|
||||||
|
|
||||||
<resources> |
|
||||||
|
|
||||||
<style name="Theme.Transdroid.Dark" parent="@style/Theme.Sherlock"> |
|
||||||
<item name="actionBarItemBackground">@drawable/selectable_background_transdroid</item> |
|
||||||
<item name="popupMenuStyle">@style/PopupMenu.Transdroid.Dark</item> |
|
||||||
<item name="dropDownListViewStyle">@style/DropDownListView.Transdroid.Dark</item> |
|
||||||
<item name="actionBarTabStyle">@style/ActionBarTabStyle.Transdroid.Dark</item> |
|
||||||
<item name="actionDropDownStyle">@style/DropDownNav.Transdroid.Dark</item> |
|
||||||
<item name="actionBarStyle">@style/ActionBar.Solid.Transdroid.Dark</item> |
|
||||||
|
|
||||||
<item name="android:actionBarItemBackground">@drawable/selectable_background_transdroid</item> |
|
||||||
<item name="android:popupMenuStyle">@style/PopupMenu.Transdroid.Dark</item> |
|
||||||
<item name="android:dropDownListViewStyle">@style/DropDownListView.Transdroid.Dark</item> |
|
||||||
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Transdroid.Dark</item> |
|
||||||
<item name="android:actionDropDownStyle">@style/DropDownNav.Transdroid.Dark</item> |
|
||||||
<item name="android:actionBarStyle">@style/ActionBar.Solid.Transdroid.Dark</item> |
|
||||||
<item name="android:panelBackground">@drawable/menu_hardkey_panel_transdroid</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
<style name="ActionBar.Solid.Transdroid.Dark" parent="@style/Widget.Sherlock.ActionBar.Solid"> |
|
||||||
<item name="background">@drawable/ab_solid_transdroid</item> |
|
||||||
<item name="backgroundStacked">@drawable/ab_stacked_solid_transdroid</item> |
|
||||||
<item name="backgroundSplit">@drawable/ab_bottom_solid_transdroid</item> |
|
||||||
|
|
||||||
<item name="android:background">@drawable/ab_solid_transdroid</item> |
|
||||||
<item name="android:backgroundStacked">@drawable/ab_stacked_solid_transdroid</item> |
|
||||||
<item name="android:backgroundSplit">@drawable/ab_bottom_solid_transdroid</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
<style name="PopupMenu.Transdroid.Dark" parent="@style/Widget.Sherlock.ListPopupWindow"> |
|
||||||
<item name="android:popupBackground">@drawable/menu_dropdown_panel_transdroid</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
<style name="DropDownListView.Transdroid.Dark" parent="@style/Widget.Sherlock.ListView.DropDown"> |
|
||||||
<item name="android:listSelector">@drawable/selectable_background_transdroid</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
<style name="ActionBarTabStyle.Transdroid.Dark" parent="@style/Widget.Sherlock.ActionBar.TabView"> |
|
||||||
<item name="background">@drawable/tab_indicator_ab_transdroid</item> |
|
||||||
|
|
||||||
<item name="android:background">@drawable/tab_indicator_ab_transdroid</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
<style name="DropDownNav.Transdroid.Dark" parent="@style/Widget.Sherlock.Spinner.DropDown.ActionBar"> |
|
||||||
<item name="background">@drawable/spinner_background_ab_transdroid</item> |
|
||||||
|
|
||||||
<item name="android:background">@drawable/spinner_background_ab_transdroid</item> |
|
||||||
<item name="android:popupBackground">@drawable/menu_dropdown_panel_transdroid</item> |
|
||||||
<item name="android:dropDownSelector">@drawable/selectable_background_transdroid</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
</resources> |
|
@ -1,44 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<!-- File created by the Android Action Bar Style Generator |
|
||||||
|
|
||||||
Copyright (C) 2011 The Android Open Source Project |
|
||||||
Copyright (C) 2012 readyState Software Ltd |
|
||||||
|
|
||||||
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. |
|
||||||
--> |
|
||||||
|
|
||||||
<resources xmlns:android="http://schemas.android.com/apk/res/android"> |
|
||||||
|
|
||||||
<style name="Theme.Transdroid.Light" parent="@style/Theme.Sherlock.Light"> |
|
||||||
<item name="android:actionBarItemBackground">@drawable/selectable_background_transdroid2</item> |
|
||||||
<item name="android:popupMenuStyle">@style/PopupMenu.Transdroid.Light</item> |
|
||||||
<item name="android:dropDownListViewStyle">@style/DropDownListView.Transdroid.Light</item> |
|
||||||
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Transdroid.Light</item> |
|
||||||
<item name="android:actionDropDownStyle">@style/DropDownNav.Transdroid.Light</item> |
|
||||||
<item name="android:actionBarStyle">@style/ActionBar.Solid.Transdroid.Light</item> |
|
||||||
<item name="android:actionModeBackground">@drawable/cab_background_top_transdroid2</item> |
|
||||||
<item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_transdroid2</item> |
|
||||||
<item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Transdroid.Light</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
<style name="ActionBar.Solid.Transdroid.Light" parent="@style/Widget.Sherlock.Light.ActionBar.Solid"> |
|
||||||
<item name="android:background">@drawable/ab_solid_transdroid2</item> |
|
||||||
<item name="android:backgroundStacked">@drawable/ab_stacked_solid_transdroid2</item> |
|
||||||
<item name="android:backgroundSplit">@drawable/ab_bottom_solid_transdroid2</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
<style name="ActionBar.Transparent.Transdroid.Light" parent="@style/Widget.Sherlock.Light.ActionBar"> |
|
||||||
<item name="android:background">@drawable/ab_transparent_transdroid2</item> |
|
||||||
</style> |
|
||||||
|
|
||||||
</resources> |
|
@ -1,346 +0,0 @@ |
|||||||
/* |
|
||||||
* Public Domain |
|
||||||
* SherlockListView.java by tweakt |
|
||||||
* https://snipt.net/tweakt/sherlocklistviewjava/
|
|
||||||
*/ |
|
||||||
package com.actionbarsherlock.view; |
|
||||||
|
|
||||||
import android.annotation.TargetApi; |
|
||||||
import android.content.Context; |
|
||||||
import android.util.AttributeSet; |
|
||||||
import android.util.SparseBooleanArray; |
|
||||||
import android.view.View; |
|
||||||
import android.widget.AdapterView; |
|
||||||
import android.widget.Checkable; |
|
||||||
import android.widget.ListView; |
|
||||||
|
|
||||||
import com.actionbarsherlock.app.SherlockActivity; |
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity; |
|
||||||
import com.actionbarsherlock.view.ActionMode; |
|
||||||
import com.actionbarsherlock.view.Menu; |
|
||||||
import com.actionbarsherlock.view.MenuItem; |
|
||||||
|
|
||||||
/** |
|
||||||
* Provides backwards compatible multiple choice ActionMode support on Froyo+ using ActionBarSherlock. |
|
||||||
*/ |
|
||||||
public class SherlockListView extends ListView { |
|
||||||
// API 11+ reference, but ok because the value will be inlined.
|
|
||||||
public static final int CHOICE_MODE_MULTIPLE_MODAL_COMPAT = CHOICE_MODE_MULTIPLE_MODAL; |
|
||||||
|
|
||||||
/** |
|
||||||
* Wrapper to intercept delegation of long click events, and pass to {@link #doLongPress} |
|
||||||
*/ |
|
||||||
class OnItemLongClickListenerWrapper implements OnItemLongClickListener { |
|
||||||
private OnItemLongClickListener wrapped; |
|
||||||
|
|
||||||
public void setWrapped(OnItemLongClickListener listener) { |
|
||||||
this.wrapped = listener; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public boolean onItemLongClick(AdapterView<?> view, View child, int position, long id) { |
|
||||||
// this would be easier if AbsListView.performLongPress wasn't package
|
|
||||||
// protected :-(
|
|
||||||
boolean handled = doLongPress(child, position, id); |
|
||||||
if (!handled && wrapped != null) { |
|
||||||
return wrapped.onItemLongClick(view, child, position, id); |
|
||||||
} |
|
||||||
return true; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Hijack the onLongClickListener so we can intercept delegation. |
|
||||||
*/ |
|
||||||
@Override |
|
||||||
public void setOnItemLongClickListener(OnItemLongClickListener listener) { |
|
||||||
if (longClickListenerWrapper == null) { |
|
||||||
longClickListenerWrapper = new OnItemLongClickListenerWrapper(); |
|
||||||
} |
|
||||||
longClickListenerWrapper.setWrapped(listener); |
|
||||||
super.setOnItemLongClickListener(longClickListenerWrapper); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* A MultiChoiceModeListener receives events for {@link AbsListView#CHOICE_MODE_MULTIPLE_MODAL}. It acts as the |
|
||||||
* {@link ActionMode.Callback} for the selection mode and also receives |
|
||||||
* {@link #onItemCheckedStateChanged(ActionMode, int, long, boolean)} events when the user selects and deselects |
|
||||||
* list items. |
|
||||||
*/ |
|
||||||
@SuppressWarnings("javadoc") |
|
||||||
public interface MultiChoiceModeListenerCompat extends ActionMode.Callback { |
|
||||||
/** |
|
||||||
* Called when an item is checked or unchecked during selection mode. |
|
||||||
* @param mode The {@link ActionMode} providing the selection mode |
|
||||||
* @param position Adapter position of the item that was checked or unchecked |
|
||||||
* @param id Adapter ID of the item that was checked or unchecked |
|
||||||
* @param checked <code>true</code> if the item is now checked, <code>false</code> if the item is now unchecked. |
|
||||||
*/ |
|
||||||
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked); |
|
||||||
} |
|
||||||
|
|
||||||
class MultiChoiceModeWrapper implements MultiChoiceModeListenerCompat { |
|
||||||
private MultiChoiceModeListenerCompat wrapped; |
|
||||||
|
|
||||||
public void setWrapped(MultiChoiceModeListenerCompat wrapped) { |
|
||||||
this.wrapped = wrapped; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) { |
|
||||||
if (wrapped == null) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
if (wrapped.onCreateActionMode(mode, menu)) { |
|
||||||
// Initialize checked graphic state?
|
|
||||||
setLongClickable(false); |
|
||||||
return true; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public boolean onPrepareActionMode(ActionMode mode, Menu menu) { |
|
||||||
if (wrapped == null) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
return wrapped.onPrepareActionMode(mode, menu); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) { |
|
||||||
if (wrapped == null) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
return wrapped.onActionItemClicked(mode, item); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void onDestroyActionMode(ActionMode mode) { |
|
||||||
if (wrapped == null) { |
|
||||||
return; |
|
||||||
} |
|
||||||
wrapped.onDestroyActionMode(mode); |
|
||||||
actionMode = null; |
|
||||||
|
|
||||||
// Ending selection mode means deselecting everything.
|
|
||||||
clearChoices(); |
|
||||||
checkedItemCount = 0; |
|
||||||
updateOnScreenCheckedViews(); |
|
||||||
invalidateViews(); |
|
||||||
setLongClickable(true); |
|
||||||
requestLayout(); |
|
||||||
invalidate(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { |
|
||||||
if (wrapped == null) { |
|
||||||
return; |
|
||||||
} |
|
||||||
wrapped.onItemCheckedStateChanged(mode, position, id, checked); |
|
||||||
|
|
||||||
// If there are no items selected we no longer need the selection mode.
|
|
||||||
if (checkedItemCount == 0) { |
|
||||||
mode.finish(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private com.actionbarsherlock.view.ActionMode actionMode; |
|
||||||
private OnItemLongClickListenerWrapper longClickListenerWrapper; |
|
||||||
private MultiChoiceModeWrapper choiceModeListener; |
|
||||||
private int choiceMode; |
|
||||||
private int checkedItemCount; |
|
||||||
|
|
||||||
public SherlockListView(Context context) { |
|
||||||
super(context); |
|
||||||
init(context); |
|
||||||
} |
|
||||||
|
|
||||||
public SherlockListView(Context context, AttributeSet attrs) { |
|
||||||
super(context, attrs); |
|
||||||
init(context); |
|
||||||
} |
|
||||||
|
|
||||||
public SherlockListView(Context context, AttributeSet attrs, int defStyle) { |
|
||||||
super(context, attrs, defStyle); |
|
||||||
init(context); |
|
||||||
} |
|
||||||
|
|
||||||
void init(Context context) { |
|
||||||
if (isInEditMode()) { |
|
||||||
// Ignore when viewing in the UI designer
|
|
||||||
return; |
|
||||||
} |
|
||||||
if (!(context instanceof SherlockActivity || context instanceof SherlockFragmentActivity)) { |
|
||||||
throw new IllegalStateException( |
|
||||||
"This view must be hosted in a SherlockActivity or SherlockFragmentActivity"); |
|
||||||
} |
|
||||||
setOnItemLongClickListener(null); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setChoiceMode(int mode) { |
|
||||||
choiceMode = mode; |
|
||||||
if (actionMode != null) { |
|
||||||
actionMode.finish(); |
|
||||||
actionMode = null; |
|
||||||
} |
|
||||||
if (choiceMode != CHOICE_MODE_NONE) { |
|
||||||
if (mode == CHOICE_MODE_MULTIPLE_MODAL_COMPAT) { |
|
||||||
clearChoices(); |
|
||||||
checkedItemCount = 0; |
|
||||||
setLongClickable(true); |
|
||||||
updateOnScreenCheckedViews(); |
|
||||||
requestLayout(); |
|
||||||
invalidate(); |
|
||||||
mode = CHOICE_MODE_MULTIPLE; |
|
||||||
} |
|
||||||
super.setChoiceMode(mode); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public int getChoiceMode() { |
|
||||||
return choiceMode; |
|
||||||
} |
|
||||||
|
|
||||||
public void setMultiChoiceModeListener(MultiChoiceModeListenerCompat listener) { |
|
||||||
if (choiceModeListener == null) { |
|
||||||
choiceModeListener = new MultiChoiceModeWrapper(); |
|
||||||
} |
|
||||||
choiceModeListener.setWrapped(listener); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public boolean performItemClick(View view, int position, long id) { |
|
||||||
boolean handled = false; |
|
||||||
boolean dispatchItemClick = true; |
|
||||||
boolean checkStateChanged = false; |
|
||||||
if (choiceMode != CHOICE_MODE_NONE) { |
|
||||||
handled = true; |
|
||||||
if (choiceMode == CHOICE_MODE_MULTIPLE |
|
||||||
|| (choiceMode == CHOICE_MODE_MULTIPLE_MODAL_COMPAT && actionMode != null)) { |
|
||||||
boolean newValue = !getCheckedItemPositions().get(position); |
|
||||||
setItemChecked(position, newValue); |
|
||||||
if (actionMode != null) { |
|
||||||
choiceModeListener.onItemCheckedStateChanged(actionMode, position, id, newValue); |
|
||||||
dispatchItemClick = false; |
|
||||||
} |
|
||||||
checkStateChanged = true; |
|
||||||
return false; |
|
||||||
} else if (choiceMode == CHOICE_MODE_SINGLE) { |
|
||||||
boolean newValue = !getCheckedItemPositions().get(position); |
|
||||||
setItemChecked(position, newValue); |
|
||||||
checkStateChanged = true; |
|
||||||
} |
|
||||||
if (checkStateChanged) { |
|
||||||
updateOnScreenCheckedViews(); |
|
||||||
} |
|
||||||
} |
|
||||||
if (dispatchItemClick) { |
|
||||||
handled |= super.performItemClick(view, position, id); |
|
||||||
} |
|
||||||
return handled; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Perform a quick, in-place update of the checked or activated state on all visible item views. This should only be |
|
||||||
* called when a valid choice mode is active. |
|
||||||
* <p> |
|
||||||
* (Taken verbatim from AbsListView.java) |
|
||||||
*/ |
|
||||||
@TargetApi(11) |
|
||||||
private void updateOnScreenCheckedViews() { |
|
||||||
final int firstPos = getFirstVisiblePosition(); |
|
||||||
final int count = getChildCount(); |
|
||||||
final boolean useActivated = getContext().getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.HONEYCOMB; |
|
||||||
for (int i = 0; i < count; i++) { |
|
||||||
final View child = getChildAt(i); |
|
||||||
final int position = firstPos + i; |
|
||||||
|
|
||||||
if (child instanceof Checkable) { |
|
||||||
((Checkable) child).setChecked(getCheckedItemPositions().get(position)); |
|
||||||
} else if (useActivated) { |
|
||||||
// TODO: Investigate the impact of this hack fix
|
|
||||||
// (API level < 11 devices still get to this code point when clicking teh CAB done button)
|
|
||||||
if (android.os.Build.VERSION.SDK_INT > 11) { |
|
||||||
child.setActivated(getCheckedItemPositions().get(position)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public ActionMode startActionMode(ActionMode.Callback callback) { |
|
||||||
if (actionMode != null) { |
|
||||||
return actionMode; |
|
||||||
} |
|
||||||
Context context = getContext(); |
|
||||||
if (context instanceof SherlockActivity) { |
|
||||||
actionMode = ((SherlockActivity) getContext()).startActionMode(callback); |
|
||||||
} else if (context instanceof SherlockFragmentActivity) { |
|
||||||
actionMode = ((SherlockFragmentActivity) context).startActionMode(callback); |
|
||||||
} else { |
|
||||||
throw new IllegalStateException( |
|
||||||
"This view must be hosted in a SherlockActivity or SherlockFragmentActivity"); |
|
||||||
} |
|
||||||
return actionMode; |
|
||||||
} |
|
||||||
|
|
||||||
boolean doLongPress(final View child, final int longPressPosition, final long longPressId) { |
|
||||||
if (choiceMode == CHOICE_MODE_MULTIPLE_MODAL_COMPAT) { |
|
||||||
if (actionMode == null && (actionMode = startActionMode(choiceModeListener)) != null) { |
|
||||||
setItemChecked(longPressPosition, true); |
|
||||||
} |
|
||||||
return true; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets the checked state of the specified position. The is only valid if the choice mode has been set to |
|
||||||
* {@link #CHOICE_MODE_SINGLE} or {@link #CHOICE_MODE_MULTIPLE}. |
|
||||||
* @param position The item whose checked state is to be checked |
|
||||||
* @param value The new checked state for the item |
|
||||||
*/ |
|
||||||
@Override |
|
||||||
public void setItemChecked(int position, boolean value) { |
|
||||||
if (choiceMode == CHOICE_MODE_NONE) { |
|
||||||
return; |
|
||||||
} |
|
||||||
SparseBooleanArray checkStates = getCheckedItemPositions(); |
|
||||||
|
|
||||||
// Start selection mode if needed. We don't need to if we're unchecking
|
|
||||||
// something.
|
|
||||||
if (value && choiceMode == CHOICE_MODE_MULTIPLE_MODAL_COMPAT && actionMode == null) { |
|
||||||
actionMode = startActionMode(choiceModeListener); |
|
||||||
} |
|
||||||
|
|
||||||
if (choiceMode == CHOICE_MODE_MULTIPLE || choiceMode == CHOICE_MODE_MULTIPLE_MODAL) { |
|
||||||
// boolean oldValue = checkStates.get(position);
|
|
||||||
checkStates.put(position, value); |
|
||||||
if (value) { |
|
||||||
checkedItemCount++; |
|
||||||
} else { |
|
||||||
checkedItemCount--; |
|
||||||
} |
|
||||||
if (actionMode != null) { |
|
||||||
final long id = getAdapter().getItemId(position); |
|
||||||
choiceModeListener.onItemCheckedStateChanged(actionMode, position, id, value); |
|
||||||
} |
|
||||||
} else { |
|
||||||
if (value || isItemChecked(position)) { |
|
||||||
checkStates.clear(); |
|
||||||
} |
|
||||||
// this may end up selecting the value we just cleared but this way
|
|
||||||
// we ensure length of checkStates is 1, a fact getCheckedItemPosition
|
|
||||||
// relies on
|
|
||||||
if (value) { |
|
||||||
checkStates.put(position, true); |
|
||||||
} |
|
||||||
} |
|
||||||
requestLayout(); |
|
||||||
invalidate(); |
|
||||||
} |
|
||||||
} |
|