Permalink
Browse files

initial import

  • Loading branch information...
0 parents commit 2c317ab6c587046a0017e9fa521c4541d824326c @commonsguy committed May 2, 2013
Showing with 1,746 additions and 0 deletions.
  1. +8 −0 .classpath
  2. +33 −0 .project
  3. +13 −0 AndroidManifest.xml
  4. +192 −0 README.markdown
  5. +99 −0 build.xml
  6. +8 −0 demo/.classpath
  7. +33 −0 demo/.project
  8. +41 −0 demo/AndroidManifest.xml
  9. +92 −0 demo/build.xml
  10. +20 −0 demo/proguard-project.txt
  11. +15 −0 demo/project.properties
  12. BIN demo/res/drawable-hdpi/ic_launcher.png
  13. BIN demo/res/drawable-ldpi/ic_launcher.png
  14. BIN demo/res/drawable-mdpi/ic_launcher.png
  15. BIN demo/res/drawable-xhdpi/ic_launcher.png
  16. +25 −0 demo/res/layout/activity_main.xml
  17. +26 −0 demo/res/layout/mirror_fragment.xml
  18. +5 −0 demo/res/layout/mirror_presentation.xml
  19. +40 −0 demo/res/layout/simple_mirror.xml
  20. +16 −0 demo/res/menu/main.xml
  21. +8 −0 demo/res/values-sw600dp/dimens.xml
  22. +9 −0 demo/res/values-sw720dp-land/dimens.xml
  23. +11 −0 demo/res/values-v11/styles.xml
  24. +12 −0 demo/res/values-v14/styles.xml
  25. +7 −0 demo/res/values/dimens.xml
  26. +13 −0 demo/res/values/strings.xml
  27. +20 −0 demo/res/values/styles.xml
  28. +120 −0 demo/src/com/commonsware/cwac/preso/demo/MainActivity.java
  29. +38 −0 demo/src/com/commonsware/cwac/preso/demo/MirrorFragmentActivity.java
  30. +80 −0 demo/src/com/commonsware/cwac/preso/demo/MirrorPresentationActivity.java
  31. +54 −0 demo/src/com/commonsware/cwac/preso/demo/SamplePresentationFragment.java
  32. +99 −0 demo/src/com/commonsware/cwac/preso/demo/VideoPresentationActivity.java
  33. +81 −0 demo/src/com/commonsware/cwac/preso/demo/VideoPresentationFragment.java
  34. +20 −0 proguard-project.txt
  35. +16 −0 project.properties
  36. +58 −0 src/com/commonsware/cwac/preso/MirrorPresentationFragment.java
  37. +69 −0 src/com/commonsware/cwac/preso/MirroringFragment.java
  38. +95 −0 src/com/commonsware/cwac/preso/MirroringWebViewFragment.java
  39. +59 −0 src/com/commonsware/cwac/preso/PresentationFragment.java
  40. +104 −0 src/com/commonsware/cwac/preso/PresentationHelper.java
  41. +107 −0 src/com/commonsware/cwac/preso/WebPresentationFragment.java
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Presentation</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,13 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.commonsware.cwac.preso"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="17"
+ android:targetSdkVersion="17"/>
+
+ <application android:allowBackup="false">
+ </application>
+
+</manifest>
@@ -0,0 +1,192 @@
+CWAC-Presentation: Second Screens Supported Succinctly
+======================================================
+
+This Android library project (also
+[available as a JAR](http://misc.commonsware.com/CWAC-Presentation.jar))
+offers a series of classes that wrap around the `Presentation` and
+`DisplayManager` of Android 4.2:
+
+- `PresentationHelper` consolidates basic `DisplayManager` handling, with
+a listener to inform you when to show or remove your `Presentation`
+
+- `PresentationFragment` extends `DialogFragment` and adds a bit of
+extra logic to allow it to handle a `Presentation` rather than a simple
+`Dialog`
+
+- `WebPresentationFragment` simply extends `PresentationFragment` and displays
+a `WebView` in the `Presentation`
+
+- `MirroringFragment`, `MirroringWebViewFragment`, and `MirrorPresentationFragment`
+leverage the mirroring logic from
+[the CWAC-Layouts project](http://github.com/commonsguy/cwac-layouts) to help you
+display a `Presentation` based upon mirrored content from the main screen
+
+Note that if you wish to use the JAR, you will need to also add the JAR from
+[the CWAC-Layouts project](http://github.com/commonsguy/cwac-layouts) to your
+project if you wish to use the `Mirror*` classes. If you are not using the `Mirror*`
+classes, then the CWAC-Presentation JAR is sufficient.
+
+Also note that if you plan to use this as an Android library project that you
+will also need to download [the CWAC-Layouts project](http://github.com/commonsguy/cwac-layouts)
+(and, if needed, modify this project's configuration to point to your copy of
+CWAC-Layouts' library project). Alternatively, download the CWAC-Layouts JAR into
+the `libs/` directory of your clone of this project and remove the dependency on
+the CWAC-Layouts library project.
+
+Usage: PresentationHelper
+-------------------------
+`PresentationHelper` is designed to be used by an `Activity` that wishes to
+display a `Presentation` when a suitable `Display` is attached, and stop displaying
+the `Presentation` when any prior such `Display` is detached.
+
+To do this:
+
+- Create an instance of `PresentationHelper`, probably in `onCreate()` of the
+activity. You will need to supply a `Context` (probably `this`) and something
+that implements the `PresentationHelper.Listener` interface.
+
+- Forward the `onPause()` and `onResume()` events to the `PresentationHelper` by
+calling the same-named methods on the helper.
+
+- Implement the `showPreso()` method on your `Listener`. This receives a `Display`
+object, and you are now able to display a `Presentation` on that `Display`.
+
+- Implement the `clearPreso()` method on your `Listener`. At this point, you
+should stop displaying any prior `Presentation`, if there was one. You are passed
+a `boolean` value, `true` indicating that the activity is going away, `false`
+indicating that we merely lost our `Display`. You can use this value to perhaps
+optimize dealing with `Display` changes, without destroying all the data.
+
+Usage: PresentationFragment
+---------------------------
+`PresentationFragment` is a thin veneer over `DialogFragment` to allow it to
+work with `Presentation` objects (which themselves inherit from `Dialog`).
+This allows you to define the content for a `Presentation` in the form of
+a fragment. And, like `DialogFragment`, you can elect to either use it for
+a `Presentation` (via a call to `show()`) or use it as an ordinary `Fragment` in
+the rest of your UI (via a `FragmentTransaction`). This can help you to work
+both in dual-screen and single-screen scenarios.
+
+Your `PresentationFragment` subclass should override `onCreateView()` to define
+the contents of the `Presentation` (or what will be shown in the `Fragment`
+when used as a regular fragment). The only significant change over any other
+`Fragment` is that you should use `getContext()`, instead of `getActivity()`,
+for any resources you create, such as inflating a layout. This ensures that
+you get the right `Context` for the situation, such as the `Context` associated
+with a secondary screen when used for a `Presentation`.
+
+However, when creating the `PresentationFragment`, you also need to call
+`setDisplay()`, to provide the `Display` object for use when the fragment is
+shown as a `Presentation`. If you are not using it for a `Presentation` in
+the current context, this call is not required. A typical approach for handling
+`setDisplay()` is to use a factory method:
+
+```
+public static YourFragment newInstance(Context ctxt, Display display) {
+ YourFragment frag=new YourFragment();
+
+ frag.setDisplay(ctxt, display);
+
+ return(frag);
+}
+```
+
+Beyond this, `PresentationFragment` is a fairly ordinary `Fragment`.
+
+If you wish to display this fragment in a `Presentation`, call `show()` on the
+`PresentationFragment`, supplying your `FragmentManager` and a tag to use for
+the fragment itself. To get rid of the `Presentation`, call `dismiss()` on
+the `PresentationFragment`.
+
+Usage: WebPresentationFragment
+------------------------------
+`WebPresentationFragment` is simply a mash-up of `PresentationFragment` and
+`WebViewFragment`, to allow a `WebView` to be displayed in a `Presentation`.
+You use it just like `WebViewFragment`, except for the need to call
+`setDisplay()` (per the `PresentationFragment` instructions above). So,
+for example, `getWebView()` returns the `WebView` hosted by the
+`WebPresentationFragment`.
+
+Usage: Mirroring Presentation Classes
+-------------------------------------
+There are three classes that take advantage of the mirroring support included
+in [the CWAC-Layouts project](http://github.com/commonsguy/cwac-layouts).
+
+`MirroringFragment` works much like a regular `Fragment`. However, instead of
+overriding `onCreateView()`, you override `onCreateMirroredContent()`.
+`onCreateMirroredContent()` takes the same parameters as does `onCreateView()`,
+and your job is the same: create the content to be displayed by the fragment.
+The difference is that your returned `View` will be wrapped in a
+`MirroringFrameLayout`.
+
+`MirroringWebViewFragment` is a mash-up of `MirroringFragment` and
+`WebViewFragment`, to allow a `WebView` to be mirrored. Use `getWebView()`
+to retrieve the `WebView` hosted by this fragment.
+
+`MirrorPresentationFragment` is a `PresentationFragment` designed to mirror
+the contents of a `MirroringFragment`. To use this, create an instance using
+the `newInstance()` factory method, taking a `Context` and the desired
+`Display` as parameters. Then, call `setMirror()` on your `MirroringFragment`,
+supplying the `MirrorPresentationFragment`. From there, you can `show()`
+and `dismiss()` the `MirrorPresentationFragment` as you would any other
+`PresentationFragment`. By having the `MirroringFragment` on the main
+screen, and having the `MirrorPresentationFragment` on an external display,
+whatever the user manipulates on the screen is rendered to the external
+display, ideal for presentation settings (e.g., conferences).
+
+Note that `MirroringFragment` suffers the same limitations as does
+`MirroringFrameLayout`, in that it will work with fairly ordinary `View`s,
+plus `WebView`, but not `SurfaceView` or things that use `SurfaceView`
+(e.g., `VideoView`, Maps V2 maps).
+
+Dependencies
+------------
+This project depends on Android 4.2 and higher (API Level 17).
+
+This project also depends upon
+[the CWAC-Layouts project](http://github.com/commonsguy/cwac-layouts).
+
+Version
+-------
+This is version v0.1.0 of this module, meaning it is brand new.
+
+Demo
+----
+In the `demo/` sub-project you will find a sample project demonstrating the use
+of all the aforementioned classes.
+
+TBD
+
+License
+-------
+The code in this project is licensed under the Apache
+Software License 2.0, per the terms of the included LICENSE
+file.
+
+Questions
+---------
+If you have questions regarding the use of this code, please post a question
+on [StackOverflow](http://stackoverflow.com/questions/ask) tagged with `commonsware` and `android`. Be sure to indicate
+what CWAC module you are having issues with, and be sure to include source code
+and stack traces if you are encountering crashes.
+
+If you have encountered what is clearly a bug, or if you have a feature request,
+please post an [issue](https://github.com/commonsguy/cwac-presentation/issues).
+Be certain to include complete steps for reproducing the issue.
+
+Do not ask for help via Twitter.
+
+Also, if you plan on hacking
+on the code with an eye for contributing something back,
+please open an issue that we can use for discussing
+implementation details. Just lobbing a pull request over
+the fence may work, but it may not.
+
+Release Notes
+-------------
+- v0.1.0: initial release
+
+Who Made This?
+--------------
+<a href="http://commonsware.com">![CommonsWare](http://commonsware.com/images/logo.png)</a>
+
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="library" default="help">
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The ant.properties file can be created by you. It is only edited by the
+ 'android' tool to add properties to it.
+ This is the place to change some Ant specific build properties.
+ Here are some properties you may want to change/update:
+
+ source.dir
+ The name of the source directory. Default is 'src'.
+ out.dir
+ The name of the output directory. Default is 'bin'.
+
+ For other overridable properties, look at the beginning of the rules
+ files in the SDK, at tools/ant/build.xml
+
+ Properties related to the SDK location or the project target should
+ be updated using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems.
+
+ -->
+ <property file="ant.properties" />
+
+ <!-- if sdk.dir was not set from one of the property file, then
+ get it from the ANDROID_HOME env var.
+ This must be done before we load project.properties since
+ the proguard config can use sdk.dir -->
+ <property environment="env" />
+ <condition property="sdk.dir" value="${env.ANDROID_HOME}">
+ <isset property="env.ANDROID_HOME" />
+ </condition>
+
+ <!-- The project.properties file is created and updated by the 'android'
+ tool, as well as ADT.
+
+ This contains project specific properties such as project target, and library
+ dependencies. Lower level build properties are stored in ant.properties
+ (or in .classpath for Eclipse projects).
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems. -->
+ <loadproperties srcFile="project.properties" />
+
+ <!-- quick check on sdk.dir -->
+ <fail
+ message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
+ unless="sdk.dir"
+ />
+
+ <!--
+ Import per project custom build rules if present at the root of the project.
+ This is the place to put custom intermediary targets such as:
+ -pre-build
+ -pre-compile
+ -post-compile (This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir})
+ -post-package
+ -post-build
+ -pre-clean
+ -->
+ <import file="custom_rules.xml" optional="true" />
+
+ <!-- Import the actual build file.
+
+ To customize existing targets, there are two options:
+ - Customize only one target:
+ - copy/paste the target into this file, *before* the
+ <import> task.
+ - customize it to your needs.
+ - Customize the whole content of build.xml
+ - copy/paste the content of the rules files (minus the top node)
+ into this file, replacing the <import> task.
+ - customize to your needs.
+
+ ***********************
+ ****** IMPORTANT ******
+ ***********************
+ In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+ in order to avoid having your file be overridden by tools such as "android update project"
+ -->
+ <!-- version-tag: custom -->
+ <import file="${sdk.dir}/tools/ant/build.xml" />
+
+ <target name="jar" depends="debug">
+ <jar
+ destfile="bin/CWAC-Presentation.jar"
+ basedir="bin/classes"
+ />
+ </target>
+
+</project>
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>PresentationDemo</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Oops, something went wrong.

0 comments on commit 2c317ab

Please sign in to comment.