diff options
41 files changed, 1022 insertions, 0 deletions
diff --git a/wearable/wear/WearDrawers/.gitignore b/wearable/wear/WearDrawers/.gitignore new file mode 100644 index 00000000..549831cd --- /dev/null +++ b/wearable/wear/WearDrawers/.gitignore @@ -0,0 +1,33 @@ +lt application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/ +gen/ + +# Ignore gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ +proguard-project.txt + +# Eclipse files +.project +.classpath +.settings/ + +# Android Studio/IDEA +*.iml +.idea diff --git a/wearable/wear/WearDrawers/Wearable/build.gradle b/wearable/wear/WearDrawers/Wearable/build.gradle new file mode 100644 index 00000000..70841eed --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/build.gradle @@ -0,0 +1,69 @@ + +buildscript { + repositories { + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:2.1.0' + } +} + +apply plugin: 'com.android.application' + + + +dependencies { + + compile 'com.google.android.support:wearable:2.0.0-alpha1' + + provided "com.google.android.wearable:wearable:1.0.0" + + compile 'com.google.android.gms:play-services-wearable:8.4.0' + compile 'com.android.support:support-v13:23.1.1' + compile 'com.google.android.support:wearable:1.4.0' +} + +// The sample build uses multiple directories to +// keep boilerplate and common code separate from +// the main sample code. +List<String> dirs = [ + 'main', // main sample code; look here for the interesting stuff. + 'common', // components that are reused by multiple samples + 'template'] // boilerplate code that is generated by the sample template process + +android { + compileSdkVersion 23 + + buildToolsVersion "23.0.2" + + defaultConfig { + versionCode 1 + versionName "1.0" + + + minSdkVersion 23 + + + + + targetSdkVersion 23 + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } + + sourceSets { + main { + dirs.each { dir -> + java.srcDirs "src/${dir}/java" + res.srcDirs "src/${dir}/res" + } + } + androidTest.setRoot('tests') + androidTest.java.srcDirs = ['tests/src'] + + } +} diff --git a/wearable/wear/WearDrawers/Wearable/src/main/AndroidManifest.xml b/wearable/wear/WearDrawers/Wearable/src/main/AndroidManifest.xml new file mode 100644 index 00000000..3044d190 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/AndroidManifest.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest package="com.example.android.wearable.wear.weardrawers" + xmlns:android="http://schemas.android.com/apk/res/android"> + + <uses-feature android:name="android.hardware.type.watch"/> + <!-- Required for Always-on. --> + <uses-permission android:name="android.permission.WAKE_LOCK" /> + + <application + android:allowBackup="true" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:supportsRtl="true" + android:theme="@android:style/Theme.DeviceDefault"> + + <!--If you want your app to run on pre-22, then set required to false --> + <uses-library android:name="com.google.android.wearable" android:required="false" /> + + <activity + android:name=".MainActivity" + android:label="@string/app_name"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + + <category android:name="android.intent.category.LAUNCHER"/> + </intent-filter> + </activity> + </application> +</manifest> diff --git a/wearable/wear/WearDrawers/Wearable/src/main/java/com/example/android/wearable/wear/weardrawers/MainActivity.java b/wearable/wear/WearDrawers/Wearable/src/main/java/com/example/android/wearable/wear/weardrawers/MainActivity.java new file mode 100644 index 00000000..cd4cd2e9 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/java/com/example/android/wearable/wear/weardrawers/MainActivity.java @@ -0,0 +1,238 @@ +/* +Copyright 2016 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 com.example.android.wearable.wear.weardrawers; + +import android.app.Fragment; +import android.app.FragmentManager; +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.support.wearable.activity.WearableActivity; +import android.support.wearable.view.drawer.WearableActionDrawer; +import android.support.wearable.view.drawer.WearableDrawerLayout; +import android.support.wearable.view.drawer.WearableNavigationDrawer; +import android.util.Log; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.Toast; + +import java.util.ArrayList; + +/** + * Demonstrates use of Navigation and Action Drawers on Android Wear. + */ +public class MainActivity extends WearableActivity implements + WearableActionDrawer.OnMenuItemClickListener { + + private static final String TAG = "MainActivity"; + + private WearableDrawerLayout mWearableDrawerLayout; + private WearableNavigationDrawer mWearableNavigationDrawer; + private WearableActionDrawer mWearableActionDrawer; + + private ArrayList<Planet> mSolarSystem; + private int mSelectedPlanet; + + private PlanetFragment mPlanetFragment; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Log.d(TAG, "onCreate()"); + + setContentView(R.layout.activity_main); + setAmbientEnabled(); + + mSolarSystem = initializeSolarSystem(); + mSelectedPlanet = 0; + + // Initialize content to first planet. + mPlanetFragment = new PlanetFragment(); + Bundle args = new Bundle(); + + int imageId = getResources().getIdentifier(mSolarSystem.get(mSelectedPlanet).getImage(), + "drawable", getPackageName()); + + + args.putInt(PlanetFragment.ARG_PLANET_IMAGE_ID, imageId); + mPlanetFragment.setArguments(args); + FragmentManager fragmentManager = getFragmentManager(); + fragmentManager.beginTransaction().replace(R.id.content_frame, mPlanetFragment).commit(); + + // Main Wearable Drawer Layout that wraps all content + mWearableDrawerLayout = (WearableDrawerLayout) findViewById(R.id.drawer_layout); + + // Top Navigation Drawer + mWearableNavigationDrawer = + (WearableNavigationDrawer) findViewById(R.id.top_navigation_drawer); + mWearableNavigationDrawer.setAdapter(new NavigationAdapter(this)); + // Peeks Navigation drawer on the top. + mWearableDrawerLayout.peekDrawer(Gravity.TOP); + + // Bottom Action Drawer + mWearableActionDrawer = + (WearableActionDrawer) findViewById(R.id.bottom_action_drawer); + // Populate Action Drawer Menu + Menu menu = mWearableActionDrawer.getMenu(); + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.action_drawer_menu, menu); + mWearableActionDrawer.setOnMenuItemClickListener(this); + // Peeks action drawer on the bottom. + mWearableDrawerLayout.peekDrawer(Gravity.BOTTOM); + + /* Action Drawer Tip: If you only have a single action for your Action Drawer, you can use a + * (custom) View to peek on top of the content by calling + * mWearableActionDrawer.setPeekContent(View). Make sure you set a click listener to handle + * a user clicking on your View. + */ + } + + private ArrayList<Planet> initializeSolarSystem() { + ArrayList<Planet> solarSystem = new ArrayList<Planet>(); + String[] planetArrayNames = getResources().getStringArray(R.array.planets_array_names); + + for (int i = 0; i < planetArrayNames.length; i++) { + String planet = planetArrayNames[i]; + int planetResourceId = + getResources().getIdentifier(planet, "array", getPackageName()); + String[] planetInformation = getResources().getStringArray(planetResourceId); + + solarSystem.add(new Planet( + planetInformation[0], // Name + planetInformation[1], // Navigation icon + planetInformation[2], // Image icon + planetInformation[3], // Moons + planetInformation[4], // Volume + planetInformation[5])); // Surface area + } + + return solarSystem; + } + + @Override + public boolean onMenuItemClick(MenuItem menuItem) { + Log.d(TAG, "onMenuItemClick(): " + menuItem); + + final int itemId = menuItem.getItemId(); + + String toastMessage = ""; + + switch (itemId) { + case R.id.menu_planet_name: + toastMessage = mSolarSystem.get(mSelectedPlanet).getName(); + break; + case R.id.menu_number_of_moons: + toastMessage = mSolarSystem.get(mSelectedPlanet).getMoons(); + break; + case R.id.menu_volume: + toastMessage = mSolarSystem.get(mSelectedPlanet).getVolume(); + break; + case R.id.menu_surface_area: + toastMessage = mSolarSystem.get(mSelectedPlanet).getSurfaceArea(); + break; + } + + mWearableDrawerLayout.closeDrawer(mWearableActionDrawer); + + if (toastMessage.length() > 0) { + Toast toast = Toast.makeText( + getApplicationContext(), + toastMessage, + Toast.LENGTH_SHORT); + toast.show(); + return true; + } else { + return false; + } + } + + private final class NavigationAdapter + extends WearableNavigationDrawer.WearableNavigationDrawerAdapter { + + private final Context mContext; + + public NavigationAdapter(Context context) { + mContext = context; + } + + @Override + public int getCount() { + return mSolarSystem.size(); + } + + @Override + public void onItemSelected(int position) { + Log.d(TAG, "WearableNavigationDrawerAdapter.onItemSelected(): " + position); + mSelectedPlanet = position; + + String selectedPlanetImage = mSolarSystem.get(mSelectedPlanet).getImage(); + int drawableId = + getResources().getIdentifier(selectedPlanetImage, "drawable", getPackageName()); + mPlanetFragment.updatePlanet(drawableId); + } + + @Override + public String getItemText(int pos) { + return mSolarSystem.get(pos).getName(); + } + + @Override + public Drawable getItemDrawable(int pos) { + String navigationIcon = mSolarSystem.get(pos).getNavigationIcon(); + + int drawableNavigationIconId = + getResources().getIdentifier(navigationIcon, "drawable", getPackageName()); + + return mContext.getDrawable(drawableNavigationIconId); + } + } + + /** + * Fragment that appears in the "content_frame", just shows the currently selected planet. + */ + public static class PlanetFragment extends Fragment { + public static final String ARG_PLANET_IMAGE_ID = "planet_image_id"; + + private ImageView mImageView; + + public PlanetFragment() { + // Empty constructor required for fragment subclasses + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_planet, container, false); + + mImageView = ((ImageView) rootView.findViewById(R.id.image)); + + int imageIdToLoad = getArguments().getInt(ARG_PLANET_IMAGE_ID); + mImageView.setImageResource(imageIdToLoad); + + return rootView; + } + + public void updatePlanet(int imageId) { + mImageView.setImageResource(imageId); + } + } +}
\ No newline at end of file diff --git a/wearable/wear/WearDrawers/Wearable/src/main/java/com/example/android/wearable/wear/weardrawers/Planet.java b/wearable/wear/WearDrawers/Wearable/src/main/java/com/example/android/wearable/wear/weardrawers/Planet.java new file mode 100644 index 00000000..67960493 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/java/com/example/android/wearable/wear/weardrawers/Planet.java @@ -0,0 +1,69 @@ +/* +Copyright 2016 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 com.example.android.wearable.wear.weardrawers; + +/** + * Represents planet for app. + */ +public class Planet { + + private String name; + private String navigationIcon; + private String image; + private String moons; + private String volume; + private String surfaceArea; + + public Planet( + String name, + String navigationIcon, + String image, + String moons, + String volume, + String surfaceArea) { + + this.name = name; + this.navigationIcon = navigationIcon; + this.image = image; + this.moons = moons; + this.volume = volume; + this.surfaceArea = surfaceArea; + } + + public String getName() { + return name; + } + + public String getNavigationIcon() { + return navigationIcon; + } + + public String getImage() { + return image; + } + + public String getMoons() { + return moons; + } + + public String getVolume() { + return volume; + } + + public String getSurfaceArea() { + return surfaceArea; + } +}
\ No newline at end of file diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/earth.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/earth.png Binary files differnew file mode 100644 index 00000000..13abd77a --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/earth.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_e_white_48dp.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_e_white_48dp.png Binary files differnew file mode 100644 index 00000000..3dc20986 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_e_white_48dp.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_info_outline_black_18dp.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_info_outline_black_18dp.png Binary files differnew file mode 100644 index 00000000..05803bd1 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_info_outline_black_18dp.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_j_white_48dp.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_j_white_48dp.png Binary files differnew file mode 100644 index 00000000..03715893 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_j_white_48dp.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_m_white_48dp.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_m_white_48dp.png Binary files differnew file mode 100644 index 00000000..00b9858c --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_m_white_48dp.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_n_white_48dp.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_n_white_48dp.png Binary files differnew file mode 100644 index 00000000..33eceae3 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_n_white_48dp.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_s_white_48dp.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_s_white_48dp.png Binary files differnew file mode 100644 index 00000000..f767c8d9 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_s_white_48dp.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_u_white_48dp.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_u_white_48dp.png Binary files differnew file mode 100644 index 00000000..a3ba71b0 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_u_white_48dp.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_v_white_48dp.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_v_white_48dp.png Binary files differnew file mode 100644 index 00000000..ddfaffe1 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/ic_v_white_48dp.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/jupiter.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/jupiter.png Binary files differnew file mode 100644 index 00000000..89150257 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/jupiter.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/mars.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/mars.png Binary files differnew file mode 100644 index 00000000..ac7e4f83 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/mars.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/mercury.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/mercury.png Binary files differnew file mode 100644 index 00000000..06329ca6 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/mercury.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/neptune.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/neptune.png Binary files differnew file mode 100644 index 00000000..ce12b372 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/neptune.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/saturn.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/saturn.png Binary files differnew file mode 100644 index 00000000..9f51ca43 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/saturn.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/uranus.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/uranus.png Binary files differnew file mode 100644 index 00000000..0cdf7881 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/uranus.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/venus.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/venus.png Binary files differnew file mode 100644 index 00000000..68fee0ed --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-hdpi/venus.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-mdpi/ic_info_outline_black_18dp.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-mdpi/ic_info_outline_black_18dp.png Binary files differnew file mode 100644 index 00000000..bb6095bd --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-mdpi/ic_info_outline_black_18dp.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-xhdpi/ic_info_outline_black_18dp.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-xhdpi/ic_info_outline_black_18dp.png Binary files differnew file mode 100644 index 00000000..4b5ab06e --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-xhdpi/ic_info_outline_black_18dp.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-xxhdpi/ic_info_outline_black_18dp.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-xxhdpi/ic_info_outline_black_18dp.png Binary files differnew file mode 100644 index 00000000..0b465fc7 --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-xxhdpi/ic_info_outline_black_18dp.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-xxxhdpi/ic_info_outline_black_18dp.png b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-xxxhdpi/ic_info_outline_black_18dp.png Binary files differnew file mode 100644 index 00000000..3847a9fe --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/drawable-xxxhdpi/ic_info_outline_black_18dp.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/layout/activity_main.xml b/wearable/wear/WearDrawers/Wearable/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..48bc3c5c --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/layout/activity_main.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright 2016 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. +--> +<android.support.wearable.view.drawer.WearableDrawerLayout + android:id="@+id/drawer_layout" + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context="com.example.android.wearable.wear.weardrawers.MainActivity" + tools:deviceIds="wear"> + + <FrameLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:id="@+id/content_frame"/> + + <android.support.wearable.view.drawer.WearableNavigationDrawer + android:id="@+id/top_navigation_drawer" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/dark_grey" /> + + <android.support.wearable.view.drawer.WearableActionDrawer + android:id="@+id/bottom_action_drawer" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/grey"/> + +</android.support.wearable.view.drawer.WearableDrawerLayout>
\ No newline at end of file diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/layout/fragment_planet.xml b/wearable/wear/WearDrawers/Wearable/src/main/res/layout/fragment_planet.xml new file mode 100644 index 00000000..6409eb0e --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/layout/fragment_planet.xml @@ -0,0 +1,20 @@ +<!-- + Copyright 2016 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. +--> +<ImageView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/image" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center"/>
\ No newline at end of file diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/menu/action_drawer_menu.xml b/wearable/wear/WearDrawers/Wearable/src/main/res/menu/action_drawer_menu.xml new file mode 100644 index 00000000..86060d2a --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/menu/action_drawer_menu.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright 2016 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. +--> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:id="@+id/menu_planet_name" + android:icon="@drawable/ic_info_outline_black_18dp" + android:title="Planet Name"/> + <item android:id="@+id/menu_number_of_moons" + android:icon="@drawable/ic_info_outline_black_18dp" + android:title="Number of Moons" /> + <item android:id="@+id/menu_volume" + android:icon="@drawable/ic_info_outline_black_18dp" + android:title="Volume" /> + <item android:id="@+id/menu_surface_area" + android:icon="@drawable/ic_info_outline_black_18dp" + android:title="Surface Area" /> +</menu>
\ No newline at end of file diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/mipmap-hdpi/ic_launcher.png b/wearable/wear/WearDrawers/Wearable/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..cde69bcc --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/mipmap-mdpi/ic_launcher.png b/wearable/wear/WearDrawers/Wearable/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..c133a0cb --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/mipmap-xhdpi/ic_launcher.png b/wearable/wear/WearDrawers/Wearable/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..bfa42f0e --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/mipmap-xxhdpi/ic_launcher.png b/wearable/wear/WearDrawers/Wearable/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..324e72cd --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/wearable/wear/WearDrawers/Wearable/src/main/res/values/strings.xml b/wearable/wear/WearDrawers/Wearable/src/main/res/values/strings.xml new file mode 100644 index 00000000..0a0cd87b --- /dev/null +++ b/wearable/wear/WearDrawers/Wearable/src/main/res/values/strings.xml @@ -0,0 +1,114 @@ +<!-- + Copyright 2016 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. +--> +<resources> + <string name="app_name">Wearable Drawer Layout</string> + + <!-- + Reference name for each planet's information array. + --> + <string-array name="planets_array_names"> + <item>mercury</item> + <item>venus</item> + <item>earth</item> + <item>mars</item> + <item>jupiter</item> + <item>saturn</item> + <item>uranus</item> + <item>neptune</item> + </string-array> + + <!-- + Keys for planet array information below: + "Planet Name", + "Navigation icon", + "Drawable for planet" + "Number of Moons", + "Volume" + "Surface Area" + + --> + <string-array name="mercury"> + <item>Mercury</item> + <item>ic_m_white_48dp</item> + <item>mercury</item> + <item>0 Moons</item> + <item>0.056 x Earth</item> + <item>0.147 x Earth</item> + </string-array> + + <string-array name="venus"> + <item>Venus</item> + <item>ic_v_white_48dp</item> + <item>venus</item> + <item>0 Moons</item> + <item>0.857 x Earth</item> + <item>0.902 x Earth</item> + </string-array> + + <string-array name="earth"> + <item>Earth</item> + <item>ic_e_white_48dp</item> + <item>earth</item> + <item>1 moon</item> + <item>1,083,206,916,846 km3</item> + <item>510,064,472 km2</item> + </string-array> + + <string-array name="mars"> + <item>Mars</item> + <item>ic_m_white_48dp</item> + <item>mars</item> + <item>2 Moons</item> + <item>0.151 x Earth</item> + <item>0.283 x Earth</item> + </string-array> + + <string-array name="jupiter"> + <item>Jupiter</item> + <item>ic_j_white_48dp</item> + <item>jupiter</item> + <item>67 Moons</item> + <item>1,321.337 x Earth</item> + <item>120.414 x Earth</item> + </string-array> + + <string-array name="saturn"> + <item>Saturn</item> + <item>ic_s_white_48dp</item> + <item>saturn</item> + <item>62 moons</item> + <item>763.594 x Earth</item> + <item>83.543 x Earth</item> + </string-array> + + <string-array name="uranus"> + <item>Uranus</item> + <item>ic_u_white_48dp</item> + <item>uranus</item> + <item>27 Moons</item> + <item>63.085 x Earth</item> + <item>15.847 x Earth</item> + </string-array> + + <string-array name="neptune"> + <item>Neptune</item> + <item>ic_n_white_48dp</item> + <item>neptune</item> + <item>14 Moons</item> + <item>57.723 x Earth</item> + <item>14.980 x Earth</item> + </string-array> +</resources>
\ No newline at end of file diff --git a/wearable/wear/WearDrawers/build.gradle b/wearable/wear/WearDrawers/build.gradle new file mode 100644 index 00000000..b95a8604 --- /dev/null +++ b/wearable/wear/WearDrawers/build.gradle @@ -0,0 +1,12 @@ + + +// BEGIN_EXCLUDE +import com.example.android.samples.build.SampleGenPlugin +apply plugin: SampleGenPlugin + +samplegen { + pathToBuild "../../../../../build" + pathToSamplesCommon "../../../common" +} +apply from: "../../../../../build/build.gradle" +// END_EXCLUDE diff --git a/wearable/wear/WearDrawers/buildSrc/build.gradle b/wearable/wear/WearDrawers/buildSrc/build.gradle new file mode 100644 index 00000000..7c150e4b --- /dev/null +++ b/wearable/wear/WearDrawers/buildSrc/build.gradle @@ -0,0 +1,16 @@ + +repositories { + jcenter() +} +dependencies { + compile 'org.freemarker:freemarker:2.3.20' +} + +sourceSets { + main { + groovy { + srcDir new File(rootDir, "../../../../../../build/buildSrc/src/main/groovy") + } + } +} + diff --git a/wearable/wear/WearDrawers/gradle/wrapper/gradle-wrapper.jar b/wearable/wear/WearDrawers/gradle/wrapper/gradle-wrapper.jar Binary files differnew file mode 100644 index 00000000..8c0fb64a --- /dev/null +++ b/wearable/wear/WearDrawers/gradle/wrapper/gradle-wrapper.jar diff --git a/wearable/wear/WearDrawers/gradle/wrapper/gradle-wrapper.properties b/wearable/wear/WearDrawers/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..be74612d --- /dev/null +++ b/wearable/wear/WearDrawers/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri May 13 11:06:21 PDT 2016 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip diff --git a/wearable/wear/WearDrawers/gradlew b/wearable/wear/WearDrawers/gradlew new file mode 100755 index 00000000..91a7e269 --- /dev/null +++ b/wearable/wear/WearDrawers/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/wearable/wear/WearDrawers/gradlew.bat b/wearable/wear/WearDrawers/gradlew.bat new file mode 100644 index 00000000..aec99730 --- /dev/null +++ b/wearable/wear/WearDrawers/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/wearable/wear/WearDrawers/settings.gradle b/wearable/wear/WearDrawers/settings.gradle new file mode 100644 index 00000000..9c2651c7 --- /dev/null +++ b/wearable/wear/WearDrawers/settings.gradle @@ -0,0 +1,2 @@ + +include ':Wearable' diff --git a/wearable/wear/WearDrawers/template-params.xml b/wearable/wear/WearDrawers/template-params.xml new file mode 100644 index 00000000..2869980a --- /dev/null +++ b/wearable/wear/WearDrawers/template-params.xml @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright 2013 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. +--> + +<sample> + <name>WearDrawers</name> + <group>Wearable</group> + <package>com.example.android.wearable.wear.weardrawers</package> + + <minSdkVersionWear>23</minSdkVersionWear>minSdkVersionWear> + <targetSdkVersion>23</targetSdkVersion> + <targetSdkVersionWear>23</targetSdkVersionWear> + + + <provided_dependency_wearable>com.google.android.wearable:wearable:1.0.0</provided_dependency_wearable> + <dependency_wearable>com.google.android.support:wearable:2.0.0-alpha1</dependency_wearable> + + + + <strings> + <intro> + <![CDATA[ + Demonstrates the use of the Navigation and Action Drawers for Wear. + ]]> + </intro> + </strings> + + <template src="base-build" /> + <template src="Wear" /> + + <metadata> + <!-- Values: {DRAFT | PUBLISHED | INTERNAL | DEPRECATED | SUPERCEDED} --> + <status>DRAFT</status> + <!-- See http://go/sample-categories for details on the next 4 fields. --> + <!-- Most samples just need to udpate the Categories field. This is a comma- + seperated list of topic tags. Unlike the old category system, samples + may have multiple categories, so feel free to add extras. Try to avoid + simply tagging everything with "UI". :)--> + <categories>Wearable</categories> + <technologies>Android</technologies> + <languages>Java</languages> + <solutions>Mobile</solutions> + <level>INTERMEDIATE</level> + <!-- TODO: Dimensions: 512x512, PNG fomrat --> + <icon>screenshots/icon-web.png</icon> + <!-- TODOD: Path to screenshots. Use <img> tags for each. --> + <screenshots> + <img>screenshots/1-main.png</img> + <img>screenshots/2-settings.png</img> + </screenshots> + <api_refs> + <android>android.support.wearable.activity.WearableActivity</android> + </api_refs> + + <!-- 1-3 line description of the sample here. + + Avoid simply rearranging the sample's title. What does this sample actually + accomplish, and how does it do it? --> + <description> + A basic sample that shows you how to use Navigation and Action Drawers for Wearables. + </description> + + <!-- TODO: Fill out --> + <intro> + Long intro here. + + Multi-paragraph introduction to sample, from an educational point-of-view. + *Markdown* formatting allowed. See [Markdown Documentation][1] + for details. + + [1]: http://daringfireball.net/projects/markdown/syntax + </intro> + </metadata> +</sample> |