Squashed merge of the material-polish branch
This commit is contained in:
parent
34e775254a
commit
4671261f1c
@ -124,17 +124,6 @@ The above copyright notice and this permission notice shall be included in all c
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
</pre>
|
||||
<h3>ViewPageIndicator [<a href='javascript:show("l3")'>show</a>]</h3>
|
||||
<pre id='l3'>
|
||||
Copyright (C) 2011 The Android Open Source Project
|
||||
Copyright (C) 2011 Jake Wharton
|
||||
|
||||
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.
|
||||
</pre>
|
||||
<h3>DragSortListView [<a href='javascript:show("l4")'>show</a>]</h3>
|
||||
<pre id='l4'>
|
||||
A subclass of the Android ListView component that enables drag
|
||||
|
BIN
res/drawable/tab_focus.9.png
Normal file
BIN
res/drawable/tab_focus.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 190 B |
@ -4,9 +4,9 @@
|
||||
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.
|
||||
@ -16,19 +16,13 @@
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Non focused states -->
|
||||
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/vpi__tab_unselected_holo" />
|
||||
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/vpi__tab_selected_holo" />
|
||||
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected" />
|
||||
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected" />
|
||||
|
||||
<!-- Focused states -->
|
||||
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/vpi__tab_unselected_focused_holo" />
|
||||
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/vpi__tab_selected_focused_holo" />
|
||||
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_focus" />
|
||||
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_focus" />
|
||||
|
||||
<!-- Pressed -->
|
||||
<!-- Non focused states -->
|
||||
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/vpi__tab_unselected_pressed_holo" />
|
||||
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/vpi__tab_selected_pressed_holo" />
|
||||
|
||||
<!-- Focused states -->
|
||||
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/vpi__tab_unselected_pressed_holo" />
|
||||
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/vpi__tab_selected_pressed_holo" />
|
||||
<item android:state_pressed="true" android:drawable="@drawable/tab_focus" />
|
||||
</selector>
|
BIN
res/drawable/tab_selected.9.png
Normal file
BIN
res/drawable/tab_selected.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 186 B |
BIN
res/drawable/tab_unselected.9.png
Normal file
BIN
res/drawable/tab_unselected.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 185 B |
@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
@ -32,29 +31,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
android:id="@+id/pmark"
|
||||
android:visibility="gone"
|
||||
android:layout_width="4dip"
|
||||
android:layout_height="44sp"
|
||||
android:layout_height="@dimen/row_normal_height"
|
||||
android:background="@color/now_playing_marker" />
|
||||
|
||||
<ch.blinkenlights.android.vanilla.LazyCoverView
|
||||
android:id="@+id/cover"
|
||||
android:visibility="gone"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:longClickable="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_width="44sp"
|
||||
android:layout_height="44sp" />
|
||||
|
||||
android:scaleType="centerCrop"
|
||||
android:layout_width="@dimen/cover_size"
|
||||
android:layout_height="@dimen/cover_size"
|
||||
android:layout_marginLeft="@dimen/cover_padding"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:visibility="gone" />
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:maxLines="2"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:gravity="left|center_vertical"
|
||||
android:layout_width="0px"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="2dip"
|
||||
android:paddingBottom="2dip"
|
||||
android:paddingLeft="4dip" />
|
||||
android:layout_height="@dimen/row_normal_height"
|
||||
android:layout_marginLeft="@dimen/text_padding"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<CheckedTextView
|
||||
android:id="@+id/checkbox"
|
||||
@ -62,20 +58,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="44sp"/>
|
||||
android:layout_width="@dimen/row_normal_height"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dragger"
|
||||
android:visibility="gone"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/grabber"
|
||||
android:layout_width="44sp"
|
||||
android:layout_height="44sp" />
|
||||
android:scaleType="center"
|
||||
android:layout_width="@dimen/row_normal_height"
|
||||
android:layout_height="@dimen/row_normal_height"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="?divider_color"/>
|
||||
android:layout_height="1dip"
|
||||
android:background="?android:attr/dividerHorizontal"/>
|
||||
|
||||
</ch.blinkenlights.android.vanilla.DraggableRow>
|
||||
|
@ -35,6 +35,7 @@ THE SOFTWARE.
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="2"
|
||||
android:layout_marginLeft="@dimen/text_padding"
|
||||
android:text="" />
|
||||
<Button
|
||||
android:id="@+id/save_button"
|
||||
@ -48,14 +49,14 @@ THE SOFTWARE.
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dp"
|
||||
android:background="?divider_color"
|
||||
android:background="?android:attr/dividerHorizontal"
|
||||
/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:divider="?divider_color"
|
||||
android:divider="?android:attr/dividerHorizontal"
|
||||
android:dividerHeight="1dip"
|
||||
android:listSelector="?android:attr/selectableItemBackground"
|
||||
android:scrollbarStyle="outsideInset" />
|
||||
|
@ -26,6 +26,14 @@ THE SOFTWARE.
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<View
|
||||
android:id="@+id/actionbar_elevation_hack"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="?float_color"
|
||||
android:elevation="4dp"
|
||||
/>
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/pager"
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -27,38 +27,36 @@ THE SOFTWARE.
|
||||
android:orientation="horizontal">
|
||||
<ch.blinkenlights.android.vanilla.LazyCoverView
|
||||
android:id="@+id/cover"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:longClickable="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_width="44sp"
|
||||
android:layout_height="44sp"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
android:scaleType="centerCrop"
|
||||
android:layout_width="@dimen/cover_size"
|
||||
android:layout_height="@dimen/cover_size"
|
||||
android:layout_marginLeft="@dimen/cover_padding"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:visibility="gone" />
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:longClickable="true"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:maxLines="2"
|
||||
android:padding="3dip"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:gravity="left|center_vertical"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="44sp"
|
||||
android:layout_height="@dimen/row_normal_height"
|
||||
android:layout_marginLeft="@dimen/text_padding"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="1dip"
|
||||
android:layout_width="@dimen/divider_size"
|
||||
android:layout_height="fill_parent"
|
||||
android:visibility="gone"
|
||||
android:background="?divider_color" />
|
||||
android:background="?android:attr/dividerHorizontal" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/arrow"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:longClickable="true"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/arrow"
|
||||
android:layout_width="44sp"
|
||||
android:layout_height="44sp"
|
||||
android:scaleType="center"
|
||||
android:layout_width="@dimen/row_normal_height"
|
||||
android:layout_height="@dimen/row_normal_height"
|
||||
android:visibility="gone"
|
||||
android:contentDescription="@string/expand" />
|
||||
</LinearLayout>
|
||||
|
@ -24,7 +24,6 @@ THE SOFTWARE.
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:divider="?divider_color"
|
||||
android:divider="?android:attr/dividerHorizontal"
|
||||
android:dividerHeight="1dip"
|
||||
android:listSelector="?android:attr/selectableItemBackground"
|
||||
android:scrollbarStyle="outsideInset" />
|
||||
|
9
res/values-v21/dimens.xml
Normal file
9
res/values-v21/dimens.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<resources>
|
||||
<dimen name="cover_size">44sp</dimen>
|
||||
<dimen name="cover_padding">14sp</dimen>
|
||||
<dimen name="text_padding">14sp</dimen>
|
||||
<dimen name="row_normal_height">56sp</dimen>
|
||||
<dimen name="divider_size">0dip</dimen>
|
||||
</resources>
|
@ -24,49 +24,53 @@ Copyright (C) 2015 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
<style name="VanillaBase" parent="android:Theme.Material.Light.DarkActionBar">
|
||||
<item name="overlay_background_color">@color/overlay_background_light</item>
|
||||
<item name="overlay_foreground_color">@color/overlay_foreground_light</item>
|
||||
<item name="divider_color">@color/button_material_light</item>
|
||||
<item name="float_color">@color/button_material_light</item>
|
||||
<item name="float_color">@color/material_grey_400</item>
|
||||
<item name="android:colorAccent">@color/vanillaAccent</item>
|
||||
<item name="android:colorPrimary">@color/vanillaPrimary</item>
|
||||
<item name="android:colorPrimaryDark">@color/vanillaPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<style name="Playback" parent="VanillaBase">
|
||||
<item name="android:actionBarStyle">@style/PlaybackActionBar</item>
|
||||
<item name="android:actionBarStyle">@style/Universal.PlaybackActionBar</item>
|
||||
</style>
|
||||
|
||||
<style name="BackActionBar" parent="VanillaBase">
|
||||
<item name="android:actionBarStyle">@style/PlaybackActionBar</item>
|
||||
<item name="android:actionBarStyle">@style/Universal.PlaybackActionBar</item>
|
||||
</style>
|
||||
|
||||
<style name="PlaybackActionBar" parent="android:Widget.Material.ActionBar">
|
||||
<style name="Library" parent="VanillaBase">
|
||||
<item name="android:actionBarStyle">@style/Universal.LibraryActionBar</item>
|
||||
<item name="android:actionBarTabStyle">@style/Universal.LibraryActionBarTabView</item>
|
||||
<item name="android:actionBarTabTextStyle">@style/Universal.LibraryActionBarTabText</item>
|
||||
</style>
|
||||
|
||||
<!-- universal styles -->
|
||||
<style name="Universal.PlaybackActionBar" parent="android:Widget.Material.ActionBar">
|
||||
<item name="android:displayOptions">showTitle|homeAsUp</item>
|
||||
<item name="android:background">@color/vanillaPrimary</item>
|
||||
</style>
|
||||
|
||||
<style name="Library" parent="VanillaBase">
|
||||
<item name="android:actionBarStyle">@style/LibraryActionBar</item>
|
||||
<item name="android:actionBarTabTextStyle">@style/LibraryActionBarTabText</item>
|
||||
</style>
|
||||
|
||||
<style name="LibraryActionBar" parent="android:Widget.Material.ActionBar">
|
||||
<style name="Universal.LibraryActionBar" parent="android:Widget.Material.ActionBar">
|
||||
<item name="android:displayOptions"></item>
|
||||
<item name="android:background">@color/vanillaPrimary</item>
|
||||
<item name="android:backgroundStacked">@color/vanillaPrimary</item>
|
||||
</style>
|
||||
|
||||
<style name="LibraryActionBarTabText" parent="android:Widget.Material.ActionBar.TabText">
|
||||
<style name="Universal.LibraryActionBarTabText" parent="android:Widget.Material.ActionBar.TabText">
|
||||
<item name="android:singleLine">true</item>
|
||||
<item name="android:textSize">11.5sp</item>
|
||||
<item name="android:textColor">@color/material_grey_900</item>
|
||||
<item name="android:textColor">@color/material_grey_300</item>
|
||||
</style>
|
||||
|
||||
<style name="Universal.LibraryActionBarTabView" parent="android:Widget.Material.ActionBar.TabView">
|
||||
<item name="android:background">@drawable/tab_indicator</item>
|
||||
</style>
|
||||
|
||||
|
||||
<!-- dark theme -->
|
||||
<style name="Dark.VanillaBase" parent="android:Theme.Material">
|
||||
<item name="overlay_background_color">@color/overlay_background_dark</item>
|
||||
<item name="overlay_foreground_color">@color/overlay_foreground_dark</item>
|
||||
<item name="divider_color">@color/button_material_dark</item>
|
||||
<item name="float_color">@color/material_grey_900</item>
|
||||
<item name="android:colorAccent">@color/vanillaAccent</item>
|
||||
<item name="android:colorPrimary">@color/vanillaPrimary</item>
|
||||
@ -74,22 +78,19 @@ Copyright (C) 2015 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
</style>
|
||||
|
||||
<style name="Dark.Playback" parent="Dark.VanillaBase">
|
||||
<item name="android:actionBarStyle">@style/PlaybackActionBar</item>
|
||||
</style>
|
||||
|
||||
<style name="Dark.Library" parent="Dark.VanillaBase">
|
||||
<item name="android:actionBarStyle">@style/LibraryActionBar</item>
|
||||
<item name="android:actionBarTabTextStyle">@style/Dark.LibraryActionBarTabText</item>
|
||||
<item name="android:actionBarStyle">@style/Universal.PlaybackActionBar</item>
|
||||
</style>
|
||||
|
||||
<style name="Dark.BackActionBar" parent="Dark.VanillaBase">
|
||||
<item name="android:actionBarStyle">@style/PlaybackActionBar</item>
|
||||
<item name="android:actionBarStyle">@style/Universal.PlaybackActionBar</item>
|
||||
</style>
|
||||
|
||||
<style name="Dark.LibraryActionBarTabText" parent="android:Widget.Material.ActionBar.TabText">
|
||||
<item name="android:singleLine">true</item>
|
||||
<item name="android:textSize">11.5sp</item>
|
||||
<item name="android:textColor">@color/material_grey_300</item>
|
||||
<style name="Dark.Library" parent="Dark.VanillaBase">
|
||||
<item name="android:actionBarStyle">@style/Universal.LibraryActionBar</item>
|
||||
<item name="android:actionBarTabStyle">@style/Universal.LibraryActionBarTabView</item>
|
||||
<item name="android:actionBarTabTextStyle">@style/Universal.LibraryActionBarTabText</item>
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
</resources>
|
||||
|
@ -1,6 +1,5 @@
|
||||
<resources>
|
||||
<attr name="overlay_background_color" format="color" />
|
||||
<attr name="overlay_foreground_color" format="color" />
|
||||
<attr name="divider_color" format="color" />
|
||||
<attr name="float_color" format="color" />
|
||||
</resources>
|
||||
|
9
res/values/dimens.xml
Normal file
9
res/values/dimens.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<resources>
|
||||
<dimen name="cover_size">44sp</dimen>
|
||||
<dimen name="cover_padding">0sp</dimen>
|
||||
<dimen name="text_padding">3sp</dimen>
|
||||
<dimen name="row_normal_height">44sp</dimen>
|
||||
<dimen name="divider_size">1dip</dimen>
|
||||
</resources>
|
@ -39,7 +39,6 @@ THE SOFTWARE.
|
||||
<item name="overlay_background_color">#a000</item>
|
||||
<!-- color to use in full_playback text, set to bright_foreground_disabled_holo_light //-->
|
||||
<item name="overlay_foreground_color">#ffb2b2b2</item>
|
||||
<item name="divider_color">#f444</item>
|
||||
<item name="float_color">#f222</item>
|
||||
</style>
|
||||
|
||||
|
@ -202,7 +202,6 @@ public class FileSystemAdapter
|
||||
holder.text = (TextView)view.findViewById(R.id.text);
|
||||
holder.divider = (View)view.findViewById(R.id.divider);
|
||||
holder.arrow = (ImageView)view.findViewById(R.id.arrow);
|
||||
holder.text.setOnClickListener(this);
|
||||
holder.arrow.setOnClickListener(this);
|
||||
view.setTag(holder);
|
||||
} else {
|
||||
@ -311,7 +310,11 @@ public class FileSystemAdapter
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = createData((View)view.getParent());
|
||||
onHandleRowClick((View)view.getParent());
|
||||
}
|
||||
|
||||
public void onHandleRowClick(View view) {
|
||||
Intent intent = createData(view);
|
||||
boolean isFolder = intent.getBooleanExtra(LibraryAdapter.DATA_EXPANDABLE, false);
|
||||
|
||||
if (FileUtils.canDispatchIntent(intent) && FileUtils.dispatchIntent(mActivity, intent))
|
||||
|
@ -62,7 +62,6 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.SearchView;
|
||||
|
||||
import com.viewpagerindicator.TabPageIndicator;
|
||||
import java.io.File;
|
||||
import junit.framework.Assert;
|
||||
|
||||
@ -128,7 +127,6 @@ public class LibraryActivity
|
||||
-1, -1, -1, SongTimeline.MODE_ENQUEUE_AS_NEXT };
|
||||
|
||||
public ViewPager mViewPager;
|
||||
private TabPageIndicator mTabs;
|
||||
|
||||
private View mActionControls;
|
||||
private TextView mTitle;
|
||||
|
@ -42,6 +42,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.util.LruCache;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.LinearLayout;
|
||||
@ -55,7 +56,7 @@ public class LibraryPagerAdapter
|
||||
implements Handler.Callback
|
||||
, ViewPager.OnPageChangeListener
|
||||
, View.OnCreateContextMenuListener
|
||||
, View.OnClickListener
|
||||
, AdapterView.OnItemClickListener
|
||||
{
|
||||
/**
|
||||
* The number of unique list types. The number of visible lists may be
|
||||
@ -346,12 +347,12 @@ public class LibraryPagerAdapter
|
||||
|
||||
view = (ListView)inflater.inflate(R.layout.listview, null);
|
||||
view.setOnCreateContextMenuListener(this);
|
||||
view.setOnItemClickListener(this);
|
||||
|
||||
view.setTag(type);
|
||||
if (header != null) {
|
||||
TextView headerText = (TextView)header.findViewById(R.id.text);
|
||||
headerText.setText(mHeaderText);
|
||||
headerText.setOnClickListener(this);
|
||||
header.setTag(new ViewHolder()); // behave like a normal library row
|
||||
view.addHeaderView(header);
|
||||
}
|
||||
@ -841,10 +842,14 @@ public class LibraryPagerAdapter
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
view = (View)view.getParent(); // get view of linear layout, not the click consumer
|
||||
Intent intent = createHeaderIntent(view);
|
||||
mActivity.onItemClicked(intent);
|
||||
public void onItemClick (AdapterView<?> parent, View view, int position, long id) {
|
||||
int type = (Integer)parent.getTag();
|
||||
if (type == MediaUtils.TYPE_FILE) {
|
||||
mFilesAdapter.onHandleRowClick(view);
|
||||
} else {
|
||||
Intent intent = id == -1 ? createHeaderIntent(view) : mCurrentAdapter.createData(view);
|
||||
mActivity.onItemClicked(intent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -480,8 +480,6 @@ public class MediaAdapter
|
||||
holder.arrow = (ImageView)view.findViewById(R.id.arrow);
|
||||
holder.cover = (LazyCoverView)view.findViewById(R.id.cover);
|
||||
holder.arrow.setOnClickListener(this);
|
||||
holder.text.setOnClickListener(this);
|
||||
holder.cover.setOnClickListener(this);
|
||||
|
||||
holder.divider.setVisibility(mExpandable ? View.VISIBLE : View.GONE);
|
||||
holder.arrow.setVisibility(mExpandable ? View.VISIBLE : View.GONE);
|
||||
@ -576,6 +574,9 @@ public class MediaAdapter
|
||||
return mSortMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an intent to dispatch
|
||||
*/
|
||||
@Override
|
||||
public Intent createData(View view)
|
||||
{
|
||||
@ -588,17 +589,16 @@ public class MediaAdapter
|
||||
return intent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback of array clicks (item clicks are handled in LibraryPagerAdapter)
|
||||
*/
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
int id = view.getId();
|
||||
view = (View)view.getParent(); // get view of linear layout, not the click consumer
|
||||
Intent intent = createData(view);
|
||||
if (id == R.id.arrow) {
|
||||
mActivity.onItemExpanded(intent);
|
||||
} else {
|
||||
mActivity.onItemClicked(intent);
|
||||
}
|
||||
mActivity.onItemExpanded(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,205 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
* Copyright (C) 2011 Jake Wharton
|
||||
*
|
||||
* 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.viewpagerindicator;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import ch.blinkenlights.android.vanilla.R;
|
||||
|
||||
/**
|
||||
* This widget implements the dynamic action bar tab behavior that can change
|
||||
* across different configurations or circumstances.
|
||||
*/
|
||||
public class TabPageIndicator extends HorizontalScrollView
|
||||
implements ViewPager.OnPageChangeListener
|
||||
, View.OnClickListener
|
||||
{
|
||||
Runnable mTabSelector;
|
||||
|
||||
private final LinearLayout mTabLayout;
|
||||
private ViewPager mViewPager;
|
||||
private ViewPager.OnPageChangeListener mListener;
|
||||
|
||||
private int mSelectedTabIndex;
|
||||
|
||||
public TabPageIndicator(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public TabPageIndicator(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setHorizontalScrollBarEnabled(false);
|
||||
|
||||
mTabLayout = new LinearLayout(getContext());
|
||||
addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
|
||||
final boolean lockedExpanded = widthMode == MeasureSpec.EXACTLY;
|
||||
setFillViewport(lockedExpanded);
|
||||
|
||||
final int oldWidth = getMeasuredWidth();
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
final int newWidth = getMeasuredWidth();
|
||||
|
||||
if (lockedExpanded && oldWidth != newWidth) {
|
||||
// Recenter the tab display if we're at a new (scrollable) size.
|
||||
setCurrentItem(mSelectedTabIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void animateToTab(final int position) {
|
||||
final View tabView = mTabLayout.getChildAt(position);
|
||||
if (mTabSelector != null) {
|
||||
removeCallbacks(mTabSelector);
|
||||
}
|
||||
mTabSelector = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2;
|
||||
smoothScrollTo(scrollPos, 0);
|
||||
mTabSelector = null;
|
||||
}
|
||||
};
|
||||
post(mTabSelector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
if (mTabSelector != null) {
|
||||
// Re-post the selector we saved
|
||||
post(mTabSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
if (mTabSelector != null) {
|
||||
removeCallbacks(mTabSelector);
|
||||
}
|
||||
}
|
||||
|
||||
private void addTab(CharSequence text, int index) {
|
||||
Context context = getContext();
|
||||
DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
||||
|
||||
int padX = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 22, dm);
|
||||
int padY = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, dm);
|
||||
|
||||
TextView tabView = new TextView(context);
|
||||
tabView.setBackgroundResource(R.drawable.vpi__tab_indicator);
|
||||
tabView.setPadding(padX, padY, padX, padY);
|
||||
tabView.setGravity(Gravity.CENTER);
|
||||
tabView.setTextColor(0xfff3f3f3);
|
||||
tabView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
|
||||
tabView.setTypeface(tabView.getTypeface(), Typeface.BOLD);
|
||||
tabView.setSingleLine();
|
||||
tabView.setTag(index);
|
||||
tabView.setFocusable(true);
|
||||
tabView.setOnClickListener(this);
|
||||
tabView.setText(text);
|
||||
|
||||
mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int arg0) {
|
||||
if (mListener != null) {
|
||||
mListener.onPageScrollStateChanged(arg0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int arg0, float arg1, int arg2) {
|
||||
if (mListener != null) {
|
||||
mListener.onPageScrolled(arg0, arg1, arg2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int arg0) {
|
||||
setCurrentItem(arg0);
|
||||
if (mListener != null) {
|
||||
mListener.onPageSelected(arg0);
|
||||
}
|
||||
}
|
||||
|
||||
public void setViewPager(ViewPager view) {
|
||||
final PagerAdapter adapter = view.getAdapter();
|
||||
if (adapter == null) {
|
||||
throw new IllegalStateException("ViewPager does not have adapter instance.");
|
||||
}
|
||||
mViewPager = view;
|
||||
view.setOnPageChangeListener(this);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void notifyDataSetChanged() {
|
||||
mTabLayout.removeAllViews();
|
||||
PagerAdapter adapter = mViewPager.getAdapter();
|
||||
final int count = adapter.getCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
addTab(adapter.getPageTitle(i), i);
|
||||
}
|
||||
if (mSelectedTabIndex > count) {
|
||||
mSelectedTabIndex = count - 1;
|
||||
}
|
||||
setCurrentItem(mSelectedTabIndex);
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public void setCurrentItem(int item) {
|
||||
if (mViewPager == null) {
|
||||
throw new IllegalStateException("ViewPager has not been bound.");
|
||||
}
|
||||
mSelectedTabIndex = item;
|
||||
final int tabCount = mTabLayout.getChildCount();
|
||||
for (int i = 0; i < tabCount; i++) {
|
||||
final View child = mTabLayout.getChildAt(i);
|
||||
final boolean isSelected = i == item;
|
||||
child.setSelected(isSelected);
|
||||
if (isSelected) {
|
||||
animateToTab(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnPageChangeListener(ViewPager.OnPageChangeListener listener) {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
mViewPager.setCurrentItem((Integer)view.getTag());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user