diff --git a/samples/browseable/ActionBarCompat-Basic/AndroidManifest.xml b/samples/browseable/ActionBarCompat-Basic/AndroidManifest.xml
index 332c055be..2e19220d2 100644
--- a/samples/browseable/ActionBarCompat-Basic/AndroidManifest.xml
+++ b/samples/browseable/ActionBarCompat-Basic/AndroidManifest.xml
@@ -21,9 +21,7 @@
android:versionName="1.0">
-
The activity in this sample extends from -{@link android.support.v7.app.ActionBarActivity}, which provides the -functionality necessary to display a compatible action bar on devices -running Android 2.1 and higher.
++ + This sample shows you how to use ActionBarCompat to create a basic Activity which + displays action items. It covers inflating items from a menu resource, as well as adding + an item in code. Items that are not shown as action items on the Action Bar are + displayed in the action bar overflow. + +
diff --git a/samples/browseable/ActionBarCompat-Basic/res/values-v21/template-styles.xml b/samples/browseable/ActionBarCompat-Basic/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/ActionBarCompat-Basic/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +The activity in this sample extends from -{@link android.support.v7.app.ActionBarActivity}, which provides the -functionality necessary to display a compatible action bar on devices -running Android 2.1 and higher.
++ + This sample shows you how to use {@link android.support.v7.widget.PopupMenu PopupMenu} + from ActionBarCompat to create a list, with each item having a dropdown menu. + +
diff --git a/samples/browseable/ActionBarCompat-ListPopupMenu/res/values-v21/template-styles.xml b/samples/browseable/ActionBarCompat-ListPopupMenu/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/ActionBarCompat-ListPopupMenu/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +The activity in this sample extends from -{@link android.support.v7.app.ActionBarActivity}, which provides the -functionality necessary to display a compatible action bar on devices -running Android 2.1 and higher.
++ + This sample shows you how a provide a context-sensitive ShareActionProvider with + ActionBarCompat, backwards compatible to API v7. + +
diff --git a/samples/browseable/ActionBarCompat-ShareActionProvider/res/values-v21/template-styles.xml b/samples/browseable/ActionBarCompat-ShareActionProvider/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/ActionBarCompat-ShareActionProvider/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +To learn more about using Android's custom testing framework, see -Testing Your -Android Activity.
++ + This sample provides a basic example of using an InstrumentationTest to probe the + internal state of an Activity. + +
diff --git a/samples/browseable/ActivityInstrumentation/res/values-v21/template-styles.xml b/samples/browseable/ActivityInstrumentation/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/ActivityInstrumentation/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +-Android 4.4 introduces a way for you to provide a more immersive screen -experience in your app by letting users show or hide the status bar and -the navigation bar with a swipe. -
- --This sample demonstrates how this feature interacts with some of the other -UI flags related to full-screen apps. The sample also shows how to implement a -"sticky" mode, which re-hides the bars a few seconds after the user swipes -them back in. -
\ No newline at end of file + + \n\n\n\"Immersive Mode\", added in Android 4.4, improves the \"hide full screen\" and + \"hide nav bar\" modes, by letting users swipe the bars in and out. This sample + lets the user experiment with immersive mode by seeing how it interacts + with some of the other UI flags related to full-screen apps. + + diff --git a/samples/browseable/AdvancedImmersiveMode/res/values-v21/template-styles.xml b/samples/browseable/AdvancedImmersiveMode/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/AdvancedImmersiveMode/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +To learn how to make the most of the accessibility features built into -the Android framework, see -Implementing Accessibility.
++ + This sample demonstrates how to create an accessible application, using a mix of different widgets demonstrating different ways of adding accessibility markup to a UI. + +
diff --git a/samples/browseable/BasicAccessibility/res/values-v21/template-styles.xml b/samples/browseable/BasicAccessibility/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/BasicAccessibility/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +To see this in action, run the sample application and click:
-+ + Welcome to the Basic Android Key Store sample!\n\n + This sample demonstrates how to use the Android Key Store to safely create and store + encryption keys that only your application can access. You can also sign data + using those keys.\n\n + To create a new KeyPair, click \"Create\".\n\n + To sign some data using a KeyPair, click \"Sign\".\n\n + To verify the data using the signature provided, click \"Verify\".\n\n +
diff --git a/samples/browseable/BasicAndroidKeyStore/res/values-v21/template-styles.xml b/samples/browseable/BasicAndroidKeyStore/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/BasicAndroidKeyStore/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +The sample sends consolidated query strings to the -{@link android.provider.ContactsContract.Data} table to match both contact -names and phone numbers. This approach helps to reduce the number of -queries needed when searching the contacts database.
++ + This sample demonstrates how to use the Contactables table to search for contacts. + \n\nQuery strings sent to the Contactables table will match both contact names and phone numbers, + reducing the number of queries your application needs to use when searching the contacts database! + +
diff --git a/samples/browseable/BasicContactables/res/values-v21/template-styles.xml b/samples/browseable/BasicContactables/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/BasicContactables/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +To learn more about detecting basic touch gestures such as scrolling, -flinging, and double-tapping, see -Detecting Common Gestures.
++ + Welcome to Basic Gesture Detect! + In order to try this sample out, try dragging or tapping this text to see what happens! + +
diff --git a/samples/browseable/BasicGestureDetect/res/values-v21/template-styles.xml b/samples/browseable/BasicGestureDetect/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/BasicGestureDetect/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +This sample demonstrates how to enable and disable this feature -programmatically.
++ + \"Immersive Mode\" is a new UI mode which improves \"hide full screen\" and + \"hide nav bar\" modes, by letting users swipe the bars in and out. This sample + demonstrates how to enable and disable immersive mode programmatically. + +
diff --git a/samples/browseable/BasicImmersiveMode/res/values-v21/template-styles.xml b/samples/browseable/BasicImmersiveMode/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/BasicImmersiveMode/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + ++ + This activity uses a TextureView to render the frames of a video decoded using the + MediaCodec API. + +
diff --git a/samples/browseable/BasicMediaDecoder/res/values-v21/template-styles.xml b/samples/browseable/BasicMediaDecoder/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/BasicMediaDecoder/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +To see this in action, run the sample and use the -Media Route Action Item in the action bar to select an -output device. If your device supports Miracast wireless displays, you may -need to enable Wireless Display functionality in the -system settings.
-You can also enable secondary screen simulation from the -Developer options in the system Settings. Once -connected, use the Change Color button to change the -background color of the secondary screen.
++ + This sample demonstrates the use of the MediaRouter API to display + content on a secondary display.\n\nUse the "Media Route Action Item" in the ActionBar + to select an output device. If your device supports Miracast wireless displays, + you may need to enable "Wireless Display" functionality in the system settings. + Secondary screen simulation can also be enabled from the "Developer Options".\n\n +Once connected, use the "Change Color" button to change the background color of the secondary screen. + +
diff --git a/samples/browseable/BasicMediaRouter/res/values-v21/template-styles.xml b/samples/browseable/BasicMediaRouter/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/BasicMediaRouter/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +To see this in action, run the sample and touch the screen with multiple -fingers to show that the pointer id (also represented by a colour) does not -change as new touch events are received.
++ +This samples demonstrates the use of MotionEvent properties to keep track of individual touches +across multiple touch events. +\n\nTouch the screen with multiple fingers to show that the pointer id +(also represented by a colour) does not change as new touch events are received.
This sample demonstrates how to use the -{@link android.net.ConnectivityManager} to determine if the device has an -active network connection, and if so, retrieve the connection type.
++ + This sample demonstrates how to use the ConnectivityManager to determine if you have + a network connection, and if so, what type of connection it is. + \n\nA "NetworkInfo" object is retrieved from the ConnectivityManager, which contains information + on the active connection, and then the connection type is printed to an on-screen console. + +
diff --git a/samples/browseable/BasicNetworking/res/values-v21/template-styles.xml b/samples/browseable/BasicNetworking/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/BasicNetworking/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + ++ + This sample demonstrates how to display events in the system\'s notification bar. The + NotificationCompat API is used for compatibility with older devices, running Android + 2.2 (Froyo) or newer. + +
diff --git a/samples/browseable/BasicNotifications/res/values-v21/template-styles.xml b/samples/browseable/BasicNotifications/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/BasicNotifications/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +This sample demonstrates how to implement a sync adapter to fetch background -data for an app that doesn't require a user-visible account type or two-way -synchronization.
-The sample periodically downloads the feed from the Android Developers Blog and caches the data in a content provider. At runtime, the cached feed data is -displayed inside a {@link android.widget.ListView}.
-To learn more about creating and using sync adapters, see -Transferring Data Using Sync Adapters.
++ + This sample demonstrates using SyncAdapter to fetch background data for an app that + doesn\'t require a user-visible account type or 2-way synchronization. + + \n\nThis sample periodically downloads the feed from the Android Developer Blog and + caches the data in a content provider. At runtime, the cached feed data is displayed + inside a ListView. + +
diff --git a/samples/browseable/BasicSyncAdapter/res/values-v21/template-styles.xml b/samples/browseable/BasicSyncAdapter/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/BasicSyncAdapter/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + ++ + This application allows two Android devices to carry out two-way text chat over + Bluetooth. It demonstrates all the fundamental Bluetooth API capabilites, such as: + (1) Scanning for other Bluetooth devices + (2) Querying the local Bluetooth adapter for paired Bluetooth devices + (3) Establishing RFCOMM channels/sockets + (4) Connecting to a remote device + (5) Transfering data over Bluetooth + +
diff --git a/samples/browseable/BluetoothChat/res/drawable-hdpi/ic_action_device_access_bluetooth_searching.png b/samples/browseable/BluetoothChat/res/drawable-hdpi/ic_action_device_access_bluetooth_searching.png new file mode 100755 index 000000000..fc0491e63 Binary files /dev/null and b/samples/browseable/BluetoothChat/res/drawable-hdpi/ic_action_device_access_bluetooth_searching.png differ diff --git a/samples/browseable/BluetoothChat/res/drawable-hdpi/ic_launcher.png b/samples/browseable/BluetoothChat/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 000000000..092887b72 Binary files /dev/null and b/samples/browseable/BluetoothChat/res/drawable-hdpi/ic_launcher.png differ diff --git a/samples/browseable/DoneBar/res/drawable-xhdpi/sample_dashboard_item_background.9.png b/samples/browseable/BluetoothChat/res/drawable-hdpi/tile.9.png similarity index 100% rename from samples/browseable/DoneBar/res/drawable-xhdpi/sample_dashboard_item_background.9.png rename to samples/browseable/BluetoothChat/res/drawable-hdpi/tile.9.png diff --git a/samples/browseable/BluetoothChat/res/drawable-mdpi/ic_action_device_access_bluetooth_searching.png b/samples/browseable/BluetoothChat/res/drawable-mdpi/ic_action_device_access_bluetooth_searching.png new file mode 100755 index 000000000..d65de0251 Binary files /dev/null and b/samples/browseable/BluetoothChat/res/drawable-mdpi/ic_action_device_access_bluetooth_searching.png differ diff --git a/samples/browseable/BluetoothChat/res/drawable-mdpi/ic_launcher.png b/samples/browseable/BluetoothChat/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 000000000..1c51ccd7c Binary files /dev/null and b/samples/browseable/BluetoothChat/res/drawable-mdpi/ic_launcher.png differ diff --git a/samples/browseable/BluetoothChat/res/drawable-xhdpi/ic_action_device_access_bluetooth_searching.png b/samples/browseable/BluetoothChat/res/drawable-xhdpi/ic_action_device_access_bluetooth_searching.png new file mode 100755 index 000000000..c4b236eea Binary files /dev/null and b/samples/browseable/BluetoothChat/res/drawable-xhdpi/ic_action_device_access_bluetooth_searching.png differ diff --git a/samples/browseable/BluetoothChat/res/drawable-xhdpi/ic_launcher.png b/samples/browseable/BluetoothChat/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 000000000..3fa260b7c Binary files /dev/null and b/samples/browseable/BluetoothChat/res/drawable-xhdpi/ic_launcher.png differ diff --git a/samples/browseable/BluetoothChat/res/drawable-xxhdpi/ic_action_device_access_bluetooth_searching.png b/samples/browseable/BluetoothChat/res/drawable-xxhdpi/ic_action_device_access_bluetooth_searching.png new file mode 100755 index 000000000..de264301c Binary files /dev/null and b/samples/browseable/BluetoothChat/res/drawable-xxhdpi/ic_action_device_access_bluetooth_searching.png differ diff --git a/samples/browseable/BluetoothChat/res/drawable-xxhdpi/ic_launcher.png b/samples/browseable/BluetoothChat/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..6beccf392 Binary files /dev/null and b/samples/browseable/BluetoothChat/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/samples/browseable/BluetoothChat/res/layout-w720dp/activity_main.xml b/samples/browseable/BluetoothChat/res/layout-w720dp/activity_main.xml new file mode 100755 index 000000000..c9a52f621 --- /dev/null +++ b/samples/browseable/BluetoothChat/res/layout-w720dp/activity_main.xml @@ -0,0 +1,73 @@ + +
+ * For devices with displays with a width of 720dp or greater, the sample log is always visible,
+ * on other devices it's visibility is controlled by an item on the Action Bar.
+ */
+public class MainActivity extends SampleActivityBase {
+
+ public static final String TAG = "MainActivity";
+
+ // Whether the Log Fragment is currently shown
+ private boolean mLogShown;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ if (savedInstanceState == null) {
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ BluetoothChatFragment fragment = new BluetoothChatFragment();
+ transaction.replace(R.id.sample_content_fragment, fragment);
+ transaction.commit();
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ MenuItem logToggle = menu.findItem(R.id.menu_toggle_log);
+ logToggle.setVisible(findViewById(R.id.sample_output) instanceof ViewAnimator);
+ logToggle.setTitle(mLogShown ? R.string.sample_hide_log : R.string.sample_show_log);
+
+ return super.onPrepareOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch(item.getItemId()) {
+ case R.id.menu_toggle_log:
+ mLogShown = !mLogShown;
+ ViewAnimator output = (ViewAnimator) findViewById(R.id.sample_output);
+ if (mLogShown) {
+ output.setDisplayedChild(1);
+ } else {
+ output.setDisplayedChild(0);
+ }
+ supportInvalidateOptionsMenu();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ /** Create a chain of targets that will receive log data */
+ @Override
+ public void initializeLogging() {
+ // Wraps Android's native log framework.
+ LogWrapper logWrapper = new LogWrapper();
+ // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
+ Log.setLogNode(logWrapper);
+
+ // Filter strips out everything except the message text.
+ MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
+ logWrapper.setNext(msgFilter);
+
+ // On screen logging via a fragment with a TextView.
+ LogFragment logFragment = (LogFragment) getSupportFragmentManager()
+ .findFragmentById(R.id.log_fragment);
+ msgFilter.setNext(logFragment.getLogView());
+
+ Log.i(TAG, "Ready");
+ }
+}
diff --git a/samples/browseable/AgendaData/Application/src/com.example.android.common/activities/SampleActivityBase.java b/samples/browseable/BluetoothChat/src/com.example.android.common/activities/SampleActivityBase.java
similarity index 100%
rename from samples/browseable/AgendaData/Application/src/com.example.android.common/activities/SampleActivityBase.java
rename to samples/browseable/BluetoothChat/src/com.example.android.common/activities/SampleActivityBase.java
diff --git a/samples/browseable/AgendaData/Application/src/com.example.android.common/logger/Log.java b/samples/browseable/BluetoothChat/src/com.example.android.common/logger/Log.java
similarity index 100%
rename from samples/browseable/AgendaData/Application/src/com.example.android.common/logger/Log.java
rename to samples/browseable/BluetoothChat/src/com.example.android.common/logger/Log.java
diff --git a/samples/browseable/AgendaData/Application/src/com.example.android.common/logger/LogFragment.java b/samples/browseable/BluetoothChat/src/com.example.android.common/logger/LogFragment.java
similarity index 100%
rename from samples/browseable/AgendaData/Application/src/com.example.android.common/logger/LogFragment.java
rename to samples/browseable/BluetoothChat/src/com.example.android.common/logger/LogFragment.java
diff --git a/samples/browseable/AgendaData/Application/src/com.example.android.common/logger/LogNode.java b/samples/browseable/BluetoothChat/src/com.example.android.common/logger/LogNode.java
similarity index 100%
rename from samples/browseable/AgendaData/Application/src/com.example.android.common/logger/LogNode.java
rename to samples/browseable/BluetoothChat/src/com.example.android.common/logger/LogNode.java
diff --git a/samples/browseable/AgendaData/Application/src/com.example.android.common/logger/LogView.java b/samples/browseable/BluetoothChat/src/com.example.android.common/logger/LogView.java
similarity index 100%
rename from samples/browseable/AgendaData/Application/src/com.example.android.common/logger/LogView.java
rename to samples/browseable/BluetoothChat/src/com.example.android.common/logger/LogView.java
diff --git a/samples/browseable/AgendaData/Application/src/com.example.android.common/logger/LogWrapper.java b/samples/browseable/BluetoothChat/src/com.example.android.common/logger/LogWrapper.java
similarity index 100%
rename from samples/browseable/AgendaData/Application/src/com.example.android.common/logger/LogWrapper.java
rename to samples/browseable/BluetoothChat/src/com.example.android.common/logger/LogWrapper.java
diff --git a/samples/browseable/AgendaData/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java b/samples/browseable/BluetoothChat/src/com.example.android.common/logger/MessageOnlyLogFilter.java
similarity index 100%
rename from samples/browseable/AgendaData/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java
rename to samples/browseable/BluetoothChat/src/com.example.android.common/logger/MessageOnlyLogFilter.java
diff --git a/samples/browseable/BluetoothLeGatt/AndroidManifest.xml b/samples/browseable/BluetoothLeGatt/AndroidManifest.xml
index babd6df2d..d3cf25757 100644
--- a/samples/browseable/BluetoothLeGatt/AndroidManifest.xml
+++ b/samples/browseable/BluetoothLeGatt/AndroidManifest.xml
@@ -22,8 +22,8 @@
android:versionCode="1"
android:versionName="1.0">
-
+ + This sample demonstrates the use of borderless buttons, bottom button bars + (OK and Cancel) and dividers to establish visual structure. + +
diff --git a/samples/browseable/BorderlessButtons/res/values-v21/template-styles.xml b/samples/browseable/BorderlessButtons/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/BorderlessButtons/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +- This sample demonstrates how to emulate an NFC card, using the Host Card Emulation - feature added in Android 4.4. This sample makes the device appear as a - loyalty card whenever the screen is on and the user taps their device on an - appropriately configured NFC reader. -
+ + This sample demonstrates how to emulate an NFC card, using the "host card emulation" + feature added in Android 4.4. This sample makes the device appear as a loyalty card + whenever the screen is on and the user taps their device on an appropriately configured + NFC reader. -- The CardReader sample - can be used to read the loyalty card implemented in this sample. -
+ The "CardReader" sample can be used to read the loyalty card implemented in this sample. + + diff --git a/samples/browseable/CardEmulation/res/values-v21/template-styles.xml b/samples/browseable/CardEmulation/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/CardEmulation/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +- This sample demonstrates how to implement a low-level NFC card reader, for - reading cards that do not contain NDEF or Android Beam data. This sample is - designed to read the virtual loyalty card implemented in the CardEmulation sample. -
+ + This sample demonstrates how to implement a low-level NFC card reader, for reading cards + that do not contain NDEF or Android Beam data. This sample is designed to read the virtual + loyalty card implemented in the "CardEmulation" sample.\n\n -- In particular, this sample demonstrates how to disable Android Beam, select - which AIDs the reader is interested in, and establish communication with the - card. See Host-based - Card Emulation for more information on the HCE APIs. -
+ In particular, this sample demonstrates how to disable Android Beam, select which AIDs the + reader is interested, and establish communication with the card + + diff --git a/samples/browseable/CardReader/res/values-v21/template-styles.xml b/samples/browseable/CardReader/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/CardReader/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + ++ + This sample demonstrates how to create custom checkable layouts, for use with ListView\'s choiceMode + attribute. + +
diff --git a/samples/browseable/CustomChoiceList/res/values-v21/template-styles.xml b/samples/browseable/CustomChoiceList/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/CustomChoiceList/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + ++ + This sample demonstrates notifications with custom content views. + +
diff --git a/samples/browseable/CustomNotifications/res/values-v21/template-styles.xml b/samples/browseable/CustomNotifications/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/CustomNotifications/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + ++ + This sample demonstrates how to create and use a custom Transition. + +
diff --git a/samples/browseable/CustomTransition/res/values-v21/template-styles.xml b/samples/browseable/CustomTransition/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/CustomTransition/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +When this is set as the head of the list, - * an instance of it can function as a drop-in replacement for {@link android.util.Log}. - * Most of the methods in this class server only to map a method call in Log to its equivalent - * in LogNode.
- */ -public class Log { - // Grabbing the native values from Android's native logging facilities, - // to make for easy migration and interop. - public static final int NONE = -1; - public static final int VERBOSE = android.util.Log.VERBOSE; - public static final int DEBUG = android.util.Log.DEBUG; - public static final int INFO = android.util.Log.INFO; - public static final int WARN = android.util.Log.WARN; - public static final int ERROR = android.util.Log.ERROR; - public static final int ASSERT = android.util.Log.ASSERT; - - // Stores the beginning of the LogNode topology. - private static LogNode mLogNode; - - /** - * Returns the next LogNode in the linked list. - */ - public static LogNode getLogNode() { - return mLogNode; - } - - /** - * Sets the LogNode data will be sent to. - */ - public static void setLogNode(LogNode node) { - mLogNode = node; - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void println(int priority, String tag, String msg, Throwable tr) { - if (mLogNode != null) { - mLogNode.println(priority, tag, msg, tr); - } - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - */ - public static void println(int priority, String tag, String msg) { - println(priority, tag, msg, null); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void v(String tag, String msg, Throwable tr) { - println(VERBOSE, tag, msg, tr); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void v(String tag, String msg) { - v(tag, msg, null); - } - - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void d(String tag, String msg, Throwable tr) { - println(DEBUG, tag, msg, tr); - } - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void d(String tag, String msg) { - d(tag, msg, null); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void i(String tag, String msg, Throwable tr) { - println(INFO, tag, msg, tr); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void i(String tag, String msg) { - i(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, String msg, Throwable tr) { - println(WARN, tag, msg, tr); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void w(String tag, String msg) { - w(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, Throwable tr) { - w(tag, null, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void e(String tag, String msg, Throwable tr) { - println(ERROR, tag, msg, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void e(String tag, String msg) { - e(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, String msg, Throwable tr) { - println(ASSERT, tag, msg, tr); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void wtf(String tag, String msg) { - wtf(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, Throwable tr) { - wtf(tag, null, tr); - } -} diff --git a/samples/browseable/DelayedConfirmation/Application/src/com.example.android.common/logger/LogFragment.java b/samples/browseable/DelayedConfirmation/Application/src/com.example.android.common/logger/LogFragment.java deleted file mode 100644 index b302acd4b..000000000 --- a/samples/browseable/DelayedConfirmation/Application/src/com.example.android.common/logger/LogFragment.java +++ /dev/null @@ -1,109 +0,0 @@ -/* -* 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. -*/ -/* - * 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. - */ - -package com.example.android.common.logger; - -import android.graphics.Typeface; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ScrollView; - -/** - * Simple fraggment which contains a LogView and uses is to output log data it receives - * through the LogNode interface. - */ -public class LogFragment extends Fragment { - - private LogView mLogView; - private ScrollView mScrollView; - - public LogFragment() {} - - public View inflateViews() { - mScrollView = new ScrollView(getActivity()); - ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT); - mScrollView.setLayoutParams(scrollParams); - - mLogView = new LogView(getActivity()); - ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); - logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; - mLogView.setLayoutParams(logParams); - mLogView.setClickable(true); - mLogView.setFocusable(true); - mLogView.setTypeface(Typeface.MONOSPACE); - - // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! - int paddingDips = 16; - double scale = getResources().getDisplayMetrics().density; - int paddingPixels = (int) ((paddingDips * (scale)) + .5); - mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); - mLogView.setCompoundDrawablePadding(paddingPixels); - - mLogView.setGravity(Gravity.BOTTOM); - mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium); - - mScrollView.addView(mLogView); - return mScrollView; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - View result = inflateViews(); - - mLogView.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} - - @Override - public void afterTextChanged(Editable s) { - mScrollView.fullScroll(ScrollView.FOCUS_DOWN); - } - }); - return result; - } - - public LogView getLogView() { - return mLogView; - } -} \ No newline at end of file diff --git a/samples/browseable/DelayedConfirmation/Application/src/com.example.android.common/logger/LogNode.java b/samples/browseable/DelayedConfirmation/Application/src/com.example.android.common/logger/LogNode.java deleted file mode 100644 index bc37cabc0..000000000 --- a/samples/browseable/DelayedConfirmation/Application/src/com.example.android.common/logger/LogNode.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -/** - * Basic interface for a logging system that can output to one or more targets. - * Note that in addition to classes that will output these logs in some format, - * one can also implement this interface over a filter and insert that in the chain, - * such that no targets further down see certain data, or see manipulated forms of the data. - * You could, for instance, write a "ToHtmlLoggerNode" that just converted all the log data - * it received to HTML and sent it along to the next node in the chain, without printing it - * anywhere. - */ -public interface LogNode { - - /** - * Instructs first LogNode in the list to print the log data provided. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public void println(int priority, String tag, String msg, Throwable tr); - -} diff --git a/samples/browseable/DelayedConfirmation/Application/src/com.example.android.common/logger/LogView.java b/samples/browseable/DelayedConfirmation/Application/src/com.example.android.common/logger/LogView.java deleted file mode 100644 index c01542b91..000000000 --- a/samples/browseable/DelayedConfirmation/Application/src/com.example.android.common/logger/LogView.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -import android.app.Activity; -import android.content.Context; -import android.util.*; -import android.widget.TextView; - -/** Simple TextView which is used to output log data received through the LogNode interface. -*/ -public class LogView extends TextView implements LogNode { - - public LogView(Context context) { - super(context); - } - - public LogView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LogView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - /** - * Formats the log data and prints it out to the LogView. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - - - String priorityStr = null; - - // For the purposes of this View, we want to print the priority as readable text. - switch(priority) { - case android.util.Log.VERBOSE: - priorityStr = "VERBOSE"; - break; - case android.util.Log.DEBUG: - priorityStr = "DEBUG"; - break; - case android.util.Log.INFO: - priorityStr = "INFO"; - break; - case android.util.Log.WARN: - priorityStr = "WARN"; - break; - case android.util.Log.ERROR: - priorityStr = "ERROR"; - break; - case android.util.Log.ASSERT: - priorityStr = "ASSERT"; - break; - default: - break; - } - - // Handily, the Log class has a facility for converting a stack trace into a usable string. - String exceptionStr = null; - if (tr != null) { - exceptionStr = android.util.Log.getStackTraceString(tr); - } - - // Take the priority, tag, message, and exception, and concatenate as necessary - // into one usable line of text. - final StringBuilder outputBuilder = new StringBuilder(); - - String delimiter = "\t"; - appendIfNotNull(outputBuilder, priorityStr, delimiter); - appendIfNotNull(outputBuilder, tag, delimiter); - appendIfNotNull(outputBuilder, msg, delimiter); - appendIfNotNull(outputBuilder, exceptionStr, delimiter); - - // In case this was originally called from an AsyncTask or some other off-UI thread, - // make sure the update occurs within the UI thread. - ((Activity) getContext()).runOnUiThread( (new Thread(new Runnable() { - @Override - public void run() { - // Display the text we just generated within the LogView. - appendToLog(outputBuilder.toString()); - } - }))); - - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } - - public LogNode getNext() { - return mNext; - } - - public void setNext(LogNode node) { - mNext = node; - } - - /** Takes a string and adds to it, with a separator, if the bit to be added isn't null. Since - * the logger takes so many arguments that might be null, this method helps cut out some of the - * agonizing tedium of writing the same 3 lines over and over. - * @param source StringBuilder containing the text to append to. - * @param addStr The String to append - * @param delimiter The String to separate the source and appended strings. A tab or comma, - * for instance. - * @return The fully concatenated String as a StringBuilder - */ - private StringBuilder appendIfNotNull(StringBuilder source, String addStr, String delimiter) { - if (addStr != null) { - if (addStr.length() == 0) { - delimiter = ""; - } - - return source.append(addStr).append(delimiter); - } - return source; - } - - // The next LogNode in the chain. - LogNode mNext; - - /** Outputs the string as a new line of log data in the LogView. */ - public void appendToLog(String s) { - append("\n" + s); - } - - -} diff --git a/samples/browseable/DelayedConfirmation/Application/src/com.example.android.common/logger/LogWrapper.java b/samples/browseable/DelayedConfirmation/Application/src/com.example.android.common/logger/LogWrapper.java deleted file mode 100644 index 16a9e7ba2..000000000 --- a/samples/browseable/DelayedConfirmation/Application/src/com.example.android.common/logger/LogWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -import android.util.Log; - -/** - * Helper class which wraps Android's native Log utility in the Logger interface. This way - * normal DDMS output can be one of the many targets receiving and outputting logs simultaneously. - */ -public class LogWrapper implements LogNode { - - // For piping: The next node to receive Log data after this one has done its work. - private LogNode mNext; - - /** - * Returns the next LogNode in the linked list. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - - /** - * Prints data out to the console using Android's native log mechanism. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - // There actually are log methods that don't take a msg parameter. For now, - // if that's the case, just convert null to the empty string and move on. - String useMsg = msg; - if (useMsg == null) { - useMsg = ""; - } - - // If an exeption was provided, convert that exception to a usable string and attach - // it to the end of the msg method. - if (tr != null) { - msg += "\n" + Log.getStackTraceString(tr); - } - - // This is functionally identical to Log.x(tag, useMsg); - // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg) - Log.println(priority, tag, useMsg); - - // If this isn't the last node in the chain, move things along. - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } -} diff --git a/samples/browseable/DelayedConfirmation/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java b/samples/browseable/DelayedConfirmation/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java deleted file mode 100644 index 19967dcd4..000000000 --- a/samples/browseable/DelayedConfirmation/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -/** - * Simple {@link LogNode} filter, removes everything except the message. - * Useful for situations like on-screen log output where you don't want a lot of metadata displayed, - * just easy-to-read message updates as they're happening. - */ -public class MessageOnlyLogFilter implements LogNode { - - LogNode mNext; - - /** - * Takes the "next" LogNode as a parameter, to simplify chaining. - * - * @param next The next LogNode in the pipeline. - */ - public MessageOnlyLogFilter(LogNode next) { - mNext = next; - } - - public MessageOnlyLogFilter() { - } - - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - if (mNext != null) { - getNext().println(Log.NONE, null, msg, null); - } - } - - /** - * Returns the next LogNode in the chain. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - -} diff --git a/samples/browseable/DelayedConfirmation/Application/src/com.example.android.delayedconfirmation/MainActivity.java b/samples/browseable/DelayedConfirmation/Application/src/com.example.android.wearable.delayedconfirmation/MainActivity.java similarity index 98% rename from samples/browseable/DelayedConfirmation/Application/src/com.example.android.delayedconfirmation/MainActivity.java rename to samples/browseable/DelayedConfirmation/Application/src/com.example.android.wearable.delayedconfirmation/MainActivity.java index 6fe681f62..3ffda5374 100644 --- a/samples/browseable/DelayedConfirmation/Application/src/com.example.android.delayedconfirmation/MainActivity.java +++ b/samples/browseable/DelayedConfirmation/Application/src/com.example.android.wearable.delayedconfirmation/MainActivity.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.delayedconfirmation; +package com.example.android.wearable.delayedconfirmation; import android.app.Activity; import android.os.Bundle; diff --git a/samples/browseable/DelayedConfirmation/Wearable/AndroidManifest.xml b/samples/browseable/DelayedConfirmation/Wearable/AndroidManifest.xml index a2200089e..b73af6276 100644 --- a/samples/browseable/DelayedConfirmation/Wearable/AndroidManifest.xml +++ b/samples/browseable/DelayedConfirmation/Wearable/AndroidManifest.xml @@ -15,7 +15,7 @@ -->This is a sample application for the -Displaying -Bitmaps Efficiently Android Training class.
--The sample demonstrates: -
-+ + This sample demonstrates two alternative presentations of the + action bar that are well-suited for simple data entry scenarios. + + In this presentation, a done bar replaces the action + bar entirely, providing two direct actions to persist or dismiss changes. This is + suitable for cases where no additional view details or actions are needed in the + action bar. + +
diff --git a/samples/browseable/DoneBar/res/layout/sample_dashboard_item.xml b/samples/browseable/DoneBar/res/layout/sample_dashboard_item.xml index 38987ee20..516d28989 100644 --- a/samples/browseable/DoneBar/res/layout/sample_dashboard_item.xml +++ b/samples/browseable/DoneBar/res/layout/sample_dashboard_item.xml @@ -14,19 +14,37 @@ limitations under the License. --> -When this is set as the head of the list, - * an instance of it can function as a drop-in replacement for {@link android.util.Log}. - * Most of the methods in this class server only to map a method call in Log to its equivalent - * in LogNode.
- */ -public class Log { - // Grabbing the native values from Android's native logging facilities, - // to make for easy migration and interop. - public static final int NONE = -1; - public static final int VERBOSE = android.util.Log.VERBOSE; - public static final int DEBUG = android.util.Log.DEBUG; - public static final int INFO = android.util.Log.INFO; - public static final int WARN = android.util.Log.WARN; - public static final int ERROR = android.util.Log.ERROR; - public static final int ASSERT = android.util.Log.ASSERT; - - // Stores the beginning of the LogNode topology. - private static LogNode mLogNode; - - /** - * Returns the next LogNode in the linked list. - */ - public static LogNode getLogNode() { - return mLogNode; - } - - /** - * Sets the LogNode data will be sent to. - */ - public static void setLogNode(LogNode node) { - mLogNode = node; - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void println(int priority, String tag, String msg, Throwable tr) { - if (mLogNode != null) { - mLogNode.println(priority, tag, msg, tr); - } - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - */ - public static void println(int priority, String tag, String msg) { - println(priority, tag, msg, null); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void v(String tag, String msg, Throwable tr) { - println(VERBOSE, tag, msg, tr); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void v(String tag, String msg) { - v(tag, msg, null); - } - - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void d(String tag, String msg, Throwable tr) { - println(DEBUG, tag, msg, tr); - } - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void d(String tag, String msg) { - d(tag, msg, null); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void i(String tag, String msg, Throwable tr) { - println(INFO, tag, msg, tr); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void i(String tag, String msg) { - i(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, String msg, Throwable tr) { - println(WARN, tag, msg, tr); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void w(String tag, String msg) { - w(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, Throwable tr) { - w(tag, null, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void e(String tag, String msg, Throwable tr) { - println(ERROR, tag, msg, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void e(String tag, String msg) { - e(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, String msg, Throwable tr) { - println(ASSERT, tag, msg, tr); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void wtf(String tag, String msg) { - wtf(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, Throwable tr) { - wtf(tag, null, tr); - } -} diff --git a/samples/browseable/ElizaChat/Application/src/com.example.android.common/logger/LogFragment.java b/samples/browseable/ElizaChat/Application/src/com.example.android.common/logger/LogFragment.java deleted file mode 100644 index b302acd4b..000000000 --- a/samples/browseable/ElizaChat/Application/src/com.example.android.common/logger/LogFragment.java +++ /dev/null @@ -1,109 +0,0 @@ -/* -* 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. -*/ -/* - * 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. - */ - -package com.example.android.common.logger; - -import android.graphics.Typeface; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ScrollView; - -/** - * Simple fraggment which contains a LogView and uses is to output log data it receives - * through the LogNode interface. - */ -public class LogFragment extends Fragment { - - private LogView mLogView; - private ScrollView mScrollView; - - public LogFragment() {} - - public View inflateViews() { - mScrollView = new ScrollView(getActivity()); - ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT); - mScrollView.setLayoutParams(scrollParams); - - mLogView = new LogView(getActivity()); - ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); - logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; - mLogView.setLayoutParams(logParams); - mLogView.setClickable(true); - mLogView.setFocusable(true); - mLogView.setTypeface(Typeface.MONOSPACE); - - // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! - int paddingDips = 16; - double scale = getResources().getDisplayMetrics().density; - int paddingPixels = (int) ((paddingDips * (scale)) + .5); - mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); - mLogView.setCompoundDrawablePadding(paddingPixels); - - mLogView.setGravity(Gravity.BOTTOM); - mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium); - - mScrollView.addView(mLogView); - return mScrollView; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - View result = inflateViews(); - - mLogView.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} - - @Override - public void afterTextChanged(Editable s) { - mScrollView.fullScroll(ScrollView.FOCUS_DOWN); - } - }); - return result; - } - - public LogView getLogView() { - return mLogView; - } -} \ No newline at end of file diff --git a/samples/browseable/ElizaChat/Application/src/com.example.android.common/logger/LogNode.java b/samples/browseable/ElizaChat/Application/src/com.example.android.common/logger/LogNode.java deleted file mode 100644 index bc37cabc0..000000000 --- a/samples/browseable/ElizaChat/Application/src/com.example.android.common/logger/LogNode.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -/** - * Basic interface for a logging system that can output to one or more targets. - * Note that in addition to classes that will output these logs in some format, - * one can also implement this interface over a filter and insert that in the chain, - * such that no targets further down see certain data, or see manipulated forms of the data. - * You could, for instance, write a "ToHtmlLoggerNode" that just converted all the log data - * it received to HTML and sent it along to the next node in the chain, without printing it - * anywhere. - */ -public interface LogNode { - - /** - * Instructs first LogNode in the list to print the log data provided. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public void println(int priority, String tag, String msg, Throwable tr); - -} diff --git a/samples/browseable/ElizaChat/Application/src/com.example.android.common/logger/LogView.java b/samples/browseable/ElizaChat/Application/src/com.example.android.common/logger/LogView.java deleted file mode 100644 index c01542b91..000000000 --- a/samples/browseable/ElizaChat/Application/src/com.example.android.common/logger/LogView.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -import android.app.Activity; -import android.content.Context; -import android.util.*; -import android.widget.TextView; - -/** Simple TextView which is used to output log data received through the LogNode interface. -*/ -public class LogView extends TextView implements LogNode { - - public LogView(Context context) { - super(context); - } - - public LogView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LogView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - /** - * Formats the log data and prints it out to the LogView. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - - - String priorityStr = null; - - // For the purposes of this View, we want to print the priority as readable text. - switch(priority) { - case android.util.Log.VERBOSE: - priorityStr = "VERBOSE"; - break; - case android.util.Log.DEBUG: - priorityStr = "DEBUG"; - break; - case android.util.Log.INFO: - priorityStr = "INFO"; - break; - case android.util.Log.WARN: - priorityStr = "WARN"; - break; - case android.util.Log.ERROR: - priorityStr = "ERROR"; - break; - case android.util.Log.ASSERT: - priorityStr = "ASSERT"; - break; - default: - break; - } - - // Handily, the Log class has a facility for converting a stack trace into a usable string. - String exceptionStr = null; - if (tr != null) { - exceptionStr = android.util.Log.getStackTraceString(tr); - } - - // Take the priority, tag, message, and exception, and concatenate as necessary - // into one usable line of text. - final StringBuilder outputBuilder = new StringBuilder(); - - String delimiter = "\t"; - appendIfNotNull(outputBuilder, priorityStr, delimiter); - appendIfNotNull(outputBuilder, tag, delimiter); - appendIfNotNull(outputBuilder, msg, delimiter); - appendIfNotNull(outputBuilder, exceptionStr, delimiter); - - // In case this was originally called from an AsyncTask or some other off-UI thread, - // make sure the update occurs within the UI thread. - ((Activity) getContext()).runOnUiThread( (new Thread(new Runnable() { - @Override - public void run() { - // Display the text we just generated within the LogView. - appendToLog(outputBuilder.toString()); - } - }))); - - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } - - public LogNode getNext() { - return mNext; - } - - public void setNext(LogNode node) { - mNext = node; - } - - /** Takes a string and adds to it, with a separator, if the bit to be added isn't null. Since - * the logger takes so many arguments that might be null, this method helps cut out some of the - * agonizing tedium of writing the same 3 lines over and over. - * @param source StringBuilder containing the text to append to. - * @param addStr The String to append - * @param delimiter The String to separate the source and appended strings. A tab or comma, - * for instance. - * @return The fully concatenated String as a StringBuilder - */ - private StringBuilder appendIfNotNull(StringBuilder source, String addStr, String delimiter) { - if (addStr != null) { - if (addStr.length() == 0) { - delimiter = ""; - } - - return source.append(addStr).append(delimiter); - } - return source; - } - - // The next LogNode in the chain. - LogNode mNext; - - /** Outputs the string as a new line of log data in the LogView. */ - public void appendToLog(String s) { - append("\n" + s); - } - - -} diff --git a/samples/browseable/ElizaChat/Application/src/com.example.android.common/logger/LogWrapper.java b/samples/browseable/ElizaChat/Application/src/com.example.android.common/logger/LogWrapper.java deleted file mode 100644 index 16a9e7ba2..000000000 --- a/samples/browseable/ElizaChat/Application/src/com.example.android.common/logger/LogWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -import android.util.Log; - -/** - * Helper class which wraps Android's native Log utility in the Logger interface. This way - * normal DDMS output can be one of the many targets receiving and outputting logs simultaneously. - */ -public class LogWrapper implements LogNode { - - // For piping: The next node to receive Log data after this one has done its work. - private LogNode mNext; - - /** - * Returns the next LogNode in the linked list. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - - /** - * Prints data out to the console using Android's native log mechanism. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - // There actually are log methods that don't take a msg parameter. For now, - // if that's the case, just convert null to the empty string and move on. - String useMsg = msg; - if (useMsg == null) { - useMsg = ""; - } - - // If an exeption was provided, convert that exception to a usable string and attach - // it to the end of the msg method. - if (tr != null) { - msg += "\n" + Log.getStackTraceString(tr); - } - - // This is functionally identical to Log.x(tag, useMsg); - // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg) - Log.println(priority, tag, useMsg); - - // If this isn't the last node in the chain, move things along. - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } -} diff --git a/samples/browseable/ElizaChat/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java b/samples/browseable/ElizaChat/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java deleted file mode 100644 index 19967dcd4..000000000 --- a/samples/browseable/ElizaChat/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -/** - * Simple {@link LogNode} filter, removes everything except the message. - * Useful for situations like on-screen log output where you don't want a lot of metadata displayed, - * just easy-to-read message updates as they're happening. - */ -public class MessageOnlyLogFilter implements LogNode { - - LogNode mNext; - - /** - * Takes the "next" LogNode as a parameter, to simplify chaining. - * - * @param next The next LogNode in the pipeline. - */ - public MessageOnlyLogFilter(LogNode next) { - mNext = next; - } - - public MessageOnlyLogFilter() { - } - - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - if (mNext != null) { - getNext().println(Log.NONE, null, msg, null); - } - } - - /** - * Returns the next LogNode in the chain. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - -} diff --git a/samples/browseable/ElizaChat/Application/src/com.example.android.elizachat/ElizaResponder.java b/samples/browseable/ElizaChat/Application/src/com.example.android.wearable.elizachat/ElizaResponder.java similarity index 99% rename from samples/browseable/ElizaChat/Application/src/com.example.android.elizachat/ElizaResponder.java rename to samples/browseable/ElizaChat/Application/src/com.example.android.wearable.elizachat/ElizaResponder.java index e87f6debd..e6c054251 100644 --- a/samples/browseable/ElizaChat/Application/src/com.example.android.elizachat/ElizaResponder.java +++ b/samples/browseable/ElizaChat/Application/src/com.example.android.wearable.elizachat/ElizaResponder.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.elizachat; +package com.example.android.wearable.elizachat; import android.text.TextUtils; diff --git a/samples/browseable/ElizaChat/Application/src/com.example.android.elizachat/MainActivity.java b/samples/browseable/ElizaChat/Application/src/com.example.android.wearable.elizachat/MainActivity.java similarity index 95% rename from samples/browseable/ElizaChat/Application/src/com.example.android.elizachat/MainActivity.java rename to samples/browseable/ElizaChat/Application/src/com.example.android.wearable.elizachat/MainActivity.java index 421dcb85a..982e3def5 100644 --- a/samples/browseable/ElizaChat/Application/src/com.example.android.elizachat/MainActivity.java +++ b/samples/browseable/ElizaChat/Application/src/com.example.android.wearable.elizachat/MainActivity.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.elizachat; +package com.example.android.wearable.elizachat; import android.app.Activity; import android.content.BroadcastReceiver; @@ -35,10 +35,10 @@ public class MainActivity extends Activity { public static final String EXTRA_MESSAGE = "message"; - public static final String ACTION_NOTIFY = "com.example.android.elizachat.NOTIFY"; + public static final String ACTION_NOTIFY = "com.example.android.wearable.elizachat.NOTIFY"; public static final String ACTION_GET_CONVERSATION - = "com.example.android.elizachat.CONVERSATION"; + = "com.example.android.wearable.elizachat.CONVERSATION"; private BroadcastReceiver mReceiver; diff --git a/samples/browseable/ElizaChat/Application/src/com.example.android.elizachat/ResponderService.java b/samples/browseable/ElizaChat/Application/src/com.example.android.wearable.elizachat/ResponderService.java similarity index 97% rename from samples/browseable/ElizaChat/Application/src/com.example.android.elizachat/ResponderService.java rename to samples/browseable/ElizaChat/Application/src/com.example.android.wearable.elizachat/ResponderService.java index 6d6cd9ab6..3bef19c6b 100644 --- a/samples/browseable/ElizaChat/Application/src/com.example.android.elizachat/ResponderService.java +++ b/samples/browseable/ElizaChat/Application/src/com.example.android.wearable.elizachat/ResponderService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.elizachat; +package com.example.android.wearable.elizachat; import android.app.Notification; import android.app.PendingIntent; @@ -36,9 +36,9 @@ import android.util.Log; */ public class ResponderService extends Service { - public static final String ACTION_INCOMING = "com.example.android.elizachat.INCOMING"; + public static final String ACTION_INCOMING = "com.example.android.wearable.elizachat.INCOMING"; - public static final String ACTION_RESPONSE = "com.example.android.elizachat.REPLY"; + public static final String ACTION_RESPONSE = "com.example.android.wearable.elizachat.REPLY"; public static final String EXTRA_REPLY = "reply"; diff --git a/samples/browseable/ElizaChat/Shared/AndroidManifest.xml b/samples/browseable/ElizaChat/Shared/AndroidManifest.xml index 9c02d59fc..dfbb0927d 100644 --- a/samples/browseable/ElizaChat/Shared/AndroidManifest.xml +++ b/samples/browseable/ElizaChat/Shared/AndroidManifest.xml @@ -16,7 +16,7 @@ -->When this is set as the head of the list, - * an instance of it can function as a drop-in replacement for {@link android.util.Log}. - * Most of the methods in this class server only to map a method call in Log to its equivalent - * in LogNode.
- */ -public class Log { - // Grabbing the native values from Android's native logging facilities, - // to make for easy migration and interop. - public static final int NONE = -1; - public static final int VERBOSE = android.util.Log.VERBOSE; - public static final int DEBUG = android.util.Log.DEBUG; - public static final int INFO = android.util.Log.INFO; - public static final int WARN = android.util.Log.WARN; - public static final int ERROR = android.util.Log.ERROR; - public static final int ASSERT = android.util.Log.ASSERT; - - // Stores the beginning of the LogNode topology. - private static LogNode mLogNode; - - /** - * Returns the next LogNode in the linked list. - */ - public static LogNode getLogNode() { - return mLogNode; - } - - /** - * Sets the LogNode data will be sent to. - */ - public static void setLogNode(LogNode node) { - mLogNode = node; - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void println(int priority, String tag, String msg, Throwable tr) { - if (mLogNode != null) { - mLogNode.println(priority, tag, msg, tr); - } - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - */ - public static void println(int priority, String tag, String msg) { - println(priority, tag, msg, null); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void v(String tag, String msg, Throwable tr) { - println(VERBOSE, tag, msg, tr); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void v(String tag, String msg) { - v(tag, msg, null); - } - - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void d(String tag, String msg, Throwable tr) { - println(DEBUG, tag, msg, tr); - } - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void d(String tag, String msg) { - d(tag, msg, null); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void i(String tag, String msg, Throwable tr) { - println(INFO, tag, msg, tr); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void i(String tag, String msg) { - i(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, String msg, Throwable tr) { - println(WARN, tag, msg, tr); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void w(String tag, String msg) { - w(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, Throwable tr) { - w(tag, null, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void e(String tag, String msg, Throwable tr) { - println(ERROR, tag, msg, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void e(String tag, String msg) { - e(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, String msg, Throwable tr) { - println(ASSERT, tag, msg, tr); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void wtf(String tag, String msg) { - wtf(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, Throwable tr) { - wtf(tag, null, tr); - } -} diff --git a/samples/browseable/EmbeddedApp/Application/src/com.example.android.common/logger/LogFragment.java b/samples/browseable/EmbeddedApp/Application/src/com.example.android.common/logger/LogFragment.java deleted file mode 100644 index b302acd4b..000000000 --- a/samples/browseable/EmbeddedApp/Application/src/com.example.android.common/logger/LogFragment.java +++ /dev/null @@ -1,109 +0,0 @@ -/* -* 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. -*/ -/* - * 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. - */ - -package com.example.android.common.logger; - -import android.graphics.Typeface; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ScrollView; - -/** - * Simple fraggment which contains a LogView and uses is to output log data it receives - * through the LogNode interface. - */ -public class LogFragment extends Fragment { - - private LogView mLogView; - private ScrollView mScrollView; - - public LogFragment() {} - - public View inflateViews() { - mScrollView = new ScrollView(getActivity()); - ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT); - mScrollView.setLayoutParams(scrollParams); - - mLogView = new LogView(getActivity()); - ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); - logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; - mLogView.setLayoutParams(logParams); - mLogView.setClickable(true); - mLogView.setFocusable(true); - mLogView.setTypeface(Typeface.MONOSPACE); - - // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! - int paddingDips = 16; - double scale = getResources().getDisplayMetrics().density; - int paddingPixels = (int) ((paddingDips * (scale)) + .5); - mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); - mLogView.setCompoundDrawablePadding(paddingPixels); - - mLogView.setGravity(Gravity.BOTTOM); - mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium); - - mScrollView.addView(mLogView); - return mScrollView; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - View result = inflateViews(); - - mLogView.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} - - @Override - public void afterTextChanged(Editable s) { - mScrollView.fullScroll(ScrollView.FOCUS_DOWN); - } - }); - return result; - } - - public LogView getLogView() { - return mLogView; - } -} \ No newline at end of file diff --git a/samples/browseable/EmbeddedApp/Application/src/com.example.android.common/logger/LogNode.java b/samples/browseable/EmbeddedApp/Application/src/com.example.android.common/logger/LogNode.java deleted file mode 100644 index bc37cabc0..000000000 --- a/samples/browseable/EmbeddedApp/Application/src/com.example.android.common/logger/LogNode.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -/** - * Basic interface for a logging system that can output to one or more targets. - * Note that in addition to classes that will output these logs in some format, - * one can also implement this interface over a filter and insert that in the chain, - * such that no targets further down see certain data, or see manipulated forms of the data. - * You could, for instance, write a "ToHtmlLoggerNode" that just converted all the log data - * it received to HTML and sent it along to the next node in the chain, without printing it - * anywhere. - */ -public interface LogNode { - - /** - * Instructs first LogNode in the list to print the log data provided. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public void println(int priority, String tag, String msg, Throwable tr); - -} diff --git a/samples/browseable/EmbeddedApp/Application/src/com.example.android.common/logger/LogView.java b/samples/browseable/EmbeddedApp/Application/src/com.example.android.common/logger/LogView.java deleted file mode 100644 index c01542b91..000000000 --- a/samples/browseable/EmbeddedApp/Application/src/com.example.android.common/logger/LogView.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -import android.app.Activity; -import android.content.Context; -import android.util.*; -import android.widget.TextView; - -/** Simple TextView which is used to output log data received through the LogNode interface. -*/ -public class LogView extends TextView implements LogNode { - - public LogView(Context context) { - super(context); - } - - public LogView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LogView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - /** - * Formats the log data and prints it out to the LogView. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - - - String priorityStr = null; - - // For the purposes of this View, we want to print the priority as readable text. - switch(priority) { - case android.util.Log.VERBOSE: - priorityStr = "VERBOSE"; - break; - case android.util.Log.DEBUG: - priorityStr = "DEBUG"; - break; - case android.util.Log.INFO: - priorityStr = "INFO"; - break; - case android.util.Log.WARN: - priorityStr = "WARN"; - break; - case android.util.Log.ERROR: - priorityStr = "ERROR"; - break; - case android.util.Log.ASSERT: - priorityStr = "ASSERT"; - break; - default: - break; - } - - // Handily, the Log class has a facility for converting a stack trace into a usable string. - String exceptionStr = null; - if (tr != null) { - exceptionStr = android.util.Log.getStackTraceString(tr); - } - - // Take the priority, tag, message, and exception, and concatenate as necessary - // into one usable line of text. - final StringBuilder outputBuilder = new StringBuilder(); - - String delimiter = "\t"; - appendIfNotNull(outputBuilder, priorityStr, delimiter); - appendIfNotNull(outputBuilder, tag, delimiter); - appendIfNotNull(outputBuilder, msg, delimiter); - appendIfNotNull(outputBuilder, exceptionStr, delimiter); - - // In case this was originally called from an AsyncTask or some other off-UI thread, - // make sure the update occurs within the UI thread. - ((Activity) getContext()).runOnUiThread( (new Thread(new Runnable() { - @Override - public void run() { - // Display the text we just generated within the LogView. - appendToLog(outputBuilder.toString()); - } - }))); - - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } - - public LogNode getNext() { - return mNext; - } - - public void setNext(LogNode node) { - mNext = node; - } - - /** Takes a string and adds to it, with a separator, if the bit to be added isn't null. Since - * the logger takes so many arguments that might be null, this method helps cut out some of the - * agonizing tedium of writing the same 3 lines over and over. - * @param source StringBuilder containing the text to append to. - * @param addStr The String to append - * @param delimiter The String to separate the source and appended strings. A tab or comma, - * for instance. - * @return The fully concatenated String as a StringBuilder - */ - private StringBuilder appendIfNotNull(StringBuilder source, String addStr, String delimiter) { - if (addStr != null) { - if (addStr.length() == 0) { - delimiter = ""; - } - - return source.append(addStr).append(delimiter); - } - return source; - } - - // The next LogNode in the chain. - LogNode mNext; - - /** Outputs the string as a new line of log data in the LogView. */ - public void appendToLog(String s) { - append("\n" + s); - } - - -} diff --git a/samples/browseable/EmbeddedApp/Application/src/com.example.android.common/logger/LogWrapper.java b/samples/browseable/EmbeddedApp/Application/src/com.example.android.common/logger/LogWrapper.java deleted file mode 100644 index 16a9e7ba2..000000000 --- a/samples/browseable/EmbeddedApp/Application/src/com.example.android.common/logger/LogWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -import android.util.Log; - -/** - * Helper class which wraps Android's native Log utility in the Logger interface. This way - * normal DDMS output can be one of the many targets receiving and outputting logs simultaneously. - */ -public class LogWrapper implements LogNode { - - // For piping: The next node to receive Log data after this one has done its work. - private LogNode mNext; - - /** - * Returns the next LogNode in the linked list. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - - /** - * Prints data out to the console using Android's native log mechanism. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - // There actually are log methods that don't take a msg parameter. For now, - // if that's the case, just convert null to the empty string and move on. - String useMsg = msg; - if (useMsg == null) { - useMsg = ""; - } - - // If an exeption was provided, convert that exception to a usable string and attach - // it to the end of the msg method. - if (tr != null) { - msg += "\n" + Log.getStackTraceString(tr); - } - - // This is functionally identical to Log.x(tag, useMsg); - // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg) - Log.println(priority, tag, useMsg); - - // If this isn't the last node in the chain, move things along. - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } -} diff --git a/samples/browseable/EmbeddedApp/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java b/samples/browseable/EmbeddedApp/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java deleted file mode 100644 index 19967dcd4..000000000 --- a/samples/browseable/EmbeddedApp/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -/** - * Simple {@link LogNode} filter, removes everything except the message. - * Useful for situations like on-screen log output where you don't want a lot of metadata displayed, - * just easy-to-read message updates as they're happening. - */ -public class MessageOnlyLogFilter implements LogNode { - - LogNode mNext; - - /** - * Takes the "next" LogNode as a parameter, to simplify chaining. - * - * @param next The next LogNode in the pipeline. - */ - public MessageOnlyLogFilter(LogNode next) { - mNext = next; - } - - public MessageOnlyLogFilter() { - } - - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - if (mNext != null) { - getNext().println(Log.NONE, null, msg, null); - } - } - - /** - * Returns the next LogNode in the chain. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - -} diff --git a/samples/browseable/EmbeddedApp/Application/src/com.example.android.embeddedapp/PhoneActivity.java b/samples/browseable/EmbeddedApp/Application/src/com.example.android.wearable.embeddedapp/PhoneActivity.java similarity index 94% rename from samples/browseable/EmbeddedApp/Application/src/com.example.android.embeddedapp/PhoneActivity.java rename to samples/browseable/EmbeddedApp/Application/src/com.example.android.wearable.embeddedapp/PhoneActivity.java index de95938ce..5a2f5ca3a 100644 --- a/samples/browseable/EmbeddedApp/Application/src/com.example.android.embeddedapp/PhoneActivity.java +++ b/samples/browseable/EmbeddedApp/Application/src/com.example.android.wearable.embeddedapp/PhoneActivity.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.embeddedapp; +package com.example.android.wearable.embeddedapp; import android.app.Activity; import android.os.Bundle; diff --git a/samples/browseable/EmbeddedApp/Shared/AndroidManifest.xml b/samples/browseable/EmbeddedApp/Shared/AndroidManifest.xml deleted file mode 100644 index f026bc505..000000000 --- a/samples/browseable/EmbeddedApp/Shared/AndroidManifest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - -When this is set as the head of the list, - * an instance of it can function as a drop-in replacement for {@link android.util.Log}. - * Most of the methods in this class server only to map a method call in Log to its equivalent - * in LogNode.
- */ -public class Log { - // Grabbing the native values from Android's native logging facilities, - // to make for easy migration and interop. - public static final int NONE = -1; - public static final int VERBOSE = android.util.Log.VERBOSE; - public static final int DEBUG = android.util.Log.DEBUG; - public static final int INFO = android.util.Log.INFO; - public static final int WARN = android.util.Log.WARN; - public static final int ERROR = android.util.Log.ERROR; - public static final int ASSERT = android.util.Log.ASSERT; - - // Stores the beginning of the LogNode topology. - private static LogNode mLogNode; - - /** - * Returns the next LogNode in the linked list. - */ - public static LogNode getLogNode() { - return mLogNode; - } - - /** - * Sets the LogNode data will be sent to. - */ - public static void setLogNode(LogNode node) { - mLogNode = node; - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void println(int priority, String tag, String msg, Throwable tr) { - if (mLogNode != null) { - mLogNode.println(priority, tag, msg, tr); - } - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - */ - public static void println(int priority, String tag, String msg) { - println(priority, tag, msg, null); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void v(String tag, String msg, Throwable tr) { - println(VERBOSE, tag, msg, tr); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void v(String tag, String msg) { - v(tag, msg, null); - } - - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void d(String tag, String msg, Throwable tr) { - println(DEBUG, tag, msg, tr); - } - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void d(String tag, String msg) { - d(tag, msg, null); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void i(String tag, String msg, Throwable tr) { - println(INFO, tag, msg, tr); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void i(String tag, String msg) { - i(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, String msg, Throwable tr) { - println(WARN, tag, msg, tr); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void w(String tag, String msg) { - w(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, Throwable tr) { - w(tag, null, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void e(String tag, String msg, Throwable tr) { - println(ERROR, tag, msg, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void e(String tag, String msg) { - e(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, String msg, Throwable tr) { - println(ASSERT, tag, msg, tr); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void wtf(String tag, String msg) { - wtf(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, Throwable tr) { - wtf(tag, null, tr); - } -} diff --git a/samples/browseable/FindMyPhone/Application/src/com.example.android.common/logger/LogFragment.java b/samples/browseable/FindMyPhone/Application/src/com.example.android.common/logger/LogFragment.java deleted file mode 100644 index b302acd4b..000000000 --- a/samples/browseable/FindMyPhone/Application/src/com.example.android.common/logger/LogFragment.java +++ /dev/null @@ -1,109 +0,0 @@ -/* -* 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. -*/ -/* - * 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. - */ - -package com.example.android.common.logger; - -import android.graphics.Typeface; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ScrollView; - -/** - * Simple fraggment which contains a LogView and uses is to output log data it receives - * through the LogNode interface. - */ -public class LogFragment extends Fragment { - - private LogView mLogView; - private ScrollView mScrollView; - - public LogFragment() {} - - public View inflateViews() { - mScrollView = new ScrollView(getActivity()); - ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT); - mScrollView.setLayoutParams(scrollParams); - - mLogView = new LogView(getActivity()); - ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); - logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; - mLogView.setLayoutParams(logParams); - mLogView.setClickable(true); - mLogView.setFocusable(true); - mLogView.setTypeface(Typeface.MONOSPACE); - - // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! - int paddingDips = 16; - double scale = getResources().getDisplayMetrics().density; - int paddingPixels = (int) ((paddingDips * (scale)) + .5); - mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); - mLogView.setCompoundDrawablePadding(paddingPixels); - - mLogView.setGravity(Gravity.BOTTOM); - mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium); - - mScrollView.addView(mLogView); - return mScrollView; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - View result = inflateViews(); - - mLogView.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} - - @Override - public void afterTextChanged(Editable s) { - mScrollView.fullScroll(ScrollView.FOCUS_DOWN); - } - }); - return result; - } - - public LogView getLogView() { - return mLogView; - } -} \ No newline at end of file diff --git a/samples/browseable/FindMyPhone/Application/src/com.example.android.common/logger/LogNode.java b/samples/browseable/FindMyPhone/Application/src/com.example.android.common/logger/LogNode.java deleted file mode 100644 index bc37cabc0..000000000 --- a/samples/browseable/FindMyPhone/Application/src/com.example.android.common/logger/LogNode.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -/** - * Basic interface for a logging system that can output to one or more targets. - * Note that in addition to classes that will output these logs in some format, - * one can also implement this interface over a filter and insert that in the chain, - * such that no targets further down see certain data, or see manipulated forms of the data. - * You could, for instance, write a "ToHtmlLoggerNode" that just converted all the log data - * it received to HTML and sent it along to the next node in the chain, without printing it - * anywhere. - */ -public interface LogNode { - - /** - * Instructs first LogNode in the list to print the log data provided. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public void println(int priority, String tag, String msg, Throwable tr); - -} diff --git a/samples/browseable/FindMyPhone/Application/src/com.example.android.common/logger/LogView.java b/samples/browseable/FindMyPhone/Application/src/com.example.android.common/logger/LogView.java deleted file mode 100644 index c01542b91..000000000 --- a/samples/browseable/FindMyPhone/Application/src/com.example.android.common/logger/LogView.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -import android.app.Activity; -import android.content.Context; -import android.util.*; -import android.widget.TextView; - -/** Simple TextView which is used to output log data received through the LogNode interface. -*/ -public class LogView extends TextView implements LogNode { - - public LogView(Context context) { - super(context); - } - - public LogView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LogView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - /** - * Formats the log data and prints it out to the LogView. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - - - String priorityStr = null; - - // For the purposes of this View, we want to print the priority as readable text. - switch(priority) { - case android.util.Log.VERBOSE: - priorityStr = "VERBOSE"; - break; - case android.util.Log.DEBUG: - priorityStr = "DEBUG"; - break; - case android.util.Log.INFO: - priorityStr = "INFO"; - break; - case android.util.Log.WARN: - priorityStr = "WARN"; - break; - case android.util.Log.ERROR: - priorityStr = "ERROR"; - break; - case android.util.Log.ASSERT: - priorityStr = "ASSERT"; - break; - default: - break; - } - - // Handily, the Log class has a facility for converting a stack trace into a usable string. - String exceptionStr = null; - if (tr != null) { - exceptionStr = android.util.Log.getStackTraceString(tr); - } - - // Take the priority, tag, message, and exception, and concatenate as necessary - // into one usable line of text. - final StringBuilder outputBuilder = new StringBuilder(); - - String delimiter = "\t"; - appendIfNotNull(outputBuilder, priorityStr, delimiter); - appendIfNotNull(outputBuilder, tag, delimiter); - appendIfNotNull(outputBuilder, msg, delimiter); - appendIfNotNull(outputBuilder, exceptionStr, delimiter); - - // In case this was originally called from an AsyncTask or some other off-UI thread, - // make sure the update occurs within the UI thread. - ((Activity) getContext()).runOnUiThread( (new Thread(new Runnable() { - @Override - public void run() { - // Display the text we just generated within the LogView. - appendToLog(outputBuilder.toString()); - } - }))); - - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } - - public LogNode getNext() { - return mNext; - } - - public void setNext(LogNode node) { - mNext = node; - } - - /** Takes a string and adds to it, with a separator, if the bit to be added isn't null. Since - * the logger takes so many arguments that might be null, this method helps cut out some of the - * agonizing tedium of writing the same 3 lines over and over. - * @param source StringBuilder containing the text to append to. - * @param addStr The String to append - * @param delimiter The String to separate the source and appended strings. A tab or comma, - * for instance. - * @return The fully concatenated String as a StringBuilder - */ - private StringBuilder appendIfNotNull(StringBuilder source, String addStr, String delimiter) { - if (addStr != null) { - if (addStr.length() == 0) { - delimiter = ""; - } - - return source.append(addStr).append(delimiter); - } - return source; - } - - // The next LogNode in the chain. - LogNode mNext; - - /** Outputs the string as a new line of log data in the LogView. */ - public void appendToLog(String s) { - append("\n" + s); - } - - -} diff --git a/samples/browseable/FindMyPhone/Application/src/com.example.android.common/logger/LogWrapper.java b/samples/browseable/FindMyPhone/Application/src/com.example.android.common/logger/LogWrapper.java deleted file mode 100644 index 16a9e7ba2..000000000 --- a/samples/browseable/FindMyPhone/Application/src/com.example.android.common/logger/LogWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -import android.util.Log; - -/** - * Helper class which wraps Android's native Log utility in the Logger interface. This way - * normal DDMS output can be one of the many targets receiving and outputting logs simultaneously. - */ -public class LogWrapper implements LogNode { - - // For piping: The next node to receive Log data after this one has done its work. - private LogNode mNext; - - /** - * Returns the next LogNode in the linked list. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - - /** - * Prints data out to the console using Android's native log mechanism. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - // There actually are log methods that don't take a msg parameter. For now, - // if that's the case, just convert null to the empty string and move on. - String useMsg = msg; - if (useMsg == null) { - useMsg = ""; - } - - // If an exeption was provided, convert that exception to a usable string and attach - // it to the end of the msg method. - if (tr != null) { - msg += "\n" + Log.getStackTraceString(tr); - } - - // This is functionally identical to Log.x(tag, useMsg); - // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg) - Log.println(priority, tag, useMsg); - - // If this isn't the last node in the chain, move things along. - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } -} diff --git a/samples/browseable/FindMyPhone/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java b/samples/browseable/FindMyPhone/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java deleted file mode 100644 index 19967dcd4..000000000 --- a/samples/browseable/FindMyPhone/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -/** - * Simple {@link LogNode} filter, removes everything except the message. - * Useful for situations like on-screen log output where you don't want a lot of metadata displayed, - * just easy-to-read message updates as they're happening. - */ -public class MessageOnlyLogFilter implements LogNode { - - LogNode mNext; - - /** - * Takes the "next" LogNode as a parameter, to simplify chaining. - * - * @param next The next LogNode in the pipeline. - */ - public MessageOnlyLogFilter(LogNode next) { - mNext = next; - } - - public MessageOnlyLogFilter() { - } - - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - if (mNext != null) { - getNext().println(Log.NONE, null, msg, null); - } - } - - /** - * Returns the next LogNode in the chain. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - -} diff --git a/samples/browseable/FindMyPhone/Application/src/com.example.android.findphone/SoundAlarmListenerService.java b/samples/browseable/FindMyPhone/Application/src/com.example.android.wearable.findphone/SoundAlarmListenerService.java similarity index 98% rename from samples/browseable/FindMyPhone/Application/src/com.example.android.findphone/SoundAlarmListenerService.java rename to samples/browseable/FindMyPhone/Application/src/com.example.android.wearable.findphone/SoundAlarmListenerService.java index 106a47a22..c89db9d3c 100644 --- a/samples/browseable/FindMyPhone/Application/src/com.example.android.findphone/SoundAlarmListenerService.java +++ b/samples/browseable/FindMyPhone/Application/src/com.example.android.wearable.findphone/SoundAlarmListenerService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.findphone; +package com.example.android.wearable.findphone; import android.media.AudioManager; import android.media.MediaPlayer; diff --git a/samples/browseable/FindMyPhone/Shared/res/values/strings.xml b/samples/browseable/FindMyPhone/Shared/res/values/strings.xml deleted file mode 100644 index 0f2bb9075..000000000 --- a/samples/browseable/FindMyPhone/Shared/res/values/strings.xml +++ /dev/null @@ -1,18 +0,0 @@ - - -+ + This sample demonstrates how to start a transition right after a fragment transaction. + +
diff --git a/samples/browseable/FragmentTransition/res/values-v21/template-styles.xml b/samples/browseable/FragmentTransition/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/FragmentTransition/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +When this is set as the head of the list, - * an instance of it can function as a drop-in replacement for {@link android.util.Log}. - * Most of the methods in this class server only to map a method call in Log to its equivalent - * in LogNode.
- */ -public class Log { - // Grabbing the native values from Android's native logging facilities, - // to make for easy migration and interop. - public static final int NONE = -1; - public static final int VERBOSE = android.util.Log.VERBOSE; - public static final int DEBUG = android.util.Log.DEBUG; - public static final int INFO = android.util.Log.INFO; - public static final int WARN = android.util.Log.WARN; - public static final int ERROR = android.util.Log.ERROR; - public static final int ASSERT = android.util.Log.ASSERT; - - // Stores the beginning of the LogNode topology. - private static LogNode mLogNode; - - /** - * Returns the next LogNode in the linked list. - */ - public static LogNode getLogNode() { - return mLogNode; - } - - /** - * Sets the LogNode data will be sent to. - */ - public static void setLogNode(LogNode node) { - mLogNode = node; - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void println(int priority, String tag, String msg, Throwable tr) { - if (mLogNode != null) { - mLogNode.println(priority, tag, msg, tr); - } - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - */ - public static void println(int priority, String tag, String msg) { - println(priority, tag, msg, null); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void v(String tag, String msg, Throwable tr) { - println(VERBOSE, tag, msg, tr); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void v(String tag, String msg) { - v(tag, msg, null); - } - - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void d(String tag, String msg, Throwable tr) { - println(DEBUG, tag, msg, tr); - } - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void d(String tag, String msg) { - d(tag, msg, null); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void i(String tag, String msg, Throwable tr) { - println(INFO, tag, msg, tr); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void i(String tag, String msg) { - i(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, String msg, Throwable tr) { - println(WARN, tag, msg, tr); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void w(String tag, String msg) { - w(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, Throwable tr) { - w(tag, null, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void e(String tag, String msg, Throwable tr) { - println(ERROR, tag, msg, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void e(String tag, String msg) { - e(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, String msg, Throwable tr) { - println(ASSERT, tag, msg, tr); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void wtf(String tag, String msg) { - wtf(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, Throwable tr) { - wtf(tag, null, tr); - } -} diff --git a/samples/browseable/Geofencing/Application/src/com.example.android.common/logger/LogFragment.java b/samples/browseable/Geofencing/Application/src/com.example.android.common/logger/LogFragment.java deleted file mode 100644 index b302acd4b..000000000 --- a/samples/browseable/Geofencing/Application/src/com.example.android.common/logger/LogFragment.java +++ /dev/null @@ -1,109 +0,0 @@ -/* -* 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. -*/ -/* - * 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. - */ - -package com.example.android.common.logger; - -import android.graphics.Typeface; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ScrollView; - -/** - * Simple fraggment which contains a LogView and uses is to output log data it receives - * through the LogNode interface. - */ -public class LogFragment extends Fragment { - - private LogView mLogView; - private ScrollView mScrollView; - - public LogFragment() {} - - public View inflateViews() { - mScrollView = new ScrollView(getActivity()); - ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT); - mScrollView.setLayoutParams(scrollParams); - - mLogView = new LogView(getActivity()); - ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); - logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; - mLogView.setLayoutParams(logParams); - mLogView.setClickable(true); - mLogView.setFocusable(true); - mLogView.setTypeface(Typeface.MONOSPACE); - - // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! - int paddingDips = 16; - double scale = getResources().getDisplayMetrics().density; - int paddingPixels = (int) ((paddingDips * (scale)) + .5); - mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); - mLogView.setCompoundDrawablePadding(paddingPixels); - - mLogView.setGravity(Gravity.BOTTOM); - mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium); - - mScrollView.addView(mLogView); - return mScrollView; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - View result = inflateViews(); - - mLogView.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} - - @Override - public void afterTextChanged(Editable s) { - mScrollView.fullScroll(ScrollView.FOCUS_DOWN); - } - }); - return result; - } - - public LogView getLogView() { - return mLogView; - } -} \ No newline at end of file diff --git a/samples/browseable/Geofencing/Application/src/com.example.android.common/logger/LogNode.java b/samples/browseable/Geofencing/Application/src/com.example.android.common/logger/LogNode.java deleted file mode 100644 index bc37cabc0..000000000 --- a/samples/browseable/Geofencing/Application/src/com.example.android.common/logger/LogNode.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -/** - * Basic interface for a logging system that can output to one or more targets. - * Note that in addition to classes that will output these logs in some format, - * one can also implement this interface over a filter and insert that in the chain, - * such that no targets further down see certain data, or see manipulated forms of the data. - * You could, for instance, write a "ToHtmlLoggerNode" that just converted all the log data - * it received to HTML and sent it along to the next node in the chain, without printing it - * anywhere. - */ -public interface LogNode { - - /** - * Instructs first LogNode in the list to print the log data provided. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public void println(int priority, String tag, String msg, Throwable tr); - -} diff --git a/samples/browseable/Geofencing/Application/src/com.example.android.common/logger/LogView.java b/samples/browseable/Geofencing/Application/src/com.example.android.common/logger/LogView.java deleted file mode 100644 index c01542b91..000000000 --- a/samples/browseable/Geofencing/Application/src/com.example.android.common/logger/LogView.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -import android.app.Activity; -import android.content.Context; -import android.util.*; -import android.widget.TextView; - -/** Simple TextView which is used to output log data received through the LogNode interface. -*/ -public class LogView extends TextView implements LogNode { - - public LogView(Context context) { - super(context); - } - - public LogView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LogView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - /** - * Formats the log data and prints it out to the LogView. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - - - String priorityStr = null; - - // For the purposes of this View, we want to print the priority as readable text. - switch(priority) { - case android.util.Log.VERBOSE: - priorityStr = "VERBOSE"; - break; - case android.util.Log.DEBUG: - priorityStr = "DEBUG"; - break; - case android.util.Log.INFO: - priorityStr = "INFO"; - break; - case android.util.Log.WARN: - priorityStr = "WARN"; - break; - case android.util.Log.ERROR: - priorityStr = "ERROR"; - break; - case android.util.Log.ASSERT: - priorityStr = "ASSERT"; - break; - default: - break; - } - - // Handily, the Log class has a facility for converting a stack trace into a usable string. - String exceptionStr = null; - if (tr != null) { - exceptionStr = android.util.Log.getStackTraceString(tr); - } - - // Take the priority, tag, message, and exception, and concatenate as necessary - // into one usable line of text. - final StringBuilder outputBuilder = new StringBuilder(); - - String delimiter = "\t"; - appendIfNotNull(outputBuilder, priorityStr, delimiter); - appendIfNotNull(outputBuilder, tag, delimiter); - appendIfNotNull(outputBuilder, msg, delimiter); - appendIfNotNull(outputBuilder, exceptionStr, delimiter); - - // In case this was originally called from an AsyncTask or some other off-UI thread, - // make sure the update occurs within the UI thread. - ((Activity) getContext()).runOnUiThread( (new Thread(new Runnable() { - @Override - public void run() { - // Display the text we just generated within the LogView. - appendToLog(outputBuilder.toString()); - } - }))); - - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } - - public LogNode getNext() { - return mNext; - } - - public void setNext(LogNode node) { - mNext = node; - } - - /** Takes a string and adds to it, with a separator, if the bit to be added isn't null. Since - * the logger takes so many arguments that might be null, this method helps cut out some of the - * agonizing tedium of writing the same 3 lines over and over. - * @param source StringBuilder containing the text to append to. - * @param addStr The String to append - * @param delimiter The String to separate the source and appended strings. A tab or comma, - * for instance. - * @return The fully concatenated String as a StringBuilder - */ - private StringBuilder appendIfNotNull(StringBuilder source, String addStr, String delimiter) { - if (addStr != null) { - if (addStr.length() == 0) { - delimiter = ""; - } - - return source.append(addStr).append(delimiter); - } - return source; - } - - // The next LogNode in the chain. - LogNode mNext; - - /** Outputs the string as a new line of log data in the LogView. */ - public void appendToLog(String s) { - append("\n" + s); - } - - -} diff --git a/samples/browseable/Geofencing/Application/src/com.example.android.common/logger/LogWrapper.java b/samples/browseable/Geofencing/Application/src/com.example.android.common/logger/LogWrapper.java deleted file mode 100644 index 16a9e7ba2..000000000 --- a/samples/browseable/Geofencing/Application/src/com.example.android.common/logger/LogWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -import android.util.Log; - -/** - * Helper class which wraps Android's native Log utility in the Logger interface. This way - * normal DDMS output can be one of the many targets receiving and outputting logs simultaneously. - */ -public class LogWrapper implements LogNode { - - // For piping: The next node to receive Log data after this one has done its work. - private LogNode mNext; - - /** - * Returns the next LogNode in the linked list. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - - /** - * Prints data out to the console using Android's native log mechanism. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - // There actually are log methods that don't take a msg parameter. For now, - // if that's the case, just convert null to the empty string and move on. - String useMsg = msg; - if (useMsg == null) { - useMsg = ""; - } - - // If an exeption was provided, convert that exception to a usable string and attach - // it to the end of the msg method. - if (tr != null) { - msg += "\n" + Log.getStackTraceString(tr); - } - - // This is functionally identical to Log.x(tag, useMsg); - // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg) - Log.println(priority, tag, useMsg); - - // If this isn't the last node in the chain, move things along. - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } -} diff --git a/samples/browseable/Geofencing/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java b/samples/browseable/Geofencing/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java deleted file mode 100644 index 19967dcd4..000000000 --- a/samples/browseable/Geofencing/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -/** - * Simple {@link LogNode} filter, removes everything except the message. - * Useful for situations like on-screen log output where you don't want a lot of metadata displayed, - * just easy-to-read message updates as they're happening. - */ -public class MessageOnlyLogFilter implements LogNode { - - LogNode mNext; - - /** - * Takes the "next" LogNode as a parameter, to simplify chaining. - * - * @param next The next LogNode in the pipeline. - */ - public MessageOnlyLogFilter(LogNode next) { - mNext = next; - } - - public MessageOnlyLogFilter() { - } - - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - if (mNext != null) { - getNext().println(Log.NONE, null, msg, null); - } - } - - /** - * Returns the next LogNode in the chain. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - -} diff --git a/samples/browseable/Geofencing/Application/src/com.example.android.geofencing/Constants.java b/samples/browseable/Geofencing/Application/src/com.example.android.wearable.geofencing/Constants.java similarity index 98% rename from samples/browseable/Geofencing/Application/src/com.example.android.geofencing/Constants.java rename to samples/browseable/Geofencing/Application/src/com.example.android.wearable.geofencing/Constants.java index b90aa3b11..6da9151dc 100644 --- a/samples/browseable/Geofencing/Application/src/com.example.android.geofencing/Constants.java +++ b/samples/browseable/Geofencing/Application/src/com.example.android.wearable.geofencing/Constants.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.geofencing; +package com.example.android.wearable.geofencing; import android.net.Uri; diff --git a/samples/browseable/Geofencing/Application/src/com.example.android.geofencing/GeofenceTransitionsIntentService.java b/samples/browseable/Geofencing/Application/src/com.example.android.wearable.geofencing/GeofenceTransitionsIntentService.java similarity index 91% rename from samples/browseable/Geofencing/Application/src/com.example.android.geofencing/GeofenceTransitionsIntentService.java rename to samples/browseable/Geofencing/Application/src/com.example.android.wearable.geofencing/GeofenceTransitionsIntentService.java index 1af7bc68f..5d1ea48e0 100644 --- a/samples/browseable/Geofencing/Application/src/com.example.android.geofencing/GeofenceTransitionsIntentService.java +++ b/samples/browseable/Geofencing/Application/src/com.example.android.wearable.geofencing/GeofenceTransitionsIntentService.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package com.example.android.geofencing; +package com.example.android.wearable.geofencing; -import static com.example.android.geofencing.Constants.CONNECTION_TIME_OUT_MS; -import static com.example.android.geofencing.Constants.GEOFENCE_DATA_ITEM_PATH; -import static com.example.android.geofencing.Constants.GEOFENCE_DATA_ITEM_URI; -import static com.example.android.geofencing.Constants.KEY_GEOFENCE_ID; -import static com.example.android.geofencing.Constants.TAG; +import static com.example.android.wearable.geofencing.Constants.CONNECTION_TIME_OUT_MS; +import static com.example.android.wearable.geofencing.Constants.GEOFENCE_DATA_ITEM_PATH; +import static com.example.android.wearable.geofencing.Constants.GEOFENCE_DATA_ITEM_URI; +import static com.example.android.wearable.geofencing.Constants.KEY_GEOFENCE_ID; +import static com.example.android.wearable.geofencing.Constants.TAG; import android.app.IntentService; import android.content.Intent; diff --git a/samples/browseable/Geofencing/Application/src/com.example.android.geofencing/MainActivity.java b/samples/browseable/Geofencing/Application/src/com.example.android.wearable.geofencing/MainActivity.java similarity index 89% rename from samples/browseable/Geofencing/Application/src/com.example.android.geofencing/MainActivity.java rename to samples/browseable/Geofencing/Application/src/com.example.android.wearable.geofencing/MainActivity.java index 67dcd077d..baef21755 100644 --- a/samples/browseable/Geofencing/Application/src/com.example.android.geofencing/MainActivity.java +++ b/samples/browseable/Geofencing/Application/src/com.example.android.wearable.geofencing/MainActivity.java @@ -14,19 +14,19 @@ * limitations under the License. */ -package com.example.android.geofencing; +package com.example.android.wearable.geofencing; -import static com.example.android.geofencing.Constants.ANDROID_BUILDING_ID; -import static com.example.android.geofencing.Constants.ANDROID_BUILDING_LATITUDE; -import static com.example.android.geofencing.Constants.ANDROID_BUILDING_LONGITUDE; -import static com.example.android.geofencing.Constants.ANDROID_BUILDING_RADIUS_METERS; -import static com.example.android.geofencing.Constants.CONNECTION_FAILURE_RESOLUTION_REQUEST; -import static com.example.android.geofencing.Constants.GEOFENCE_EXPIRATION_TIME; -import static com.example.android.geofencing.Constants.TAG; -import static com.example.android.geofencing.Constants.YERBA_BUENA_ID; -import static com.example.android.geofencing.Constants.YERBA_BUENA_LATITUDE; -import static com.example.android.geofencing.Constants.YERBA_BUENA_LONGITUDE; -import static com.example.android.geofencing.Constants.YERBA_BUENA_RADIUS_METERS; +import static com.example.android.wearable.geofencing.Constants.ANDROID_BUILDING_ID; +import static com.example.android.wearable.geofencing.Constants.ANDROID_BUILDING_LATITUDE; +import static com.example.android.wearable.geofencing.Constants.ANDROID_BUILDING_LONGITUDE; +import static com.example.android.wearable.geofencing.Constants.ANDROID_BUILDING_RADIUS_METERS; +import static com.example.android.wearable.geofencing.Constants.CONNECTION_FAILURE_RESOLUTION_REQUEST; +import static com.example.android.wearable.geofencing.Constants.GEOFENCE_EXPIRATION_TIME; +import static com.example.android.wearable.geofencing.Constants.TAG; +import static com.example.android.wearable.geofencing.Constants.YERBA_BUENA_ID; +import static com.example.android.wearable.geofencing.Constants.YERBA_BUENA_LATITUDE; +import static com.example.android.wearable.geofencing.Constants.YERBA_BUENA_LONGITUDE; +import static com.example.android.wearable.geofencing.Constants.YERBA_BUENA_RADIUS_METERS; import android.app.Activity; import android.app.PendingIntent; diff --git a/samples/browseable/Geofencing/Application/src/com.example.android.geofencing/SimpleGeofence.java b/samples/browseable/Geofencing/Application/src/com.example.android.wearable.geofencing/SimpleGeofence.java similarity index 98% rename from samples/browseable/Geofencing/Application/src/com.example.android.geofencing/SimpleGeofence.java rename to samples/browseable/Geofencing/Application/src/com.example.android.wearable.geofencing/SimpleGeofence.java index 8e175269d..50f02c371 100644 --- a/samples/browseable/Geofencing/Application/src/com.example.android.geofencing/SimpleGeofence.java +++ b/samples/browseable/Geofencing/Application/src/com.example.android.wearable.geofencing/SimpleGeofence.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.geofencing; +package com.example.android.wearable.geofencing; import com.google.android.gms.location.Geofence; diff --git a/samples/browseable/Geofencing/Application/src/com.example.android.geofencing/SimpleGeofenceStore.java b/samples/browseable/Geofencing/Application/src/com.example.android.wearable.geofencing/SimpleGeofenceStore.java similarity index 86% rename from samples/browseable/Geofencing/Application/src/com.example.android.geofencing/SimpleGeofenceStore.java rename to samples/browseable/Geofencing/Application/src/com.example.android.wearable.geofencing/SimpleGeofenceStore.java index fcdf8f814..47584f5a3 100644 --- a/samples/browseable/Geofencing/Application/src/com.example.android.geofencing/SimpleGeofenceStore.java +++ b/samples/browseable/Geofencing/Application/src/com.example.android.wearable.geofencing/SimpleGeofenceStore.java @@ -14,17 +14,17 @@ * limitations under the License. */ -package com.example.android.geofencing; +package com.example.android.wearable.geofencing; -import static com.example.android.geofencing.Constants.INVALID_FLOAT_VALUE; -import static com.example.android.geofencing.Constants.INVALID_INT_VALUE; -import static com.example.android.geofencing.Constants.INVALID_LONG_VALUE; -import static com.example.android.geofencing.Constants.KEY_EXPIRATION_DURATION; -import static com.example.android.geofencing.Constants.KEY_LATITUDE; -import static com.example.android.geofencing.Constants.KEY_LONGITUDE; -import static com.example.android.geofencing.Constants.KEY_PREFIX; -import static com.example.android.geofencing.Constants.KEY_RADIUS; -import static com.example.android.geofencing.Constants.KEY_TRANSITION_TYPE; +import static com.example.android.wearable.geofencing.Constants.INVALID_FLOAT_VALUE; +import static com.example.android.wearable.geofencing.Constants.INVALID_INT_VALUE; +import static com.example.android.wearable.geofencing.Constants.INVALID_LONG_VALUE; +import static com.example.android.wearable.geofencing.Constants.KEY_EXPIRATION_DURATION; +import static com.example.android.wearable.geofencing.Constants.KEY_LATITUDE; +import static com.example.android.wearable.geofencing.Constants.KEY_LONGITUDE; +import static com.example.android.wearable.geofencing.Constants.KEY_PREFIX; +import static com.example.android.wearable.geofencing.Constants.KEY_RADIUS; +import static com.example.android.wearable.geofencing.Constants.KEY_TRANSITION_TYPE; import android.content.Context; import android.content.SharedPreferences; diff --git a/samples/browseable/Geofencing/Shared/AndroidManifest.xml b/samples/browseable/Geofencing/Shared/AndroidManifest.xml deleted file mode 100644 index 2b60180a8..000000000 --- a/samples/browseable/Geofencing/Shared/AndroidManifest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - -When this is set as the head of the list, - * an instance of it can function as a drop-in replacement for {@link android.util.Log}. - * Most of the methods in this class server only to map a method call in Log to its equivalent - * in LogNode.
- */ -public class Log { - // Grabbing the native values from Android's native logging facilities, - // to make for easy migration and interop. - public static final int NONE = -1; - public static final int VERBOSE = android.util.Log.VERBOSE; - public static final int DEBUG = android.util.Log.DEBUG; - public static final int INFO = android.util.Log.INFO; - public static final int WARN = android.util.Log.WARN; - public static final int ERROR = android.util.Log.ERROR; - public static final int ASSERT = android.util.Log.ASSERT; - - // Stores the beginning of the LogNode topology. - private static LogNode mLogNode; - - /** - * Returns the next LogNode in the linked list. - */ - public static LogNode getLogNode() { - return mLogNode; - } - - /** - * Sets the LogNode data will be sent to. - */ - public static void setLogNode(LogNode node) { - mLogNode = node; - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void println(int priority, String tag, String msg, Throwable tr) { - if (mLogNode != null) { - mLogNode.println(priority, tag, msg, tr); - } - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - */ - public static void println(int priority, String tag, String msg) { - println(priority, tag, msg, null); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void v(String tag, String msg, Throwable tr) { - println(VERBOSE, tag, msg, tr); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void v(String tag, String msg) { - v(tag, msg, null); - } - - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void d(String tag, String msg, Throwable tr) { - println(DEBUG, tag, msg, tr); - } - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void d(String tag, String msg) { - d(tag, msg, null); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void i(String tag, String msg, Throwable tr) { - println(INFO, tag, msg, tr); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void i(String tag, String msg) { - i(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, String msg, Throwable tr) { - println(WARN, tag, msg, tr); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void w(String tag, String msg) { - w(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, Throwable tr) { - w(tag, null, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void e(String tag, String msg, Throwable tr) { - println(ERROR, tag, msg, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void e(String tag, String msg) { - e(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, String msg, Throwable tr) { - println(ASSERT, tag, msg, tr); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void wtf(String tag, String msg) { - wtf(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, Throwable tr) { - wtf(tag, null, tr); - } -} diff --git a/samples/browseable/GridViewPager/Application/src/com.example.android.common/logger/LogFragment.java b/samples/browseable/GridViewPager/Application/src/com.example.android.common/logger/LogFragment.java deleted file mode 100644 index b302acd4b..000000000 --- a/samples/browseable/GridViewPager/Application/src/com.example.android.common/logger/LogFragment.java +++ /dev/null @@ -1,109 +0,0 @@ -/* -* 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. -*/ -/* - * 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. - */ - -package com.example.android.common.logger; - -import android.graphics.Typeface; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ScrollView; - -/** - * Simple fraggment which contains a LogView and uses is to output log data it receives - * through the LogNode interface. - */ -public class LogFragment extends Fragment { - - private LogView mLogView; - private ScrollView mScrollView; - - public LogFragment() {} - - public View inflateViews() { - mScrollView = new ScrollView(getActivity()); - ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT); - mScrollView.setLayoutParams(scrollParams); - - mLogView = new LogView(getActivity()); - ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); - logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; - mLogView.setLayoutParams(logParams); - mLogView.setClickable(true); - mLogView.setFocusable(true); - mLogView.setTypeface(Typeface.MONOSPACE); - - // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! - int paddingDips = 16; - double scale = getResources().getDisplayMetrics().density; - int paddingPixels = (int) ((paddingDips * (scale)) + .5); - mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); - mLogView.setCompoundDrawablePadding(paddingPixels); - - mLogView.setGravity(Gravity.BOTTOM); - mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium); - - mScrollView.addView(mLogView); - return mScrollView; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - View result = inflateViews(); - - mLogView.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} - - @Override - public void afterTextChanged(Editable s) { - mScrollView.fullScroll(ScrollView.FOCUS_DOWN); - } - }); - return result; - } - - public LogView getLogView() { - return mLogView; - } -} \ No newline at end of file diff --git a/samples/browseable/GridViewPager/Application/src/com.example.android.common/logger/LogNode.java b/samples/browseable/GridViewPager/Application/src/com.example.android.common/logger/LogNode.java deleted file mode 100644 index bc37cabc0..000000000 --- a/samples/browseable/GridViewPager/Application/src/com.example.android.common/logger/LogNode.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -/** - * Basic interface for a logging system that can output to one or more targets. - * Note that in addition to classes that will output these logs in some format, - * one can also implement this interface over a filter and insert that in the chain, - * such that no targets further down see certain data, or see manipulated forms of the data. - * You could, for instance, write a "ToHtmlLoggerNode" that just converted all the log data - * it received to HTML and sent it along to the next node in the chain, without printing it - * anywhere. - */ -public interface LogNode { - - /** - * Instructs first LogNode in the list to print the log data provided. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public void println(int priority, String tag, String msg, Throwable tr); - -} diff --git a/samples/browseable/GridViewPager/Application/src/com.example.android.common/logger/LogView.java b/samples/browseable/GridViewPager/Application/src/com.example.android.common/logger/LogView.java deleted file mode 100644 index c01542b91..000000000 --- a/samples/browseable/GridViewPager/Application/src/com.example.android.common/logger/LogView.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -import android.app.Activity; -import android.content.Context; -import android.util.*; -import android.widget.TextView; - -/** Simple TextView which is used to output log data received through the LogNode interface. -*/ -public class LogView extends TextView implements LogNode { - - public LogView(Context context) { - super(context); - } - - public LogView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LogView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - /** - * Formats the log data and prints it out to the LogView. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - - - String priorityStr = null; - - // For the purposes of this View, we want to print the priority as readable text. - switch(priority) { - case android.util.Log.VERBOSE: - priorityStr = "VERBOSE"; - break; - case android.util.Log.DEBUG: - priorityStr = "DEBUG"; - break; - case android.util.Log.INFO: - priorityStr = "INFO"; - break; - case android.util.Log.WARN: - priorityStr = "WARN"; - break; - case android.util.Log.ERROR: - priorityStr = "ERROR"; - break; - case android.util.Log.ASSERT: - priorityStr = "ASSERT"; - break; - default: - break; - } - - // Handily, the Log class has a facility for converting a stack trace into a usable string. - String exceptionStr = null; - if (tr != null) { - exceptionStr = android.util.Log.getStackTraceString(tr); - } - - // Take the priority, tag, message, and exception, and concatenate as necessary - // into one usable line of text. - final StringBuilder outputBuilder = new StringBuilder(); - - String delimiter = "\t"; - appendIfNotNull(outputBuilder, priorityStr, delimiter); - appendIfNotNull(outputBuilder, tag, delimiter); - appendIfNotNull(outputBuilder, msg, delimiter); - appendIfNotNull(outputBuilder, exceptionStr, delimiter); - - // In case this was originally called from an AsyncTask or some other off-UI thread, - // make sure the update occurs within the UI thread. - ((Activity) getContext()).runOnUiThread( (new Thread(new Runnable() { - @Override - public void run() { - // Display the text we just generated within the LogView. - appendToLog(outputBuilder.toString()); - } - }))); - - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } - - public LogNode getNext() { - return mNext; - } - - public void setNext(LogNode node) { - mNext = node; - } - - /** Takes a string and adds to it, with a separator, if the bit to be added isn't null. Since - * the logger takes so many arguments that might be null, this method helps cut out some of the - * agonizing tedium of writing the same 3 lines over and over. - * @param source StringBuilder containing the text to append to. - * @param addStr The String to append - * @param delimiter The String to separate the source and appended strings. A tab or comma, - * for instance. - * @return The fully concatenated String as a StringBuilder - */ - private StringBuilder appendIfNotNull(StringBuilder source, String addStr, String delimiter) { - if (addStr != null) { - if (addStr.length() == 0) { - delimiter = ""; - } - - return source.append(addStr).append(delimiter); - } - return source; - } - - // The next LogNode in the chain. - LogNode mNext; - - /** Outputs the string as a new line of log data in the LogView. */ - public void appendToLog(String s) { - append("\n" + s); - } - - -} diff --git a/samples/browseable/GridViewPager/Application/src/com.example.android.common/logger/LogWrapper.java b/samples/browseable/GridViewPager/Application/src/com.example.android.common/logger/LogWrapper.java deleted file mode 100644 index 16a9e7ba2..000000000 --- a/samples/browseable/GridViewPager/Application/src/com.example.android.common/logger/LogWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -import android.util.Log; - -/** - * Helper class which wraps Android's native Log utility in the Logger interface. This way - * normal DDMS output can be one of the many targets receiving and outputting logs simultaneously. - */ -public class LogWrapper implements LogNode { - - // For piping: The next node to receive Log data after this one has done its work. - private LogNode mNext; - - /** - * Returns the next LogNode in the linked list. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - - /** - * Prints data out to the console using Android's native log mechanism. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - // There actually are log methods that don't take a msg parameter. For now, - // if that's the case, just convert null to the empty string and move on. - String useMsg = msg; - if (useMsg == null) { - useMsg = ""; - } - - // If an exeption was provided, convert that exception to a usable string and attach - // it to the end of the msg method. - if (tr != null) { - msg += "\n" + Log.getStackTraceString(tr); - } - - // This is functionally identical to Log.x(tag, useMsg); - // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg) - Log.println(priority, tag, useMsg); - - // If this isn't the last node in the chain, move things along. - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } -} diff --git a/samples/browseable/GridViewPager/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java b/samples/browseable/GridViewPager/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java deleted file mode 100644 index 19967dcd4..000000000 --- a/samples/browseable/GridViewPager/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -/** - * Simple {@link LogNode} filter, removes everything except the message. - * Useful for situations like on-screen log output where you don't want a lot of metadata displayed, - * just easy-to-read message updates as they're happening. - */ -public class MessageOnlyLogFilter implements LogNode { - - LogNode mNext; - - /** - * Takes the "next" LogNode as a parameter, to simplify chaining. - * - * @param next The next LogNode in the pipeline. - */ - public MessageOnlyLogFilter(LogNode next) { - mNext = next; - } - - public MessageOnlyLogFilter() { - } - - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - if (mNext != null) { - getNext().println(Log.NONE, null, msg, null); - } - } - - /** - * Returns the next LogNode in the chain. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - -} diff --git a/samples/browseable/GridViewPager/Shared/AndroidManifest.xml b/samples/browseable/GridViewPager/Shared/AndroidManifest.xml deleted file mode 100644 index 1be08aaeb..000000000 --- a/samples/browseable/GridViewPager/Shared/AndroidManifest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - -+ + This sample demonstrates how to implement horizontal paging between fragments in + applications that use ActionBar, using a ViewPager widget. + +
diff --git a/samples/browseable/HorizontalPaging/res/values-v21/template-styles.xml b/samples/browseable/HorizontalPaging/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/HorizontalPaging/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +This sample demonstrates how to enable toggling of this feature in a -{@link android.support.v4.app.Fragment}.
++ + One of the features introduced in KitKat is "immersive mode". Immersive mode gives the + user the ability to show/hide the status bar and navigation bar with a swipe. To try, + click the "Toggle immersive mode" button, then try swiping the bar in and out! + +
diff --git a/samples/browseable/ImmersiveMode/res/values-v21/template-styles.xml b/samples/browseable/ImmersiveMode/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/ImmersiveMode/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +
diff --git a/samples/browseable/MediaBrowserService/AndroidManifest.xml b/samples/browseable/MediaBrowserService/AndroidManifest.xml
new file mode 100644
index 000000000..6d05c2791
--- /dev/null
+++ b/samples/browseable/MediaBrowserService/AndroidManifest.xml
@@ -0,0 +1,65 @@
+
+
+
+ + This sample shows how to implement an audio media app that provides + media library metadata and playback controls through a standard + service. + +
diff --git a/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_launcher.png b/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 000000000..47d6854e2 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_launcher.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_notification.png b/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_notification.png new file mode 100644 index 000000000..d8ea5a906 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_notification.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_pause_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_pause_white_24dp.png new file mode 100644 index 000000000..b4bdbb558 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_pause_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_play_arrow_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_play_arrow_white_24dp.png new file mode 100644 index 000000000..164385d04 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_play_arrow_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_shuffle_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_shuffle_white_24dp.png new file mode 100644 index 000000000..3eeb0ef5b Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_shuffle_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_skip_next_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_skip_next_white_24dp.png new file mode 100644 index 000000000..4eaf7caab Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_skip_next_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_skip_previous_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_skip_previous_white_24dp.png new file mode 100644 index 000000000..e59dedb62 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-hdpi/ic_skip_previous_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-mdpi/ic_launcher.png b/samples/browseable/MediaBrowserService/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 000000000..01b53fd50 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-mdpi/ic_launcher.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-night-xxhdpi/ic_star_off.png b/samples/browseable/MediaBrowserService/res/drawable-night-xxhdpi/ic_star_off.png new file mode 100644 index 000000000..e435d2a9f Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-night-xxhdpi/ic_star_off.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-night-xxhdpi/ic_star_on.png b/samples/browseable/MediaBrowserService/res/drawable-night-xxhdpi/ic_star_on.png new file mode 100644 index 000000000..0c75bb6da Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-night-xxhdpi/ic_star_on.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_equalizer_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_equalizer_white_24dp.png new file mode 100644 index 000000000..dbba844df Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_equalizer_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_launcher.png b/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 000000000..af762f2be Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_launcher.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_pause_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_pause_white_24dp.png new file mode 100644 index 000000000..14b6d17d4 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_pause_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_play_arrow_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_play_arrow_white_24dp.png new file mode 100644 index 000000000..a55d19922 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_play_arrow_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_shuffle_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_shuffle_white_24dp.png new file mode 100644 index 000000000..8ce3a6008 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_shuffle_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_skip_next_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_skip_next_white_24dp.png new file mode 100644 index 000000000..f282b9245 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_skip_next_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_skip_previous_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_skip_previous_white_24dp.png new file mode 100644 index 000000000..2522877df Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xhdpi/ic_skip_previous_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_by_genre.png b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_by_genre.png new file mode 100644 index 000000000..da3b4a74c Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_by_genre.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_default_art.png b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_default_art.png new file mode 100644 index 000000000..dfb9e670a Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_default_art.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_equalizer_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_equalizer_white_24dp.png new file mode 100644 index 000000000..b82a8d98d Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_equalizer_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_launcher.png b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..eef47aa34 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_pause_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_pause_white_24dp.png new file mode 100644 index 000000000..72dfa9fa6 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_pause_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_play_arrow_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_play_arrow_white_24dp.png new file mode 100644 index 000000000..043acd808 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_play_arrow_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_shuffle_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_shuffle_white_24dp.png new file mode 100644 index 000000000..718b6b5ce Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_shuffle_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_skip_next_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_skip_next_white_24dp.png new file mode 100644 index 000000000..4fe60888b Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_skip_next_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_skip_previous_white_24dp.png b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_skip_previous_white_24dp.png new file mode 100644 index 000000000..2c9310af9 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_skip_previous_white_24dp.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_off.png b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_off.png new file mode 100644 index 000000000..836085b68 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_off.png differ diff --git a/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_on.png b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_on.png new file mode 100644 index 000000000..7cd6cfc52 Binary files /dev/null and b/samples/browseable/MediaBrowserService/res/drawable-xxhdpi/ic_star_on.png differ diff --git a/samples/browseable/MediaBrowserService/res/layout/activity_player.xml b/samples/browseable/MediaBrowserService/res/layout/activity_player.xml new file mode 100644 index 000000000..21cdbbd9c --- /dev/null +++ b/samples/browseable/MediaBrowserService/res/layout/activity_player.xml @@ -0,0 +1,22 @@ + ++ + This sample shows how to use the Media Effects APIs that were introduced in Android 4.0. + These APIs let you apply effects to image frames represented as OpenGL ES 2.0 textures. + Image frames can be images loaded from disk, frames from the device\'s camera, or other + video streams. + +
diff --git a/samples/browseable/MediaEffects/res/drawable-hdpi/ic_launcher.png b/samples/browseable/MediaEffects/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 000000000..960dc8eb1 Binary files /dev/null and b/samples/browseable/MediaEffects/res/drawable-hdpi/ic_launcher.png differ diff --git a/samples/browseable/NavigationDrawer/res/drawable-xhdpi/sample_dashboard_item_background.9.png b/samples/browseable/MediaEffects/res/drawable-hdpi/tile.9.png similarity index 100% rename from samples/browseable/NavigationDrawer/res/drawable-xhdpi/sample_dashboard_item_background.9.png rename to samples/browseable/MediaEffects/res/drawable-hdpi/tile.9.png diff --git a/samples/browseable/MediaEffects/res/drawable-mdpi/ic_launcher.png b/samples/browseable/MediaEffects/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 000000000..9356f268e Binary files /dev/null and b/samples/browseable/MediaEffects/res/drawable-mdpi/ic_launcher.png differ diff --git a/samples/browseable/MediaEffects/res/drawable-nodpi/puppy.jpg b/samples/browseable/MediaEffects/res/drawable-nodpi/puppy.jpg new file mode 100644 index 000000000..ef79be200 Binary files /dev/null and b/samples/browseable/MediaEffects/res/drawable-nodpi/puppy.jpg differ diff --git a/samples/browseable/MediaEffects/res/drawable-xhdpi/ic_launcher.png b/samples/browseable/MediaEffects/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 000000000..230d5584d Binary files /dev/null and b/samples/browseable/MediaEffects/res/drawable-xhdpi/ic_launcher.png differ diff --git a/samples/browseable/MediaEffects/res/drawable-xxhdpi/ic_launcher.png b/samples/browseable/MediaEffects/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..c825d4e4e Binary files /dev/null and b/samples/browseable/MediaEffects/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/samples/browseable/MediaEffects/res/layout-w720dp/activity_main.xml b/samples/browseable/MediaEffects/res/layout-w720dp/activity_main.xml new file mode 100755 index 000000000..c9a52f621 --- /dev/null +++ b/samples/browseable/MediaEffects/res/layout-w720dp/activity_main.xml @@ -0,0 +1,73 @@ + +
+ * For devices with displays with a width of 720dp or greater, the sample log is always visible,
+ * on other devices it's visibility is controlled by an item on the Action Bar.
+ */
+public class MainActivity extends SampleActivityBase {
+
+ public static final String TAG = "MainActivity";
+
+ // Whether the Log Fragment is currently shown
+ private boolean mLogShown;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ if (savedInstanceState == null) {
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ MediaEffectsFragment fragment = new MediaEffectsFragment();
+ transaction.replace(R.id.sample_content_fragment, fragment);
+ transaction.commit();
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ MenuItem logToggle = menu.findItem(R.id.menu_toggle_log);
+ logToggle.setVisible(findViewById(R.id.sample_output) instanceof ViewAnimator);
+ logToggle.setTitle(mLogShown ? R.string.sample_hide_log : R.string.sample_show_log);
+
+ return super.onPrepareOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch(item.getItemId()) {
+ case R.id.menu_toggle_log:
+ mLogShown = !mLogShown;
+ ViewAnimator output = (ViewAnimator) findViewById(R.id.sample_output);
+ if (mLogShown) {
+ output.setDisplayedChild(1);
+ } else {
+ output.setDisplayedChild(0);
+ }
+ supportInvalidateOptionsMenu();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ /** Create a chain of targets that will receive log data */
+ @Override
+ public void initializeLogging() {
+ // Wraps Android's native log framework.
+ LogWrapper logWrapper = new LogWrapper();
+ // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
+ Log.setLogNode(logWrapper);
+
+ // Filter strips out everything except the message text.
+ MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
+ logWrapper.setNext(msgFilter);
+
+ // On screen logging via a fragment with a TextView.
+ LogFragment logFragment = (LogFragment) getSupportFragmentManager()
+ .findFragmentById(R.id.log_fragment);
+ msgFilter.setNext(logFragment.getLogView());
+
+ Log.i(TAG, "Ready");
+ }
+}
diff --git a/samples/browseable/MediaEffects/src/com.example.android.mediaeffects/MediaEffectsFragment.java b/samples/browseable/MediaEffects/src/com.example.android.mediaeffects/MediaEffectsFragment.java
new file mode 100644
index 000000000..5af16845f
--- /dev/null
+++ b/samples/browseable/MediaEffects/src/com.example.android.mediaeffects/MediaEffectsFragment.java
@@ -0,0 +1,287 @@
+/*
+ * 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 com.example.android.mediaeffects;
+
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Color;
+import android.media.effect.Effect;
+import android.media.effect.EffectContext;
+import android.media.effect.EffectFactory;
+import android.opengl.GLES20;
+import android.opengl.GLSurfaceView;
+import android.opengl.GLUtils;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+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 javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL10;
+
+public class MediaEffectsFragment extends Fragment implements GLSurfaceView.Renderer {
+
+ private static final String STATE_CURRENT_EFFECT = "current_effect";
+
+ private GLSurfaceView mEffectView;
+ private int[] mTextures = new int[2];
+ private EffectContext mEffectContext;
+ private Effect mEffect;
+ private TextureRenderer mTexRenderer = new TextureRenderer();
+ private int mImageWidth;
+ private int mImageHeight;
+ private boolean mInitialized = false;
+ private int mCurrentEffect;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.fragment_media_effects, container, false);
+ }
+
+ @Override
+ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ mEffectView = (GLSurfaceView) view.findViewById(R.id.effectsview);
+ mEffectView.setEGLContextClientVersion(2);
+ mEffectView.setRenderer(this);
+ mEffectView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
+ if (null != savedInstanceState && savedInstanceState.containsKey(STATE_CURRENT_EFFECT)) {
+ setCurrentEffect(savedInstanceState.getInt(STATE_CURRENT_EFFECT));
+ } else {
+ setCurrentEffect(R.id.none);
+ }
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ inflater.inflate(R.menu.media_effects, menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ setCurrentEffect(item.getItemId());
+ mEffectView.requestRender();
+ return true;
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ outState.putInt(STATE_CURRENT_EFFECT, mCurrentEffect);
+ }
+
+ @Override
+ public void onSurfaceCreated(GL10 gl, EGLConfig eglConfig) {
+ // Nothing to do here
+ }
+
+ @Override
+ public void onSurfaceChanged(GL10 gl, int width, int height) {
+ if (mTexRenderer != null) {
+ mTexRenderer.updateViewSize(width, height);
+ }
+ }
+
+ @Override
+ public void onDrawFrame(GL10 gl) {
+ if (!mInitialized) {
+ //Only need to do this once
+ mEffectContext = EffectContext.createWithCurrentGlContext();
+ mTexRenderer.init();
+ loadTextures();
+ mInitialized = true;
+ }
+ if (mCurrentEffect != R.id.none) {
+ //if an effect is chosen initialize it and apply it to the texture
+ initEffect();
+ applyEffect();
+ }
+ renderResult();
+ }
+
+ private void setCurrentEffect(int effect) {
+ mCurrentEffect = effect;
+ }
+
+ private void loadTextures() {
+ // Generate textures
+ GLES20.glGenTextures(2, mTextures, 0);
+
+ // Load input bitmap
+ Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.puppy);
+ mImageWidth = bitmap.getWidth();
+ mImageHeight = bitmap.getHeight();
+ mTexRenderer.updateTextureSize(mImageWidth, mImageHeight);
+
+ // Upload to texture
+ GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures[0]);
+ GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
+
+ // Set texture parameters
+ GLToolbox.initTexParams();
+ }
+
+ private void initEffect() {
+ EffectFactory effectFactory = mEffectContext.getFactory();
+ if (mEffect != null) {
+ mEffect.release();
+ }
+ // Initialize the correct effect based on the selected menu/action item
+ switch (mCurrentEffect) {
+
+ case R.id.none:
+ break;
+
+ case R.id.autofix:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_AUTOFIX);
+ mEffect.setParameter("scale", 0.5f);
+ break;
+
+ case R.id.bw:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_BLACKWHITE);
+ mEffect.setParameter("black", .1f);
+ mEffect.setParameter("white", .7f);
+ break;
+
+ case R.id.brightness:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_BRIGHTNESS);
+ mEffect.setParameter("brightness", 2.0f);
+ break;
+
+ case R.id.contrast:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_CONTRAST);
+ mEffect.setParameter("contrast", 1.4f);
+ break;
+
+ case R.id.crossprocess:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_CROSSPROCESS);
+ break;
+
+ case R.id.documentary:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_DOCUMENTARY);
+ break;
+
+ case R.id.duotone:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_DUOTONE);
+ mEffect.setParameter("first_color", Color.YELLOW);
+ mEffect.setParameter("second_color", Color.DKGRAY);
+ break;
+
+ case R.id.filllight:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_FILLLIGHT);
+ mEffect.setParameter("strength", .8f);
+ break;
+
+ case R.id.fisheye:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_FISHEYE);
+ mEffect.setParameter("scale", .5f);
+ break;
+
+ case R.id.flipvert:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_FLIP);
+ mEffect.setParameter("vertical", true);
+ break;
+
+ case R.id.fliphor:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_FLIP);
+ mEffect.setParameter("horizontal", true);
+ break;
+
+ case R.id.grain:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_GRAIN);
+ mEffect.setParameter("strength", 1.0f);
+ break;
+
+ case R.id.grayscale:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_GRAYSCALE);
+ break;
+
+ case R.id.lomoish:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_LOMOISH);
+ break;
+
+ case R.id.negative:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_NEGATIVE);
+ break;
+
+ case R.id.posterize:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_POSTERIZE);
+ break;
+
+ case R.id.rotate:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_ROTATE);
+ mEffect.setParameter("angle", 180);
+ break;
+
+ case R.id.saturate:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_SATURATE);
+ mEffect.setParameter("scale", .5f);
+ break;
+
+ case R.id.sepia:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_SEPIA);
+ break;
+
+ case R.id.sharpen:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_SHARPEN);
+ break;
+
+ case R.id.temperature:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_TEMPERATURE);
+ mEffect.setParameter("scale", .9f);
+ break;
+
+ case R.id.tint:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_TINT);
+ mEffect.setParameter("tint", Color.MAGENTA);
+ break;
+
+ case R.id.vignette:
+ mEffect = effectFactory.createEffect(EffectFactory.EFFECT_VIGNETTE);
+ mEffect.setParameter("scale", .5f);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ private void applyEffect() {
+ mEffect.apply(mTextures[0], mImageWidth, mImageHeight, mTextures[1]);
+ }
+
+ private void renderResult() {
+ if (mCurrentEffect != R.id.none) {
+ // if no effect is chosen, just render the original bitmap
+ mTexRenderer.renderTexture(mTextures[1]);
+ } else {
+ // render the result of applyEffect()
+ mTexRenderer.renderTexture(mTextures[0]);
+ }
+ }
+
+}
diff --git a/samples/browseable/MediaEffects/src/com.example.android.mediaeffects/TextureRenderer.java b/samples/browseable/MediaEffects/src/com.example.android.mediaeffects/TextureRenderer.java
new file mode 100644
index 000000000..9c77927d2
--- /dev/null
+++ b/samples/browseable/MediaEffects/src/com.example.android.mediaeffects/TextureRenderer.java
@@ -0,0 +1,164 @@
+/*
+ * 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 com.example.android.mediaeffects;
+
+import android.opengl.GLES20;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.FloatBuffer;
+
+public class TextureRenderer {
+
+ private int mProgram;
+ private int mTexSamplerHandle;
+ private int mTexCoordHandle;
+ private int mPosCoordHandle;
+
+ private FloatBuffer mTexVertices;
+ private FloatBuffer mPosVertices;
+
+ private int mViewWidth;
+ private int mViewHeight;
+
+ private int mTexWidth;
+ private int mTexHeight;
+
+ private static final String VERTEX_SHADER =
+ "attribute vec4 a_position;\n" +
+ "attribute vec2 a_texcoord;\n" +
+ "varying vec2 v_texcoord;\n" +
+ "void main() {\n" +
+ " gl_Position = a_position;\n" +
+ " v_texcoord = a_texcoord;\n" +
+ "}\n";
+
+ private static final String FRAGMENT_SHADER =
+ "precision mediump float;\n" +
+ "uniform sampler2D tex_sampler;\n" +
+ "varying vec2 v_texcoord;\n" +
+ "void main() {\n" +
+ " gl_FragColor = texture2D(tex_sampler, v_texcoord);\n" +
+ "}\n";
+
+ private static final float[] TEX_VERTICES = {
+ 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f
+ };
+
+ private static final float[] POS_VERTICES = {
+ -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f
+ };
+
+ private static final int FLOAT_SIZE_BYTES = 4;
+
+ public void init() {
+ // Create program
+ mProgram = GLToolbox.createProgram(VERTEX_SHADER, FRAGMENT_SHADER);
+
+ // Bind attributes and uniforms
+ mTexSamplerHandle = GLES20.glGetUniformLocation(mProgram,
+ "tex_sampler");
+ mTexCoordHandle = GLES20.glGetAttribLocation(mProgram, "a_texcoord");
+ mPosCoordHandle = GLES20.glGetAttribLocation(mProgram, "a_position");
+
+ // Setup coordinate buffers
+ mTexVertices = ByteBuffer.allocateDirect(
+ TEX_VERTICES.length * FLOAT_SIZE_BYTES)
+ .order(ByteOrder.nativeOrder()).asFloatBuffer();
+ mTexVertices.put(TEX_VERTICES).position(0);
+ mPosVertices = ByteBuffer.allocateDirect(
+ POS_VERTICES.length * FLOAT_SIZE_BYTES)
+ .order(ByteOrder.nativeOrder()).asFloatBuffer();
+ mPosVertices.put(POS_VERTICES).position(0);
+ }
+
+ public void tearDown() {
+ GLES20.glDeleteProgram(mProgram);
+ }
+
+ public void updateTextureSize(int texWidth, int texHeight) {
+ mTexWidth = texWidth;
+ mTexHeight = texHeight;
+ computeOutputVertices();
+ }
+
+ public void updateViewSize(int viewWidth, int viewHeight) {
+ mViewWidth = viewWidth;
+ mViewHeight = viewHeight;
+ computeOutputVertices();
+ }
+
+ public void renderTexture(int texId) {
+ // Bind default FBO
+ GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
+
+ // Use our shader program
+ GLES20.glUseProgram(mProgram);
+ GLToolbox.checkGlError("glUseProgram");
+
+ // Set viewport
+ GLES20.glViewport(0, 0, mViewWidth, mViewHeight);
+ GLToolbox.checkGlError("glViewport");
+
+ // Disable blending
+ GLES20.glDisable(GLES20.GL_BLEND);
+
+ // Set the vertex attributes
+ GLES20.glVertexAttribPointer(mTexCoordHandle, 2, GLES20.GL_FLOAT, false,
+ 0, mTexVertices);
+ GLES20.glEnableVertexAttribArray(mTexCoordHandle);
+ GLES20.glVertexAttribPointer(mPosCoordHandle, 2, GLES20.GL_FLOAT, false,
+ 0, mPosVertices);
+ GLES20.glEnableVertexAttribArray(mPosCoordHandle);
+ GLToolbox.checkGlError("vertex attribute setup");
+
+ // Set the input texture
+ GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
+ GLToolbox.checkGlError("glActiveTexture");
+ GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texId);
+ GLToolbox.checkGlError("glBindTexture");
+ GLES20.glUniform1i(mTexSamplerHandle, 0);
+
+ // Draw
+ GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+ GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
+ GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
+ }
+
+ private void computeOutputVertices() {
+ if (mPosVertices != null) {
+ float imgAspectRatio = mTexWidth / (float)mTexHeight;
+ float viewAspectRatio = mViewWidth / (float)mViewHeight;
+ float relativeAspectRatio = viewAspectRatio / imgAspectRatio;
+ float x0, y0, x1, y1;
+ if (relativeAspectRatio > 1.0f) {
+ x0 = -1.0f / relativeAspectRatio;
+ y0 = -1.0f;
+ x1 = 1.0f / relativeAspectRatio;
+ y1 = 1.0f;
+ } else {
+ x0 = -1.0f;
+ y0 = -relativeAspectRatio;
+ x1 = 1.0f;
+ y1 = relativeAspectRatio;
+ }
+ float[] coords = new float[] { x0, y0, x1, y0, x0, y1, x1, y1 };
+ mPosVertices.put(coords).position(0);
+ }
+ }
+
+}
diff --git a/samples/browseable/MediaRecorder/AndroidManifest.xml b/samples/browseable/MediaRecorder/AndroidManifest.xml
index 32f88f64f..539dc2c3d 100644
--- a/samples/browseable/MediaRecorder/AndroidManifest.xml
+++ b/samples/browseable/MediaRecorder/AndroidManifest.xml
@@ -22,9 +22,7 @@
android:versionCode="1"
android:versionName="1.0">
-
This sample demonstrates how to use the {@link android.media.MediaRecorder} -API to record video from a camera or camcorder, and display a preview of the -recording.
++ + This sample uses the camera/camcorder as the A/V source for the MediaRecorder API. + A TextureView is used as the camera preview which limits the code to API 14+. This + can be easily replaced with a SurfaceView to run on older devices. + +
diff --git a/samples/browseable/MediaRecorder/res/values-v21/template-styles.xml b/samples/browseable/MediaRecorder/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/MediaRecorder/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + ++ +This sample shows a simple service that sends notifications using +NotificationCompat. In addition to sending a notification, it also extends +the notification with a CarExtender to make it compatible with Android Auto. +Each unread conversation from a user is sent as a distinct notification. + +
diff --git a/samples/browseable/MessagingService/res/drawable-hdpi/android_contact.png b/samples/browseable/MessagingService/res/drawable-hdpi/android_contact.png new file mode 100644 index 000000000..00d0ec43a Binary files /dev/null and b/samples/browseable/MessagingService/res/drawable-hdpi/android_contact.png differ diff --git a/samples/browseable/MessagingService/res/drawable-hdpi/ic_launcher.png b/samples/browseable/MessagingService/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 000000000..06d85f166 Binary files /dev/null and b/samples/browseable/MessagingService/res/drawable-hdpi/ic_launcher.png differ diff --git a/samples/browseable/MessagingService/res/drawable-hdpi/notification_icon.png b/samples/browseable/MessagingService/res/drawable-hdpi/notification_icon.png new file mode 100644 index 000000000..9cdfca1e5 Binary files /dev/null and b/samples/browseable/MessagingService/res/drawable-hdpi/notification_icon.png differ diff --git a/samples/browseable/MessagingService/res/drawable-mdpi/android_contact.png b/samples/browseable/MessagingService/res/drawable-mdpi/android_contact.png new file mode 100644 index 000000000..771cb6bb8 Binary files /dev/null and b/samples/browseable/MessagingService/res/drawable-mdpi/android_contact.png differ diff --git a/samples/browseable/MessagingService/res/drawable-mdpi/ic_launcher.png b/samples/browseable/MessagingService/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 000000000..4e1cc86b4 Binary files /dev/null and b/samples/browseable/MessagingService/res/drawable-mdpi/ic_launcher.png differ diff --git a/samples/browseable/MessagingService/res/drawable-mdpi/notification_icon.png b/samples/browseable/MessagingService/res/drawable-mdpi/notification_icon.png new file mode 100644 index 000000000..d6069ebc9 Binary files /dev/null and b/samples/browseable/MessagingService/res/drawable-mdpi/notification_icon.png differ diff --git a/samples/browseable/MessagingService/res/drawable-xhdpi/android_contact.png b/samples/browseable/MessagingService/res/drawable-xhdpi/android_contact.png new file mode 100644 index 000000000..bdba57b6b Binary files /dev/null and b/samples/browseable/MessagingService/res/drawable-xhdpi/android_contact.png differ diff --git a/samples/browseable/MessagingService/res/drawable-xhdpi/ic_launcher.png b/samples/browseable/MessagingService/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 000000000..92f1e2ddd Binary files /dev/null and b/samples/browseable/MessagingService/res/drawable-xhdpi/ic_launcher.png differ diff --git a/samples/browseable/MessagingService/res/drawable-xhdpi/notification_icon.png b/samples/browseable/MessagingService/res/drawable-xhdpi/notification_icon.png new file mode 100644 index 000000000..786ed17b7 Binary files /dev/null and b/samples/browseable/MessagingService/res/drawable-xhdpi/notification_icon.png differ diff --git a/samples/browseable/MessagingService/res/drawable-xxhdpi/android_contact.png b/samples/browseable/MessagingService/res/drawable-xxhdpi/android_contact.png new file mode 100644 index 000000000..b36ec1730 Binary files /dev/null and b/samples/browseable/MessagingService/res/drawable-xxhdpi/android_contact.png differ diff --git a/samples/browseable/MessagingService/res/drawable-xxhdpi/ic_launcher.png b/samples/browseable/MessagingService/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..2476cbddd Binary files /dev/null and b/samples/browseable/MessagingService/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/samples/browseable/MessagingService/res/drawable-xxhdpi/notification_icon.png b/samples/browseable/MessagingService/res/drawable-xxhdpi/notification_icon.png new file mode 100644 index 000000000..005207cc0 Binary files /dev/null and b/samples/browseable/MessagingService/res/drawable-xxhdpi/notification_icon.png differ diff --git a/samples/browseable/MessagingService/res/layout-land/fragment_message_me.xml b/samples/browseable/MessagingService/res/layout-land/fragment_message_me.xml new file mode 100644 index 000000000..8f7b60a23 --- /dev/null +++ b/samples/browseable/MessagingService/res/layout-land/fragment_message_me.xml @@ -0,0 +1,67 @@ + +This sample demonstrates how to connect to the network and fetch raw HTML. -The sample uses {@link android.os.AsyncTask} to perform the fetch on a -background thread.
++ + This sample demonstrates how to connect to the network and fetch raw HTML using + HttpURLConnection. AsyncTask is used to perform the fetch on a background thread. + +
diff --git a/samples/browseable/NetworkConnect/res/values-v21/template-styles.xml b/samples/browseable/NetworkConnect/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/NetworkConnect/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +When this is set as the head of the list, - * an instance of it can function as a drop-in replacement for {@link android.util.Log}. - * Most of the methods in this class server only to map a method call in Log to its equivalent - * in LogNode.
- */ -public class Log { - // Grabbing the native values from Android's native logging facilities, - // to make for easy migration and interop. - public static final int NONE = -1; - public static final int VERBOSE = android.util.Log.VERBOSE; - public static final int DEBUG = android.util.Log.DEBUG; - public static final int INFO = android.util.Log.INFO; - public static final int WARN = android.util.Log.WARN; - public static final int ERROR = android.util.Log.ERROR; - public static final int ASSERT = android.util.Log.ASSERT; - - // Stores the beginning of the LogNode topology. - private static LogNode mLogNode; - - /** - * Returns the next LogNode in the linked list. - */ - public static LogNode getLogNode() { - return mLogNode; - } - - /** - * Sets the LogNode data will be sent to. - */ - public static void setLogNode(LogNode node) { - mLogNode = node; - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void println(int priority, String tag, String msg, Throwable tr) { - if (mLogNode != null) { - mLogNode.println(priority, tag, msg, tr); - } - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - */ - public static void println(int priority, String tag, String msg) { - println(priority, tag, msg, null); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void v(String tag, String msg, Throwable tr) { - println(VERBOSE, tag, msg, tr); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void v(String tag, String msg) { - v(tag, msg, null); - } - - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void d(String tag, String msg, Throwable tr) { - println(DEBUG, tag, msg, tr); - } - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void d(String tag, String msg) { - d(tag, msg, null); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void i(String tag, String msg, Throwable tr) { - println(INFO, tag, msg, tr); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void i(String tag, String msg) { - i(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, String msg, Throwable tr) { - println(WARN, tag, msg, tr); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void w(String tag, String msg) { - w(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, Throwable tr) { - w(tag, null, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void e(String tag, String msg, Throwable tr) { - println(ERROR, tag, msg, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void e(String tag, String msg) { - e(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, String msg, Throwable tr) { - println(ASSERT, tag, msg, tr); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void wtf(String tag, String msg) { - wtf(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, Throwable tr) { - wtf(tag, null, tr); - } -} diff --git a/samples/browseable/Notifications/Application/src/com.example.android.common/logger/LogFragment.java b/samples/browseable/Notifications/Application/src/com.example.android.common/logger/LogFragment.java deleted file mode 100644 index b302acd4b..000000000 --- a/samples/browseable/Notifications/Application/src/com.example.android.common/logger/LogFragment.java +++ /dev/null @@ -1,109 +0,0 @@ -/* -* 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. -*/ -/* - * 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. - */ - -package com.example.android.common.logger; - -import android.graphics.Typeface; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ScrollView; - -/** - * Simple fraggment which contains a LogView and uses is to output log data it receives - * through the LogNode interface. - */ -public class LogFragment extends Fragment { - - private LogView mLogView; - private ScrollView mScrollView; - - public LogFragment() {} - - public View inflateViews() { - mScrollView = new ScrollView(getActivity()); - ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT); - mScrollView.setLayoutParams(scrollParams); - - mLogView = new LogView(getActivity()); - ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); - logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; - mLogView.setLayoutParams(logParams); - mLogView.setClickable(true); - mLogView.setFocusable(true); - mLogView.setTypeface(Typeface.MONOSPACE); - - // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! - int paddingDips = 16; - double scale = getResources().getDisplayMetrics().density; - int paddingPixels = (int) ((paddingDips * (scale)) + .5); - mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); - mLogView.setCompoundDrawablePadding(paddingPixels); - - mLogView.setGravity(Gravity.BOTTOM); - mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium); - - mScrollView.addView(mLogView); - return mScrollView; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - View result = inflateViews(); - - mLogView.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} - - @Override - public void afterTextChanged(Editable s) { - mScrollView.fullScroll(ScrollView.FOCUS_DOWN); - } - }); - return result; - } - - public LogView getLogView() { - return mLogView; - } -} \ No newline at end of file diff --git a/samples/browseable/Notifications/Application/src/com.example.android.common/logger/LogNode.java b/samples/browseable/Notifications/Application/src/com.example.android.common/logger/LogNode.java deleted file mode 100644 index bc37cabc0..000000000 --- a/samples/browseable/Notifications/Application/src/com.example.android.common/logger/LogNode.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -/** - * Basic interface for a logging system that can output to one or more targets. - * Note that in addition to classes that will output these logs in some format, - * one can also implement this interface over a filter and insert that in the chain, - * such that no targets further down see certain data, or see manipulated forms of the data. - * You could, for instance, write a "ToHtmlLoggerNode" that just converted all the log data - * it received to HTML and sent it along to the next node in the chain, without printing it - * anywhere. - */ -public interface LogNode { - - /** - * Instructs first LogNode in the list to print the log data provided. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public void println(int priority, String tag, String msg, Throwable tr); - -} diff --git a/samples/browseable/Notifications/Application/src/com.example.android.common/logger/LogView.java b/samples/browseable/Notifications/Application/src/com.example.android.common/logger/LogView.java deleted file mode 100644 index c01542b91..000000000 --- a/samples/browseable/Notifications/Application/src/com.example.android.common/logger/LogView.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -import android.app.Activity; -import android.content.Context; -import android.util.*; -import android.widget.TextView; - -/** Simple TextView which is used to output log data received through the LogNode interface. -*/ -public class LogView extends TextView implements LogNode { - - public LogView(Context context) { - super(context); - } - - public LogView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LogView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - /** - * Formats the log data and prints it out to the LogView. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - - - String priorityStr = null; - - // For the purposes of this View, we want to print the priority as readable text. - switch(priority) { - case android.util.Log.VERBOSE: - priorityStr = "VERBOSE"; - break; - case android.util.Log.DEBUG: - priorityStr = "DEBUG"; - break; - case android.util.Log.INFO: - priorityStr = "INFO"; - break; - case android.util.Log.WARN: - priorityStr = "WARN"; - break; - case android.util.Log.ERROR: - priorityStr = "ERROR"; - break; - case android.util.Log.ASSERT: - priorityStr = "ASSERT"; - break; - default: - break; - } - - // Handily, the Log class has a facility for converting a stack trace into a usable string. - String exceptionStr = null; - if (tr != null) { - exceptionStr = android.util.Log.getStackTraceString(tr); - } - - // Take the priority, tag, message, and exception, and concatenate as necessary - // into one usable line of text. - final StringBuilder outputBuilder = new StringBuilder(); - - String delimiter = "\t"; - appendIfNotNull(outputBuilder, priorityStr, delimiter); - appendIfNotNull(outputBuilder, tag, delimiter); - appendIfNotNull(outputBuilder, msg, delimiter); - appendIfNotNull(outputBuilder, exceptionStr, delimiter); - - // In case this was originally called from an AsyncTask or some other off-UI thread, - // make sure the update occurs within the UI thread. - ((Activity) getContext()).runOnUiThread( (new Thread(new Runnable() { - @Override - public void run() { - // Display the text we just generated within the LogView. - appendToLog(outputBuilder.toString()); - } - }))); - - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } - - public LogNode getNext() { - return mNext; - } - - public void setNext(LogNode node) { - mNext = node; - } - - /** Takes a string and adds to it, with a separator, if the bit to be added isn't null. Since - * the logger takes so many arguments that might be null, this method helps cut out some of the - * agonizing tedium of writing the same 3 lines over and over. - * @param source StringBuilder containing the text to append to. - * @param addStr The String to append - * @param delimiter The String to separate the source and appended strings. A tab or comma, - * for instance. - * @return The fully concatenated String as a StringBuilder - */ - private StringBuilder appendIfNotNull(StringBuilder source, String addStr, String delimiter) { - if (addStr != null) { - if (addStr.length() == 0) { - delimiter = ""; - } - - return source.append(addStr).append(delimiter); - } - return source; - } - - // The next LogNode in the chain. - LogNode mNext; - - /** Outputs the string as a new line of log data in the LogView. */ - public void appendToLog(String s) { - append("\n" + s); - } - - -} diff --git a/samples/browseable/Notifications/Application/src/com.example.android.common/logger/LogWrapper.java b/samples/browseable/Notifications/Application/src/com.example.android.common/logger/LogWrapper.java deleted file mode 100644 index 16a9e7ba2..000000000 --- a/samples/browseable/Notifications/Application/src/com.example.android.common/logger/LogWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -import android.util.Log; - -/** - * Helper class which wraps Android's native Log utility in the Logger interface. This way - * normal DDMS output can be one of the many targets receiving and outputting logs simultaneously. - */ -public class LogWrapper implements LogNode { - - // For piping: The next node to receive Log data after this one has done its work. - private LogNode mNext; - - /** - * Returns the next LogNode in the linked list. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - - /** - * Prints data out to the console using Android's native log mechanism. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - // There actually are log methods that don't take a msg parameter. For now, - // if that's the case, just convert null to the empty string and move on. - String useMsg = msg; - if (useMsg == null) { - useMsg = ""; - } - - // If an exeption was provided, convert that exception to a usable string and attach - // it to the end of the msg method. - if (tr != null) { - msg += "\n" + Log.getStackTraceString(tr); - } - - // This is functionally identical to Log.x(tag, useMsg); - // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg) - Log.println(priority, tag, useMsg); - - // If this isn't the last node in the chain, move things along. - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } -} diff --git a/samples/browseable/Notifications/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java b/samples/browseable/Notifications/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java deleted file mode 100644 index 19967dcd4..000000000 --- a/samples/browseable/Notifications/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -/** - * Simple {@link LogNode} filter, removes everything except the message. - * Useful for situations like on-screen log output where you don't want a lot of metadata displayed, - * just easy-to-read message updates as they're happening. - */ -public class MessageOnlyLogFilter implements LogNode { - - LogNode mNext; - - /** - * Takes the "next" LogNode as a parameter, to simplify chaining. - * - * @param next The next LogNode in the pipeline. - */ - public MessageOnlyLogFilter(LogNode next) { - mNext = next; - } - - public MessageOnlyLogFilter() { - } - - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - if (mNext != null) { - getNext().println(Log.NONE, null, msg, null); - } - } - - /** - * Returns the next LogNode in the chain. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - -} diff --git a/samples/browseable/Notifications/Application/src/com.example.android.notifications/ActionsPreset.java b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/ActionsPreset.java similarity index 94% rename from samples/browseable/Notifications/Application/src/com.example.android.notifications/ActionsPreset.java rename to samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/ActionsPreset.java index 32be1a698..a550912df 100644 --- a/samples/browseable/Notifications/Application/src/com.example.android.notifications/ActionsPreset.java +++ b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/ActionsPreset.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.notifications; +package com.example.android.support.wearable.notifications; import android.content.Context; import android.support.v4.app.NotificationCompat; diff --git a/samples/browseable/Notifications/Application/src/com.example.android.notifications/ActionsPresets.java b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/ActionsPresets.java similarity index 99% rename from samples/browseable/Notifications/Application/src/com.example.android.notifications/ActionsPresets.java rename to samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/ActionsPresets.java index 2481ac8d3..ff639dcb9 100644 --- a/samples/browseable/Notifications/Application/src/com.example.android.notifications/ActionsPresets.java +++ b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/ActionsPresets.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.notifications; +package com.example.android.support.wearable.notifications; import android.content.Context; import android.support.v4.app.NotificationCompat; diff --git a/samples/browseable/Notifications/Application/src/com.example.android.notifications/BackgroundPickers.java b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/BackgroundPickers.java similarity index 98% rename from samples/browseable/Notifications/Application/src/com.example.android.notifications/BackgroundPickers.java rename to samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/BackgroundPickers.java index 69263b25f..aedd548df 100644 --- a/samples/browseable/Notifications/Application/src/com.example.android.notifications/BackgroundPickers.java +++ b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/BackgroundPickers.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.notifications; +package com.example.android.support.wearable.notifications; import android.content.Context; import android.content.res.Resources; diff --git a/samples/browseable/Notifications/Application/src/com.example.android.notifications/MainActivity.java b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/MainActivity.java similarity index 99% rename from samples/browseable/Notifications/Application/src/com.example.android.notifications/MainActivity.java rename to samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/MainActivity.java index 22b105975..c2be39539 100644 --- a/samples/browseable/Notifications/Application/src/com.example.android.notifications/MainActivity.java +++ b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/MainActivity.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.notifications; +package com.example.android.support.wearable.notifications; import android.app.Activity; import android.app.Notification; diff --git a/samples/browseable/Notifications/Application/src/com.example.android.notifications/NamedPreset.java b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NamedPreset.java similarity index 93% rename from samples/browseable/Notifications/Application/src/com.example.android.notifications/NamedPreset.java rename to samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NamedPreset.java index b97bcb9cb..afc5f169d 100644 --- a/samples/browseable/Notifications/Application/src/com.example.android.notifications/NamedPreset.java +++ b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NamedPreset.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.notifications; +package com.example.android.support.wearable.notifications; /** * Base class for presets that have a simple name to display. diff --git a/samples/browseable/Notifications/Application/src/com.example.android.notifications/NotificationIntentReceiver.java b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationIntentReceiver.java similarity index 87% rename from samples/browseable/Notifications/Application/src/com.example.android.notifications/NotificationIntentReceiver.java rename to samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationIntentReceiver.java index 8dabb342a..39a1c7850 100644 --- a/samples/browseable/Notifications/Application/src/com.example.android.notifications/NotificationIntentReceiver.java +++ b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationIntentReceiver.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.notifications; +package com.example.android.support.wearable.notifications; import android.content.BroadcastReceiver; import android.content.Context; @@ -28,11 +28,11 @@ import android.widget.Toast; */ public class NotificationIntentReceiver extends BroadcastReceiver { public static final String ACTION_EXAMPLE = - "com.example.android.notifications.ACTION_EXAMPLE"; + "com.example.android.support.wearable.notifications.ACTION_EXAMPLE"; public static final String ACTION_ENABLE_MESSAGES = - "com.example.android.notifications.ACTION_ENABLE_MESSAGES"; + "com.example.android.support.wearable.notifications.ACTION_ENABLE_MESSAGES"; public static final String ACTION_DISABLE_MESSAGES = - "com.example.android.notifications.ACTION_DISABLE_MESSAGES"; + "com.example.android.support.wearable.notifications.ACTION_DISABLE_MESSAGES"; private boolean mEnableMessages = true; diff --git a/samples/browseable/Notifications/Application/src/com.example.android.notifications/NotificationPreset.java b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationPreset.java similarity index 97% rename from samples/browseable/Notifications/Application/src/com.example.android.notifications/NotificationPreset.java rename to samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationPreset.java index 3ab792be5..a0dff1874 100644 --- a/samples/browseable/Notifications/Application/src/com.example.android.notifications/NotificationPreset.java +++ b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationPreset.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.notifications; +package com.example.android.support.wearable.notifications; import android.app.Notification; import android.content.Context; diff --git a/samples/browseable/Notifications/Application/src/com.example.android.notifications/NotificationPresets.java b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationPresets.java similarity index 99% rename from samples/browseable/Notifications/Application/src/com.example.android.notifications/NotificationPresets.java rename to samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationPresets.java index b6fe24aac..e175d1120 100644 --- a/samples/browseable/Notifications/Application/src/com.example.android.notifications/NotificationPresets.java +++ b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationPresets.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.notifications; +package com.example.android.support.wearable.notifications; import android.app.Notification; import android.content.Context; diff --git a/samples/browseable/Notifications/Application/src/com.example.android.notifications/NotificationUtil.java b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationUtil.java similarity index 86% rename from samples/browseable/Notifications/Application/src/com.example.android.notifications/NotificationUtil.java rename to samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationUtil.java index b5c43e501..389b90a5a 100644 --- a/samples/browseable/Notifications/Application/src/com.example.android.notifications/NotificationUtil.java +++ b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationUtil.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.notifications; +package com.example.android.support.wearable.notifications; import android.app.PendingIntent; import android.content.Context; @@ -22,9 +22,9 @@ import android.content.Intent; public class NotificationUtil { public static final String EXTRA_MESSAGE = - "com.example.android.notifications.MESSAGE"; + "com.example.android.support.wearable.notifications.MESSAGE"; public static final String EXTRA_REPLY = - "com.example.android.notifications.REPLY"; + "com.example.android.support.wearable.notifications.REPLY"; public static PendingIntent getExamplePendingIntent(Context context, int messageResId) { Intent intent = new Intent(NotificationIntentReceiver.ACTION_EXAMPLE) diff --git a/samples/browseable/Notifications/Application/src/com.example.android.notifications/PriorityPreset.java b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/PriorityPreset.java similarity index 94% rename from samples/browseable/Notifications/Application/src/com.example.android.notifications/PriorityPreset.java rename to samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/PriorityPreset.java index eaddb83f2..b4298fd30 100644 --- a/samples/browseable/Notifications/Application/src/com.example.android.notifications/PriorityPreset.java +++ b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/PriorityPreset.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.notifications; +package com.example.android.support.wearable.notifications; import android.support.v4.app.NotificationCompat; diff --git a/samples/browseable/Notifications/Application/src/com.example.android.notifications/PriorityPresets.java b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/PriorityPresets.java similarity index 97% rename from samples/browseable/Notifications/Application/src/com.example.android.notifications/PriorityPresets.java rename to samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/PriorityPresets.java index 7d1ed7c0a..c33b59d7a 100644 --- a/samples/browseable/Notifications/Application/src/com.example.android.notifications/PriorityPresets.java +++ b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/PriorityPresets.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.notifications; +package com.example.android.support.wearable.notifications; import android.app.Notification; import android.support.v4.app.NotificationCompat; diff --git a/samples/browseable/Notifications/Shared/AndroidManifest.xml b/samples/browseable/Notifications/Shared/AndroidManifest.xml deleted file mode 100644 index 00541435e..000000000 --- a/samples/browseable/Notifications/Shared/AndroidManifest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - -+ + This sample demonstrates how to use PdfRenderer to display PDF documents on the screen. + +
diff --git a/samples/browseable/PdfRendererBasic/res/drawable-hdpi/ic_action_info.png b/samples/browseable/PdfRendererBasic/res/drawable-hdpi/ic_action_info.png new file mode 100644 index 000000000..32bd1aabc Binary files /dev/null and b/samples/browseable/PdfRendererBasic/res/drawable-hdpi/ic_action_info.png differ diff --git a/samples/browseable/PdfRendererBasic/res/drawable-hdpi/ic_launcher.png b/samples/browseable/PdfRendererBasic/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 000000000..0c9b69468 Binary files /dev/null and b/samples/browseable/PdfRendererBasic/res/drawable-hdpi/ic_launcher.png differ diff --git a/samples/browseable/PdfRendererBasic/res/drawable-hdpi/tile.9.png b/samples/browseable/PdfRendererBasic/res/drawable-hdpi/tile.9.png new file mode 100644 index 000000000..135862883 Binary files /dev/null and b/samples/browseable/PdfRendererBasic/res/drawable-hdpi/tile.9.png differ diff --git a/samples/browseable/PdfRendererBasic/res/drawable-mdpi/ic_action_info.png b/samples/browseable/PdfRendererBasic/res/drawable-mdpi/ic_action_info.png new file mode 100644 index 000000000..8efbbf8b3 Binary files /dev/null and b/samples/browseable/PdfRendererBasic/res/drawable-mdpi/ic_action_info.png differ diff --git a/samples/browseable/PdfRendererBasic/res/drawable-mdpi/ic_launcher.png b/samples/browseable/PdfRendererBasic/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 000000000..1a6c3d0d8 Binary files /dev/null and b/samples/browseable/PdfRendererBasic/res/drawable-mdpi/ic_launcher.png differ diff --git a/samples/browseable/PdfRendererBasic/res/drawable-xhdpi/ic_action_info.png b/samples/browseable/PdfRendererBasic/res/drawable-xhdpi/ic_action_info.png new file mode 100644 index 000000000..ba143ea7a Binary files /dev/null and b/samples/browseable/PdfRendererBasic/res/drawable-xhdpi/ic_action_info.png differ diff --git a/samples/browseable/PdfRendererBasic/res/drawable-xhdpi/ic_launcher.png b/samples/browseable/PdfRendererBasic/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 000000000..2081f403b Binary files /dev/null and b/samples/browseable/PdfRendererBasic/res/drawable-xhdpi/ic_launcher.png differ diff --git a/samples/browseable/PdfRendererBasic/res/drawable-xxhdpi/ic_action_info.png b/samples/browseable/PdfRendererBasic/res/drawable-xxhdpi/ic_action_info.png new file mode 100644 index 000000000..394eb7e53 Binary files /dev/null and b/samples/browseable/PdfRendererBasic/res/drawable-xxhdpi/ic_action_info.png differ diff --git a/samples/browseable/PdfRendererBasic/res/drawable-xxhdpi/ic_launcher.png b/samples/browseable/PdfRendererBasic/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..b506de4d5 Binary files /dev/null and b/samples/browseable/PdfRendererBasic/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/samples/browseable/PdfRendererBasic/res/layout/activity_main.xml b/samples/browseable/PdfRendererBasic/res/layout/activity_main.xml new file mode 100755 index 000000000..be1aa49d9 --- /dev/null +++ b/samples/browseable/PdfRendererBasic/res/layout/activity_main.xml @@ -0,0 +1,36 @@ + + +When this is set as the head of the list, - * an instance of it can function as a drop-in replacement for {@link android.util.Log}. - * Most of the methods in this class server only to map a method call in Log to its equivalent - * in LogNode.
- */ -public class Log { - // Grabbing the native values from Android's native logging facilities, - // to make for easy migration and interop. - public static final int NONE = -1; - public static final int VERBOSE = android.util.Log.VERBOSE; - public static final int DEBUG = android.util.Log.DEBUG; - public static final int INFO = android.util.Log.INFO; - public static final int WARN = android.util.Log.WARN; - public static final int ERROR = android.util.Log.ERROR; - public static final int ASSERT = android.util.Log.ASSERT; - - // Stores the beginning of the LogNode topology. - private static LogNode mLogNode; - - /** - * Returns the next LogNode in the linked list. - */ - public static LogNode getLogNode() { - return mLogNode; - } - - /** - * Sets the LogNode data will be sent to. - */ - public static void setLogNode(LogNode node) { - mLogNode = node; - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void println(int priority, String tag, String msg, Throwable tr) { - if (mLogNode != null) { - mLogNode.println(priority, tag, msg, tr); - } - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - */ - public static void println(int priority, String tag, String msg) { - println(priority, tag, msg, null); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void v(String tag, String msg, Throwable tr) { - println(VERBOSE, tag, msg, tr); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void v(String tag, String msg) { - v(tag, msg, null); - } - - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void d(String tag, String msg, Throwable tr) { - println(DEBUG, tag, msg, tr); - } - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void d(String tag, String msg) { - d(tag, msg, null); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void i(String tag, String msg, Throwable tr) { - println(INFO, tag, msg, tr); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void i(String tag, String msg) { - i(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, String msg, Throwable tr) { - println(WARN, tag, msg, tr); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void w(String tag, String msg) { - w(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, Throwable tr) { - w(tag, null, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void e(String tag, String msg, Throwable tr) { - println(ERROR, tag, msg, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void e(String tag, String msg) { - e(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, String msg, Throwable tr) { - println(ASSERT, tag, msg, tr); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void wtf(String tag, String msg) { - wtf(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, Throwable tr) { - wtf(tag, null, tr); - } -} diff --git a/samples/browseable/Quiz/Application/src/com.example.android.common/logger/LogFragment.java b/samples/browseable/Quiz/Application/src/com.example.android.common/logger/LogFragment.java deleted file mode 100644 index b302acd4b..000000000 --- a/samples/browseable/Quiz/Application/src/com.example.android.common/logger/LogFragment.java +++ /dev/null @@ -1,109 +0,0 @@ -/* -* 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. -*/ -/* - * 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. - */ - -package com.example.android.common.logger; - -import android.graphics.Typeface; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ScrollView; - -/** - * Simple fraggment which contains a LogView and uses is to output log data it receives - * through the LogNode interface. - */ -public class LogFragment extends Fragment { - - private LogView mLogView; - private ScrollView mScrollView; - - public LogFragment() {} - - public View inflateViews() { - mScrollView = new ScrollView(getActivity()); - ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT); - mScrollView.setLayoutParams(scrollParams); - - mLogView = new LogView(getActivity()); - ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); - logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; - mLogView.setLayoutParams(logParams); - mLogView.setClickable(true); - mLogView.setFocusable(true); - mLogView.setTypeface(Typeface.MONOSPACE); - - // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! - int paddingDips = 16; - double scale = getResources().getDisplayMetrics().density; - int paddingPixels = (int) ((paddingDips * (scale)) + .5); - mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); - mLogView.setCompoundDrawablePadding(paddingPixels); - - mLogView.setGravity(Gravity.BOTTOM); - mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium); - - mScrollView.addView(mLogView); - return mScrollView; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - View result = inflateViews(); - - mLogView.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} - - @Override - public void afterTextChanged(Editable s) { - mScrollView.fullScroll(ScrollView.FOCUS_DOWN); - } - }); - return result; - } - - public LogView getLogView() { - return mLogView; - } -} \ No newline at end of file diff --git a/samples/browseable/Quiz/Application/src/com.example.android.common/logger/LogNode.java b/samples/browseable/Quiz/Application/src/com.example.android.common/logger/LogNode.java deleted file mode 100644 index bc37cabc0..000000000 --- a/samples/browseable/Quiz/Application/src/com.example.android.common/logger/LogNode.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -/** - * Basic interface for a logging system that can output to one or more targets. - * Note that in addition to classes that will output these logs in some format, - * one can also implement this interface over a filter and insert that in the chain, - * such that no targets further down see certain data, or see manipulated forms of the data. - * You could, for instance, write a "ToHtmlLoggerNode" that just converted all the log data - * it received to HTML and sent it along to the next node in the chain, without printing it - * anywhere. - */ -public interface LogNode { - - /** - * Instructs first LogNode in the list to print the log data provided. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public void println(int priority, String tag, String msg, Throwable tr); - -} diff --git a/samples/browseable/Quiz/Application/src/com.example.android.common/logger/LogView.java b/samples/browseable/Quiz/Application/src/com.example.android.common/logger/LogView.java deleted file mode 100644 index c01542b91..000000000 --- a/samples/browseable/Quiz/Application/src/com.example.android.common/logger/LogView.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -import android.app.Activity; -import android.content.Context; -import android.util.*; -import android.widget.TextView; - -/** Simple TextView which is used to output log data received through the LogNode interface. -*/ -public class LogView extends TextView implements LogNode { - - public LogView(Context context) { - super(context); - } - - public LogView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LogView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - /** - * Formats the log data and prints it out to the LogView. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - - - String priorityStr = null; - - // For the purposes of this View, we want to print the priority as readable text. - switch(priority) { - case android.util.Log.VERBOSE: - priorityStr = "VERBOSE"; - break; - case android.util.Log.DEBUG: - priorityStr = "DEBUG"; - break; - case android.util.Log.INFO: - priorityStr = "INFO"; - break; - case android.util.Log.WARN: - priorityStr = "WARN"; - break; - case android.util.Log.ERROR: - priorityStr = "ERROR"; - break; - case android.util.Log.ASSERT: - priorityStr = "ASSERT"; - break; - default: - break; - } - - // Handily, the Log class has a facility for converting a stack trace into a usable string. - String exceptionStr = null; - if (tr != null) { - exceptionStr = android.util.Log.getStackTraceString(tr); - } - - // Take the priority, tag, message, and exception, and concatenate as necessary - // into one usable line of text. - final StringBuilder outputBuilder = new StringBuilder(); - - String delimiter = "\t"; - appendIfNotNull(outputBuilder, priorityStr, delimiter); - appendIfNotNull(outputBuilder, tag, delimiter); - appendIfNotNull(outputBuilder, msg, delimiter); - appendIfNotNull(outputBuilder, exceptionStr, delimiter); - - // In case this was originally called from an AsyncTask or some other off-UI thread, - // make sure the update occurs within the UI thread. - ((Activity) getContext()).runOnUiThread( (new Thread(new Runnable() { - @Override - public void run() { - // Display the text we just generated within the LogView. - appendToLog(outputBuilder.toString()); - } - }))); - - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } - - public LogNode getNext() { - return mNext; - } - - public void setNext(LogNode node) { - mNext = node; - } - - /** Takes a string and adds to it, with a separator, if the bit to be added isn't null. Since - * the logger takes so many arguments that might be null, this method helps cut out some of the - * agonizing tedium of writing the same 3 lines over and over. - * @param source StringBuilder containing the text to append to. - * @param addStr The String to append - * @param delimiter The String to separate the source and appended strings. A tab or comma, - * for instance. - * @return The fully concatenated String as a StringBuilder - */ - private StringBuilder appendIfNotNull(StringBuilder source, String addStr, String delimiter) { - if (addStr != null) { - if (addStr.length() == 0) { - delimiter = ""; - } - - return source.append(addStr).append(delimiter); - } - return source; - } - - // The next LogNode in the chain. - LogNode mNext; - - /** Outputs the string as a new line of log data in the LogView. */ - public void appendToLog(String s) { - append("\n" + s); - } - - -} diff --git a/samples/browseable/Quiz/Application/src/com.example.android.common/logger/LogWrapper.java b/samples/browseable/Quiz/Application/src/com.example.android.common/logger/LogWrapper.java deleted file mode 100644 index 16a9e7ba2..000000000 --- a/samples/browseable/Quiz/Application/src/com.example.android.common/logger/LogWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -import android.util.Log; - -/** - * Helper class which wraps Android's native Log utility in the Logger interface. This way - * normal DDMS output can be one of the many targets receiving and outputting logs simultaneously. - */ -public class LogWrapper implements LogNode { - - // For piping: The next node to receive Log data after this one has done its work. - private LogNode mNext; - - /** - * Returns the next LogNode in the linked list. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - - /** - * Prints data out to the console using Android's native log mechanism. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - // There actually are log methods that don't take a msg parameter. For now, - // if that's the case, just convert null to the empty string and move on. - String useMsg = msg; - if (useMsg == null) { - useMsg = ""; - } - - // If an exeption was provided, convert that exception to a usable string and attach - // it to the end of the msg method. - if (tr != null) { - msg += "\n" + Log.getStackTraceString(tr); - } - - // This is functionally identical to Log.x(tag, useMsg); - // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg) - Log.println(priority, tag, useMsg); - - // If this isn't the last node in the chain, move things along. - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } -} diff --git a/samples/browseable/Quiz/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java b/samples/browseable/Quiz/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java deleted file mode 100644 index 19967dcd4..000000000 --- a/samples/browseable/Quiz/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -/** - * Simple {@link LogNode} filter, removes everything except the message. - * Useful for situations like on-screen log output where you don't want a lot of metadata displayed, - * just easy-to-read message updates as they're happening. - */ -public class MessageOnlyLogFilter implements LogNode { - - LogNode mNext; - - /** - * Takes the "next" LogNode as a parameter, to simplify chaining. - * - * @param next The next LogNode in the pipeline. - */ - public MessageOnlyLogFilter(LogNode next) { - mNext = next; - } - - public MessageOnlyLogFilter() { - } - - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - if (mNext != null) { - getNext().println(Log.NONE, null, msg, null); - } - } - - /** - * Returns the next LogNode in the chain. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - -} diff --git a/samples/browseable/Quiz/Application/src/com.example.android.quiz/Constants.java b/samples/browseable/Quiz/Application/src/com.example.android.wearable.quiz/Constants.java similarity index 97% rename from samples/browseable/Quiz/Application/src/com.example.android.quiz/Constants.java rename to samples/browseable/Quiz/Application/src/com.example.android.wearable.quiz/Constants.java index ea5c56b5e..2bcfe5f18 100644 --- a/samples/browseable/Quiz/Application/src/com.example.android.quiz/Constants.java +++ b/samples/browseable/Quiz/Application/src/com.example.android.wearable.quiz/Constants.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.quiz; +package com.example.android.wearable.quiz; /** Constants used in the companion app. */ public final class Constants { diff --git a/samples/browseable/Quiz/Application/src/com.example.android.quiz/JsonUtils.java b/samples/browseable/Quiz/Application/src/com.example.android.wearable.quiz/JsonUtils.java similarity index 97% rename from samples/browseable/Quiz/Application/src/com.example.android.quiz/JsonUtils.java rename to samples/browseable/Quiz/Application/src/com.example.android.wearable.quiz/JsonUtils.java index a0f98c12b..df8c8998e 100644 --- a/samples/browseable/Quiz/Application/src/com.example.android.quiz/JsonUtils.java +++ b/samples/browseable/Quiz/Application/src/com.example.android.wearable.quiz/JsonUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.example.android.quiz; +package com.example.android.wearable.quiz; import android.content.Context; diff --git a/samples/browseable/Quiz/Application/src/com.example.android.quiz/MainActivity.java b/samples/browseable/Quiz/Application/src/com.example.android.wearable.quiz/MainActivity.java similarity index 96% rename from samples/browseable/Quiz/Application/src/com.example.android.quiz/MainActivity.java rename to samples/browseable/Quiz/Application/src/com.example.android.wearable.quiz/MainActivity.java index ab8e3b45b..0ff41f42d 100644 --- a/samples/browseable/Quiz/Application/src/com.example.android.quiz/MainActivity.java +++ b/samples/browseable/Quiz/Application/src/com.example.android.wearable.quiz/MainActivity.java @@ -14,21 +14,21 @@ * limitations under the License. */ -package com.example.android.quiz; +package com.example.android.wearable.quiz; -import static com.example.android.quiz.Constants.ANSWERS; -import static com.example.android.quiz.Constants.CHOSEN_ANSWER_CORRECT; -import static com.example.android.quiz.Constants.CORRECT_ANSWER_INDEX; -import static com.example.android.quiz.Constants.NUM_CORRECT; -import static com.example.android.quiz.Constants.NUM_INCORRECT; -import static com.example.android.quiz.Constants.NUM_SKIPPED; -import static com.example.android.quiz.Constants.QUESTION; -import static com.example.android.quiz.Constants.QUESTION_INDEX; -import static com.example.android.quiz.Constants.QUESTION_WAS_ANSWERED; -import static com.example.android.quiz.Constants.QUESTION_WAS_DELETED; -import static com.example.android.quiz.Constants.QUIZ_ENDED_PATH; -import static com.example.android.quiz.Constants.QUIZ_EXITED_PATH; -import static com.example.android.quiz.Constants.RESET_QUIZ_PATH; +import static com.example.android.wearable.quiz.Constants.ANSWERS; +import static com.example.android.wearable.quiz.Constants.CHOSEN_ANSWER_CORRECT; +import static com.example.android.wearable.quiz.Constants.CORRECT_ANSWER_INDEX; +import static com.example.android.wearable.quiz.Constants.NUM_CORRECT; +import static com.example.android.wearable.quiz.Constants.NUM_INCORRECT; +import static com.example.android.wearable.quiz.Constants.NUM_SKIPPED; +import static com.example.android.wearable.quiz.Constants.QUESTION; +import static com.example.android.wearable.quiz.Constants.QUESTION_INDEX; +import static com.example.android.wearable.quiz.Constants.QUESTION_WAS_ANSWERED; +import static com.example.android.wearable.quiz.Constants.QUESTION_WAS_DELETED; +import static com.example.android.wearable.quiz.Constants.QUIZ_ENDED_PATH; +import static com.example.android.wearable.quiz.Constants.QUIZ_EXITED_PATH; +import static com.example.android.wearable.quiz.Constants.RESET_QUIZ_PATH; import android.app.Activity; import android.graphics.Color; diff --git a/samples/browseable/Quiz/Shared/AndroidManifest.xml b/samples/browseable/Quiz/Shared/AndroidManifest.xml deleted file mode 100644 index 0d7b8a69c..000000000 --- a/samples/browseable/Quiz/Shared/AndroidManifest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - -+ + Introductory text that explains what the sample is intended to demonstrate. Edit + in template-params.xml. + +
diff --git a/samples/browseable/RepeatingAlarm/res/values-v21/template-styles.xml b/samples/browseable/RepeatingAlarm/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/RepeatingAlarm/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +When this is set as the head of the list, - * an instance of it can function as a drop-in replacement for {@link android.util.Log}. - * Most of the methods in this class server only to map a method call in Log to its equivalent - * in LogNode.
- */ -public class Log { - // Grabbing the native values from Android's native logging facilities, - // to make for easy migration and interop. - public static final int NONE = -1; - public static final int VERBOSE = android.util.Log.VERBOSE; - public static final int DEBUG = android.util.Log.DEBUG; - public static final int INFO = android.util.Log.INFO; - public static final int WARN = android.util.Log.WARN; - public static final int ERROR = android.util.Log.ERROR; - public static final int ASSERT = android.util.Log.ASSERT; - - // Stores the beginning of the LogNode topology. - private static LogNode mLogNode; - - /** - * Returns the next LogNode in the linked list. - */ - public static LogNode getLogNode() { - return mLogNode; - } - - /** - * Sets the LogNode data will be sent to. - */ - public static void setLogNode(LogNode node) { - mLogNode = node; - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void println(int priority, String tag, String msg, Throwable tr) { - if (mLogNode != null) { - mLogNode.println(priority, tag, msg, tr); - } - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - */ - public static void println(int priority, String tag, String msg) { - println(priority, tag, msg, null); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void v(String tag, String msg, Throwable tr) { - println(VERBOSE, tag, msg, tr); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void v(String tag, String msg) { - v(tag, msg, null); - } - - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void d(String tag, String msg, Throwable tr) { - println(DEBUG, tag, msg, tr); - } - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void d(String tag, String msg) { - d(tag, msg, null); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void i(String tag, String msg, Throwable tr) { - println(INFO, tag, msg, tr); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void i(String tag, String msg) { - i(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, String msg, Throwable tr) { - println(WARN, tag, msg, tr); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void w(String tag, String msg) { - w(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, Throwable tr) { - w(tag, null, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void e(String tag, String msg, Throwable tr) { - println(ERROR, tag, msg, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void e(String tag, String msg) { - e(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, String msg, Throwable tr) { - println(ASSERT, tag, msg, tr); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void wtf(String tag, String msg) { - wtf(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, Throwable tr) { - wtf(tag, null, tr); - } -} diff --git a/samples/browseable/SkeletonWearableApp/Application/src/com.example.android.common/logger/LogFragment.java b/samples/browseable/SkeletonWearableApp/Application/src/com.example.android.common/logger/LogFragment.java deleted file mode 100644 index b302acd4b..000000000 --- a/samples/browseable/SkeletonWearableApp/Application/src/com.example.android.common/logger/LogFragment.java +++ /dev/null @@ -1,109 +0,0 @@ -/* -* 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. -*/ -/* - * 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. - */ - -package com.example.android.common.logger; - -import android.graphics.Typeface; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ScrollView; - -/** - * Simple fraggment which contains a LogView and uses is to output log data it receives - * through the LogNode interface. - */ -public class LogFragment extends Fragment { - - private LogView mLogView; - private ScrollView mScrollView; - - public LogFragment() {} - - public View inflateViews() { - mScrollView = new ScrollView(getActivity()); - ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT); - mScrollView.setLayoutParams(scrollParams); - - mLogView = new LogView(getActivity()); - ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); - logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; - mLogView.setLayoutParams(logParams); - mLogView.setClickable(true); - mLogView.setFocusable(true); - mLogView.setTypeface(Typeface.MONOSPACE); - - // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! - int paddingDips = 16; - double scale = getResources().getDisplayMetrics().density; - int paddingPixels = (int) ((paddingDips * (scale)) + .5); - mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); - mLogView.setCompoundDrawablePadding(paddingPixels); - - mLogView.setGravity(Gravity.BOTTOM); - mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium); - - mScrollView.addView(mLogView); - return mScrollView; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - View result = inflateViews(); - - mLogView.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} - - @Override - public void afterTextChanged(Editable s) { - mScrollView.fullScroll(ScrollView.FOCUS_DOWN); - } - }); - return result; - } - - public LogView getLogView() { - return mLogView; - } -} \ No newline at end of file diff --git a/samples/browseable/SkeletonWearableApp/Application/src/com.example.android.common/logger/LogNode.java b/samples/browseable/SkeletonWearableApp/Application/src/com.example.android.common/logger/LogNode.java deleted file mode 100644 index bc37cabc0..000000000 --- a/samples/browseable/SkeletonWearableApp/Application/src/com.example.android.common/logger/LogNode.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -/** - * Basic interface for a logging system that can output to one or more targets. - * Note that in addition to classes that will output these logs in some format, - * one can also implement this interface over a filter and insert that in the chain, - * such that no targets further down see certain data, or see manipulated forms of the data. - * You could, for instance, write a "ToHtmlLoggerNode" that just converted all the log data - * it received to HTML and sent it along to the next node in the chain, without printing it - * anywhere. - */ -public interface LogNode { - - /** - * Instructs first LogNode in the list to print the log data provided. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public void println(int priority, String tag, String msg, Throwable tr); - -} diff --git a/samples/browseable/SkeletonWearableApp/Application/src/com.example.android.common/logger/LogView.java b/samples/browseable/SkeletonWearableApp/Application/src/com.example.android.common/logger/LogView.java deleted file mode 100644 index c01542b91..000000000 --- a/samples/browseable/SkeletonWearableApp/Application/src/com.example.android.common/logger/LogView.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -import android.app.Activity; -import android.content.Context; -import android.util.*; -import android.widget.TextView; - -/** Simple TextView which is used to output log data received through the LogNode interface. -*/ -public class LogView extends TextView implements LogNode { - - public LogView(Context context) { - super(context); - } - - public LogView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LogView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - /** - * Formats the log data and prints it out to the LogView. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - - - String priorityStr = null; - - // For the purposes of this View, we want to print the priority as readable text. - switch(priority) { - case android.util.Log.VERBOSE: - priorityStr = "VERBOSE"; - break; - case android.util.Log.DEBUG: - priorityStr = "DEBUG"; - break; - case android.util.Log.INFO: - priorityStr = "INFO"; - break; - case android.util.Log.WARN: - priorityStr = "WARN"; - break; - case android.util.Log.ERROR: - priorityStr = "ERROR"; - break; - case android.util.Log.ASSERT: - priorityStr = "ASSERT"; - break; - default: - break; - } - - // Handily, the Log class has a facility for converting a stack trace into a usable string. - String exceptionStr = null; - if (tr != null) { - exceptionStr = android.util.Log.getStackTraceString(tr); - } - - // Take the priority, tag, message, and exception, and concatenate as necessary - // into one usable line of text. - final StringBuilder outputBuilder = new StringBuilder(); - - String delimiter = "\t"; - appendIfNotNull(outputBuilder, priorityStr, delimiter); - appendIfNotNull(outputBuilder, tag, delimiter); - appendIfNotNull(outputBuilder, msg, delimiter); - appendIfNotNull(outputBuilder, exceptionStr, delimiter); - - // In case this was originally called from an AsyncTask or some other off-UI thread, - // make sure the update occurs within the UI thread. - ((Activity) getContext()).runOnUiThread( (new Thread(new Runnable() { - @Override - public void run() { - // Display the text we just generated within the LogView. - appendToLog(outputBuilder.toString()); - } - }))); - - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } - - public LogNode getNext() { - return mNext; - } - - public void setNext(LogNode node) { - mNext = node; - } - - /** Takes a string and adds to it, with a separator, if the bit to be added isn't null. Since - * the logger takes so many arguments that might be null, this method helps cut out some of the - * agonizing tedium of writing the same 3 lines over and over. - * @param source StringBuilder containing the text to append to. - * @param addStr The String to append - * @param delimiter The String to separate the source and appended strings. A tab or comma, - * for instance. - * @return The fully concatenated String as a StringBuilder - */ - private StringBuilder appendIfNotNull(StringBuilder source, String addStr, String delimiter) { - if (addStr != null) { - if (addStr.length() == 0) { - delimiter = ""; - } - - return source.append(addStr).append(delimiter); - } - return source; - } - - // The next LogNode in the chain. - LogNode mNext; - - /** Outputs the string as a new line of log data in the LogView. */ - public void appendToLog(String s) { - append("\n" + s); - } - - -} diff --git a/samples/browseable/SkeletonWearableApp/Application/src/com.example.android.common/logger/LogWrapper.java b/samples/browseable/SkeletonWearableApp/Application/src/com.example.android.common/logger/LogWrapper.java deleted file mode 100644 index 16a9e7ba2..000000000 --- a/samples/browseable/SkeletonWearableApp/Application/src/com.example.android.common/logger/LogWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -import android.util.Log; - -/** - * Helper class which wraps Android's native Log utility in the Logger interface. This way - * normal DDMS output can be one of the many targets receiving and outputting logs simultaneously. - */ -public class LogWrapper implements LogNode { - - // For piping: The next node to receive Log data after this one has done its work. - private LogNode mNext; - - /** - * Returns the next LogNode in the linked list. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - - /** - * Prints data out to the console using Android's native log mechanism. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - // There actually are log methods that don't take a msg parameter. For now, - // if that's the case, just convert null to the empty string and move on. - String useMsg = msg; - if (useMsg == null) { - useMsg = ""; - } - - // If an exeption was provided, convert that exception to a usable string and attach - // it to the end of the msg method. - if (tr != null) { - msg += "\n" + Log.getStackTraceString(tr); - } - - // This is functionally identical to Log.x(tag, useMsg); - // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg) - Log.println(priority, tag, useMsg); - - // If this isn't the last node in the chain, move things along. - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } -} diff --git a/samples/browseable/SkeletonWearableApp/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java b/samples/browseable/SkeletonWearableApp/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java deleted file mode 100644 index 19967dcd4..000000000 --- a/samples/browseable/SkeletonWearableApp/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -/** - * Simple {@link LogNode} filter, removes everything except the message. - * Useful for situations like on-screen log output where you don't want a lot of metadata displayed, - * just easy-to-read message updates as they're happening. - */ -public class MessageOnlyLogFilter implements LogNode { - - LogNode mNext; - - /** - * Takes the "next" LogNode as a parameter, to simplify chaining. - * - * @param next The next LogNode in the pipeline. - */ - public MessageOnlyLogFilter(LogNode next) { - mNext = next; - } - - public MessageOnlyLogFilter() { - } - - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - if (mNext != null) { - getNext().println(Log.NONE, null, msg, null); - } - } - - /** - * Returns the next LogNode in the chain. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - -} diff --git a/samples/browseable/SkeletonWearableApp/Shared/AndroidManifest.xml b/samples/browseable/SkeletonWearableApp/Shared/AndroidManifest.xml deleted file mode 100644 index 5e29d53dc..000000000 --- a/samples/browseable/SkeletonWearableApp/Shared/AndroidManifest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - -
- SlidingTabLayout to display a custom {@link
- android.support.v4.view.ViewPager ViewPager} title strip that gives
- continuous feedback to the user when scrolling.
-
\ No newline at end of file
+
+ A basic sample which shows how to use SlidingTabLayout to display a custom
+ ViewPager title strip which gives continuous feedback to the user when scrolling.
+
+
diff --git a/samples/browseable/SlidingTabsBasic/res/values-v21/template-styles.xml b/samples/browseable/SlidingTabsBasic/res/values-v21/template-styles.xml
new file mode 100644
index 000000000..134fcd9d3
--- /dev/null
+++ b/samples/browseable/SlidingTabsBasic/res/values-v21/template-styles.xml
@@ -0,0 +1,22 @@
+
+
+
- SlidingTabLayout to display a custom {@link
- android.support.v4.view.ViewPager ViewPager} title strip, with custom
- coloring for each tab.
-
\ No newline at end of file
+
+ A more advanced sample which shows how to use SlidingTabLayout to display a custom
+ ViewPager title strip, with custom coloring for each tab.
+
+
diff --git a/samples/browseable/SlidingTabsColors/res/values-v21/template-styles.xml b/samples/browseable/SlidingTabsColors/res/values-v21/template-styles.xml
new file mode 100644
index 000000000..134fcd9d3
--- /dev/null
+++ b/samples/browseable/SlidingTabsColors/res/values-v21/template-styles.xml
@@ -0,0 +1,22 @@
+
+
+When this is set as the head of the list, - * an instance of it can function as a drop-in replacement for {@link android.util.Log}. - * Most of the methods in this class server only to map a method call in Log to its equivalent - * in LogNode.
- */ -public class Log { - // Grabbing the native values from Android's native logging facilities, - // to make for easy migration and interop. - public static final int NONE = -1; - public static final int VERBOSE = android.util.Log.VERBOSE; - public static final int DEBUG = android.util.Log.DEBUG; - public static final int INFO = android.util.Log.INFO; - public static final int WARN = android.util.Log.WARN; - public static final int ERROR = android.util.Log.ERROR; - public static final int ASSERT = android.util.Log.ASSERT; - - // Stores the beginning of the LogNode topology. - private static LogNode mLogNode; - - /** - * Returns the next LogNode in the linked list. - */ - public static LogNode getLogNode() { - return mLogNode; - } - - /** - * Sets the LogNode data will be sent to. - */ - public static void setLogNode(LogNode node) { - mLogNode = node; - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void println(int priority, String tag, String msg, Throwable tr) { - if (mLogNode != null) { - mLogNode.println(priority, tag, msg, tr); - } - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - */ - public static void println(int priority, String tag, String msg) { - println(priority, tag, msg, null); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void v(String tag, String msg, Throwable tr) { - println(VERBOSE, tag, msg, tr); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void v(String tag, String msg) { - v(tag, msg, null); - } - - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void d(String tag, String msg, Throwable tr) { - println(DEBUG, tag, msg, tr); - } - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void d(String tag, String msg) { - d(tag, msg, null); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void i(String tag, String msg, Throwable tr) { - println(INFO, tag, msg, tr); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void i(String tag, String msg) { - i(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, String msg, Throwable tr) { - println(WARN, tag, msg, tr); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void w(String tag, String msg) { - w(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, Throwable tr) { - w(tag, null, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void e(String tag, String msg, Throwable tr) { - println(ERROR, tag, msg, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void e(String tag, String msg) { - e(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, String msg, Throwable tr) { - println(ASSERT, tag, msg, tr); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void wtf(String tag, String msg) { - wtf(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, Throwable tr) { - wtf(tag, null, tr); - } -} diff --git a/samples/browseable/SpeedTracker/Application/src/com.example.android.common/logger/LogFragment.java b/samples/browseable/SpeedTracker/Application/src/com.example.android.common/logger/LogFragment.java deleted file mode 100644 index b302acd4b..000000000 --- a/samples/browseable/SpeedTracker/Application/src/com.example.android.common/logger/LogFragment.java +++ /dev/null @@ -1,109 +0,0 @@ -/* -* 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. -*/ -/* - * 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. - */ - -package com.example.android.common.logger; - -import android.graphics.Typeface; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ScrollView; - -/** - * Simple fraggment which contains a LogView and uses is to output log data it receives - * through the LogNode interface. - */ -public class LogFragment extends Fragment { - - private LogView mLogView; - private ScrollView mScrollView; - - public LogFragment() {} - - public View inflateViews() { - mScrollView = new ScrollView(getActivity()); - ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT); - mScrollView.setLayoutParams(scrollParams); - - mLogView = new LogView(getActivity()); - ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); - logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; - mLogView.setLayoutParams(logParams); - mLogView.setClickable(true); - mLogView.setFocusable(true); - mLogView.setTypeface(Typeface.MONOSPACE); - - // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! - int paddingDips = 16; - double scale = getResources().getDisplayMetrics().density; - int paddingPixels = (int) ((paddingDips * (scale)) + .5); - mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); - mLogView.setCompoundDrawablePadding(paddingPixels); - - mLogView.setGravity(Gravity.BOTTOM); - mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium); - - mScrollView.addView(mLogView); - return mScrollView; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - View result = inflateViews(); - - mLogView.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} - - @Override - public void afterTextChanged(Editable s) { - mScrollView.fullScroll(ScrollView.FOCUS_DOWN); - } - }); - return result; - } - - public LogView getLogView() { - return mLogView; - } -} \ No newline at end of file diff --git a/samples/browseable/SpeedTracker/Application/src/com.example.android.common/logger/LogNode.java b/samples/browseable/SpeedTracker/Application/src/com.example.android.common/logger/LogNode.java deleted file mode 100644 index bc37cabc0..000000000 --- a/samples/browseable/SpeedTracker/Application/src/com.example.android.common/logger/LogNode.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -/** - * Basic interface for a logging system that can output to one or more targets. - * Note that in addition to classes that will output these logs in some format, - * one can also implement this interface over a filter and insert that in the chain, - * such that no targets further down see certain data, or see manipulated forms of the data. - * You could, for instance, write a "ToHtmlLoggerNode" that just converted all the log data - * it received to HTML and sent it along to the next node in the chain, without printing it - * anywhere. - */ -public interface LogNode { - - /** - * Instructs first LogNode in the list to print the log data provided. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public void println(int priority, String tag, String msg, Throwable tr); - -} diff --git a/samples/browseable/SpeedTracker/Application/src/com.example.android.common/logger/LogView.java b/samples/browseable/SpeedTracker/Application/src/com.example.android.common/logger/LogView.java deleted file mode 100644 index c01542b91..000000000 --- a/samples/browseable/SpeedTracker/Application/src/com.example.android.common/logger/LogView.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -import android.app.Activity; -import android.content.Context; -import android.util.*; -import android.widget.TextView; - -/** Simple TextView which is used to output log data received through the LogNode interface. -*/ -public class LogView extends TextView implements LogNode { - - public LogView(Context context) { - super(context); - } - - public LogView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LogView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - /** - * Formats the log data and prints it out to the LogView. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - - - String priorityStr = null; - - // For the purposes of this View, we want to print the priority as readable text. - switch(priority) { - case android.util.Log.VERBOSE: - priorityStr = "VERBOSE"; - break; - case android.util.Log.DEBUG: - priorityStr = "DEBUG"; - break; - case android.util.Log.INFO: - priorityStr = "INFO"; - break; - case android.util.Log.WARN: - priorityStr = "WARN"; - break; - case android.util.Log.ERROR: - priorityStr = "ERROR"; - break; - case android.util.Log.ASSERT: - priorityStr = "ASSERT"; - break; - default: - break; - } - - // Handily, the Log class has a facility for converting a stack trace into a usable string. - String exceptionStr = null; - if (tr != null) { - exceptionStr = android.util.Log.getStackTraceString(tr); - } - - // Take the priority, tag, message, and exception, and concatenate as necessary - // into one usable line of text. - final StringBuilder outputBuilder = new StringBuilder(); - - String delimiter = "\t"; - appendIfNotNull(outputBuilder, priorityStr, delimiter); - appendIfNotNull(outputBuilder, tag, delimiter); - appendIfNotNull(outputBuilder, msg, delimiter); - appendIfNotNull(outputBuilder, exceptionStr, delimiter); - - // In case this was originally called from an AsyncTask or some other off-UI thread, - // make sure the update occurs within the UI thread. - ((Activity) getContext()).runOnUiThread( (new Thread(new Runnable() { - @Override - public void run() { - // Display the text we just generated within the LogView. - appendToLog(outputBuilder.toString()); - } - }))); - - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } - - public LogNode getNext() { - return mNext; - } - - public void setNext(LogNode node) { - mNext = node; - } - - /** Takes a string and adds to it, with a separator, if the bit to be added isn't null. Since - * the logger takes so many arguments that might be null, this method helps cut out some of the - * agonizing tedium of writing the same 3 lines over and over. - * @param source StringBuilder containing the text to append to. - * @param addStr The String to append - * @param delimiter The String to separate the source and appended strings. A tab or comma, - * for instance. - * @return The fully concatenated String as a StringBuilder - */ - private StringBuilder appendIfNotNull(StringBuilder source, String addStr, String delimiter) { - if (addStr != null) { - if (addStr.length() == 0) { - delimiter = ""; - } - - return source.append(addStr).append(delimiter); - } - return source; - } - - // The next LogNode in the chain. - LogNode mNext; - - /** Outputs the string as a new line of log data in the LogView. */ - public void appendToLog(String s) { - append("\n" + s); - } - - -} diff --git a/samples/browseable/SpeedTracker/Application/src/com.example.android.common/logger/LogWrapper.java b/samples/browseable/SpeedTracker/Application/src/com.example.android.common/logger/LogWrapper.java deleted file mode 100644 index 16a9e7ba2..000000000 --- a/samples/browseable/SpeedTracker/Application/src/com.example.android.common/logger/LogWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -import android.util.Log; - -/** - * Helper class which wraps Android's native Log utility in the Logger interface. This way - * normal DDMS output can be one of the many targets receiving and outputting logs simultaneously. - */ -public class LogWrapper implements LogNode { - - // For piping: The next node to receive Log data after this one has done its work. - private LogNode mNext; - - /** - * Returns the next LogNode in the linked list. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - - /** - * Prints data out to the console using Android's native log mechanism. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - // There actually are log methods that don't take a msg parameter. For now, - // if that's the case, just convert null to the empty string and move on. - String useMsg = msg; - if (useMsg == null) { - useMsg = ""; - } - - // If an exeption was provided, convert that exception to a usable string and attach - // it to the end of the msg method. - if (tr != null) { - msg += "\n" + Log.getStackTraceString(tr); - } - - // This is functionally identical to Log.x(tag, useMsg); - // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg) - Log.println(priority, tag, useMsg); - - // If this isn't the last node in the chain, move things along. - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } -} diff --git a/samples/browseable/SpeedTracker/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java b/samples/browseable/SpeedTracker/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java deleted file mode 100644 index 19967dcd4..000000000 --- a/samples/browseable/SpeedTracker/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -/** - * Simple {@link LogNode} filter, removes everything except the message. - * Useful for situations like on-screen log output where you don't want a lot of metadata displayed, - * just easy-to-read message updates as they're happening. - */ -public class MessageOnlyLogFilter implements LogNode { - - LogNode mNext; - - /** - * Takes the "next" LogNode as a parameter, to simplify chaining. - * - * @param next The next LogNode in the pipeline. - */ - public MessageOnlyLogFilter(LogNode next) { - mNext = next; - } - - public MessageOnlyLogFilter() { - } - - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - if (mNext != null) { - getNext().println(Log.NONE, null, msg, null); - } - } - - /** - * Returns the next LogNode in the chain. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - -} diff --git a/samples/browseable/StorageClient/AndroidManifest.xml b/samples/browseable/StorageClient/AndroidManifest.xml index d35a4ec22..0bcfde911 100644 --- a/samples/browseable/StorageClient/AndroidManifest.xml +++ b/samples/browseable/StorageClient/AndroidManifest.xml @@ -19,7 +19,7 @@ android:versionCode="1" android:versionName="1.0"> -+ + Using the OPEN_DOCUMENT intent, a client app can access a list of Document Providers + on the device, and choose a file from any of them. + \n\nTo demonstrate this, click the button below to open up the Storage Access Framework + interface, and choose an image on your device. It will be displayed in this app. + +
diff --git a/samples/browseable/StorageClient/res/values-v21/template-styles.xml b/samples/browseable/StorageClient/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/StorageClient/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +This sample demonstrates how to use the -{@link android.provider.DocumentsProvider} API to manage documents and -expose them to the Android system for sharing.
++ + \nA simple implementation of a documents provider using the storage access framework in + Android 4.4. + +
diff --git a/samples/browseable/StorageProvider/res/values-v21/template-styles.xml b/samples/browseable/StorageProvider/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/StorageProvider/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + ++ + A basic sample which shows how to use SwipeRefreshLayout to add the \'swipe-to-refresh\' + gesture to a View, enabling the ability to trigger a refresh from swiping down on the view. + In this sample the View which can be refreshed is a ListView. + +
diff --git a/samples/browseable/SwipeRefreshLayoutBasic/res/values-v21/template-styles.xml b/samples/browseable/SwipeRefreshLayoutBasic/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/SwipeRefreshLayoutBasic/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +SwipeRefreshListFragment class, which you
-can reuse.
++ + A sample which shows how to use SwipeRefreshLayout within a ListFragment to add the + \'swipe-to-refresh\' gesture to a ListView, enabling the ability to trigger a refresh + from swiping down on that view. This is provided through the re-usable + SwipeRefreshListFragment class. + +
diff --git a/samples/browseable/SwipeRefreshListFragment/res/values-v21/template-styles.xml b/samples/browseable/SwipeRefreshListFragment/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/SwipeRefreshListFragment/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + ++ + A sample which shows how to use SwipeRefreshLayout to add the \'swipe-to-refresh\' + gesture to a layout with multiple children, enabling the ability to trigger a + refresh from swiping down on the visible view. In this sample, SwipeRefreshLayout + contains a scrollable GridView, along with a TextView empty view. + +
diff --git a/samples/browseable/SwipeRefreshMultipleViews/res/values-v21/template-styles.xml b/samples/browseable/SwipeRefreshMultipleViews/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/SwipeRefreshMultipleViews/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + ++ + This sample illustrates how links can be added to a TextView. This can be done either + automatically by setting the "autoLink" property or explicitly. + +
diff --git a/samples/browseable/TextLinkify/res/values-v21/template-styles.xml b/samples/browseable/TextLinkify/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/TextLinkify/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + ++ + This sample illustrates the use of a TextSwitcher to display text. + \n\nClick the button below to set new text in the TextSwitcher and observe the + in and out fade animations. + +
diff --git a/samples/browseable/TextSwitcher/res/values-v21/template-styles.xml b/samples/browseable/TextSwitcher/res/values-v21/template-styles.xml new file mode 100644 index 000000000..134fcd9d3 --- /dev/null +++ b/samples/browseable/TextSwitcher/res/values-v21/template-styles.xml @@ -0,0 +1,22 @@ + + +When this is set as the head of the list, - * an instance of it can function as a drop-in replacement for {@link android.util.Log}. - * Most of the methods in this class server only to map a method call in Log to its equivalent - * in LogNode.
- */ -public class Log { - // Grabbing the native values from Android's native logging facilities, - // to make for easy migration and interop. - public static final int NONE = -1; - public static final int VERBOSE = android.util.Log.VERBOSE; - public static final int DEBUG = android.util.Log.DEBUG; - public static final int INFO = android.util.Log.INFO; - public static final int WARN = android.util.Log.WARN; - public static final int ERROR = android.util.Log.ERROR; - public static final int ASSERT = android.util.Log.ASSERT; - - // Stores the beginning of the LogNode topology. - private static LogNode mLogNode; - - /** - * Returns the next LogNode in the linked list. - */ - public static LogNode getLogNode() { - return mLogNode; - } - - /** - * Sets the LogNode data will be sent to. - */ - public static void setLogNode(LogNode node) { - mLogNode = node; - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void println(int priority, String tag, String msg, Throwable tr) { - if (mLogNode != null) { - mLogNode.println(priority, tag, msg, tr); - } - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - */ - public static void println(int priority, String tag, String msg) { - println(priority, tag, msg, null); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void v(String tag, String msg, Throwable tr) { - println(VERBOSE, tag, msg, tr); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void v(String tag, String msg) { - v(tag, msg, null); - } - - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void d(String tag, String msg, Throwable tr) { - println(DEBUG, tag, msg, tr); - } - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void d(String tag, String msg) { - d(tag, msg, null); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void i(String tag, String msg, Throwable tr) { - println(INFO, tag, msg, tr); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void i(String tag, String msg) { - i(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, String msg, Throwable tr) { - println(WARN, tag, msg, tr); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void w(String tag, String msg) { - w(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, Throwable tr) { - w(tag, null, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void e(String tag, String msg, Throwable tr) { - println(ERROR, tag, msg, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void e(String tag, String msg) { - e(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, String msg, Throwable tr) { - println(ASSERT, tag, msg, tr); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void wtf(String tag, String msg) { - wtf(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, Throwable tr) { - wtf(tag, null, tr); - } -} diff --git a/samples/browseable/Timer/Application/src/com.example.android.common/logger/LogFragment.java b/samples/browseable/Timer/Application/src/com.example.android.common/logger/LogFragment.java deleted file mode 100644 index b302acd4b..000000000 --- a/samples/browseable/Timer/Application/src/com.example.android.common/logger/LogFragment.java +++ /dev/null @@ -1,109 +0,0 @@ -/* -* 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. -*/ -/* - * 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. - */ - -package com.example.android.common.logger; - -import android.graphics.Typeface; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ScrollView; - -/** - * Simple fraggment which contains a LogView and uses is to output log data it receives - * through the LogNode interface. - */ -public class LogFragment extends Fragment { - - private LogView mLogView; - private ScrollView mScrollView; - - public LogFragment() {} - - public View inflateViews() { - mScrollView = new ScrollView(getActivity()); - ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT); - mScrollView.setLayoutParams(scrollParams); - - mLogView = new LogView(getActivity()); - ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); - logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; - mLogView.setLayoutParams(logParams); - mLogView.setClickable(true); - mLogView.setFocusable(true); - mLogView.setTypeface(Typeface.MONOSPACE); - - // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! - int paddingDips = 16; - double scale = getResources().getDisplayMetrics().density; - int paddingPixels = (int) ((paddingDips * (scale)) + .5); - mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); - mLogView.setCompoundDrawablePadding(paddingPixels); - - mLogView.setGravity(Gravity.BOTTOM); - mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium); - - mScrollView.addView(mLogView); - return mScrollView; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - View result = inflateViews(); - - mLogView.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} - - @Override - public void afterTextChanged(Editable s) { - mScrollView.fullScroll(ScrollView.FOCUS_DOWN); - } - }); - return result; - } - - public LogView getLogView() { - return mLogView; - } -} \ No newline at end of file diff --git a/samples/browseable/Timer/Application/src/com.example.android.common/logger/LogNode.java b/samples/browseable/Timer/Application/src/com.example.android.common/logger/LogNode.java deleted file mode 100644 index bc37cabc0..000000000 --- a/samples/browseable/Timer/Application/src/com.example.android.common/logger/LogNode.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -/** - * Basic interface for a logging system that can output to one or more targets. - * Note that in addition to classes that will output these logs in some format, - * one can also implement this interface over a filter and insert that in the chain, - * such that no targets further down see certain data, or see manipulated forms of the data. - * You could, for instance, write a "ToHtmlLoggerNode" that just converted all the log data - * it received to HTML and sent it along to the next node in the chain, without printing it - * anywhere. - */ -public interface LogNode { - - /** - * Instructs first LogNode in the list to print the log data provided. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public void println(int priority, String tag, String msg, Throwable tr); - -} diff --git a/samples/browseable/Timer/Application/src/com.example.android.common/logger/LogView.java b/samples/browseable/Timer/Application/src/com.example.android.common/logger/LogView.java deleted file mode 100644 index c01542b91..000000000 --- a/samples/browseable/Timer/Application/src/com.example.android.common/logger/LogView.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -import android.app.Activity; -import android.content.Context; -import android.util.*; -import android.widget.TextView; - -/** Simple TextView which is used to output log data received through the LogNode interface. -*/ -public class LogView extends TextView implements LogNode { - - public LogView(Context context) { - super(context); - } - - public LogView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LogView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - /** - * Formats the log data and prints it out to the LogView. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - - - String priorityStr = null; - - // For the purposes of this View, we want to print the priority as readable text. - switch(priority) { - case android.util.Log.VERBOSE: - priorityStr = "VERBOSE"; - break; - case android.util.Log.DEBUG: - priorityStr = "DEBUG"; - break; - case android.util.Log.INFO: - priorityStr = "INFO"; - break; - case android.util.Log.WARN: - priorityStr = "WARN"; - break; - case android.util.Log.ERROR: - priorityStr = "ERROR"; - break; - case android.util.Log.ASSERT: - priorityStr = "ASSERT"; - break; - default: - break; - } - - // Handily, the Log class has a facility for converting a stack trace into a usable string. - String exceptionStr = null; - if (tr != null) { - exceptionStr = android.util.Log.getStackTraceString(tr); - } - - // Take the priority, tag, message, and exception, and concatenate as necessary - // into one usable line of text. - final StringBuilder outputBuilder = new StringBuilder(); - - String delimiter = "\t"; - appendIfNotNull(outputBuilder, priorityStr, delimiter); - appendIfNotNull(outputBuilder, tag, delimiter); - appendIfNotNull(outputBuilder, msg, delimiter); - appendIfNotNull(outputBuilder, exceptionStr, delimiter); - - // In case this was originally called from an AsyncTask or some other off-UI thread, - // make sure the update occurs within the UI thread. - ((Activity) getContext()).runOnUiThread( (new Thread(new Runnable() { - @Override - public void run() { - // Display the text we just generated within the LogView. - appendToLog(outputBuilder.toString()); - } - }))); - - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } - - public LogNode getNext() { - return mNext; - } - - public void setNext(LogNode node) { - mNext = node; - } - - /** Takes a string and adds to it, with a separator, if the bit to be added isn't null. Since - * the logger takes so many arguments that might be null, this method helps cut out some of the - * agonizing tedium of writing the same 3 lines over and over. - * @param source StringBuilder containing the text to append to. - * @param addStr The String to append - * @param delimiter The String to separate the source and appended strings. A tab or comma, - * for instance. - * @return The fully concatenated String as a StringBuilder - */ - private StringBuilder appendIfNotNull(StringBuilder source, String addStr, String delimiter) { - if (addStr != null) { - if (addStr.length() == 0) { - delimiter = ""; - } - - return source.append(addStr).append(delimiter); - } - return source; - } - - // The next LogNode in the chain. - LogNode mNext; - - /** Outputs the string as a new line of log data in the LogView. */ - public void appendToLog(String s) { - append("\n" + s); - } - - -} diff --git a/samples/browseable/Timer/Application/src/com.example.android.common/logger/LogWrapper.java b/samples/browseable/Timer/Application/src/com.example.android.common/logger/LogWrapper.java deleted file mode 100644 index 16a9e7ba2..000000000 --- a/samples/browseable/Timer/Application/src/com.example.android.common/logger/LogWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -import android.util.Log; - -/** - * Helper class which wraps Android's native Log utility in the Logger interface. This way - * normal DDMS output can be one of the many targets receiving and outputting logs simultaneously. - */ -public class LogWrapper implements LogNode { - - // For piping: The next node to receive Log data after this one has done its work. - private LogNode mNext; - - /** - * Returns the next LogNode in the linked list. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - - /** - * Prints data out to the console using Android's native log mechanism. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - // There actually are log methods that don't take a msg parameter. For now, - // if that's the case, just convert null to the empty string and move on. - String useMsg = msg; - if (useMsg == null) { - useMsg = ""; - } - - // If an exeption was provided, convert that exception to a usable string and attach - // it to the end of the msg method. - if (tr != null) { - msg += "\n" + Log.getStackTraceString(tr); - } - - // This is functionally identical to Log.x(tag, useMsg); - // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg) - Log.println(priority, tag, useMsg); - - // If this isn't the last node in the chain, move things along. - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } -} diff --git a/samples/browseable/Timer/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java b/samples/browseable/Timer/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java deleted file mode 100644 index 19967dcd4..000000000 --- a/samples/browseable/Timer/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -/** - * Simple {@link LogNode} filter, removes everything except the message. - * Useful for situations like on-screen log output where you don't want a lot of metadata displayed, - * just easy-to-read message updates as they're happening. - */ -public class MessageOnlyLogFilter implements LogNode { - - LogNode mNext; - - /** - * Takes the "next" LogNode as a parameter, to simplify chaining. - * - * @param next The next LogNode in the pipeline. - */ - public MessageOnlyLogFilter(LogNode next) { - mNext = next; - } - - public MessageOnlyLogFilter() { - } - - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - if (mNext != null) { - getNext().println(Log.NONE, null, msg, null); - } - } - - /** - * Returns the next LogNode in the chain. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - -} diff --git a/samples/browseable/Timer/Shared/AndroidManifest.xml b/samples/browseable/Timer/Shared/AndroidManifest.xml deleted file mode 100644 index c332a848b..000000000 --- a/samples/browseable/Timer/Shared/AndroidManifest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - -When this is set as the head of the list, - * an instance of it can function as a drop-in replacement for {@link android.util.Log}. - * Most of the methods in this class server only to map a method call in Log to its equivalent - * in LogNode.
- */ -public class Log { - // Grabbing the native values from Android's native logging facilities, - // to make for easy migration and interop. - public static final int NONE = -1; - public static final int VERBOSE = android.util.Log.VERBOSE; - public static final int DEBUG = android.util.Log.DEBUG; - public static final int INFO = android.util.Log.INFO; - public static final int WARN = android.util.Log.WARN; - public static final int ERROR = android.util.Log.ERROR; - public static final int ASSERT = android.util.Log.ASSERT; - - // Stores the beginning of the LogNode topology. - private static LogNode mLogNode; - - /** - * Returns the next LogNode in the linked list. - */ - public static LogNode getLogNode() { - return mLogNode; - } - - /** - * Sets the LogNode data will be sent to. - */ - public static void setLogNode(LogNode node) { - mLogNode = node; - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void println(int priority, String tag, String msg, Throwable tr) { - if (mLogNode != null) { - mLogNode.println(priority, tag, msg, tr); - } - } - - /** - * Instructs the LogNode to print the log data provided. Other LogNodes can - * be chained to the end of the LogNode as desired. - * - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - */ - public static void println(int priority, String tag, String msg) { - println(priority, tag, msg, null); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void v(String tag, String msg, Throwable tr) { - println(VERBOSE, tag, msg, tr); - } - - /** - * Prints a message at VERBOSE priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void v(String tag, String msg) { - v(tag, msg, null); - } - - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void d(String tag, String msg, Throwable tr) { - println(DEBUG, tag, msg, tr); - } - - /** - * Prints a message at DEBUG priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void d(String tag, String msg) { - d(tag, msg, null); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void i(String tag, String msg, Throwable tr) { - println(INFO, tag, msg, tr); - } - - /** - * Prints a message at INFO priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void i(String tag, String msg) { - i(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, String msg, Throwable tr) { - println(WARN, tag, msg, tr); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void w(String tag, String msg) { - w(tag, msg, null); - } - - /** - * Prints a message at WARN priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void w(String tag, Throwable tr) { - w(tag, null, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void e(String tag, String msg, Throwable tr) { - println(ERROR, tag, msg, tr); - } - - /** - * Prints a message at ERROR priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void e(String tag, String msg) { - e(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, String msg, Throwable tr) { - println(ASSERT, tag, msg, tr); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. - */ - public static void wtf(String tag, String msg) { - wtf(tag, msg, null); - } - - /** - * Prints a message at ASSERT priority. - * - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public static void wtf(String tag, Throwable tr) { - wtf(tag, null, tr); - } -} diff --git a/samples/browseable/WatchViewStub/Application/src/com.example.android.common/logger/LogFragment.java b/samples/browseable/WatchViewStub/Application/src/com.example.android.common/logger/LogFragment.java deleted file mode 100644 index b302acd4b..000000000 --- a/samples/browseable/WatchViewStub/Application/src/com.example.android.common/logger/LogFragment.java +++ /dev/null @@ -1,109 +0,0 @@ -/* -* 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. -*/ -/* - * 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. - */ - -package com.example.android.common.logger; - -import android.graphics.Typeface; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ScrollView; - -/** - * Simple fraggment which contains a LogView and uses is to output log data it receives - * through the LogNode interface. - */ -public class LogFragment extends Fragment { - - private LogView mLogView; - private ScrollView mScrollView; - - public LogFragment() {} - - public View inflateViews() { - mScrollView = new ScrollView(getActivity()); - ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT); - mScrollView.setLayoutParams(scrollParams); - - mLogView = new LogView(getActivity()); - ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); - logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; - mLogView.setLayoutParams(logParams); - mLogView.setClickable(true); - mLogView.setFocusable(true); - mLogView.setTypeface(Typeface.MONOSPACE); - - // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! - int paddingDips = 16; - double scale = getResources().getDisplayMetrics().density; - int paddingPixels = (int) ((paddingDips * (scale)) + .5); - mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); - mLogView.setCompoundDrawablePadding(paddingPixels); - - mLogView.setGravity(Gravity.BOTTOM); - mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium); - - mScrollView.addView(mLogView); - return mScrollView; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - View result = inflateViews(); - - mLogView.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} - - @Override - public void afterTextChanged(Editable s) { - mScrollView.fullScroll(ScrollView.FOCUS_DOWN); - } - }); - return result; - } - - public LogView getLogView() { - return mLogView; - } -} \ No newline at end of file diff --git a/samples/browseable/WatchViewStub/Application/src/com.example.android.common/logger/LogNode.java b/samples/browseable/WatchViewStub/Application/src/com.example.android.common/logger/LogNode.java deleted file mode 100644 index bc37cabc0..000000000 --- a/samples/browseable/WatchViewStub/Application/src/com.example.android.common/logger/LogNode.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -/** - * Basic interface for a logging system that can output to one or more targets. - * Note that in addition to classes that will output these logs in some format, - * one can also implement this interface over a filter and insert that in the chain, - * such that no targets further down see certain data, or see manipulated forms of the data. - * You could, for instance, write a "ToHtmlLoggerNode" that just converted all the log data - * it received to HTML and sent it along to the next node in the chain, without printing it - * anywhere. - */ -public interface LogNode { - - /** - * Instructs first LogNode in the list to print the log data provided. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - public void println(int priority, String tag, String msg, Throwable tr); - -} diff --git a/samples/browseable/WatchViewStub/Application/src/com.example.android.common/logger/LogView.java b/samples/browseable/WatchViewStub/Application/src/com.example.android.common/logger/LogView.java deleted file mode 100644 index c01542b91..000000000 --- a/samples/browseable/WatchViewStub/Application/src/com.example.android.common/logger/LogView.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -import android.app.Activity; -import android.content.Context; -import android.util.*; -import android.widget.TextView; - -/** Simple TextView which is used to output log data received through the LogNode interface. -*/ -public class LogView extends TextView implements LogNode { - - public LogView(Context context) { - super(context); - } - - public LogView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LogView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - /** - * Formats the log data and prints it out to the LogView. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - - - String priorityStr = null; - - // For the purposes of this View, we want to print the priority as readable text. - switch(priority) { - case android.util.Log.VERBOSE: - priorityStr = "VERBOSE"; - break; - case android.util.Log.DEBUG: - priorityStr = "DEBUG"; - break; - case android.util.Log.INFO: - priorityStr = "INFO"; - break; - case android.util.Log.WARN: - priorityStr = "WARN"; - break; - case android.util.Log.ERROR: - priorityStr = "ERROR"; - break; - case android.util.Log.ASSERT: - priorityStr = "ASSERT"; - break; - default: - break; - } - - // Handily, the Log class has a facility for converting a stack trace into a usable string. - String exceptionStr = null; - if (tr != null) { - exceptionStr = android.util.Log.getStackTraceString(tr); - } - - // Take the priority, tag, message, and exception, and concatenate as necessary - // into one usable line of text. - final StringBuilder outputBuilder = new StringBuilder(); - - String delimiter = "\t"; - appendIfNotNull(outputBuilder, priorityStr, delimiter); - appendIfNotNull(outputBuilder, tag, delimiter); - appendIfNotNull(outputBuilder, msg, delimiter); - appendIfNotNull(outputBuilder, exceptionStr, delimiter); - - // In case this was originally called from an AsyncTask or some other off-UI thread, - // make sure the update occurs within the UI thread. - ((Activity) getContext()).runOnUiThread( (new Thread(new Runnable() { - @Override - public void run() { - // Display the text we just generated within the LogView. - appendToLog(outputBuilder.toString()); - } - }))); - - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } - - public LogNode getNext() { - return mNext; - } - - public void setNext(LogNode node) { - mNext = node; - } - - /** Takes a string and adds to it, with a separator, if the bit to be added isn't null. Since - * the logger takes so many arguments that might be null, this method helps cut out some of the - * agonizing tedium of writing the same 3 lines over and over. - * @param source StringBuilder containing the text to append to. - * @param addStr The String to append - * @param delimiter The String to separate the source and appended strings. A tab or comma, - * for instance. - * @return The fully concatenated String as a StringBuilder - */ - private StringBuilder appendIfNotNull(StringBuilder source, String addStr, String delimiter) { - if (addStr != null) { - if (addStr.length() == 0) { - delimiter = ""; - } - - return source.append(addStr).append(delimiter); - } - return source; - } - - // The next LogNode in the chain. - LogNode mNext; - - /** Outputs the string as a new line of log data in the LogView. */ - public void appendToLog(String s) { - append("\n" + s); - } - - -} diff --git a/samples/browseable/WatchViewStub/Application/src/com.example.android.common/logger/LogWrapper.java b/samples/browseable/WatchViewStub/Application/src/com.example.android.common/logger/LogWrapper.java deleted file mode 100644 index 16a9e7ba2..000000000 --- a/samples/browseable/WatchViewStub/Application/src/com.example.android.common/logger/LogWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 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.common.logger; - -import android.util.Log; - -/** - * Helper class which wraps Android's native Log utility in the Logger interface. This way - * normal DDMS output can be one of the many targets receiving and outputting logs simultaneously. - */ -public class LogWrapper implements LogNode { - - // For piping: The next node to receive Log data after this one has done its work. - private LogNode mNext; - - /** - * Returns the next LogNode in the linked list. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - - /** - * Prints data out to the console using Android's native log mechanism. - * @param priority Log level of the data being logged. Verbose, Error, etc. - * @param tag Tag for for the log data. Can be used to organize log statements. - * @param msg The actual message to be logged. The actual message to be logged. - * @param tr If an exception was thrown, this can be sent along for the logging facilities - * to extract and print useful information. - */ - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - // There actually are log methods that don't take a msg parameter. For now, - // if that's the case, just convert null to the empty string and move on. - String useMsg = msg; - if (useMsg == null) { - useMsg = ""; - } - - // If an exeption was provided, convert that exception to a usable string and attach - // it to the end of the msg method. - if (tr != null) { - msg += "\n" + Log.getStackTraceString(tr); - } - - // This is functionally identical to Log.x(tag, useMsg); - // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg) - Log.println(priority, tag, useMsg); - - // If this isn't the last node in the chain, move things along. - if (mNext != null) { - mNext.println(priority, tag, msg, tr); - } - } -} diff --git a/samples/browseable/WatchViewStub/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java b/samples/browseable/WatchViewStub/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java deleted file mode 100644 index 19967dcd4..000000000 --- a/samples/browseable/WatchViewStub/Application/src/com.example.android.common/logger/MessageOnlyLogFilter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 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. - */ -package com.example.android.common.logger; - -/** - * Simple {@link LogNode} filter, removes everything except the message. - * Useful for situations like on-screen log output where you don't want a lot of metadata displayed, - * just easy-to-read message updates as they're happening. - */ -public class MessageOnlyLogFilter implements LogNode { - - LogNode mNext; - - /** - * Takes the "next" LogNode as a parameter, to simplify chaining. - * - * @param next The next LogNode in the pipeline. - */ - public MessageOnlyLogFilter(LogNode next) { - mNext = next; - } - - public MessageOnlyLogFilter() { - } - - @Override - public void println(int priority, String tag, String msg, Throwable tr) { - if (mNext != null) { - getNext().println(Log.NONE, null, msg, null); - } - } - - /** - * Returns the next LogNode in the chain. - */ - public LogNode getNext() { - return mNext; - } - - /** - * Sets the LogNode data will be sent to.. - */ - public void setNext(LogNode node) { - mNext = node; - } - -} diff --git a/samples/browseable/WatchViewStub/Shared/AndroidManifest.xml b/samples/browseable/WatchViewStub/Shared/AndroidManifest.xml deleted file mode 100644 index 846fa9d2e..000000000 --- a/samples/browseable/WatchViewStub/Shared/AndroidManifest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - -