Polished Grid example and added a few missing details at
Launcher fragment. Video- and Music examples now also use an Activity. BackgroundHandler in MainFragment removed. Removed unused Log-Tag field and added correct background. Changed Grid Zoom factor. Moved Grid- and Card example to their own packages and they now are started using an Activity. Launcher fragment uses correct primaryColor and its row has been lowered. Music and Video consumption example are using Activities as well. Thus BackgroundManager in MainFragment is unnecessair, which is why it got removed. Change-Id: I928614314677706f19e648666697f0a710d88e0a
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
android:icon="@mipmap/app_banner_sample_app"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:theme="@style/Theme.Example.Leanback">
|
||||
android:theme="@style/Theme.Example.LeanbackLauncher">
|
||||
<activity
|
||||
android:name=".app.MainActivity"
|
||||
android:icon="@mipmap/app_banner_sample_app"
|
||||
@@ -42,6 +42,18 @@
|
||||
<activity
|
||||
android:name=".app.details.DetailViewExampleActivity"
|
||||
android:theme="@style/Theme.Example.LeanbackDetailView"></activity>
|
||||
<activity
|
||||
android:name=".app.cards.CardExampleActivity"
|
||||
android:theme="@style/Theme.Example.Leanback"></activity>
|
||||
<activity
|
||||
android:name=".app.grid.GridExampleActivity"
|
||||
android:theme="@style/Theme.Example.Leanback"></activity>
|
||||
<activity
|
||||
android:name=".app.media.VideoExampleActivity"
|
||||
android:theme="@style/Theme.Example.Leanback"></activity>
|
||||
<activity
|
||||
android:name=".app.media.MusicExampleActivity"
|
||||
android:theme="@style/Theme.Example.Leanback"></activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
@@ -14,29 +14,23 @@
|
||||
|
||||
package android.support.v17.leanback.supportleanbackshowcase.app;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v17.leanback.app.BackgroundManager;
|
||||
import android.support.v17.leanback.app.BrowseFragment;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.R;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.app.cards.CardExampleActivity;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.app.details.DetailViewExampleActivity;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.app.dialog.DialogExampleActivity;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.app.media.MusicConsumptionExampleFragment;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.app.media.VideoConsumptionExampleFragment;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.app.media.VideoSurfaceFragment;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.app.grid.GridExampleActivity;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.app.media.MusicExampleActivity;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.app.media.VideoExampleActivity;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.app.settings.SettingsExampleActivity;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.app.wizard.WizardExampleActivity;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.utils.Constants;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.models.Movie;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.utils.PicassoBackgroundManagerTarget;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.R;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.utils.Utils;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.cards.presenters.CardPresenterSelector;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.models.Card;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.models.CardRow;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.cards.presenters.CardPresenterSelector;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.models.Movie;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.utils.Utils;
|
||||
import android.support.v17.leanback.widget.ArrayObjectAdapter;
|
||||
import android.support.v17.leanback.widget.ListRow;
|
||||
import android.support.v17.leanback.widget.ListRowPresenter;
|
||||
@@ -46,50 +40,23 @@ import android.support.v17.leanback.widget.Presenter;
|
||||
import android.support.v17.leanback.widget.PresenterSelector;
|
||||
import android.support.v17.leanback.widget.Row;
|
||||
import android.support.v17.leanback.widget.RowPresenter;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Target;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
|
||||
public class MainFragment extends BrowseFragment {
|
||||
|
||||
public static final String VIDEO_SURFACE_FRAGMENT_TAG = "VIDEO_SURFACE";
|
||||
private static final String TAG = "MainFragment";
|
||||
private static final int BACKGROUND_UPDATE_DELAY = 300;
|
||||
private static final int DEFAULT_BACKGROUND_IMAGE = R.drawable.default_background;
|
||||
private final Handler mHandler = new Handler();
|
||||
private ArrayObjectAdapter mRowsAdapter;
|
||||
private Target mBackgroundTarget;
|
||||
private Timer mBackgroundTimer;
|
||||
private URI mBackgroundURI;
|
||||
private BackgroundManager mBackgroundManager;
|
||||
private DisplayMetrics mMetrics;
|
||||
|
||||
@Override public void onActivityCreated(Bundle savedInstanceState) {
|
||||
if (Constants.LOCAL_LOGD) Log.d(TAG, "onActivityCreated");
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
setupBackgroundManager();
|
||||
setupUIElements();
|
||||
setupRowAdapter();
|
||||
setupEventListeners();
|
||||
}
|
||||
|
||||
@Override public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (null != mBackgroundTimer) {
|
||||
if (Constants.LOCAL_LOGD) Log.d(TAG, "onDestroy: " + mBackgroundTimer.toString());
|
||||
mBackgroundTimer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupRowAdapter() {
|
||||
mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
|
||||
createRows();
|
||||
@@ -114,18 +81,6 @@ public class MainFragment extends BrowseFragment {
|
||||
return new ListRow(listRowAdapter);
|
||||
}
|
||||
|
||||
private void setupBackgroundManager() {
|
||||
mBackgroundManager = BackgroundManager.getInstance(getActivity());
|
||||
mBackgroundManager.setThemeDrawableResourceId(DEFAULT_BACKGROUND_IMAGE);
|
||||
mBackgroundManager.attach(getActivity().getWindow());
|
||||
|
||||
mBackgroundTarget = new PicassoBackgroundManagerTarget(mBackgroundManager);
|
||||
mMetrics = new DisplayMetrics();
|
||||
getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
|
||||
getView().setBackgroundResource(R.drawable.bg_living_room_wide);
|
||||
//updateBackgroundImage(R.drawable.bg_living_room_wide);
|
||||
}
|
||||
|
||||
private void setupUIElements() {
|
||||
setTitle(getString(R.string.browse_title));
|
||||
setBadgeDrawable(getResources().getDrawable(R.drawable.title_android_tv, null));
|
||||
@@ -139,53 +94,24 @@ public class MainFragment extends BrowseFragment {
|
||||
setOnItemViewSelectedListener(new ItemViewSelectedListener());
|
||||
}
|
||||
|
||||
protected void updateBackgroundImage(URI uri) {
|
||||
// Deactivated until we decide whether to load a background image from an URL or resource. @hahnr
|
||||
if (true) return;
|
||||
Picasso.with(getActivity()).load(uri.toString())
|
||||
.resize(mMetrics.widthPixels, mMetrics.heightPixels).centerCrop()
|
||||
.error(DEFAULT_BACKGROUND_IMAGE).into(mBackgroundTarget);
|
||||
}
|
||||
|
||||
protected void updateBackgroundImage(Drawable drawable) {
|
||||
mBackgroundManager.setDrawable(drawable);
|
||||
}
|
||||
|
||||
protected void updateBackgroundImage(int resId) {
|
||||
mBackgroundManager.setDrawable(getResources().getDrawable(resId, null));
|
||||
}
|
||||
|
||||
private void startBackgroundTimer() {
|
||||
if (null != mBackgroundTimer) {
|
||||
mBackgroundTimer.cancel();
|
||||
}
|
||||
mBackgroundTimer = new Timer();
|
||||
mBackgroundTimer.schedule(new UpdateBackgroundTask(), BACKGROUND_UPDATE_DELAY);
|
||||
}
|
||||
|
||||
private final class ItemViewClickedListener implements OnItemViewClickedListener {
|
||||
|
||||
@Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
|
||||
RowPresenter.ViewHolder rowViewHolder, Row row) {
|
||||
@Override
|
||||
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
|
||||
RowPresenter.ViewHolder rowViewHolder, Row row) {
|
||||
Card card = (Card) item;
|
||||
int id = card.getId();
|
||||
switch (id) {
|
||||
case 0: {
|
||||
updateBackgroundImage(new ColorDrawable(
|
||||
getResources().getColor(R.color.card_examples_background)));
|
||||
Fragment fragment = new CardExampleFragment();
|
||||
getFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragmentContainer, fragment)
|
||||
.addToBackStack(null).commit();
|
||||
Intent intent = new Intent(getActivity().getBaseContext(),
|
||||
CardExampleActivity.class);
|
||||
startActivity(intent);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
updateBackgroundImage(
|
||||
getResources().getDrawable(R.drawable.background_canyon, null));
|
||||
Fragment fragment = new GridExample();
|
||||
getFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragmentContainer, fragment)
|
||||
.addToBackStack(null).commit();
|
||||
Intent intent = new Intent(getActivity().getBaseContext(),
|
||||
GridExampleActivity.class);
|
||||
startActivity(intent);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
@@ -195,23 +121,15 @@ public class MainFragment extends BrowseFragment {
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
updateBackgroundImage(
|
||||
getResources().getDrawable(R.drawable.background_canyon, null));
|
||||
Fragment fragment = new VideoConsumptionExampleFragment();
|
||||
getFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragmentContainer, new VideoSurfaceFragment(),
|
||||
VIDEO_SURFACE_FRAGMENT_TAG)
|
||||
.add(R.id.fragmentContainer, fragment).addToBackStack(null)
|
||||
.commit();
|
||||
Intent intent = new Intent(getActivity().getBaseContext(),
|
||||
VideoExampleActivity.class);
|
||||
startActivity(intent);
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
updateBackgroundImage(
|
||||
getResources().getDrawable(R.drawable.background_sax, null));
|
||||
Fragment fragment = new MusicConsumptionExampleFragment();
|
||||
getFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragmentContainer, fragment)
|
||||
.addToBackStack(null).commit();
|
||||
Intent intent = new Intent(getActivity().getBaseContext(),
|
||||
MusicExampleActivity.class);
|
||||
startActivity(intent);
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
@@ -254,21 +172,9 @@ public class MainFragment extends BrowseFragment {
|
||||
|
||||
private final class ItemViewSelectedListener implements OnItemViewSelectedListener {
|
||||
|
||||
@Override public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
|
||||
RowPresenter.ViewHolder rowViewHolder, Row row) {
|
||||
}
|
||||
}
|
||||
|
||||
private class UpdateBackgroundTask extends TimerTask {
|
||||
|
||||
@Override public void run() {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override public void run() {
|
||||
if (mBackgroundURI != null) {
|
||||
updateBackgroundImage(mBackgroundURI);
|
||||
}
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
|
||||
RowPresenter.ViewHolder rowViewHolder, Row row) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package android.support.v17.leanback.supportleanbackshowcase.app.cards;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v17.leanback.app.GuidedStepFragment;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.R;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.app.dialog.DialogExampleFragment;
|
||||
|
||||
/**
|
||||
* TODO: Javadoc
|
||||
*/
|
||||
public class CardExampleActivity extends Activity {
|
||||
|
||||
@Override public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_cards_example);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package android.support.v17.leanback.supportleanbackshowcase.app;
|
||||
package android.support.v17.leanback.supportleanbackshowcase.app.cards;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v17.leanback.app.BrowseFragment;
|
||||
@@ -39,8 +39,6 @@ import com.google.gson.Gson;
|
||||
*/
|
||||
public class CardExampleFragment extends BrowseFragment {
|
||||
|
||||
private static final String TAG = "CardExampleFragment";
|
||||
|
||||
private ArrayObjectAdapter mRowsAdapter;
|
||||
|
||||
@Override public void onActivityCreated(Bundle savedInstanceState) {
|
||||
@@ -148,7 +148,7 @@ public class DetailViewExampleFragment extends DetailsFragment implements OnItem
|
||||
null);
|
||||
getView().setBackgroundColor(backgroundColor);
|
||||
} else {
|
||||
getView().setBackgroundResource(R.drawable.background_canyon);
|
||||
getView().setBackground(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package android.support.v17.leanback.supportleanbackshowcase.app;
|
||||
package android.support.v17.leanback.supportleanbackshowcase.app.grid;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v17.leanback.app.VerticalGridFragment;
|
||||
@@ -32,9 +32,8 @@ import com.google.gson.Gson;
|
||||
*/
|
||||
public class GridExample extends VerticalGridFragment {
|
||||
|
||||
private static final String TAG = "GridExample";
|
||||
private static final int COLUMNS = 4;
|
||||
private static final int ZOOM_FACTOR = FocusHighlight.ZOOM_FACTOR_NONE;
|
||||
private static final int ZOOM_FACTOR = FocusHighlight.ZOOM_FACTOR_MEDIUM;
|
||||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package android.support.v17.leanback.supportleanbackshowcase.app.grid;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.R;
|
||||
|
||||
/**
|
||||
* TODO: Javadoc
|
||||
*/
|
||||
public class GridExampleActivity extends Activity {
|
||||
|
||||
@Override public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_grid_example);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package android.support.v17.leanback.supportleanbackshowcase.app.media;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.R;
|
||||
|
||||
/**
|
||||
* TODO: Javadoc
|
||||
*/
|
||||
public class MusicExampleActivity extends Activity {
|
||||
|
||||
@Override public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_music_example);
|
||||
}
|
||||
}
|
||||
@@ -37,12 +37,14 @@ public class VideoConsumptionExampleFragment extends PlaybackOverlayFragment imp
|
||||
private ArrayObjectAdapter mRowsAdapter;
|
||||
private MediaPlayerGlue mGlue;
|
||||
|
||||
@Override public void onCreate(Bundle savedInstanceState) {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mGlue = new VideoMediaPlayerGlue(getActivity(), this) {
|
||||
|
||||
@Override protected void onRowChanged(PlaybackControlsRow row) {
|
||||
@Override
|
||||
protected void onRowChanged(PlaybackControlsRow row) {
|
||||
if (mRowsAdapter == null) return;
|
||||
mRowsAdapter.notifyArrayItemRangeChanged(0, 1);
|
||||
}
|
||||
@@ -55,10 +57,11 @@ public class VideoConsumptionExampleFragment extends PlaybackOverlayFragment imp
|
||||
mGlue.setMediaSource(URL);
|
||||
|
||||
Fragment videoSurfaceFragment = getFragmentManager()
|
||||
.findFragmentByTag(MainFragment.VIDEO_SURFACE_FRAGMENT_TAG);
|
||||
.findFragmentByTag(VideoExampleActivity.VIDEO_SURFACE_FRAGMENT_TAG);
|
||||
SurfaceView surface = (SurfaceView) videoSurfaceFragment.getView();
|
||||
surface.getHolder().addCallback(new SurfaceHolder.Callback() {
|
||||
@Override public void surfaceCreated(SurfaceHolder holder) {
|
||||
@Override
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
mGlue.setDisplay(holder);
|
||||
}
|
||||
|
||||
@@ -67,7 +70,8 @@ public class VideoConsumptionExampleFragment extends PlaybackOverlayFragment imp
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
@Override public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
}
|
||||
});
|
||||
|
||||
@@ -75,12 +79,14 @@ public class VideoConsumptionExampleFragment extends PlaybackOverlayFragment imp
|
||||
addPlaybackControlsRow();
|
||||
}
|
||||
|
||||
@Override public void onStart() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
mGlue.enableProgressUpdating(mGlue.hasValidMedia() && mGlue.isMediaPlaying());
|
||||
}
|
||||
|
||||
@Override public void onStop() {
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
mGlue.enableProgressUpdating(false);
|
||||
mGlue.reset();
|
||||
@@ -95,14 +101,16 @@ public class VideoConsumptionExampleFragment extends PlaybackOverlayFragment imp
|
||||
setOnItemViewClickedListener(this);
|
||||
}
|
||||
|
||||
@Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
|
||||
RowPresenter.ViewHolder rowViewHolder, Row row) {
|
||||
@Override
|
||||
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
|
||||
RowPresenter.ViewHolder rowViewHolder, Row row) {
|
||||
if (!(item instanceof Action)) return;
|
||||
mGlue.onActionClicked((Action) item);
|
||||
}
|
||||
|
||||
|
||||
@Override public void onMediaFileFinishedPlaying(MediaPlayerGlue.MetaData metaData) {
|
||||
@Override
|
||||
public void onMediaFileFinishedPlaying(MediaPlayerGlue.MetaData metaData) {
|
||||
mGlue.startPlayback();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package android.support.v17.leanback.supportleanbackshowcase.app.media;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.R;
|
||||
|
||||
/**
|
||||
* TODO: Javadoc
|
||||
*/
|
||||
public class VideoExampleActivity extends Activity {
|
||||
|
||||
public static final String VIDEO_SURFACE_FRAGMENT_TAG = "VIDEO_SURFACE";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_video_example);
|
||||
|
||||
|
||||
getFragmentManager().beginTransaction()
|
||||
.replace(R.id.videoFragment, new VideoSurfaceFragment(), VIDEO_SURFACE_FRAGMENT_TAG)
|
||||
.add(R.id.videoFragment, new VideoConsumptionExampleFragment())
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.utils.Constants;
|
||||
import android.support.v17.leanback.supportleanbackshowcase.R;
|
||||
import android.support.v17.preference.LeanbackPreferenceFragment;
|
||||
import android.support.v17.preference.LeanbackSettingsFragment;
|
||||
@@ -26,13 +25,13 @@ import android.support.v7.preference.DialogPreference;
|
||||
import android.support.v7.preference.ListPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Stack;
|
||||
|
||||
public class SettingsExampleFragment extends LeanbackSettingsFragment implements DialogPreference.TargetFragment {
|
||||
|
||||
public static final String TAG = "SettingsExampleFragment";
|
||||
private final Stack<Fragment> fragments = new Stack<Fragment>();
|
||||
|
||||
@Override
|
||||
@@ -50,12 +49,6 @@ public class SettingsExampleFragment extends LeanbackSettingsFragment implements
|
||||
public boolean onPreferenceStartScreen(PreferenceFragment preferenceFragment,
|
||||
PreferenceScreen preferenceScreen) {
|
||||
PreferenceFragment frag = buildPreferenceFragment(R.xml.prefs, preferenceScreen.getKey());
|
||||
if ("prefs_wifi_screen_key".equals(preferenceScreen.getKey())) {
|
||||
ListPreference pref = (ListPreference)preferenceScreen.findPreference("prefs_wifi_key");
|
||||
pref.setEntries(new String[] {"Wi-Fi Network 01"});
|
||||
pref.setEntryValues(new String[] {"01"});
|
||||
if (Constants.LOCAL_LOGD) Log.d(TAG, "pref: " + pref);
|
||||
}
|
||||
startPreferenceFragment(frag);
|
||||
return true;
|
||||
}
|
||||
@@ -87,6 +80,18 @@ public class SettingsExampleFragment extends LeanbackSettingsFragment implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(Preference preference) {
|
||||
final String[] keys = {"prefs_wifi_connect_wps", "prefs_date", "prefs_time",
|
||||
"prefs_date_time_use_timezone", "app_banner_sample_app", "pref_force_stop",
|
||||
"pref_uninstall", "pref_more_info"};
|
||||
if (Arrays.asList(keys).contains(preference.getKey())) {
|
||||
Toast.makeText(getActivity(), "Implement your own action handler.", Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
return super.onPreferenceTreeClick(preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
fragments.push(this);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 228 KiB |
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 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.
|
||||
-->
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@color/card_examples_background"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/cardsFragment"
|
||||
android:name="android.support.v17.leanback.supportleanbackshowcase.app.cards.CardExampleFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"></fragment>
|
||||
</RelativeLayout>
|
||||
@@ -16,6 +16,7 @@
|
||||
-->
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@drawable/background_canyon"
|
||||
android:layout_height="match_parent">
|
||||
<fragment
|
||||
android:id="@+id/detailsFragment"
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 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.
|
||||
-->
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@drawable/background_food"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/cardsFragment"
|
||||
android:name="android.support.v17.leanback.supportleanbackshowcase.app.grid.GridExample"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"></fragment>
|
||||
</RelativeLayout>
|
||||
@@ -21,5 +21,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:deviceIds="tv"
|
||||
android:background="@drawable/bg_living_room_wide"
|
||||
tools:ignore="MergeRootFrame">
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 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.
|
||||
-->
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@drawable/background_sax"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/musicFragment"
|
||||
android:name="android.support.v17.leanback.supportleanbackshowcase.app.media.MusicConsumptionExampleFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"></fragment>
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 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.
|
||||
-->
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/videoFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
@@ -33,4 +33,12 @@
|
||||
<item>This description becomes visible only on focus.</item>
|
||||
<item>This description becomes visible only on focus.</item>
|
||||
</array>
|
||||
<array name="pref_wifi_networks">
|
||||
<item>Wi-Fi network 1</item>
|
||||
<item>Wi-Fi network 2</item>
|
||||
<item>Wi-Fi network 3</item>
|
||||
<item>Wi-Fi network 4</item>
|
||||
<item>Wi-Fi network 5</item>
|
||||
<item>Wi-Fi network 6</item>
|
||||
</array>
|
||||
</resources>
|
||||
@@ -42,6 +42,10 @@
|
||||
<item name="android:visibility">invisible</item>
|
||||
</style>
|
||||
|
||||
<style name="MovieCardContentStyle" parent="Widget.Leanback.ImageCardView.ContentStyle">
|
||||
<item name="android:gravity">right</item>
|
||||
</style>
|
||||
|
||||
<style name="MovieCardImageStyle" parent="Widget.Leanback.ImageCardView.ImageStyle">
|
||||
<item name="android:layout_width">@dimen/movie_image_card_width</item>
|
||||
<item name="android:layout_height">@dimen/movie_image_card_height</item>
|
||||
@@ -55,6 +59,7 @@
|
||||
<style name="MovieCardCompleteStyle" parent="MovieCardSimpleStyle">
|
||||
<item name="lbImageCardViewTitleStyle">@style/MovieCardTitleTwoLineStyle</item>
|
||||
<item name="lbImageCardViewBadgeStyle">@style/MovieCardBadgeStyle</item>
|
||||
<item name="lbImageCardViewContentStyle">@style/MovieCardContentStyle</item>
|
||||
<item name="lbImageCardViewType">Title|Content|IconOnLeft</item>
|
||||
</style>
|
||||
|
||||
|
||||
@@ -23,11 +23,15 @@
|
||||
<item name="android:windowAllowReturnTransitionOverlap">true</item>
|
||||
<item name="android:windowAllowEnterTransitionOverlap">true</item>
|
||||
<item name="android:windowContentTransitions">true</item>
|
||||
<item name="android:colorPrimary">@color/search_color</item>
|
||||
<item name="android:colorPrimary">#00A2B8</item>
|
||||
<item name="android:colorAccent">@color/accent</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Example.LeanbackLauncher" parent="Theme.Example.Leanback">
|
||||
<item name="browseRowsMarginTop">275dp</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Example.LeanbackWizard" parent="Theme.Leanback.GuidedStep">
|
||||
<item name="guidedActionsContainerStyle">@style/WizardActionsContainerStyle</item>
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:summary="This is a dummy activitiy only to show case how to build a settings in an application. Changing configurations in this example doesn't affect anything."
|
||||
android:title="Settings Example">
|
||||
<PreferenceScreen
|
||||
@@ -11,14 +12,19 @@
|
||||
android:title="Available Wi-Fi networks">
|
||||
<ListPreference
|
||||
android:defaultValue="-1"
|
||||
android:title="More Wi-Fi networks"
|
||||
android:entries="@array/pref_wifi_networks"
|
||||
android:entryValues="@array/pref_wifi_networks"
|
||||
android:title="Available Wi-Fi networks"
|
||||
android:key="prefs_wifi_key">
|
||||
</ListPreference>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="prefs_wifi_others_key"
|
||||
android:title="Other options">
|
||||
<Preference android:title="Connect via WPS"><!-- You can use Intents here --></Preference>
|
||||
<Preference
|
||||
android:title="Connect via WPS"
|
||||
android:key="prefs_wifi_connect_wps"><!-- You can use Intents here -->
|
||||
</Preference>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
<PreferenceScreen
|
||||
@@ -53,18 +59,15 @@
|
||||
android:summary="GMT 07:00 Pacific Daylight Time"
|
||||
android:title="Time zone"></Preference>
|
||||
</PreferenceScreen>
|
||||
<PreferenceScreen
|
||||
<ListPreference
|
||||
android:defaultValue="everyone"
|
||||
android:icon="@drawable/ic_settings_parental_control"
|
||||
android:key="prefs_parental_control_screen_key"
|
||||
android:entries="@array/pref_parent_control_entries"
|
||||
android:entryValues="@array/pref_parent_control_entries_values"
|
||||
android:key="prefs_parental_control_level_key"
|
||||
android:dialogMessage="Allow contents rated for"
|
||||
android:title="Parental Control">
|
||||
<ListPreference
|
||||
android:defaultValue="everyone"
|
||||
android:entries="@array/pref_parent_control_entries"
|
||||
android:entryValues="@array/pref_parent_control_entries_values"
|
||||
android:key="prefs_parental_control_level_key"
|
||||
android:title="Allow contents rated for">
|
||||
</ListPreference>
|
||||
</PreferenceScreen>
|
||||
</ListPreference>
|
||||
<PreferenceScreen
|
||||
android:icon="@drawable/ic_settings_apps"
|
||||
android:key="prefs_apps_screen_key"
|
||||
@@ -77,14 +80,34 @@
|
||||
android:summary="Lorem ipsum dolor sit amet consectur adipiscing."
|
||||
android:title="App permissions">
|
||||
<Preference
|
||||
android:icon="@drawable/face_01"
|
||||
android:icon="@mipmap/app_banner_sample_app"
|
||||
android:summary="45.5 MB"
|
||||
android:selectable="false"
|
||||
android:title="Application A"></Preference>
|
||||
<Preference android:summary="Hier steht ein voelligst sinnfreier Text den ja sowieso niemandhier lesen kann. Deshalb macht es auch keinen Unterschied ob hier sinnvolles und nicht so sinnvolles Zeug steht."></Preference>
|
||||
<Preference android:title="Force Stop"><!-- Start an Intent --></Preference>
|
||||
<Preference android:title="Uninstall"><!-- Start an Intent --></Preference>
|
||||
<Preference android:title="More Information"></Preference>
|
||||
<Preference
|
||||
android:selectable="false"
|
||||
android:summary="Hier steht ein voelligst sinnfreier Text den ja sowieso niemandhier lesen kann. Deshalb macht es auch keinen Unterschied ob hier sinnvolles und nicht so sinnvolles Zeug steht. Hm... Sasha, du kannst das vielleicht lesen und denkst dir jetzt auch, dass ich voll haengen geblieben bin, oder?... ^_^"></Preference>
|
||||
<Preference
|
||||
android:title="Force Stop"
|
||||
android:key="pref_force_stop"><!-- Start an Intent --></Preference>
|
||||
<Preference
|
||||
android:title="Uninstall"
|
||||
android:key="pref_uninstall"><!-- Start an Intent --></Preference>
|
||||
<Preference
|
||||
android:title="More Information"
|
||||
android:key="pref_more_info"></Preference>
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="prefs_app_downloaded_apps_category"
|
||||
android:title="Downloaded Apps">
|
||||
<ListPreference
|
||||
android:defaultValue="everyone"
|
||||
android:entries="@array/pref_parent_control_entries"
|
||||
android:entryValues="@array/pref_parent_control_entries_values"
|
||||
android:key="prefs_parental_control_level_key"
|
||||
android:title="Downloaded Apps">
|
||||
</ListPreference>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
</PreferenceScreen>
|
||||
|
||||
Reference in New Issue
Block a user