Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Auto-update
Browse files Browse the repository at this point in the history
  • Loading branch information
google-automerger committed Oct 25, 2017
1 parent 386f36e commit 2f5c463
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 9 deletions.
10 changes: 5 additions & 5 deletions Wearable/build.gradle
Expand Up @@ -22,15 +22,15 @@ repositories {

dependencies {

compile 'com.android.support:wear:26.0.0'
compile 'com.android.support:wear:27.0.0'


compile 'com.google.android.gms:play-services-wearable:11.4.0'
compile 'com.android.support:support-v13:26.1.0'
compile 'com.google.android.gms:play-services-wearable:11.4.2'
compile 'com.android.support:support-v13:27.0.0'

provided 'com.google.android.wearable:wearable:2.0.5'
provided 'com.google.android.wearable:wearable:2.1.0'

compile 'com.google.android.support:wearable:2.0.5'
compile 'com.google.android.support:wearable:2.1.0'

}

Expand Down
Expand Up @@ -15,14 +15,18 @@
*/
package com.example.android.wearable.wear.weardrawers;

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.graphics.ColorFilter;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.wear.ambient.AmbientMode;
import android.support.wear.widget.drawer.WearableActionDrawerView;
import android.support.wear.widget.drawer.WearableNavigationDrawerView;
import android.support.wearable.activity.WearableActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
Expand All @@ -36,8 +40,10 @@
/**
* Demonstrates use of Navigation and Action Drawers on Android Wear.
*/
public class MainActivity extends WearableActivity implements
MenuItem.OnMenuItemClickListener, WearableNavigationDrawerView.OnItemSelectedListener {
public class MainActivity extends Activity implements
AmbientMode.AmbientCallbackProvider,
MenuItem.OnMenuItemClickListener,
WearableNavigationDrawerView.OnItemSelectedListener {

private static final String TAG = "MainActivity";

Expand All @@ -55,7 +61,9 @@ protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate()");

setContentView(R.layout.activity_main);
setAmbientEnabled();

// Enables Ambient mode.
AmbientMode.attachAmbientSupport(this);

mSolarSystem = initializeSolarSystem();
mSelectedPlanet = 0;
Expand Down Expand Up @@ -204,6 +212,7 @@ public static class PlanetFragment extends Fragment {
public static final String ARG_PLANET_IMAGE_ID = "planet_image_id";

private ImageView mImageView;
private ColorFilter mImageViewColorFilter;

public PlanetFragment() {
// Empty constructor required for fragment subclasses
Expand All @@ -219,11 +228,59 @@ public View onCreateView(
int imageIdToLoad = getArguments().getInt(ARG_PLANET_IMAGE_ID);
mImageView.setImageResource(imageIdToLoad);

mImageViewColorFilter = mImageView.getColorFilter();

return rootView;
}

public void updatePlanet(int imageId) {
mImageView.setImageResource(imageId);
}

public void onEnterAmbientInFragment(Bundle ambientDetails) {
Log.d(TAG, "PlanetFragment.onEnterAmbient() " + ambientDetails);

// Convert image to grayscale for ambient mode.
ColorMatrix matrix = new ColorMatrix();
matrix.setSaturation(0);

ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
mImageView.setColorFilter(filter);
}

/** Restores the UI to active (non-ambient) mode. */
public void onExitAmbientInFragment() {
Log.d(TAG, "PlanetFragment.onExitAmbient()");

mImageView.setColorFilter(mImageViewColorFilter);
}
}

@Override
public AmbientMode.AmbientCallback getAmbientCallback() {
return new MyAmbientCallback();
}

private class MyAmbientCallback extends AmbientMode.AmbientCallback {
/** Prepares the UI for ambient mode. */
@Override
public void onEnterAmbient(Bundle ambientDetails) {
super.onEnterAmbient(ambientDetails);
Log.d(TAG, "onEnterAmbient() " + ambientDetails);

mPlanetFragment.onEnterAmbientInFragment(ambientDetails);
mWearableNavigationDrawer.getController().closeDrawer();
mWearableActionDrawer.getController().closeDrawer();
}

/** Restores the UI to active (non-ambient) mode. */
@Override
public void onExitAmbient() {
super.onExitAmbient();
Log.d(TAG, "onExitAmbient()");

mPlanetFragment.onExitAmbientInFragment();
mWearableActionDrawer.getController().peekDrawer();
}
}
}

0 comments on commit 2f5c463

Please sign in to comment.