diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000000..47c694d982
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1 @@
+open_collective: openrocket
diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml
new file mode 100644
index 0000000000..e53b7d2c16
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug-report.yml
@@ -0,0 +1,70 @@
+name: Bug report
+description: Help us make OpenRocket better
+title: '[Bug] REPLACE WITH YOUR TITLE HERE'
+labels: bug
+body:
+- type: markdown
+ attributes:
+ value: "Thanks for taking the time to fill out this bug report!"
+- type: textarea
+ id: description
+ attributes:
+ label: Describe the bug
+ description: What happened? Also tell us what you've expect to happen.
+ placeholder: Describe your bug in detail.
+ validations:
+ required: true
+- type: textarea
+ id: repro
+ attributes:
+ label: To Reproduce
+ description: "Steps to reproduce the behavior:"
+ value: |
+ 1.
+ 2.
+ 3.
+ ...
+ validations:
+ required: true
+- type: textarea
+ id: files
+ attributes:
+ label: Screenshots / .ork file
+ description: Provide screenshots for clarification and/or the .ork file that caused the issue.
+ value: |
+ #### Screenshot(s):
+ *(drag-and-drop the screenshot(s) here)*
+
+
+ #### .ork file:
+ *(drag-and-drop the file here as a .zip file)*
+
+
+ validations:
+ required: false
+- type: input
+ id: version-openrocket
+ attributes:
+ label: OpenRocket version
+ description: In what version(s) of OpenRocket does this bug happen?
+ placeholder: 22.02, unstable...
+ validations:
+ required: true
+- type: dropdown
+ id: platform
+ attributes:
+ label: What platform are you running on?
+ options:
+ - Windows
+ - macOS
+ - Linux
+ validations:
+ required: true
+- type: textarea
+ id: context
+ attributes:
+ label: Additional context
+ description: Add any other context about the problem here.
+ placeholder:
+ validations:
+ required: false
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000000..7f4e5fd8d6
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,20 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+title: '[Feature Request] REPLACE WITH YOUR TITLE HERE'
+labels: Feature request
+assignees: ''
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
diff --git a/.github/OpenRocket_home_2D.png b/.github/OpenRocket_home_2D.png
new file mode 100644
index 0000000000..ea1851b061
Binary files /dev/null and b/.github/OpenRocket_home_2D.png differ
diff --git a/.github/OpenRocket_home_3D.png b/.github/OpenRocket_home_3D.png
new file mode 100644
index 0000000000..f03a54b711
Binary files /dev/null and b/.github/OpenRocket_home_3D.png differ
diff --git a/.github/OpenRocket_sim.png b/.github/OpenRocket_sim.png
new file mode 100644
index 0000000000..73399a1094
Binary files /dev/null and b/.github/OpenRocket_sim.png differ
diff --git a/.github/getting-started.png b/.github/getting-started.png
new file mode 100644
index 0000000000..0c64d1aa89
Binary files /dev/null and b/.github/getting-started.png differ
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000000..9ea9a89013
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,48 @@
+name: Build
+
+on:
+ push:
+ branches:
+ - unstable
+ pull_request:
+ branches:
+ - unstable
+
+jobs:
+ gradle:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository and submodules
+ uses: actions/checkout@v5
+ with:
+ submodules: 'recursive'
+ - name: Setup JDK 17
+ uses: actions/setup-java@v5
+ with:
+ distribution: 'temurin'
+ java-version: '17'
+ - name: Setup Gradle
+ uses: gradle/actions/setup-gradle@v5
+ - name: Execute Gradle build
+ run: ./gradlew clean check build dist
+ # If wanting to serialize all the engines during build
+ # run: ./gradlew clean serializeEnginesDist build dist
+ - name: Generate JaCoCo HTML
+ run: |
+ ./gradlew test jacocoTestReport || true
+ - name: Upload build reports
+ uses: actions/upload-artifact@v5
+ with:
+ name: build-reports
+ path: build/reports/
+ - name: Upload Coverage HTML
+ uses: actions/upload-artifact@v5
+ with:
+ name: coverage-html
+ path: '**/build/reports/jacoco/test/html/**'
+ - name: Upload Artifact
+ uses: actions/upload-artifact@v5
+ with:
+ name: openrocket_build_${{ github.run_number }}
+ path: ${{github.workspace}}/build/libs/OpenRocket*.jar
diff --git a/.gitignore b/.gitignore
index 31a45400e0..310d645ced 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,19 +13,12 @@
/tmp
/loganalysis
-# /android/
-/android/bin
-
-# /android-libraries/achartengine/
-/android-libraries/achartengine/gen
-/android-libraries/achartengine/bin
-/android-libraries/achartengine/lint.xml
-
# /core/
/core/loganalysis
/core/build
/core/tmp
/core/misc
+/core/bin
# /core/doc/techdoc/
/core/doc/techdoc/*.aux
@@ -39,7 +32,10 @@
/core/resources-src/pix/splashscreen-sormus.xcf.gz
/swing/build
+/swing/bin
/swing/tmp
+/core/src/main/resources/datafiles/components
+/core/src/main/resources/ReleaseNotes.md
# IntelliJ
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
@@ -47,37 +43,54 @@
# https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore
# User-specific stuff:
-.idea/workspace.xml
-.idea/tasks.xml
-.idea/dictionaries
-.idea/vcs.xml
-.idea/jsLibraryMappings.xml
+**/.idea/workspace.xml
+**/.idea/tasks.xml
+**/.idea/dictionaries
+**/.idea/vcs.xml
+**/.idea/jsLibraryMappings.xml
+**/.idea/copilot
+**/.idea/shelf
+swing/OpenRocket Swing.iml
+core/OpenRocket Core.iml
+lib-test/OpenRocket Library Test.iml
# Sensitive or high-churn files:
-.idea/dataSources.ids
-.idea/dataSources.xml
-.idea/dataSources.local.xml
-.idea/sqlDataSources.xml
-.idea/dynamic.xml
-.idea/uiDesigner.xml
+**/.idea/dataSources.ids
+**/.idea/dataSources.xml
+**/.idea/dataSources.local.xml
+**/.idea/sqlDataSources.xml
+**/.idea/dynamic.xml
+**/.idea/uiDesigner.xml
+**/.idea/workspace.xml
# Gradle:
-.idea/gradle.xml
-.idea/libraries
+**/.idea/gradle.xml
+**/.idea/libraries
# Mongo Explorer plugin:
-.idea/mongoSettings.xml
+**/.idea/mongoSettings.xml
## File-based project format:
-*.iws
+**/*.iws
## Plugin-specific files:
# IntelliJ
-/out/
+**/out/
+**/build/
+**/.gradle**
+
+# IntelliJ run configurations (keep some default configs though)
+!/.idea/runConfigurations/SwingStartup.xml
+!/.idea/runConfigurations/openrocket_jar.xml
+!/.idea/runConfigurations/openrocket_test.xml
+/.idea/runConfigurations/
+
+# VSCode
+.vscode/
# mpeltonen/sbt-idea plugin
-.idea_modules/
+**/.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
@@ -87,3 +100,17 @@ com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
+
+openrocket.log
+**/hs_err_pid*.log
+
+*.snap
+
+# Sphinx documentation
+docs/build
+
+# AI tools
+**/copilot.*.xml
+**/AGENTS.md
+**/CLAUDE.md
+**/GEMINI.md
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000000..43d11981fd
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "core/resources-src/datafiles/openrocket-database"]
+ path = core/resources-src/datafiles/openrocket-database
+ url = https://github.com/openrocket/openrocket-database.git
diff --git a/.idea/artifacts/openrocket_jar.xml b/.idea/artifacts/openrocket_jar.xml
index 9bbc47070b..5298229fa2 100644
--- a/.idea/artifacts/openrocket_jar.xml
+++ b/.idea/artifacts/openrocket_jar.xml
@@ -1,39 +1,50 @@
-
- $PROJECT_DIR$/build/jar
-
-
-
+
+ $PROJECT_DIR$/build/jar
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 219fad8eae..3dac0cf34a 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,8 +1,6 @@
-
-
@@ -13,10 +11,23 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000000..1ba6caf5b2
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000000..0eeb1e5e87
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 938905647a..dd4d9cc550 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,52 +1,10 @@
-
-
-
-
-
-
-
-
- Class structure
-
-
- Code maturity issues
-
-
- Java language level migration aids
-
-
- Javadoc issues
-
-
- Performance issues
-
-
- Portability issues
-
-
- Probable bugs
-
-
- Resource management issues
-
-
- TestNG
-
-
- Threading issues
-
-
-
-
- Abstraction issues
-
-
-
-
+
+
+
-
+
-
\ No newline at end of file
+
diff --git a/.idea/modules/core/info.openrocket.core.iml b/.idea/modules/core/info.openrocket.core.iml
new file mode 100644
index 0000000000..d3213b4da8
--- /dev/null
+++ b/.idea/modules/core/info.openrocket.core.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules/swing/info.openrocket.swing.iml b/.idea/modules/swing/info.openrocket.swing.iml
new file mode 100644
index 0000000000..cfd25693c8
--- /dev/null
+++ b/.idea/modules/swing/info.openrocket.swing.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/All_tests.xml b/.idea/runConfigurations/All_tests.xml
deleted file mode 100644
index 26cc40265c..0000000000
--- a/.idea/runConfigurations/All_tests.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/Openrocket_UI_Jar.xml b/.idea/runConfigurations/Openrocket_UI_Jar.xml
deleted file mode 100644
index f5e1da03e7..0000000000
--- a/.idea/runConfigurations/Openrocket_UI_Jar.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/SwingStartup.xml b/.idea/runConfigurations/SwingStartup.xml
new file mode 100644
index 0000000000..73705a124b
--- /dev/null
+++ b/.idea/runConfigurations/SwingStartup.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/openrocket_jar.xml b/.idea/runConfigurations/openrocket_jar.xml
new file mode 100644
index 0000000000..32fd631186
--- /dev/null
+++ b/.idea/runConfigurations/openrocket_jar.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/openrocket_test.xml b/.idea/runConfigurations/openrocket_test.xml
new file mode 100644
index 0000000000..f7c2912110
--- /dev/null
+++ b/.idea/runConfigurations/openrocket_test.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/.readthedocs.yaml b/.readthedocs.yaml
new file mode 100644
index 0000000000..3a7e5af642
--- /dev/null
+++ b/.readthedocs.yaml
@@ -0,0 +1,13 @@
+version: "2"
+
+build:
+ os: "ubuntu-22.04"
+ tools:
+ python: "3.10"
+
+python:
+ install:
+ - requirements: docs/requirements.txt
+
+sphinx:
+ configuration: docs/source/conf.py
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 07cb80df8c..0000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-language: java
-dist: trusty
-sudo: false
-addons:
- apt:
- packages:
- - ant-optional
-jdk:
- - openjdk8
-script:
- - "ant -buildfile build.xml clean check jar unittest"
-
-after_success:
- - ls -lh /home/travis/build/openrocket/openrocket/swing/build/jar/OpenRocket.jar
- - ls -lh /home/travis/build/openrocket/openrocket/swing/build/jar/OpenRocket-Core.jar
- - wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
- - bash upload.sh /home/travis/build/openrocket/openrocket/swing/build/jar/OpenRocket.jar
- - bash upload.sh /home/travis/build/openrocket/openrocket/swing/build/jar/OpenRocket-Core.jar
-
-branches:
- except:
- - # Do not build tags that we create when we upload to GitHub Releases
- - /^(?i:continuous)$/
diff --git a/CITATION.cff b/CITATION.cff
new file mode 100644
index 0000000000..02fe919e8f
--- /dev/null
+++ b/CITATION.cff
@@ -0,0 +1,9 @@
+cff-version: 1.2.0
+message: "If you use this software, please cite it as below."
+authors:
+- family-names: "Niskanen"
+ given-names: "Sampo"
+title: "OpenRocket"
+version: 15.03
+date-released: 2015-03-28
+url: "https://github.com/openrocket/openrocket"
\ No newline at end of file
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000000..5cf0455e63
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,133 @@
+# Contributor Code of Conduct
+
+## Our Pledge
+
+We as members, contributors, and leaders pledge to make participation in our
+community a harassment-free experience for everyone, regardless of age, body
+size, visible or invisible disability, ethnicity, sex characteristics, gender
+identity and expression, level of experience, education, socio-economic status,
+nationality, personal appearance, race, caste, color, religion, or sexual
+identity and orientation.
+
+We pledge to act and interact in ways that contribute to an open, welcoming,
+diverse, inclusive, and healthy community.
+
+## Our Standards
+
+Examples of behavior that contributes to a positive environment for our
+community include:
+
+* Demonstrating empathy and kindness toward other people
+* Being respectful of differing opinions, viewpoints, and experiences
+* Giving and gracefully accepting constructive feedback
+* Accepting responsibility and apologizing to those affected by our mistakes,
+ and learning from the experience
+* Focusing on what is best not just for us as individuals, but for the overall
+ community
+
+Examples of unacceptable behavior include:
+
+* The use of sexualized language or imagery, and sexual attention or advances of
+ any kind
+* Trolling, insulting or derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or email address,
+ without their explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Enforcement Responsibilities
+
+Community leaders are responsible for clarifying and enforcing our standards of
+acceptable behavior and will take appropriate and fair corrective action in
+response to any behavior that they deem inappropriate, threatening, offensive,
+or harmful.
+
+Community leaders have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct, and will communicate reasons for moderation
+decisions when appropriate.
+
+## Scope
+
+This Code of Conduct applies within all community spaces, and also applies when
+an individual is officially representing the community in public spaces.
+Examples of representing our community include using an official e-mail address,
+posting via an official social media account, or acting as an appointed
+representative at an online or offline event.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported to the community leaders responsible for enforcement by sending them a
+private email, message on Slack, or any other communication method that you find
+suitable.
+All complaints will be reviewed and investigated promptly and fairly.
+
+All community leaders are obligated to respect the privacy and security of the
+reporter of any incident.
+
+## Enforcement Guidelines
+
+Community leaders will follow these Community Impact Guidelines in determining
+the consequences for any action they deem in violation of this Code of Conduct:
+
+### 1. Correction
+
+**Community Impact**: Use of inappropriate language or other behavior deemed
+unprofessional or unwelcome in the community.
+
+**Consequence**: A private, written warning from community leaders, providing
+clarity around the nature of the violation and an explanation of why the
+behavior was inappropriate. A public apology may be requested.
+
+### 2. Warning
+
+**Community Impact**: A violation through a single incident or series of
+actions.
+
+**Consequence**: A warning with consequences for continued behavior. No
+interaction with the people involved, including unsolicited interaction with
+those enforcing the Code of Conduct, for a specified period of time. This
+includes avoiding interactions in community spaces as well as external channels
+like social media. Violating these terms may lead to a temporary or permanent
+ban.
+
+### 3. Temporary Ban
+
+**Community Impact**: A serious violation of community standards, including
+sustained inappropriate behavior.
+
+**Consequence**: A temporary ban from any sort of interaction or public
+communication with the community for a specified period of time. No public or
+private interaction with the people involved, including unsolicited interaction
+with those enforcing the Code of Conduct, is allowed during this period.
+Violating these terms may lead to a permanent ban.
+
+### 4. Permanent Ban
+
+**Community Impact**: Demonstrating a pattern of violation of community
+standards, including sustained inappropriate behavior, harassment of an
+individual, or aggression toward or disparagement of classes of individuals.
+
+**Consequence**: A permanent ban from any sort of public interaction within the
+community.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage],
+version 2.1, available at
+[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
+
+Community Impact Guidelines were inspired by
+[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
+
+For answers to common questions about this code of conduct, see the FAQ at
+[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
+[https://www.contributor-covenant.org/translations][translations].
+
+[homepage]: https://www.contributor-covenant.org
+[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
+[Mozilla CoC]: https://github.com/mozilla/diversity
+[FAQ]: https://www.contributor-covenant.org/faq
+[translations]: https://www.contributor-covenant.org/translations
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000000..f4041d4ae9
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,79 @@
+# Contributing to OpenRocket 🚀
+Hi, thank you for your interest in OpenRocket! 😊
+
+I will guide you to contributing to OpenRocket, be it as a developer, tester or any other type of help that will launch - *pun intended* - OpenRocket to the next level.
+
+Before I move on: time is money, so to save you time, get used to how OpenRocket is abbreviated with _OR_.
+
+#### Table Of Contents
+[Testing](#testing)
+* [Reporting bugs](#reporting-bugs)
+* [Suggesting new features](#suggesting-new-features)
+
+[Development](#development)
+* [Commit etiquette](#commit-etiquette)
+* [Pull requests](#pull-requests)
+
+[Translation](#translation)
+
+[Documentation](#documentation)
+
+[Anything else](#anything-else)
+
+## Testing
+OpenRocket is not perfect, but we need people to discover and clearly document all of its imperfections. The job of a tester is to discover bugs, formulate new feature requests and to test out software updates. 📝
+
+### Reporting bugs
+Please be very concise when you post a new issue. Give a short and appropriate title, preferably with the '[Bug]'-tag in the beginning to indicate a bug.
+
+When explaining the issue, the following elements are important:
+* Explain how you expected OpenRocket to behave, and how it behaved instead
+* Go through the different steps that you took to (re)create the issue
+* Include information about your operating system (e.g. 'macOS Monterey version 12.1') and which version of OpenRocket you are using (e.g. 'the latest unstable branch')
+* If applicable, include a Bug Report (preferably in a separate .txt file) of the exception that OpenRocket threw
+
+Providing extra information like a screenshot, a screen recording, the .ork file that produced an error etc. really help understand and solve the issue more quickly.
+
+### Suggesting new features
+If you would like to see a new feature implemented in OR, make a new issue for it. Preferably include the tag '[Feature Request]' in the issue's title.
+
+Explain the new feature in detail:
+* Which new behavior would you like OR to have
+* Why is this new feature important
+
+## Development
+Please read our [Developer's Guide](https://openrocket.readthedocs.io/en/latest/dev_guide/development_overview.html). If you still have questions about how to set up your environment, with which issues you should start etc., then don't be afraid to send us a message on [Slack](https://join.slack.com/t/openrocket/shared_invite/zt-dh0wtpc4-WmkSK1ysqAOqHa6eFN7zgA).
+
+Developing OpenRocket may be daunting at first, but if you keep Google, your IDE's search and debug features, and the other developers as close friends, then you will easily create your first pull request.
+
+If you want to work on a certain issue, you should first communicate that you want to work on that issue. This can be done by commenting on the issue something like 'I would like to work on this issue'. This ensures that no more than one person works on a given issue.
+
+### Commit etiquette
+Please make use of **atomic commits**. This means: don't fix 10 different issues and cram them in one commit. Split up commits into smaller commits that fix only one issue/feature.
+
+For example: I fixed an issue where a button was displayed as red instead of blue, but I also found that there was a typo in a text somewhere else. Then put the button-fix in a one commit, give it an appropriate name, and put the typo-fix in another commit. Atomic commits make it much easier for code reviewers to review the code changes.
+
+Also give **useful names** to your commits. A good naming convention of a commit is in the form of '[#{GitHub issue number of the issue you are trying to fix}] {Commit subject}'.
+
+Take the example of fixing the red button from issue #123: '[#123] Display red button as blue'. Mentioning '#123' will also automatically link your pull request to the corresponding issue. The commit subject should be short and precise. It is also very useful to include a git commit message body besides just the commit subject to explain why and how you made that commit.
+
+### Pull requests
+Right, you've dug into the codebase, found that one nasty line that caused all your troubles and fixed it. It is now time to push your code and create a pull request of the branch from your own repository to the official repository. As your PR (Pull Request) text, it is good to have the following structure:
+
+1. Explain briefly which issue that you are trying to solve, e.g. 'This PR solves #123 in which buttons were displayed as red instead of blue'
+2. Next explain what the underlying issue was, e.g. 'The problem was that by default Java swing displays buttons as red.'
+3. Next is how you fixed the issue, e.g. 'Fixed it by overriding the default button color to blue'
+
+You can take a look at example PR [#979](https://github.com/openrocket/openrocket/pull/979).
+
+## Translation
+Both the OpenRocket software and the end-user documentation site are multilingual. The job of a translator is to maintain the existing languages, or to make a new translation of an unlisted language. During the development sometimes new translation keys get added in the English language that are not simultaneously translated to other languages. The translator must therefore check which translation keys are still missing in his/her/their language.
+
+How you can make/edit a translation can be found in the [Developer's Guide](https://openrocket.readthedocs.io/en/latest/dev_guide/contributing_to_translations.html).
+
+## Documentation
+Our documentation is hosted on [ReadTheDocs](https://openrocket.readthedocs.io/en/latest/index.html).
+
+## Anything else
+Do you have the perfect voice for making OpenRocket tutorials, are you a graphical designer that screams to improve OR's design, or are you the salesman that can grow OR's influence? Then go for it! We highly appreciate any help that we get, in any shape or form. 🙃
+
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000000..3f0411c660
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,763 @@
+2023-11-16 Sibo Van Gool
+
+ * Released version 23.09. See Release Notes for changes.
+
+2023-02-06 Sibo Van Gool
+
+ * Released version 22.02. See Release Notes of 22.02.beta.01, 22.02.beta.02, 22.02.beta.03, 22.02.beta.04,
+ 22.02.beta.05, and 22.02.RC.01 for changes.
+ * Final changes between 22.02.RC.01 and 22.02:
+ * Minor fixes to software updater (PR #2016 & #2022)
+ * Added show/hide warnings checkbox (PR #2010)
+ * Mark document as unsaved on simulation edit (PR #2008)
+ * Include base drag example (PR #2007)
+ * Improvements to decal file chooser and edit button (PR #1993 & #1996)
+ * Decal editing fixed on Linux (PR #1995)
+ * Improved geometry warnings for gaps in airframe and zero-volume components (PR #1979 & #1985)
+ * Change pod/booster marker rendering based on its actual reference point (PR #1984)
+ * Fixed booster markers not drawing when it had no children (PR #1983)
+
+2015-03-28 Kevin Ruland
+
+ * Released version 15.03 See Release Notes for changes.
+
+2014-11-02 Kevin Ruland
+
+ * Released version 14.11 See Release Notes for changes.
+
+2014-06-26 Kevin Ruland
+
+ * Released version 14.06 See Release Notes for changes.
+
+2014-05-21 Kevin Ruland
+
+ * Released version 14.05 See Release Notes for changes.
+
+2013-11-07 Kevin Ruland
+
+ * Released version 13.11
+
+2013-10-05 Kevin Ruland
+
+ * Released version 13.09.1
+
+2013-09-08 Sampo Niskanen
+
+ * Released version 13.09
+
+2013-08-18 Bill Kuker
+
+ * Upgraded JOGL to version 2.0.2
+
+2013-05-04 Sampo Niskanen
+
+ * Released version 13.05
+
+2013-04-17 Bill Kuker and Kevin Ruland
+
+ * Added support for decals on rockets. Added two new 3d views - 3d finished and 3d unfinshed. Added support to export and
+ apply decals (images) to rocket components. Added ability to launch external graphics editor to edit decals and monitor
+ file for writes to update the rocket view.
+
+2013-04-17 Kevin Ruland
+
+ * Added simulation of tumble recovery based on experimentation done by Sampo Niskane. This is particularly useful
+ for low power staged flights.
+
+2013-04-17 Kevin Ruland
+
+ * Extended "motor configuration" concept to cover more properties. The concept was renamed "Flight Configuration" and
+ allows the user to override stage separation, recovery deployment, and motor ignition per flight configuration.
+ These configurations are stored in the ork file with each component. If no override is specified then the user specified
+ default is used (set in the component edit dialog). The flight configuration dialog was reworked to make it more
+ usable. The user selects the configuration in a drop down with buttons for "add", "delete" and "rename". After selecting
+ the configuration, the tabbed area below allows the user to change the configuration for this simulation.
+
+2013-04-17 Kevin Ruland
+
+ * Allow simulation of stages without a motor. Users in the past have attempted to simulate separate recovery of payload
+ and booster by tricking OpenRocket using a dummy motor with trivial thrust curve. Now the user does not need to do this.
+ There is an example of this provided in TARC Payloader.ork and Boosted Dart.ork
+
+2013-04-17 Kevin Ruland
+
+ * Simulate recovery of boosters. The simulation engine will create new FlightDataBranches for each stage after
+ separation. The data for the boosters begins at t=separation. The simulation plot allows the user to select
+ which stage's data to show (or all).
+
+2013-04-17 Kevin Ruland
+
+ * Modified the zoom and pan controls in the simulation plot. Added zoom in, out, and reset buttons. Added
+ scroll with mouse wheel. If the alt key is used with either of these, only the domain is zoomed. Richard
+ contributed a more logical mouse controlled zoom - right click and drag will zoom (either domain, range or both).
+
+2012-09-28 Sampo Niskane
+
+ * Released version 12.09.1
+
+2012-09-25 Doug Pedrick
+
+ * Added preference to open last edited design file upon startup.
+
+ * [BUG] Fixed printing of transitions bug where the transition is deeply parented.
+
+ * Cleaned up Swing listeners of Configuration (memory leak).
+
+2012-09-16 Sampo Niskanen
+
+ * Released version 12.09
+
+2012-08-28 Bill Kuker
+
+ * Removed late GL initialization, was causing issues with Java 7.
+
+ * Added -Dopenrocket.3d.disable option for anyone experiencing crashes as a result of OpenGL.
+
+2012-08-01 Kevin Ruland
+
+ * Changed the loader to pull *.rkt files from zip containers.
+
+ * Modified the BasicFrame so it doesn't automatically open the Rocket configuration dialog when opening a new rocket.
+
+ * Unified the behavior for replacing (automatically closing) the base frame when opening a file, loading an example,
+ or picking from the Most-recently-used list.
+
+2012-06-24 Bill Kuker
+
+ * OSX UI Elements: Screen menu bar, Application name, Dock Icon, Quit, About & Preference
+ handlers. Stubs for the "Apple Java Extensions" to allow other platforms to compile provided
+ by https://github.com/ymasory/OrangeExtensions.
+
+2012-06-11 Bill Kuker
+
+ * Added a 3D view of the rocket to the figure panel.
+
+2012-06-05 Doug Pedrick
+
+ * Most recently used design files added to File menu.
+
+2012-05-23 Doug Pedrick
+
+ * Centering ring templates can now be chosen for printing.
+ * Calibration ruler added to printed templates.
+
+2012-05-09 Kevin Ruland
+
+ * Add ComponentPreset functionality. These are commercial components which can be used in rocket designs.
+ System currently support Body Tube, Nose Cone, Transition, Tube Coupler, Centering Ring, Engine Block, Bulk Head,
+ Launch Lug, Streamer and Parachutes. Received permission from Always Ready Rocketry, Balsa Machining Service, Giant
+ Leap Rocketry, Public Missiles, Semroc and Fliskits to include their parts catalogs in OR.
+
+2012-05-09 Kevin Ruland
+
+ * Add fractional inch unit 'in/64' to Length unit group.
+
+2012-05-09 Jason Blood
+
+ * Add PageFitPrintStrategy and related files to print multiple fins, transitions, and nosecones onto the same page(s)
+
+2012-04-19 Sampo Niskanen
+
+ * Allow opening recovery device on stage separation
+
+2012-04-11 Doug Pedrick
+
+ * [BUG] Printed simulation did not honor launch conditions
+
+2012-04-09 Sampo Niskanen
+
+ * [BUG] Cancelling simulation causes later simulations to fail
+ * Add debugging for NPE in GeneralOptimizationDialog
+
+2012-03-27 Sampo Niskanen
+
+ * [BUG] Inputting negative rotation angle values of components
+
+2012-03-25 Sampo Niskanen
+
+ * [BUG] Removed locale-specific toLowerCase/toUpperCase
+
+2012-03-25 Doug Pedrick
+
+ * Printed rocket figure in design report now honors rotation angle of main figure; fixed bug in layout where the
+ figure was clipped in the page margin.
+
+2012-03-18 Jason Blood
+
+ * Updated importing images to freeform fin sets to work with color images with improved description
+
+2012-03-17 Sampo Niskanen
+
+ * Released version 12.03
+
+2012-03-14 Jason Blood
+
+ * Importing images to freeform fin sets
+
+2012-03-13 Sampo Niskanne
+
+ * [BUG] Threads piled up when running simulations
+
+2012-03-11 Sampo Niskanen
+
+ * Update copyright statements
+
+2012-02-19 Sampo Niskanen
+
+ * Display computed motor class
+
+2012-02-16 Sampo Niskanen
+
+ * [BUG] Freeze when dropping component on child component
+
+2012-02-10 Sampo Niskanen
+
+ * Configurable stage separation events
+
+2012-00-00 Doug Pedrick
+
+ * RKT saving support
+
+2011-11-24 Sampo Niskanen
+
+ * Released version 1.1.9
+
+2011-11-18 Doug Pedrick
+
+ * Printable Fin Marking Guides, Transitions, and Nose Cones
+
+2011-10-20 Sampo Niskanen
+
+ * [BUG] NPE if plot data type is not present
+
+2011-10-11 Sampo Niskanen
+
+ * [BUG] Translators fetched before initialization
+
+2011-10-05 Doug Pedrick
+
+ * Fin tab autocalculation
+
+2011-09-26 Sampo Niskanen
+
+ * [BUG] Thrust was computed from dropped stages
+
+2011-09-18 Sampo Niskanen
+
+ * Remember window/dialog sizes and/or positions
+
+2011-09-13 Sampo Niskanen
+
+ * Added icons to help menu
+
+2011-08-28 Richard Graham
+
+ * Patch for geodetic computations + coriolis effect
+ * Patch for enhanced gravity model
+
+2011-08-25 Sampo Niskanen
+
+ * Released version 1.1.8
+ * [BUG] Ignore synthetic methods in logging traces
+ * [BUG] Ignore JRE bug #6826104
+
+2011-08-24 Sampo Niskanen
+
+ * [BUG] NPE in SimulationOptions.equals
+ * [BUG] Exception in plotting optimization path
+ * [BUG] Exception in saving optimization path
+
+2011-08-17 Justin Seitz
+
+ * Added Blue tube to materials database.
+
+2011-08-13 Sampo Niskanen
+
+ * [BUG] JDK7 returns null font for TitledBorder
+
+2011-08-12 Sampo Niskanen
+
+ * Released version 1.1.7
+
+2011-08-08 Sampo Niskanen
+
+ * Enhanced one-dimensional optimization algorithm
+ * [BUG] l10n/ directory not included in source distribution
+
+2011-08-07 Sampo Niskanen
+
+ * Optimization implementation
+
+2011-07-29 Sampo Niskanen
+
+ * [BUG] NaN in transition radius calculation
+
+2011-07-22 Sampo Niskanen
+
+ * Released version 1.1.6.
+
+2011-07-21 Sampo Niskanen
+
+ * [BUG] Converting triangular fin to freeform
+ * [BUG] Unit conversions in printout
+ * [BUG] Mass computations in printout
+ * [BUG] "Not a drop" exception in ComponentTreeTransferHandler
+ * [BUG] Plot annotation positioned wrong
+ * [BUG] Exception when writing PDF failed
+ * Language selector in preferences
+
+2011-07-18 Sampo Niskanen
+
+ * Select motor type based on known manufacturers
+ * Updated motor thrust curves from thrustcurve.org
+
+2011-07-17 Sampo Niskanen
+
+ * Component scaling support
+
+2011-07-14 Sampo Niskanen
+
+ * [BUG] Body tube auto-radius not enabled
+ * Optimization implementation
+
+2011-06-26 Sampo Niskanen
+
+ * [BUG] Original rocket was modified when sim.listener modified rocket
+
+2011-06-18 Sampo Niskanen
+
+ * Merged l10n branch into trunk, initial l10n support
+
+2011-06-10 Sampo Niskanen
+
+ * Released version 1.1.5
+
+2011-05-16 Sampo Niskanen
+
+ * Updated about dialog
+
+2011-04-15 Sampo Niskanen
+
+ * Removed native printing support
+
+2011-03-05 Sampo Niskanen
+
+ * Released version 1.1.4
+
+2011-01-20 Sampo Niskanen
+
+ * Initial i18n support
+
+2011-01-18 Sampo Niskanen
+
+ * [BUG] Simulation warnings were not being stored
+ * [BUG] Exclamation mark did not fit in simulation table
+ * Added instructions for zooming in plot dialog
+
+2010-12-01 Doug Pedrick
+
+ * Merging printing support
+
+2010-10-30 Sampo Niskanen
+
+ * [BUG] Invalid refereces to components used in caches
+
+2010-10-25 Doug Pedrick
+
+ * [BUG] Take launch lug radial angle into account when loading rkt file
+
+2010-10-24 Sampo Niskanen
+
+ * Added SafetyMutex and took into use in Simulation
+
+2010-10-18 Sampo Niskanen
+
+ * Ignore Sun JRE bug in D3D
+
+2010-10-09 Sampo Niskanen
+
+ * [BUG] Fixed conversion to freeform fin set
+ * Enhanced logging
+
+2010-10-08 Sampo Niskanen
+
+ * New components no longer look expandable in the component tree
+
+2010-10-06 Sampo Niskanen
+
+ * Released version 1.1.3
+
+2010-10-05 Sampo Niskanen
+
+ * Display comment as tooltip in component tree
+ * Limited allowed component attachments to those of the component add buttons
+
+2010-10-03 Sampo Niskanen
+
+ * Added VBOSE logging level
+
+2010-10-02 Sampo Niskanen
+
+ * [BUG] Exception when undoing changes
+
+2010-09-27 Sampo Niskanen
+
+ * Implemented DnD for component tree
+ * Documented undo/redo functionality
+
+2010-09-07 Sampo Niskanen
+
+ * Released version 1.1.2
+
+2010-09-05 Sampo Niskanen
+
+ * [BUG] Fixed bug that prevents adding stages to a rocket
+
+2010-09-04 Sampo Niskanen
+
+ * Added launch rod velocity to FlightData
+ * [BUG] Total velocity was measured from airspeed
+
+2010-09-03 Sampo Niskanen
+
+ * Released version 1.1.1
+
+2010-09-01 Sampo Niskanen
+
+ * [BUG] Fixed rocket config dialog being too large
+
+2010-08-31 Sampo Niskanen
+
+ * Updated all thrust curves from thrustcurve.org
+
+2010-08-30 Sampo Niskanen
+
+ * Implemented user-defined thrust curve loading
+
+2010-07-30 Sampo Niskanen
+
+ * [BUG] Fixed motor statistic computation
+ * Finalized enhanced motor selection dialog
+
+2010-07-22 Doug Pedrick
+
+ * [BUG] Fixed RockSim fin loading
+
+2010-07-21 Sampo Niskanen
+
+ * Implemented enhanced motor selection dialog
+ * Background motor loading & startup time optimization
+
+2010-07-20 Doug Pedrick
+
+ * [BUG] Exception when loading Rocksim files
+
+2010-07-19 Sampo Niskanen
+
+ * [BUG] Various small bug fixes
+
+2010-07-18 Sampo Niskanen
+
+ * Major refactoring of simulation code
+
+2010-03-21 Sampo Niskanen
+
+ * Released version 1.1.0
+
+2010-03-20 Doug Pedrick
+
+ * [BUG] Fixed RockSim design material loading
+
+2010-03-20 Sampo Niskanen
+
+ * Minor enhancements to the logging system
+ * Updated unit tests of Rocksim file loading
+
+2010-03-13 Doug Pedrick / Sampo Niskanen
+
+ * Initial RockSim design loading support
+
+2010-03-10 Sampo Niskanen
+
+ * Released version 1.0.0
+ * [BUG] Removing point of freeform fin could create intersecting shape
+
+2010-03-09 Sampo Niskanen
+
+ * Updated thrustcurves with newest curves from thrustcurve.org
+ * Updated splash screen
+
+2010-03-05 Sampo Niskanen
+
+ * [BUG] Fixed exception for fins with small root chord
+
+2010-02-26 Sampo Niskanen
+
+ * Simulation panel max.acceleration now from flight stage only
+
+2010-02-17 Sampo Niskanen
+
+ * Released version 0.9.6
+
+2010-01-11 Sampo Niskanen
+
+ * Detect out of memory condition even if masked by another exception
+ * Updated copyright year
+
+2009-12-31 Sampo Niskanen
+
+ * [BUG] Exception when removing component listeners
+ * [BUG] OutOfMemoryError was masked when saving file
+
+2009-12-30 Sampo Niskanen
+
+ * [BUG] "Reset" button did nothing for simulation time step
+
+2009-12-29 Sampo Niskanen
+
+ * Update fin calculation methods for 1 and 2 fin sets
+ * Rotate rocket to worst roll angle before simulations
+
+2009-12-23 Sampo Niskanen
+
+ * Updated time step selection methods
+
+2009-12-16 Sampo Niskanen
+
+ * [BUG] Fixed NullPointerException in ComponentConfigDialog
+
+2009-12-15 Sampo Niskanen
+
+ * [BUG] Illegal mapping in SimulationRunDialog
+ * [BUG] Fixed assertions in Quaternion class
+
+2009-12-14 Sampo Niskanen
+
+ * Implemented central logging system (not taken into use yet)
+
+2009-12-05 Sampo Niskanen
+
+ * [BUG] Fixed assertions in Quaternion class
+
+2009-12-03 Sampo Niskanen
+
+ * [BUG] Fixed fin computation of two-fin set
+
+2009-12-02 Sampo Niskanen
+
+ * Take into account all fins in fin-fin interference
+ * Removed 15%/6% fin dependence on lateral wind direction
+
+2009-11-28 Sampo Niskanen
+
+ * Released version 0.9.5
+ * [BUG] NPE when clearing combo box selections
+ * Minor fixes to update checking
+ * Added a few guidance texts
+
+2009-11-27 Sampo Niskanen
+
+ * [BUG] Fixed computing inner radius of centering ring
+ * Removed RuntimeException instantiation from all classes
+
+2009-11-24 Sampo Niskanen
+
+ * Released version 0.9.4
+
+2009-11-24 Sampo Niskanen
+
+ * Close original window when opening example design
+
+2009-11-10 Sampo Niskanen
+
+ * [BUG] Fixed transition volume/mass computation
+ * [BUG] Simulations etc. using removed motor configuration IDs
+
+2009-10-11 Sampo Niskanen
+
+ * [BUG] Sorting motor selection dialog with ',' decimal separator
+
+2009-10-10 Sampo Niskanen
+
+ * Removed non-ASCII characters from source code files
+ * Created Chars class for non-ASCII characters
+ * Added styrofoam materials
+
+2009-10-04 Sampo Niskanen
+
+ * [BUG] Fixed too high configuration dialogs
+
+2009-10-03 Sampo Niskanen
+
+ * Added debug information to ant build file compilation
+ * Implemented update information fetching (client side)
+
+2009-09-26 Sampo Niskanen
+
+ * Implemented custom material editing
+
+2009-09-20 Sampo Niskanen
+
+ * Implemented more unit tests, fixed bugs
+
+2009-09-19 Sampo Niskanen
+
+ * [BUG] Ignore Sun JRE bug 6828938 in ExceptionHandler
+ * Implemented non-exception throwing bug handling
+ * [BUG] Fixed unnecessary cropping for component tree names
+
+2009-09-10 Sampo Niskanen
+
+ * [BUG] Freeform fin set shape undo not working
+ * [BUG] Conversion to freeform fin set not working
+
+2009-09-08 Sampo Niskanen
+
+ * Allow components to be attached to tube coupler
+
+2009-09-07 Sampo Niskanen
+
+ * Implemented fin tab save/load
+
+2009-09-04 Sampo Niskanen
+
+ * Implemented through-the-wall fin tabs (excluding save/load)
+
+2009-09-01 Sampo Niskanen
+
+ * Released version 0.9.3
+
+2009-08-29 Sampo Niskanen
+
+ * Extracted motor manufacturer into separate class
+ * Started writing unit tests
+
+2009-08-28 Sampo Niskanen
+
+ * Added icon and source info to About dialog
+ * Finalized flight event plot icons
+
+2009-08-27 Sampo Niskanen
+
+ * Allow clicking on label to toggle checkbox in two tables
+
+2009-08-21 Sampo Niskanen
+
+ * Showing events in non-time-domain-plots
+
+2009-08-20 Sampo Niskanen
+
+ * Showing events in time-domain plots
+
+2009-08-15 Sampo Niskanen
+
+ * Possibility to save user-defined materials
+
+2009-08-14 Sampo Niskanen
+
+ * Plots ignore trailing NaN values
+
+2009-08-13 Sampo Niskanen
+
+ * [BUG] Added fin cant for elliptical fins
+
+2009-08-12 Sampo Niskanen
+
+ * Warning dialog when loading files
+ * [BUG] Unnecessary warnings when loading files
+
+2009-08-09 Sampo Niskanen
+
+ * [BUG] Fixed various bugs in motor loading (e.g. mass calculation,
+ more rigorous input checking etc)
+
+2009-08-08 Sampo Niskanen
+
+ * Refactored motor loading and "Simple XML" loading classes
+ * Implemented RockSim motor definition file loading
+
+2009-08-07 Sampo Niskanen
+
+ * Created window icons and took into use
+ * Changed motor burn time and avg. thrust calculations to be
+ NFPA 1125 compliant
+
+2009-08-03 Sampo Niskanen
+
+ * Automatic bug reporting when uncaught exceptions occur
+
+2009-07-29 Sampo Niskanen
+
+ * Clustered inner tube splitting
+ * [BUG] Copy-pasted inner tubes shared motors
+
+2009-07-28 Sampo Niskanen
+
+ * Opening of example rocket designs
+
+2009-07-27 Sampo Niskanen
+
+ * [BUG] Launch lug radial position not correctly loaded
+
+2009-07-26 Sampo Niskanen
+
+ * [BUG] Fixed unit name of ft/s^2
+ * Implemented flight data exporting
+ * [BUG] Fixed "unknown error" when opening file of zero size
+ * [BUG] Fixed exception in motor configuration name editing
+
+2009-07-13 Sampo Niskanen
+
+ * Released version 0.9.2
+
+2009-07-12 Sampo Niskanen
+
+ * [BUG] Better DescriptionArea based on JEditorPane
+
+2009-07-09 Sampo Niskanen
+
+ * [BUG] Fixed imperial unit conversions
+ * [BUG] Fixed engine block icon transparency
+
+2009-06-26 Sampo Niskanen
+
+ * Progress dialogs for file open/save
+ * File size estimate in save dialog
+
+2009-06-20 Sampo Niskanen
+
+ * New edit motor configurations dialog
+ * Changed FreeformFinSet to throw checked exceptions
+
+2009-06-11 Sampo Niskanen
+
+ * Added search field to motor chooser dialog
+
+2009-06-09 Sampo Niskanen
+
+ * Released version 0.9.1
+
+2009-06-08 Sampo Niskanen
+
+ * Fixed loading of icons from JAR
+
+2009-06-06 Sampo Niskanen
+
+ * Cut/Copy/Paste of simulations
+ * Improved build scripts
+
+2009-05-28 Sampo Niskanen
+
+ * Added startup check for Java 1.6 and OpenJDK
+
+2009-05-28 Sampo Niskanen
+
+ * Fixed FixedPrecisionUnit formatting
+ * Fixed saving of transitions
+ * Fixed file dialog directory browsing
+ * Initial shift-click selects second component from figure
+ * Allow adding body components without selecting stage
+
+2009-05-24 Sampo Niskanen
+
+ * Initial release 0.9.0
diff --git a/core/LICENSE.TXT b/LICENSE.TXT
similarity index 99%
rename from core/LICENSE.TXT
rename to LICENSE.TXT
index 31fc843335..73f460eaa6 100644
--- a/core/LICENSE.TXT
+++ b/LICENSE.TXT
@@ -1,6 +1,6 @@
OpenRocket - A model rocket simulator
-Copyright (C) 2007-2013 Sampo Niskanen and others
+Copyright (C) 2007-2025 Sampo Niskanen and others
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/README.md b/README.md
index 47abc97bae..06325913f5 100644
--- a/README.md
+++ b/README.md
@@ -1,32 +1,149 @@
-OpenRocket
-==========
+# OpenRocket 🚀
-Build Status - [  ](https://travis-ci.org/openrocket/openrocket)
-------------
+OpenRocket is a free, fully featured model rocket simulator that allows you to design and simulate your rockets before actually building and flying them.
+
+
+[](https://www.gnu.org/licenses/gpl-3.0)
+
+[](https://GitHub.com/openrocket/openrocket/releases/)
+[](https://openrocket.readthedocs.io/en/latest/)
+
+[](https://snapcraft.io/openrocket)
+
+[](https://crowdin.com/project/openrocket)
+[](https://discord.gg/qD2G5v2FAw)
-Overview
--------
-OpenRocket is a free, fully featured model rocket simulator that allows you to design and simulate your rockets before actually building and flying them.
+## 🛠️ Design, Visualize, and Analyze
+
+1. **Design** your rockets using a rich selection of built-in components:
+ 
+
+2. **Visualize** your masterpiece in 3D:
+ 
+
+3. **Plot & Analyze** your simulation results for precision and improvements:
+ 
+
+## 🌟 Features
+
+- **Six-degree-of-freedom flight simulation**
+- **Automatic design optimization**
+- **Realtime simulated altitude, velocity, and acceleration display**
+- **Staging and clustering support**
+- **Export to other simulation programs (RockSim, RASAero II)**
+- **Export component(s) to OBJ file for 3D printing**
+- **Cross-platform (Java-based)**
+
+... plus many more
+
+📖 Read more on [our website](https://openrocket.info/).
+
+## 💾 Installers
+
+You can find the OpenRocket installers [here](https://openrocket.info/downloads.html).
+
+Release notes are available on each [release's page](https://github.com/openrocket/openrocket/releases) or on [our website](https://openrocket.info/release_notes.html).
+
+## 📖 Documentation
+
+You can find our documentation on [ReadTheDocs](https://openrocket.readthedocs.io/en/latest/).
-The main features include:
+## 🚀 Getting started
-* Six-degree-of-freedom flight simulation
-* Automatic design optimization
-* Realtime simulated altitude, velocity and acceleration display
-* Staging and clustering support
-* Cross-platform (Java-based)
+**Check out [our documentation](https://openrocket.readthedocs.io/en/latest/setup/getting_started.html) for a detailled guide on how to get started.**
-Read more about it on the [OpenRocket Wiki](http://wiki.openrocket.info).
+The easiest way to get familiar with OpenRocket is to open one of our in-program example designs:
-License
--------
+
-OpenRocket is an Open Source project licensed under the [GNU GPL](http://openrocket.sourceforge.net/license.html). This means that the software is free to use for whatever purposes, and the source code is also available for studying and extending.
+Dive into the essentials: adjust component dimensions, plot a simulation, swap out motors, ... Explore the impact of your changes and, most importantly, enjoy the process! 😊
-Contributing
-------------
+---
-OpenRocket needs help to become even better. Implementing features, writing documentation and creating example designs are just a few ways of helping. If you are interested in helping make OpenRocket the best rocket simulator out there, please [click here for information on how to get involved!](http://openrocket.sourceforge.net/getinvolved.html)
+## 📐 OpenRocket-related Projects & Tools
+*Note: If you have an OpenRocket-related project you would like included in the list, you can file a new issue for it.*
+### Core Projects
+| Project | Type | Description |
+|---------------------------------------------------------------------------------------|------------------|----------------------------------------------------------------|
+| [openrocket/openrocket](https://github.com/openrocket/openrocket) | Core project | Main simulator (Java) |
+| [openrocket/openrocket.github.io](https://github.com/openrocket/openrocket.github.io) | Website source | Website content (Jekyll) |
+| [openrocket/openrocket-database](https://github.com/openrocket/openrocket-database) | Data enhancement | Expanded parts catalog (originally [dbcook/openrocket-database](https://github.com/dbcook/openrocket-database)) |
+
+### Integration & Scripting
+| Project | Type | Description |
+|-----------------------------------------------------------------------------------------|----------------------------|-------------------------------------------------------------------------------------|
+| [openrocket/orhelper](https://github.com/openrocket/orhelper) | Integration (Python) | Python scripting/module for OpenRocket (via JPype) (forked from [SilentSys/orhelper](https://github.com/SilentSys/orhelper)) |
+| [RocketPy-Team/RocketSerializer](https://github.com/RocketPy-Team/RocketSerializer) | Integration (Python) | Convert `.ork` files to RocketPy-compatible formats |
+| [SpaceTeam/ortools](https://github.com/SpaceTeam/ortools) | Integration Tools (Python) | Scripts like 6DOF landing scatter visualization |
+| [schrum2/OpenRocketQD](https://github.com/schrum2/OpenRocketQD) | Optimization tool (Python) | Quality Diversity optimization for rocket designs |
+| [waterloo-rocketry/or-monte-carlo](https://github.com/waterloo-rocketry/or-monte-carlo) | Simulation tool (Java) | Monte Carlo simulation wrapper for OpenRocket |
+
+### Engine & Aerodynamics Extensions
+| Project | Type | Description |
+|----------------------------------------------------------------------|--------------------------|----------------------------------------|
+| [SpaceTeam/ORLEG](https://github.com/SpaceTeam/ORLEG) | Engine modeling (Python) | Liquid-engine generator for OpenRocket |
+| [WPI-HPRC/ORBrake](https://github.com/WPI-HPRC/ORBrake) *(archived)* | Plugin (Java) | Active drag control (air-brakes) |
+
+### Wind & Atmospheric Data
+| Project | Type | Description |
+|--------------------------------------------|--------------------------|--------------------------------------------------------------------------------------|
+| [ORWind](https://gpsdriftcast.com/orwind/) | Atmospheric data utility | Fetches/imports multi-level wind data for OpenRocket |
+| [Aloft](https://aloft.onrender.com/) | Weather data utility | Retrieves weather/atmospheric profiles (winds, temp, pressure) for flight simulation |
+
+### Design & CAD Integration
+| Project | Type | Description |
+|-----------------------------------------------------------------------|---------------|-------------------------------------------------------------------------------|
+| [FreeCAD Rocket Workbench](https://github.com/davesrocketshop/Rocket) | CAD workbench | A rocket design workbench for FreeCAD that can import OpenRocket `.ork` files |
+
+### Example Designs / Showcase
+| Project | Type | Description |
+|-----------------------------------------------------------------------------------|-----------------|-------------------------|
+| [TrinetraOne-OpenRocket](https://github.com/ChinmayBhattt/TrinetraOne-OpenRocket) | Example designs | Showcase rocket project |
+
+---
+
+## 💪 Contribute
+
+Help us soar higher! Whether it's implementing features, writing documentation, or creating design examples, every contribution matters. Interested? Check out [how to get involved](https://openrocket.info/contribute.html) and the [practicalities of contributing](CONTRIBUTING.md).
+
+### ✨ Contributors
+- [Sampo Niskanen](https://github.com/plaa) - Original developer
+- [Doug Pedrick](https://github.com/rodinia814) - RockSim designs, printing
+- [Kevin Ruland](https://github.com/kruland2607) - Android version
+- [Bill Kuker](https://github.com/bkuker) - 3D visualization
+- [Richard Graham](https://github.com/rdgraham) - Geodetic computations
+- Jason Blood - Freeform fin set import
+- [Boris du Reau](https://github.com/bdureau) - Internationalization
+- [Daniel Williams](https://github.com/teyrana) - Pod support, maintainer
+- [Joe Pfeiffer](https://github.com/JoePfeiffer) - Maintainer
+- [Billy Olsen](https://github.com/wolsen) - Maintainer
+- [Sibo Van Gool](https://github.com/SiboVG) - RASAero file format, 3D OBJ export, dark theme, maintainer
+- [Neil Weinstock](https://github.com/neilweinstock) - Tester, icons, forum support
+- [H. Craig Miller](https://github.com/hcraigmiller) - Tester
+
+You can view the full list of contributors [here](https://github.com/openrocket/openrocket/graphs/contributors).
+
+### 🌍Translators
+- Tripoli France
+- Tripoli Spain
+- Stefan Lobas / ERIG
+- Mauro Biasutti
+- Sky Dart Team / Ruslan V. Uss
+- Vladimir Beran
+- Polish Rocketry Society / Łukasz & Alex Kazanski
+- Sibo Van Gool
+- Mohamed Amin Elkebsi
+- Oleksandr Hladin
+
+## 📜 License
+
+OpenRocket is proudly open-source under the [GNU GPL](https://www.gnu.org/licenses/gpl-3.0.en.html) license. Feel free to use, study, and extend.
+
+---
+⭐ Please give us a star if you find OpenRocket useful, and spread the word! ⭐
+
+[](https://star-history.com/#openrocket/openrocket&Date)
diff --git a/ReleaseNotes.md b/ReleaseNotes.md
new file mode 100644
index 0000000000..879d759880
--- /dev/null
+++ b/ReleaseNotes.md
@@ -0,0 +1,1074 @@
+
+
+
+
+
+Release Notes
+=============
+
+
+
+
+
+OpenRocket 24.12 (2025-07-27)
+-------------------------------------
+
+These release notes cover the entire 24.12 release. Changes since 24.12.RC.01 are listed at the end. Notable features and fixes shown in **bold**.
+
+### RELEASE HIGHLIGHTS
+* **Enhanced Simulation tab UI**: This is the beginning of a multi-release effort to make it easier to manage simulations and interpret their results. Please let us know what you think so far.
+* **Multi-level wind input**: Configure different wind settings at different altitudes (in the simulation configuration dialog).
+* **New Component Analysis Parameter Sweep Tool**: Plot and export Component Analysis parameter sweeps in the new Component Analysis Plot/Export tab. For instance, you can plot the rocket CD as a function of Mach number.
+* **SVG Fin Export**: Export fin shapes directly to SVG for laser cutting or importing into CAD tools.
+* **Window Ghosting Eliminated on Windows OS (!)**
+* **Extensive Improvements to error handling**: There should be far fewer instances of ORK files encountering errors or exceptions while loading.
+* **Expanded Platform Support**: We now offer installers for x86_64 and Arm64 on Windows, Mac, and Linux.
+* **Project documentation moved to Sphinx**: See it at [https://openrocket.readthedocs.io/](https://openrocket.readthedocs.io/).
+
+### Simulation
+* **Overhauled Sim table GUI** (fixes #2456)
+* **Multi-level Wind Feature**
+ * **Enter wind speed and direction at arbitrary set of altitudes for simulation** (fixes #922, #2060, #2558)
+ * **CSV Wind Data Import**: Import detailed wind profiles directly from CSV files.
+ * Add "Wind Direction" flight data type
+* **Plotting**
+ * **Organize axis plot types selector into categories and add search function** (fixes #2338)
+ * Increase size of legend color patches for improved color visibility (fixes #2836)
+ * Add air density as plottable variable (fixes #2462)
+ * Show stage name in sim plot tooltips (fixes #2521)
+ * Keep edit sim dialog open after plotting/exporting (fixes #2531)
+ * Add Flight Warning events to plots
+* **Warnings**
+ * **Standardize Warning format** (fixes #2669)
+ * **Add SIM_ABORT flight event type, instead of throwing exceptions**
+ * Improve how warnings are saved to and reloaded from ORK file (fixes #2694)
+ * Don't warn about large angle of attack when we start to tumble
+ * Don't set open airframe warning on booster stages if either they're about to deploy a recovery device or they're unstable (and improve wording)
+ * Clarify "Open airframe" warnings when due to separated booster stage
+ * Don't generate spurious warning when using a single tube fin (fixes #2663)
+* **Other**
+ * Add "Altitude above Sea Level" as new flight data type
+ * Include side boosters in thrust calculation (fixes #2639)
+ * Allow for configurable maximum simulation time
+ * Sync wind speed, deviation, and turbulence widgets together in sim settings (fixes #2388)
+ * Add South/West units for latitude and longitude of launch site (fixes #2178)
+ * Abort sim when recovery deployment occurs under thrust
+ * Allow sustainer to tumble before apogee; if under thrust, abort sim
+ * Fire outdated sim on stage rename (fixes #2532)
+ * Added "aborted" status mark to simulations
+ * Don't show vertical acceleration as negative before liftoff
+
+### Motor Configurations
+* **Separate motor nominal vs. actual diameter** (fixes #2569): This allows Loki 76mm motors to pass the 75mm motor filter.
+* Add 6mm (MicroMaxx) motor diameter to filter table
+* Add "Save as default" option to motor config name (fixes #2537)
+
+### Multi-stage Rockets
+* **Add stage separation options for deployable payloads and a deployable payload example** (fixes #852, #2519): We had many requests for this from various competition participants.
+* Don't add motor delay time to upper stage motor ignition time (fixes #2450)
+
+### Calculations
+* Correctly calculate CG on zero-length components (fixes #2626)
+* Improve handling of very small fins (fixes #2633)
+* Include enabled stages in calculations even if parent stage is disabled (fixes #2657)
+* Correctly handle "auto" mass object size when parent component is filled (fixes #2660)
+* Fix CP calculation error with tail cones (fixes #2751)
+* Clamp compressibility factor to avoid singularity at Mach 1 (fixes #2543)
+
+### Component Analysis
+* **Plot and export component analysis parameter sweeps** (fixes #2525): See the new Plot/Export tab.
+* Highlight component selected in Component Analysis in the rocket figure display
+* Add per-instance Cd column to Component Analysis Dialog (fixes #2019)
+* Select components for plot/export
+* Fix export of Component Analysis data (fixes #2697)
+
+### Import/Export
+* **Export fins to SVG file**: See button at bottom of config window
+* Improve OBJ export using Delaunay triangulation (fixes #2444)
+* Correct conical nose cone/transition OBJ exporting (fixes #2609)
+* Add option to export only one instance of component to OBJ
+* Support booster export and import with Rocksim, other bug fixes (fixes #2437, #2377, #2435)
+* Correct launch rod length when exporting to RASAero
+* Correctly handle periods in file path when exporting (fixes #2701)
+
+### Materials
+* **Add material groups with search**: Check this out in any config window.
+* **Add "document materials" that can be reused within a document (i.e. ORK file)**
+* Easier to add custom materials
+* Set balsa as default fin material
+
+### Preset Library
+* **Fix parachute length resizing when using preset parachute**: Lots of folks reported this one.
+* **Fix transition and nose cone component presets defaulting to a filled shape** (fixes #2480 and #2614)
+* Correct diameter of Spherachutes to match Cd (fixes #2517)
+* Fix sorting problems in preset library (fixes #2576)
+
+### User Interface
+* **Window Ghosting Eliminated on Windows OS**: @SiboVG finally squashed this vexing problem (fixes #1667)
+* **Change look-and-feel engine to FlatLaf for all UI themes**: after plenty of tweaking we think it's looking pretty good
+* **Add UI Customization**: You can now tweak the UI to your liking. Added "UI Scale", "Font Size", and "Character Spacing". See the "UI" tab in app preferences.
+* **Rotate 2D views by click-dragging** (fixes #2093)
+* **Show Flight Config in Design View**: This should make it easier to get all necessary information when screenshotting just the rocket figure display (fixes #2735)
+* **Improvements to Rotation Control in 2D Views**: You can now lock the angle so you don't accidentally rotate it with a click-drag; you can also enter the desired angle directly
+* **Allow components to be hidden from view** (fixes #2485): Use the edit menu or contextual menu to show/hide selected components
+* **Constrain angles in freeform fin editor** (fixes #427): Hold down shift or control-shift while dragging a point.
+* **Add hex color input field in appearance panel** (fixes #2224)
+* Include number of assembly copies in motor count display (fixes #2725)
+* Better positioning of modal dialogs (fixes #2652)
+* Correctly track when files have changed (fixes #2679)
+* Allow 3 digits of precision in "shape" parameter (fixes #2409)
+* Fix Mass Object radial rotation in 3D view (fixes #2550)
+
+### Developer stuff
+* **Move project documentation to Sphinx**
+* **Switched build system from Ant to Gradle**
+* **Added Arm64 support for Windows and Linux**
+* Adopted Java Platform Module System
+* Renamed `net.sf.openrocket` package to `info.openrocket.core` and `info.openrocket.swing`.
+* Add compatibility with plugins using the old `net.sf.openrocket` package instead of the new `info.openrocket.core` and `info.openrocket.swing`. The old plugins are copied and migrated to the new package structure with a `-migrated` suffix. (fixes #2676)
+* Clean up the "CSV Save" example simulation extension (fixes #2696)
+* Improve core startup for using OR in external Java app
+* Add clone helper methods to WorldCoordinate, Quaternion, and SimulationStatus
+* Choose user-defined component preset locations (fixes #1081)
+* Suppress preset and motor loading at startup (fixes #1579)
+
+### Misc
+* **Re-introduced motor ignition delay optimization to Rocket Optimization** (fixes #2345)
+* Support more and larger page sizes for printing (fixes #2483)
+* Improve manufacturer search in Component preset library (fixes #2479)
+* Fix shoulder scaling (fixes #2463)
+* Fix exception when changing the opacity setting in the appearance panel (fixes #2644)
+* Improvements to the software updater (fixes #2648)
+* Update "modified data" file metadata when saving
+* Add additional file properties (fixes #2664)
+* Honor Cd override when reading from a file (fixes #2745)
+* Add Piotr Tendera Rocket Motors (TSP) and Raketenmodelbau Klima (Klima) motor manufacturers to motor database
+* Enhancements and fixes to motor length and diameter filters
+
+### Notable Changes since 24.12.RC.01
+* Multi-level winds feature
+ * Correct wind direction visualization
+ * Remove 10 m/s max wind speed and 11 km altitude limit for wind levels (fixes #2767)
+ * Allow for comments (starting with "#") and blank lines in multi-level wind CSV import
+* Major improvements to error handling (fixes to #2777, #2785, #2800, #2804)
+* Miscellaneous
+ * Reduce size of simulation edit and Component Analysis dialogs for low-res screens
+ * Make lateral angle and lateral orientation use north 0 (fixes #2811)
+ * Example design updates: Rename TARC example to ARC, rurn example sims without errors
+ * Include super-parent angles in instance rotation to ensure correct display in rocket figure display (fixes #2776)
+ * Save latitude and longitude in degrees
+ * Save and restore launchintowind element in ORK file (fixes #2802)
+* Developer features
+ * Improve core startup for using OR in external apps
+ * Add clone helper methods to WorldCoordinate, Quaternion, and SimulationStatus
+
+_...and countless additional fixes and tweaks._
+
+
+
+
+
+OpenRocket 23.09 (2023-11-16)
+------------------------
+
+You can find a visual overview of what's new for this release on [our website](https://openrocket.info//downloads.html?vers=23.09#whats-new).
+
+### Major Updates
+
+#### New Features:
+* **3D Printing Support: Export any component or combination to OBJ file** (fixes #604)
+* **RASAero compatibility: Import/Export CDX1 files** (fixes #875 and #1147)
+* **Dark mode (normal and high-contrast) and custom UI font size support** (fixes #1089)
+* **Export sim table to CSV** (fixes #2077)
+
+#### Bug Fixes:
+* **Fix Tube fin drag** (fixes #2065)
+* **Fix Base drag when using Cd override** (fixes base drag hack sim error, fixes #2118)
+* **Fix Atmospheric pressure when using ISA conditions** (fixes #2103)
+* **Properly sanitize XML in ORK file** (eliminates corrupt ORK files, fixes #2051)
+
+
+### Other New Features
+* Bumped app to Java 17
+* Export and import preferences to XML file
+* Display secondary stability unit. This means you can display stability in both calibers *and* percentage of length (fixes #2079)
+* Added "cases" and "manufacturers" substitution in motor config names (fixes #2055 and #2204)
+* Selection of "common name" or "manufacturer's designation" in motor selection table is now reflected everywhere else in the program (fixes #2072)
+* Added "plugged" option in charge delay combobox (fixes #2090)
+* Added motor type to "show details" in motor selection (fixes #2069)
+* Added instances settings in launch lug config (fixes #2035)
+* Account for fin cant in fin root points, and support canted fins in fin marking guide (fixes #2231 and #2242)
+* Set cluster tube separation in absolute or relative units (fixes #1970)
+* Support transparent rendering and export of Photo Studio images (fixes #2076)
+* Added "Select -> Components of same color" and "Select -> None" options (fixes #2129)
+* Remember column width, order and visibility in component preset table (fixes #2357)
+
+### Bug Fixes
+* Fixed mass issues with fin sets (fixes #2217)
+* Fixed CG issues for launch lugs and rail buttons (fixes #2040)
+* Improved rail button drag calculations
+* Added parts detail for pods and boosters (fixes #2084)
+* Fixed parachute position when using auto radius (fixes #2036)
+* Fixed pod set and booster marker position under certain circumstances (fixes #2047)
+* Fix CG marker location in top view (fixes #2050)
+* Handle zero-area fins (warn and don't crash with NaN error) (fixes #2032)
+* Don't dispose config dialog when no components are selected in 3D view (fixes #2108)
+* Display ISA values in temp and pressure fields (fixes #2104)
+* Improved simulation of fins on transitions and nose cones (fixes #2113)
+* Cleaned up multi-sim editing (fixes #2138 and #1826)
+* Update ruler units immediately when preferences are changed (fixes #2151)
+* Compute CG and CP based on currently active stages (fixes #2171)
+* Improved mass/CG calculations for fillets (fixes 2209)
+* Set auto radius correctly for mass objects (fixes #2267)
+* Apply radial positioning to multi-engine clusters (fixes #2283)
+* Fixed 3D rendering of fin tabs (fixes #2286)
+* Update recent file list when opening via file association (fixes #2222)
+* Corrected the columns displayed in the component preset table's popup menu, ensuring only relevant columns appear
+* Ensured optimum delay is saved in flight summary and .ork files (fixes #2353)
+* Corrected longitudinal moment of inertia calculations by excluding shoulders (fixes #2278)
+* Fixed exception when setting wind speed to zero (fixes #2386)
+* Fixed unexpected mass and CG override interaction (fixes #2394)
+
+### Miscellaneous
+* Updated example rockets (including brand-new two stage example)
+* Show calculated values in override tab (fixes #1629)
+* Decrease minimum FoV to 10 degrees in Photo Studio
+* Increase resolution of launch temperature and pressure to 2 decimal places (fixes #2003)
+* Display Cd override with 3 decimal places
+* Added wiki button to help menu (fixes #2046)
+* Eliminate option to save "some" sim data (fixes #2024)
+* Added OK/Cancel buttons when editing simulations (fixes #2158)
+* Added OK/Cancel buttons when editing preferences (fixes #2266)
+* Added multi-sim edit indicators (fixes #2159)
+* Show warning when motor file has illegal format (fixes #2150)
+* Reset window position if off-screen (fixes #2141)
+* Keep current field value when "auto" option is unchecked (fixes #2096)
+* Open dialog to save design info when first saving file
+* Added '3D Printable Nose Cone and Fins' to example rockets
+* Use more sensible colors for thrust curve selection in motor selection dialog (fixes #2385)
+
+
+...along with numerous other minor fixes and enhancements.
+
+
+
+
+OpenRocket 22.02 (2023-02-08)
+------------------------
+
+You can find a visual overview of what's new for this release on [our website](https://openrocket.info//downloads.html?vers=22.02#whats-new).
+
+The 22.02 release includes hundreds of new features, bug fixes, and UI improvements, more than we could ever fit into one set of release notes. These notes summarize the highlights of the entire release; for more detail consult the notes from the five previous public beta releases.
+
+Please note that version 22.02 is required for Macs running macOS 13.0 or later.
+
+## New Features
+* Rocket design features
+ * Pods and strap-on boosters
+ * Tail cones
+ * Freeform fins on nose cones and transitions
+ * Highly configurable rail buttons
+ * Massive update to parachute configuration and part library
+ * Dave Cook's extensive component library now built-in
+ * Coefficient of Drag Override for components and assemblies (and more flexible override settings in general)
+ * Lots more detailed geometry warnings which identify the components involved
+* Appearance updates
+ * Settable opacity per-component
+ * Separate left/right appearance for fins, and inner/outer appearance for tubes
+* App Infrastructure
+ * Packaged installers for Windows, Linux, and macOS (JAR file still available)
+ * Updated to Java 11
+ * Native ARM version for Apple Silicon Macs (snappy!)
+ * File association for ORK files: double-click files to open in the app
+ * On Mac, app stays open after last window is closed
+
+## Simulation and Staging Improvements
+ * Assorted CP calculation fixes
+ * Improved nose cone drag calculations
+ * Improved ground hit velocity calculations
+ * Completely reworked tube fin simulation (no longer "experimental")
+ * Improved time step selection for descent
+ * Improved simulation plot appearance
+ * Support for scientific notation and custom decimal places in simulation exports
+ * Simulations now properly account for disabled stages
+ * Update CG correctly when stages are toggled on or off
+ * Display stage names in stage enable buttons
+ * More reliable deployment of booster stage recovery device
+
+## UI Improvements
+* Updated icons everywhere
+* Rocket figure display updates
+ * Option to display stability margin as percentage of rocket length
+ * New "Top View" option
+ * Cleaned-up toolbar
+ * Option to show/hide warnings
+ * Option to show/hide CG and CP markings
+ * Improved click and double-click behavior on rocket
+* Component Configuration Editor
+ * Extensively reorganized for clarity and consistency
+ * Massively improved keyboard navigation
+ * Config panels remember which tab you were on previously
+ * Cancel button to exit config panel without saving changes
+* Contextual menus for managing the component tree
+* Simultaneous multi-component edit (great for appearance editing)
+* Completely updated operation of motor config and simulation tables
+* Improved workflow when creating motor configurations
+* Greatly improved component library browser
+* Greatly improved freeform fin editor operation
+* Photo Studio
+ * sliders for settings
+ * keyboard input for settings
+ * settings remembered for each rocket
+
+## Misc
+* Extensively updated and reorganized example rocket collection
+* Much improved RockSim import and export
+* Updated motor database
+
+_...plus about a billion bug fixes and so much more._
+
+Huge thanks to all the users who gave us feedback throughout the public beta period and helped us get to our first release in eight years!
+
+
+
+
+OpenRocket 22.02.RC.01 (2023-01-27)
+------------------------
+(through PR1996)
+
+## New Features
+* **Native ARM build for Apple Silicon Macs!** (fixes #1136 and #1533)
+* Added "Cancel" button to component config window (fixes #960)
+* Added component information box in config window (fixes #1564)
+* Example designs have been updated and reorganized
+* Add option to switch flight event markers to icons in sim plots
+* Add support for tail cones (fixes #1889)
+* Added additional warnings for inline pods, gaps and overlaps in airframe (fixes #1894)
+* Added "plugged" to delay options for all motors
+* Support rail button screws, updated rail button aerodynamics
+* Updated surface roughness settings to be consistent with standard terminology
+* Separate "override subcomponents" option for mass, CG, and drag (fixes #1750)
+* Add motor designation to motor selection table
+* Enable decal editing on Linux
+
+## UI Improvements
+* Reorganized Config dialogs for improved clarity and consistency
+* Added "Top View" option to rocket display
+* Add option to automatically open preset dialog when creating new component (fixes #1479)
+* Tell user where body discontinuities are (fixes #241)
+* Improved consistency of warning message text
+* Hitting left arrow moves cursor to front of text fields (fixes #1942)
+* Grey out texture edit button if using default material
+* New app icons
+* Zoom to active stages in rocket display
+* Added welcome dialog (fixes #1768)
+* Updated bug report form
+
+## Notable Bug Fixes
+* Fix various significant 3D view issues (fixes #939, #966, #1191, #1771)
+* Don't mark all simulations out-of-date on flight config change (fixes #1973)
+* Account for all recovery devices in pods when calculating descent rate (fixes #1910)
+* Eliminated many occurrences of mystery discontinuity warnings (fixes #999)
+* Rocksim import/export file updates
+ * Support import and export of pods (fixes #1348)
+ * Support import of trapezoidal fins on transitions (fixes #1553)
+ * Support subassembly import
+* Assorted extension and plug-in fixes
+
+
+
+
+
+
+OpenRocket 22.02.beta.05 (2022-09-28)
+------------------------
+(through PR1688)
+
+## New Features
+* **C_D Override for subassemblies now implemented. Please test!** [See this wiki help page](http://wiki.openrocket.info/Overrides_and_Surface_Finish#How_and_Why_to_Use_Surface_Finish_Settings_and_Coefficient_of_Drag_.28CD.29_Overrides) for important instructions (fixes #1171)
+* Simulations now properly account for disabled stages (fixes #1477 and #1460)
+* Rail Button improvements:
+ * Additional parameters for rail buttons (fixes #1537)
+ * Added rail buttons to preset parts database
+ * Scaling now supported for rail buttons (fixes #1661)
+* Don't include inactive stages in calculations. Disabling stages using the stage selector buttons now also affects the simulation results. (fixes #1477 and #1460)
+* Mass objects maintain fixed volume when container diameter changes in auto mode (fixes #1315)
+* Inner tubes can have custom inner/outer appearance (fixes #1509)
+
+## UI Improvements
+* Visually select child components of assembly components when selecting the parent (fixes #1489). Try selecting a pod, stage, or booster and see.
+* Significant improvements to preset selection window (fixes #1481)
+* Added sliders to Photo Studio settings (fixes #1524)
+* Show markers for pods and boosters in rocket side view (fixes #1146)
+* Major improvements to focus behavior. Keyboard navigation in the Component Config dialog is now _much_ more convenient.
+ * When setting focus to a spinner field, select the entire field by default (fixes #1506)
+ * After selecting a preset, automatically highlight most commonly edited parameter (fixes #1488). So, for example, after selecting a body tube preset the Length parameter will be selected by default.
+ * Restore focus to motors, recovery, stage and simulation tables after table action and others (fixes #1558). Simply put, you shouldn't need to click in the table areas just to enable keyboard shortcuts to work.
+ * Use tab and arrow keys to traverse sim table (fixes #1552)
+* Added and/or improved hover texts on a bunch of different buttons and controls
+* Apply preset after double-clicking (fixes #1539)
+* Pre-check diameter filters in preset chooser (fixes #1480)
+* Preset selection window opens larger, and remembers column widths (fixes #1305). Separate column widths are remembered for each component type.
+* Ctrl/Cmd+A (select all) keyboard shortcut in component tree, simulation and motor configuration tables (fixes #1549)
+
+## Notable Bug Fixes
+* **Scripting now works again. Please test!** (fixes #308, #826, #1108, and #1270)
+* Don't re-run simulations when new sim is created with same motor (fixes #1510)
+* Ensure simulations finish when running from scripts (fixes #1575)
+* Fixed Cd reporting for fin sets (fixes #1440)
+* Move component config window back to same monitor as main app window first time it is opened. No more lost config windows! (fixes #1470)
+* Rocket side view updates
+ * Don't recenter rocket when zooming (fixes #1464)
+ * Ensure full rocket is always visible and positioned correctly in rocket side view (fixes #1465)
+* Fixed root edge display in 3D view and fin templates (fixes #1227). This matters when you are attaching fins to a nose cone or transition.
+* Numerous bug fixes in component scaling (fixes #1649, #1651, #1653, #1661, #1662, and #1663)
+* Better register of double-clicks in 3D view (fixes #1054)
+* Increased component analysis drag precision to three decimal digits (fixes #1476)
+* Select recovery device/stage after config panel select (fixes #1490)
+* Fixed an exception when scaling freeform fins (fixes #1520)
+* Improved performance of freeform fin shape editor (fixes #1533)
+* Better automatic calculation of fin tab sizes (fixes #1600)
+* Fixed simulation errors when there were empty stages in the design (fixes #1617)
+* Fixed stage activeness not updating when moving, deleting, or copying stages (fixes #1680)
+* Fixed exception for zero-length transitions and nose cones (fixes #1677)
+
+## Other
+* Don't open motor selection dialog when duplicating motor configurations (fixes #1555)
+* A bunch of updated component icons
+* Added icons to most buttons
+* Improvements to Undo behavior when adding new components (fixes #1513)
+* Improvements to scale dialog (fixes #411)
+* Component tree now set to reasonable minimum width (fixes #1648)
+* Removed "show all compatible" option in preset chooser (fixes #1405)
+* Cleaned up several of the example rockets
+* Added warning to launch preferences that changes only affect new sims (fixes #1497)
+* Fixed overlapping labels in motor selection diameter filter slider (fixes #1643)
+* More Russian translation updates
+
+
+
+
+
+OpenRocket 22.02.beta.04 (2022-06-17)
+------------------------
+(through PR1456)
+
+**Please note:** For this new beta, the packaged installers are now back to using Java 11, due to multiple bug reports related to Java 17.
+However, the JAR file will still allow Java 11 *or* 17, so if you want to keep experimenting with Java 17 then feel free.
+
+### New Features
+* **File association now works on all platforms** (fixes #1135)
+* **Contextual menus now available via right-click throughout the program**
+* **Edit multiple selected items at once (great for appearance editing!)**
+* Show/hide CG/CP markings in rocket display
+* Support for custom decimal places and exponential notation in simulation exports (fixes #1307 and #1354)
+* Simulation warning when no recovery device is enabled (fixes #1436)
+* Remember previously selected tab when opening component edit dialog (fixes #974)
+* On Mac, app remains open when last window is closed (normal Mac behavior)
+
+### Notable Bug Fixes
+* **Tube fins are fixed!** Both CP and drag calculations should be good now. So good that we are no longer calling tube fin support "experimental". Feedback please! (fixes #1258)
+* Guarantee fit in rocket view (fixes #1231 and #1351)
+* Corrected mass display in some situations (fixes #1409)
+* Show combined mass of multi-selected components when hovering (fixes #1411)
+* Fix greyed-out buttons on Mac (fixes #1099)
+* Improve scalability of Motors and Configurations tab (fixes #1285)
+
+### Other
+* Many component edit dialogs reorganized for consistency and clarity
+* Loads more tweaks to parachute and streamer config dialog
+* Modified file size estimation in Save dialog. Feedback please!
+* Improved layout of rocket view ribbon
+* Improved icons for zoom buttons, and launch lugs and tube fins
+* Added sliders to Pod Set config
+* Preset dialog now sorted by manufacturer by default
+* Updated guided tours
+* Improved Russian translation
+
+
+
+
+
+OpenRocket 22.02.beta.03 (2022-05-18)
+------------------------
+(through PR1361)
+
+### New Features
+* Big improvements to parachutes:
+ * Added manufacturers: Front Range, Fruity Chutes, Rocketman, b2 Rocketry, Spherachutes
+ * Added additional fields to preset DB (e.g. spill holes)
+ * Automatic packed size calculation (for select chute manufacturers only)
+ * Parachute mass is automatically overridden with manufacturer data (when available)
+ * Parachute component name is automatically populated with preset description
+
+### Notable bug Fixes
+* __Tube fin drag simulation has been extensively rewritten__. This should fix flight simulations of tube fin models. Please test your sims and let us know how it works for you (fixes issue 1207). _Note that CP calculations for tube fins are still not fixed._
+* Improved ground hit velocity estimation (partially fixes issue 1349)
+* Rail buttons now included in Fin Marking Guide (fixes issue 1259)
+* Tube fin sets now included in Fin Marking Guide (fixes issue... ah, there wasn't one)
+* Override mass now divides when fin set is split (fixes issue 1292)
+* Fixes exception when splitting fin sets (fixes issue 1302)
+* Hovering over pod set reports total mass of pod set (fixes issue 1291)
+* Fixes exception when putting fins on transitions (fixes issue 1247)
+* Opacity slider now stays in sync with alpha changes in color selector (fixes issue 1326)
+
+### Other
+* Major cleanup of File menu. Let us know how you like it.
+* Improved time step selection for descent
+* Java 17 is now included in the packaged installers and supported by the JAR file.
+
+
+
+
+
+OpenRocket 22.02.beta.02 (2022-03-26)
+------------------------
+(through PR1261)
+
+NOTE: Tube fin simulation is currently broken, and will be fixed in a future beta.
+
+### New Features
+* Check Java version at startup (requires Java 11)
+* Opacity slider on appearance panel
+* Export sim plots as PNG images
+
+### Notable Bug Fixes
+* Rocksim Import/Export
+ * Corrected position offsets when importing and exporting (fixes issue 1164)
+ * Corrected fin shape when importing (fixes issue 1220)
+* Side boosters
+ * Added stage selector for side boosters (fixes issue 1208)
+ * Fixed simulation bug with side boosters (fixes issue 1210)
+ * Eliminated warning when loading designs with boosters (fixes issue 1196)
+ * Fixed Simulation Plot range with boosters (fixes issue 1228)
+* More reliable creation of simulation when creating a new configuration (fixes issue 1163)
+* No longer need to click on motor config to get flight data (fixes issue 1175)
+* Motor database search more robust, especially for CTI (fixes issue 1174)
+* More accurate and reliable simulation of fins on transitions (fixes issues 1173 and 1243)
+* _plus other miscellaneous fixes_
+
+### Other
+* Set default color for all components to #BBBBBB, with Shine=30 (closes issue 1192)
+* Update Mac installer style to more standard "drag app to Applications folder"
+
+
+
+
+
+OpenRocket 22.02.beta.01 (2022-02-25)
+------------------------
+(through PR1155)
+
+### Application
+* Update to Java 11
+* Distributed as packaged installers
+
+### New Rocket Design Capabilities
+* **Pods**
+* **Drop-off Boosters**
+* **Rail buttons**
+* **Attach freeform fins to nose cones and transitions**
+* **Coefficient of Drag override**
+* **Added Dave Cook's rocket component library**
+
+### Staging Improvements
+* Update CG correctly when stages are toggled
+* Display stage names instead of numbers in Stage enable buttons
+* Reported length reflects length of selected stages only
+* More reliable deployment of booster stage recovery device
+* Fixed booster tumbling behavior
+* Eliminate exceptions during multi-stage simulation
+* Improved accuracy of nose cone simulation
+
+### Simulation Improvements
+* Assorted CP calculation fixes
+* Improved nose cone drag calculations
+* Properly run all simulations when any design change is made
+* Use actual burn time for determination of burnout event
+* Improve mass calculation accuracy for motors
+* Correct linear interpolation of motor CG
+* Copy Simulation results to clipboard
+* Report wind speed correctly
+* Improved ground hit velocity calculations
+* Run simulations all the way to the end
+* No more warning if recovery device is deployed while motor is coasting
+
+### Rocket Appearance
+* Support rendering of transparent or translucent components
+* Separate inside and outside color for tube components
+* Separate left and right appearance for fin components
+
+### User Interface
+* Multi-select/copy/paste components in the tree
+* Option to display rocket stability as percentage of length
+* Improved layout on many windows and dialogs
+* Now use "Export" to save to RKT format
+* Improved File Dialog behavior
+* Multi-select/delete motor configurations
+* Improved UI appearance on Mac
+* Motor Selection
+ * Automatically open motor selection dialog when adding new motor configuation
+ * Added checkbox to hide motors which are out of production
+ * Highlight motor mount in rocket display when motor is selected
+* Many improvements to freeform fin editor, including
+ * More accurate insertion of new points
+ * Highlight coordinates of selected point
+ * Export fin profile to CSV file
+ * Fixed scrolling and zooming
+* Improvements to Photo Studio
+ * Respond instantly to design changes
+ * Settings saved per rocket
+ * Settings layout improved
+ * Settings values can now be entered via keyboard
+
+### Misc
+* Updated motor list to latest data from Thrustcurve.org
+* Added additional fields to motors
+* Disable fin-thickness warnings on phantom tubes
+* Added warning message for phantom body tubes
+* Updated print dialog to allow simulation control
+* Improved Rocksim import
+* Added or improved Spanish, Dutch, and simplified Chinese translations
+
+..._plus many, many additional bug fixes and refinements_
+
+
+
+
+
+OpenRocket 15.03 (2015-03-28)
+-----------------------------
+
+OpenRocket now requires Java 1.7 for execution.
+
+New Features
+
+ * Experimental support for tube fins
+ * Updated thrustcurves
+ * Scriptable simulation extensions
+ * Fin fillet mass
+ * Better icons for different kinds of masses - altimeters, computers, etc.
+ * Configurable default mach number
+ * Improved preferences UI
+
+Bug Fixes
+
+ * Always use the correct filename extension when saving
+
+
+
+
+
+OpenRocket 14.11 (2014-11-02)
+-----------------------------
+
+New Features
+
+ * Updated thrustcurves
+
+Bug Fixes
+
+ * Fixed a couple of bugs.
+
+
+
+
+
+OpenRocket 14.06 (2014-06-25)
+-----------------------------
+
+New Features
+
+ * Klima motor textures
+ * Added knots to windspeed and velocity units
+ * Updated thrustcurves
+
+Bug Fixes
+
+ * Fixed annoying IndexOutOfBounds bug in tables.
+
+
+
+
+
+OpenRocket 14.05 (2014-05-21)
+-----------------------------
+
+New Features
+
+ * Compute optimimum delay time when simulating
+ * Display cg/mass overrides using icons in the component tree
+
+Bug Fixes
+
+ * Bug fixes in the motor selection dialog
+ * Updated thrustcurves
+ * Updated 3d libraries to 2.1.5
+
+
+
+
+
+OpenRocket 14.03 (2014-03-20)
+-----------------------------
+
+New Features
+
+ * Photo Realistic 3d rocket renderer
+
+Bug Fixes
+
+ * Fixes to the flight configuration tab and motor selection dialog
+ * Updated thrustcurves
+
+
+
+
+
+OpenRocket 13.11.2 (2014-01-01)
+-------------------------------
+
+Bug Fixes
+
+ * Numerous bug fixes and usability improvements in the new
+ flight configuration tab.
+ * Fix couple of layout issues
+ * Updated Spanish, French and Chinese translations
+
+
+
+
+
+OpenRocket 13.11.1 (2013-11-15)
+-------------------------------
+
+Bug Fixes
+
+ * Added back the TubeConfiguration Configuration dialog
+ * Seems the jogl update didn't happen in the 13.11 build.
+ * Made the motor filter remember previous settings
+ * Fixed various exceptions in flight configuration tables due to column reordering
+ * Fixed NPE when deleting a configuration
+
+
+
+
+
+OpenRocket 13.11 (2013-11-08)
+------------------------------
+
+New Features
+
+ * Chinese translations
+ * Replaced flight configuration dialog with more efficient configuration tab
+ * Improved filtering in motor chooser dialog
+
+Bug Fixes
+
+ * Updated jogl to correct 3d problems on various platforms
+ * Fixed NPE introduced by changes in Java 1.7.0_45-b18
+
+
+
+
+
+OpenRocket 13.09.1 (2013-10-05)
+-------------------------------
+
+This release contains a number of bug fixes, updated 3D JOGL
+libraries. Added preliminary thrustcurves for Aerotech C3 and D2 18mm
+reloads.
+
+
+
+
+
+OpenRocket 13.09 (2013-09-08)
+-----------------------------
+
+This release contains a number of bug fixes, updated 3D JOGL
+libraries, and separates simulation edit and plot dialogs.
+
+
+
+
+
+OpenRocket 13.05 (2013-05-04)
+-----------------------------
+
+New Features
+
+ * Added support for decals on rockets. Added two new 3d views - 3d finished and 3d unfinshed. Added support to export and
+ apply decals (images) to rocket components. Added ability to launch external graphics editor to edit decals and monitor
+ file for writes to update the rocket view.
+ * Added simulation of tumble recovery based on experimentation done by Sampo Niskanen. This is particularly useful
+ for low power staged flights.
+ * Extended "motor configuration" concept to cover more properties. The concept was renamed "Flight Configuration" and
+ allows the user to override stage separation, recovery deployment, and motor ignition per flight configuration.
+ These configurations are stored in the ork file with each component. If no override is specified then the user specified
+ default is used (set in the component edit dialog). The flight configuration dialog was reworked to make it more
+ usable. The user selects the configuration in a drop down with buttons for "add", "delete" and "rename". After selecting
+ the configuration, the tabbed area below allows the user to change the configuration for this simulation.
+ * Allow simulation of stages without a motor. Users in the past have attempted to simulate separate recovery of payload
+ and booster by tricking OpenRocket using a dummy motor with trivial thrust curve. Now the user does not need to do this.
+ There is an example of this provided in TARC Payloader.ork and Boosted Dart.ork
+ * Simulate recovery of boosters. The simulation engine will create new FlightDataBranches for each stage after
+ separation. The data for the boosters begins at t=separation. The simulation plot allows the user to select
+ which stage's data to show (or all).
+ * Modified the zoom and pan controls in the simulation plot. Added zoom in, out, and reset buttons. Added
+ scroll with mouse wheel. If the alt key is used with either of these, only the domain is zoomed. Richard
+ contributed a more logical mouse controlled zoom - right click and drag will zoom (either domain, range or both).
+
+
+
+
+
+OpenRocket 12.09.1 (2012-06-28)
+-------------------------------
+
+Bug-fix release for 12.09, fixing numerous bugs. Only new feature is
+the possiblity to automatically open the latest design file on startup
+(in Edit -> Preferences -> Options).
+
+
+
+
+
+OpenRocket 12.09 (2012-09-16)
+------------------------------
+
+Numerous new features by many contributors
+
+- 3D rocket design view
+- Component Presets
+- Custom expressions in simulations
+- Printing for centering ring and clustered centering ring components.
+- Support simple arthmatic in dimension entry
+- Support deploying recovery device at stage separation
+- Support for fractional inches (1/64) for unit length
+- Added preference for windspeed units separately
+- Added "most recently used files" in File Menu.
+- Improved printed accurracy in fin marking guide
+- Calibration rulers added to printed templates
+- Translations in Czech and Polish, numerous updates
+
+
+
+
+
+OpenRocket 12.03 (2012-03-17)
+------------------------------
+
+In this release the version numbering scheme has been changed to be
+"YY.MM" indicating the year and month of the release.
+
+Enhancements in the desktop version include saving designs in RKT
+format thanks to Doug Pedrick, freeform fin set import from images by
+Jason Blood, configurable stage separation events, guided help tours
+and displaying the computed motor designation class. The application
+has also been translated to Italian by Mauro Biasutti and Russian by
+the Sky Dart Team.
+
+This also marks the first release for Android devices. In this first
+release you can open files and examine existing simulations, stability
+data and motor files. The Android port is thanks to work by Kevin
+Ruland.
+
+
+
+
+
+OpenRocket 1.1.9 (2011-11-24)
+------------------------------
+
+This release calculates rocket flight in real-world coordinates and
+takes into account geodetic effects (including coriolis effect) thanks
+to work by Richard Graham. Printing of transitions, nose cone
+profiles and fin marking guides is available thanks to Doug Pedrick.
+It also contains some usability features and bug fixes.
+
+
+
+
+
+OpenRocket 1.1.8 (2011-08-25)
+------------------------------
+
+This release contains bug fixes to the optimization methods.
+It also contains a workaround to a JRE bug that prevents running
+OpenRocket on Java 7.
+
+
+
+
+
+OpenRocket 1.1.7 (2011-08-12)
+------------------------------
+
+This release contains automatic rocket design optimization
+functionality. However, be cautious when using it and take the
+results with a grain of salt.
+
+
+
+
+
+OpenRocket 1.1.6 (2011-07-22)
+------------------------------
+
+Internationalization support thanks to work by Boris du Reau and
+translations by Tripoli Spain, Tripoli France and Stefan Lobas
+(ERIG e.V.). The release also contains rocket design scaling support
+and numerous bug fixes.
+
+
+
+
+
+OpenRocket 1.1.5 (2011-06-10)
+------------------------------
+
+Removed native printing support. Printing is now handled via PDF
+viewer, which should make printing much more reliable and less
+bug-prone.
+
+
+
+
+
+OpenRocket 1.1.4 (2011-03-05)
+------------------------------
+
+Initial printing support by Doug Pedrick, and various bug fixes.
+
+
+
+
+
+OpenRocket 1.1.3 (2010-10-06)
+------------------------------
+
+Support for drag-drop moving and copying of components. Fixes a
+severe bug in the undo system.
+
+
+
+
+
+OpenRocket 1.1.2 (2010-09-07)
+------------------------------
+
+Fixes a severe bug that prevented adding stages to rockets.
+
+
+
+
+
+OpenRocket 1.1.1 (2010-09-03)
+------------------------------
+
+Major rewrite of the simulation code, enhanced support for thrust
+curve loading and selection, faster startup time and bug fixes.
+
+Old simulation listeners are incompatible with this release.
+
+
+
+
+
+OpenRocket 1.1.0 (2010-03-21)
+------------------------------
+
+Support for loading RockSim rocket design files (.rkt) thanks to
+Doug Pedrick.
+
+
+
+
+
+OpenRocket 1.0.0 (2010-03-10)
+------------------------------
+
+Added numerous new motor thrustcurves from thrustcurve.org, and fixed
+a few more bugs.
+
+
+
+
+
+OpenRocket 0.9.6 (2010-02-17)
+------------------------------
+
+Updated aerodynamic calculation methods to be more in line with the
+Barrowman method and enhanced simulation time step selection. Fixed
+numerous bugs.
+
+
+
+
+
+OpenRocket 0.9.5 (2009-11-28)
+------------------------------
+
+Fixed a serious defect which prevented adding a tube coupler and
+centering ring on the same body tube. Other minor improvements.
+
+
+
+
+
+OpenRocket 0.9.4 (2009-11-24)
+------------------------------
+
+Added through-the-wall fin tabs, attaching components to tube
+couplers, material editing and automatic update checks, and fixed
+numerous of the most commonly occurring bugs.
+
+
+
+
+
+OpenRocket 0.9.3 (2009-09-01)
+------------------------------
+
+Numerous bug fixes and enhancements including data exporting, showing
+flight events in plots, example rocket designs, splitting clustered
+inner tubes and automated bug reporting.
+
+
+
+
+
+OpenRocket 0.9.2 (2009-07-13)
+------------------------------
+
+Fixed imperial unit conversions. Significant UI enhancements to the
+motor configuration edit dialog, motor selection dialog and file
+open/save.
+
+
+
+
+
+OpenRocket 0.9.1 (2009-06-09)
+------------------------------
+
+Bug fixes to file dialog and saving; initial support for cut/copy/paste
+of simulations.
+
+
+
diff --git a/SUPPORT.md b/SUPPORT.md
new file mode 100644
index 0000000000..99cde87962
--- /dev/null
+++ b/SUPPORT.md
@@ -0,0 +1,15 @@
+# OpenRocket support
+
+OpenRocket's documentation is available in the following places:':
+* [GitHub Documentation](https://openrocket.readthedocs.io/en/latest/)
+* [OpenRocket website](https://openrocket.info/index.html)
+
+Also check out our tutorials to get you going on OpenRocket:
+* [OpenRocket tutorials](https://openrocket.info/tutorials/)
+
+Our main communication channel are:
+* [Discord](https://discord.gg/qD2G5v2FAw) = **primary communication channel**
+* [OpenRocket forum](https://www.rocketryforum.com/forums/rocketry-electronics-software.36/)
+* [OpenRocket-devel mailing list](https://sourceforge.net/projects/openrocket/lists/openrocket-devel) for discussion related to OpenRocket development, documentation and upcoming features
+* [OpenRocket-announce mailing list](https://sourceforge.net/projects/openrocket/lists/openrocket-announce) for announcements of new OpenRocket versions and developments
+* [OpenRocket-website](https://lists.sourceforge.net/lists/listinfo/openrocket-website) for discussions around our website ([openrocket.info](openrocket.info))
diff --git a/android-libraries/ActionBarSherlock/.classpath b/android-libraries/ActionBarSherlock/.classpath
deleted file mode 100644
index 8531be1069..0000000000
--- a/android-libraries/ActionBarSherlock/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/android-libraries/ActionBarSherlock/.project b/android-libraries/ActionBarSherlock/.project
deleted file mode 100644
index cbcf5a2245..0000000000
--- a/android-libraries/ActionBarSherlock/.project
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
- ActionBarSherlock
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
diff --git a/android-libraries/ActionBarSherlock/AndroidManifest.xml b/android-libraries/ActionBarSherlock/AndroidManifest.xml
deleted file mode 100644
index c4a75f32c2..0000000000
--- a/android-libraries/ActionBarSherlock/AndroidManifest.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/android-libraries/ActionBarSherlock/gen/com/actionbarsherlock/BuildConfig.java b/android-libraries/ActionBarSherlock/gen/com/actionbarsherlock/BuildConfig.java
deleted file mode 100644
index ceb2ab073c..0000000000
--- a/android-libraries/ActionBarSherlock/gen/com/actionbarsherlock/BuildConfig.java
+++ /dev/null
@@ -1,6 +0,0 @@
-/** Automatically generated file. DO NOT MODIFY */
-package com.actionbarsherlock;
-
-public final class BuildConfig {
- public final static boolean DEBUG = true;
-}
\ No newline at end of file
diff --git a/android-libraries/ActionBarSherlock/gen/com/actionbarsherlock/R.java b/android-libraries/ActionBarSherlock/gen/com/actionbarsherlock/R.java
deleted file mode 100644
index b48b62429d..0000000000
--- a/android-libraries/ActionBarSherlock/gen/com/actionbarsherlock/R.java
+++ /dev/null
@@ -1,2813 +0,0 @@
-/* AUTO-GENERATED FILE. DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * aapt tool from the resource data it found. It
- * should not be modified by hand.
- */
-
-package com.actionbarsherlock;
-
-public final class R {
- public static final class attr {
- /** Specified if we are forcing an action item overflow menu.
-
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int absForceOverflow=0x7f010039;
- /** Custom divider drawable to use for elements in the action bar.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionBarDivider=0x7f01000e;
- /** Custom item state list drawable background for action bar items.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionBarItemBackground=0x7f01000f;
- /** Size of the Action Bar, including the contextual
- bar used to present Action Modes.
-
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
-
May be one of the following constant values.
-
-
-
-
-
Constant
Value
Description
-
wrap_content
0
-
- */
- public static int actionBarSize=0x7f01000d;
- /** Reference to a style for the split Action Bar. This style
- controls the split component that holds the menu/action
- buttons. actionBarStyle is still used for the primary
- bar.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionBarSplitStyle=0x7f01000b;
- /** Reference to a style for the Action Bar
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionBarStyle=0x7f01000a;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionBarTabBarStyle=0x7f010007;
- /** Default style for tabs within an action bar
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionBarTabStyle=0x7f010006;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionBarTabTextStyle=0x7f010008;
- /** Reference to a theme that should be used to inflate widgets
- and layouts destined for the action bar. Most of the time
- this will be a reference to the current theme, but when
- the action bar has a significantly different contrast
- profile than the rest of the activity the difference
- can become important. If this is set to @null the current
- theme will be used.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionBarWidgetTheme=0x7f01000c;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionButtonStyle=0x7f01002b;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionDropDownStyle=0x7f01002a;
- /** TextAppearance style that will be applied to text that
- appears within action menu items.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionMenuTextAppearance=0x7f010010;
- /** Color for text that appears within action menu items.
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
- */
- public static int actionMenuTextColor=0x7f010011;
- /** Background drawable to use for action mode UI
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionModeBackground=0x7f010014;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionModeCloseButtonStyle=0x7f010013;
- /** Drawable to use for the close action mode button
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionModeCloseDrawable=0x7f010016;
- /** PopupWindow style to use for action modes when showing as a window overlay.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionModePopupWindowStyle=0x7f010018;
- /** Drawable to use for the Share action button in WebView selection action modes
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionModeShareDrawable=0x7f010017;
- /** Background drawable to use for action mode UI in the lower split bar
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionModeSplitBackground=0x7f010015;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionModeStyle=0x7f010012;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionOverflowButtonStyle=0x7f010009;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int actionSpinnerItemStyle=0x7f010030;
- /** Drawable used as a background for activated items.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int activatedBackgroundIndicator=0x7f010038;
- /** Default ActivityChooserView style.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int activityChooserViewStyle=0x7f010037;
- /**
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
- */
- public static int background=0x7f010002;
- /**
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
- */
- public static int backgroundSplit=0x7f010003;
- /** Specifies a background drawable for a second stacked row of the action bar.
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
- */
- public static int backgroundStacked=0x7f010040;
- /** Small Button style.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int buttonStyleSmall=0x7f010019;
- /** Specifies a layout for custom navigation. Overrides navigationMode.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int customNavigationLayout=0x7f010041;
- /** Options affecting how the action bar is displayed.
-
Must be one or more (separated by '|') of the following constant values.
-
-
-
-
-
Constant
Value
Description
-
useLogo
0x1
-
showHome
0x2
-
homeAsUp
0x4
-
showTitle
0x8
-
showCustom
0x10
-
disableHome
0x20
-
- */
- public static int displayOptions=0x7f01003b;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int divider=0x7f010005;
- /** Drawable to use for generic vertical dividers.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int dividerVertical=0x7f010029;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int dropDownListViewStyle=0x7f01002d;
- /**
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int dropdownListPreferredItemHeight=0x7f01002f;
- /** The drawable to show in the button for expanding the activities overflow popup.
- Note: Clients would like to set this drawable
- as a clue about the action the chosen activity will perform. For
- example, if share activity is to be chosen the drawable should
- give a clue that sharing is to be performed.
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int expandActivityOverflowButtonDrawable=0x7f010050;
- /** Default background for the menu header.
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
- */
- public static int headerBackground=0x7f01004a;
- /**
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int height=0x7f010004;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int homeAsUpIndicator=0x7f01002c;
- /** Specifies a layout to use for the "home" section of the action bar.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int homeLayout=0x7f010042;
- /** Default horizontal divider between rows of menu items.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int horizontalDivider=0x7f010048;
- /** Specifies the drawable used for the application icon.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int icon=0x7f01003e;
- /** Specifies a style resource to use for an indeterminate progress spinner.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int indeterminateProgressStyle=0x7f010044;
- /** The maximal number of items initially shown in the activity list.
-
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int initialActivityCount=0x7f01004f;
- /** Default background for each menu item.
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
- */
- public static int itemBackground=0x7f01004b;
- /** Default disabled icon alpha for each menu item that shows an icon.
-
Must be a floating point value, such as "1.2".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int itemIconDisabledAlpha=0x7f01004d;
- /** Specifies padding that should be applied to the left and right sides of
- system-provided items in the bar.
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int itemPadding=0x7f010046;
- /** Default appearance of menu item text.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int itemTextAppearance=0x7f010047;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int listPopupWindowStyle=0x7f010036;
- /** A smaller, sleeker list item height.
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int listPreferredItemHeightSmall=0x7f010023;
- /** The preferred padding along the left edge of list items.
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int listPreferredItemPaddingLeft=0x7f010024;
- /** The preferred padding along the right edge of list items.
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int listPreferredItemPaddingRight=0x7f010025;
- /** Specifies the drawable used for the application logo.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int logo=0x7f01003f;
- /** The type of navigation to use.
-
Must be one of the following constant values.
-
-
-
-
-
Constant
Value
Description
-
normal
0
Normal static title text
-
listMode
1
The action bar will use a selection list for navigation.
-
tabMode
2
The action bar will use a series of horizontal tabs for navigation.
-
- */
- public static int navigationMode=0x7f01003a;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int popupMenuStyle=0x7f01002e;
- /** Whether space should be reserved in layout when an icon is missing.
-
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int preserveIconSpacing=0x7f01004e;
- /** Specifies the horizontal padding on either end for an embedded progress bar.
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int progressBarPadding=0x7f010045;
- /** Specifies a style resource to use for an embedded progress bar.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int progressBarStyle=0x7f010043;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int spinnerDropDownItemStyle=0x7f010022;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int spinnerItemStyle=0x7f010021;
- /** Specifies subtitle text used for navigationMode="normal"
-
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int subtitle=0x7f01003d;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int subtitleTextStyle=0x7f010001;
- /** Text color, typeface, size, and style for the text inside of a popup menu.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int textAppearanceLargePopupMenu=0x7f01001b;
- /** The preferred TextAppearance for the primary text of small list items.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int textAppearanceListItemSmall=0x7f010026;
- /** Text color, typeface, size, and style for "small" text. Defaults to secondary text color.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int textAppearanceSmall=0x7f01001d;
- /** Text color, typeface, size, and style for small text inside of a popup menu.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int textAppearanceSmallPopupMenu=0x7f01001c;
- /**
Must be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int textColorPrimary=0x7f01001e;
- /**
Must be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int textColorPrimaryDisableOnly=0x7f01001f;
- /**
Must be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int textColorPrimaryInverse=0x7f010020;
- /** Specifies title text used for navigationMode="normal"
-
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int title=0x7f01003c;
- /**
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int titleTextStyle=0x7f010000;
- /** Default vertical divider between menu items.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int verticalDivider=0x7f010049;
- /**
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int windowActionBar=0x7f010032;
- /**
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int windowActionBarOverlay=0x7f010033;
- /**
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int windowActionModeOverlay=0x7f010034;
- /** Default animations for the menu.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int windowAnimationStyle=0x7f01004c;
- /** This Drawable is overlaid over the foreground of the Window's content area, usually
- to place a shadow below the title.
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- */
- public static int windowContentOverlay=0x7f01001a;
- /**
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int windowMinWidthMajor=0x7f010027;
- /**
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int windowMinWidthMinor=0x7f010028;
- /**
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int windowNoTitle=0x7f010031;
- /**
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int windowSplitActionBar=0x7f010035;
- }
- public static final class bool {
- public static int abs__action_bar_embed_tabs=0x7f050000;
- public static int abs__action_bar_expanded_action_views_exclusive=0x7f050002;
- /** Whether action menu items should be displayed in ALLCAPS or not.
- Defaults to true. If this is not appropriate for specific locales
- it should be disabled in that locale's resources.
- */
- public static int abs__config_actionMenuItemAllCaps=0x7f050004;
- /** Whether action menu items should obey the "withText" showAsAction
- flag. This may be set to false for situations where space is
- extremely limited.
- Whether action menu items should obey the "withText" showAsAction
- flag. This may be set to false for situations where space is
- extremely limited.
- */
- public static int abs__config_allowActionMenuItemTextWithIcon=0x7f050005;
- /** Sets whether menu shortcuts should be displayed on panel menus when
- a keyboard is present.
- */
- public static int abs__config_showMenuShortcutsWhenKeyboardPresent=0x7f050003;
- public static int abs__split_action_bar_is_narrow=0x7f050001;
- }
- public static final class color {
- public static int abs__background_holo_dark=0x7f060000;
- public static int abs__background_holo_light=0x7f060001;
- public static int abs__bright_foreground_disabled_holo_dark=0x7f060004;
- public static int abs__bright_foreground_disabled_holo_light=0x7f060005;
- public static int abs__bright_foreground_holo_dark=0x7f060002;
- public static int abs__bright_foreground_holo_light=0x7f060003;
- public static int abs__bright_foreground_inverse_holo_dark=0x7f060006;
- public static int abs__bright_foreground_inverse_holo_light=0x7f060007;
- public static int abs__holo_blue_light=0x7f060008;
- public static int abs__primary_text_disable_only_holo_dark=0x7f060009;
- public static int abs__primary_text_disable_only_holo_light=0x7f06000a;
- public static int abs__primary_text_holo_dark=0x7f06000b;
- public static int abs__primary_text_holo_light=0x7f06000c;
- }
- public static final class dimen {
- /** Default height of an action bar.
- Default height of an action bar.
- Default height of an action bar.
- Default height of an action bar.
- Default height of an action bar.
- Default height of an action bar.
- Default height of an action bar.
- Default height of an action bar.
- */
- public static int abs__action_bar_default_height=0x7f070001;
- /** Vertical padding around action bar icons.
- Vertical padding around action bar icons.
- Vertical padding around action bar icons.
- Vertical padding around action bar icons.
- Vertical padding around action bar icons.
- Vertical padding around action bar icons.
- Vertical padding around action bar icons.
- Vertical padding around action bar icons.
- */
- public static int abs__action_bar_icon_vertical_padding=0x7f070002;
- /** Bottom margin for action bar subtitles
- Bottom margin for action bar subtitles
- Bottom margin for action bar subtitles
- Bottom margin for action bar subtitles
- Bottom margin for action bar subtitles
- Bottom margin for action bar subtitles
- Bottom margin for action bar subtitles
- Bottom margin for action bar subtitles
- */
- public static int abs__action_bar_subtitle_bottom_margin=0x7f070006;
- /** Text size for action bar subtitles
- Text size for action bar subtitles
- Text size for action bar subtitles
- Text size for action bar subtitles
- Text size for action bar subtitles
- Text size for action bar subtitles
- Text size for action bar subtitles
- Text size for action bar subtitles
- */
- public static int abs__action_bar_subtitle_text_size=0x7f070004;
- /** Top margin for action bar subtitles
- Top margin for action bar subtitles
- Top margin for action bar subtitles
- Top margin for action bar subtitles
- Top margin for action bar subtitles
- Top margin for action bar subtitles
- Top margin for action bar subtitles
- Top margin for action bar subtitles
- */
- public static int abs__action_bar_subtitle_top_margin=0x7f070005;
- /** Text size for action bar titles
- Text size for action bar titles
- Text size for action bar titles
- Text size for action bar titles
- Text size for action bar titles
- Text size for action bar titles
- Text size for action bar titles
- Text size for action bar titles
- */
- public static int abs__action_bar_title_text_size=0x7f070003;
- /** Minimum width for an action button in the menu area of an action bar
- Minimum width for an action button in the menu area of an action bar
- */
- public static int abs__action_button_min_width=0x7f070007;
- /** Dialog title height
- */
- public static int abs__alert_dialog_title_height=0x7f070008;
- /** The maximum width we would prefer dialogs to be. 0 if there is no
- maximum (let them grow as large as the screen). Actual values are
- specified for -large and -xlarge configurations.
- */
- public static int abs__config_prefDialogWidth=0x7f070000;
- /** The platform's desired minimum size for a dialog's width when it
- is along the major axis (that is the screen is landscape). This may
- be either a fraction or a dimension.
- The platform's desired minimum size for a dialog's width when it
- is along the major axis (that is the screen is landscape). This may
- be either a fraction or a dimension.
- The platform's desired minimum size for a dialog's width when it
- is along the major axis (that is the screen is landscape). This may
- be either a fraction or a dimension.
- */
- public static int abs__dialog_min_width_major=0x7f070009;
- /** The platform's desired minimum size for a dialog's width when it
- is along the minor axis (that is the screen is portrait). This may
- be either a fraction or a dimension.
- The platform's desired minimum size for a dialog's width when it
- is along the minor axis (that is the screen is portrait). This may
- be either a fraction or a dimension.
- The platform's desired minimum size for a dialog's width when it
- is along the minor axis (that is the screen is portrait). This may
- be either a fraction or a dimension.
- */
- public static int abs__dialog_min_width_minor=0x7f07000a;
- /** Minimum width for an action button in the menu area of an action bar
- Minimum width for an action button in the menu area of an action bar
- */
- public static int action_button_min_width=0x7f07000b;
- }
- public static final class drawable {
- public static int abs__ab_bottom_solid_dark_holo=0x7f020000;
- public static int abs__ab_bottom_solid_inverse_holo=0x7f020001;
- public static int abs__ab_bottom_solid_light_holo=0x7f020002;
- public static int abs__ab_bottom_transparent_dark_holo=0x7f020003;
- public static int abs__ab_bottom_transparent_light_holo=0x7f020004;
- public static int abs__ab_share_pack_holo_dark=0x7f020005;
- public static int abs__ab_share_pack_holo_light=0x7f020006;
- public static int abs__ab_solid_dark_holo=0x7f020007;
- public static int abs__ab_solid_light_holo=0x7f020008;
- public static int abs__ab_solid_shadow_holo=0x7f020009;
- public static int abs__ab_stacked_solid_dark_holo=0x7f02000a;
- public static int abs__ab_stacked_solid_light_holo=0x7f02000b;
- public static int abs__ab_stacked_transparent_dark_holo=0x7f02000c;
- public static int abs__ab_stacked_transparent_light_holo=0x7f02000d;
- public static int abs__ab_transparent_dark_holo=0x7f02000e;
- public static int abs__ab_transparent_light_holo=0x7f02000f;
- public static int abs__activated_background_holo_dark=0x7f020010;
- public static int abs__activated_background_holo_light=0x7f020011;
- public static int abs__btn_cab_done_default_holo_dark=0x7f020012;
- public static int abs__btn_cab_done_default_holo_light=0x7f020013;
- public static int abs__btn_cab_done_focused_holo_dark=0x7f020014;
- public static int abs__btn_cab_done_focused_holo_light=0x7f020015;
- public static int abs__btn_cab_done_holo_dark=0x7f020016;
- public static int abs__btn_cab_done_holo_light=0x7f020017;
- public static int abs__btn_cab_done_pressed_holo_dark=0x7f020018;
- public static int abs__btn_cab_done_pressed_holo_light=0x7f020019;
- public static int abs__cab_background_bottom_holo_dark=0x7f02001a;
- public static int abs__cab_background_bottom_holo_light=0x7f02001b;
- public static int abs__cab_background_top_holo_dark=0x7f02001c;
- public static int abs__cab_background_top_holo_light=0x7f02001d;
- public static int abs__dialog_full_holo_dark=0x7f02001e;
- public static int abs__dialog_full_holo_light=0x7f02001f;
- public static int abs__ic_ab_back_holo_dark=0x7f020020;
- public static int abs__ic_ab_back_holo_light=0x7f020021;
- public static int abs__ic_cab_done_holo_dark=0x7f020022;
- public static int abs__ic_cab_done_holo_light=0x7f020023;
- public static int abs__ic_menu_moreoverflow_holo_dark=0x7f020024;
- public static int abs__ic_menu_moreoverflow_holo_light=0x7f020025;
- public static int abs__ic_menu_moreoverflow_normal_holo_dark=0x7f020026;
- public static int abs__ic_menu_moreoverflow_normal_holo_light=0x7f020027;
- public static int abs__ic_menu_share_holo_dark=0x7f020028;
- public static int abs__ic_menu_share_holo_light=0x7f020029;
- public static int abs__item_background_holo_dark=0x7f02002a;
- public static int abs__item_background_holo_light=0x7f02002b;
- public static int abs__list_activated_holo=0x7f02002c;
- public static int abs__list_divider_holo_dark=0x7f02002d;
- public static int abs__list_divider_holo_light=0x7f02002e;
- public static int abs__list_focused_holo=0x7f02002f;
- public static int abs__list_longpressed_holo=0x7f020030;
- public static int abs__list_pressed_holo_dark=0x7f020031;
- public static int abs__list_pressed_holo_light=0x7f020032;
- public static int abs__list_selector_background_transition_holo_dark=0x7f020033;
- public static int abs__list_selector_background_transition_holo_light=0x7f020034;
- public static int abs__list_selector_disabled_holo_dark=0x7f020035;
- public static int abs__list_selector_disabled_holo_light=0x7f020036;
- public static int abs__list_selector_holo_dark=0x7f020037;
- public static int abs__list_selector_holo_light=0x7f020038;
- public static int abs__menu_dropdown_panel_holo_dark=0x7f020039;
- public static int abs__menu_dropdown_panel_holo_light=0x7f02003a;
- public static int abs__progress_bg_holo_dark=0x7f02003b;
- public static int abs__progress_bg_holo_light=0x7f02003c;
- public static int abs__progress_horizontal_holo_dark=0x7f02003d;
- public static int abs__progress_horizontal_holo_light=0x7f02003e;
- public static int abs__progress_medium_holo=0x7f02003f;
- public static int abs__progress_primary_holo_dark=0x7f020040;
- public static int abs__progress_primary_holo_light=0x7f020041;
- public static int abs__progress_secondary_holo_dark=0x7f020042;
- public static int abs__progress_secondary_holo_light=0x7f020043;
- public static int abs__spinner_48_inner_holo=0x7f020044;
- public static int abs__spinner_48_outer_holo=0x7f020045;
- public static int abs__spinner_ab_default_holo_dark=0x7f020046;
- public static int abs__spinner_ab_default_holo_light=0x7f020047;
- public static int abs__spinner_ab_disabled_holo_dark=0x7f020048;
- public static int abs__spinner_ab_disabled_holo_light=0x7f020049;
- public static int abs__spinner_ab_focused_holo_dark=0x7f02004a;
- public static int abs__spinner_ab_focused_holo_light=0x7f02004b;
- public static int abs__spinner_ab_holo_dark=0x7f02004c;
- public static int abs__spinner_ab_holo_light=0x7f02004d;
- public static int abs__spinner_ab_pressed_holo_dark=0x7f02004e;
- public static int abs__spinner_ab_pressed_holo_light=0x7f02004f;
- public static int abs__tab_indicator_ab_holo=0x7f020050;
- public static int abs__tab_selected_focused_holo=0x7f020051;
- public static int abs__tab_selected_holo=0x7f020052;
- public static int abs__tab_selected_pressed_holo=0x7f020053;
- public static int abs__tab_unselected_pressed_holo=0x7f020054;
- public static int ic_launcher=0x7f020055;
- }
- public static final class id {
- public static int abs__action_bar=0x7f040022;
- public static int abs__action_bar_container=0x7f040021;
- public static int abs__action_bar_subtitle=0x7f040011;
- public static int abs__action_bar_title=0x7f040010;
- public static int abs__action_context_bar=0x7f040023;
- public static int abs__action_menu_divider=0x7f04000c;
- public static int abs__action_menu_presenter=0x7f04000d;
- public static int abs__action_mode_bar=0x7f040026;
- public static int abs__action_mode_bar_stub=0x7f040025;
- public static int abs__action_mode_close_button=0x7f040014;
- public static int abs__activity_chooser_view_content=0x7f040015;
- public static int abs__checkbox=0x7f04001e;
- public static int abs__content=0x7f04001d;
- public static int abs__default_activity_button=0x7f040018;
- public static int abs__expand_activities_button=0x7f040016;
- public static int abs__home=0x7f04000a;
- public static int abs__icon=0x7f04001a;
- public static int abs__image=0x7f040017;
- public static int abs__imageButton=0x7f040012;
- public static int abs__list_item=0x7f040019;
- public static int abs__progress_circular=0x7f04000e;
- public static int abs__progress_horizontal=0x7f04000f;
- public static int abs__radio=0x7f040020;
- public static int abs__shortcut=0x7f04001f;
- public static int abs__split_action_bar=0x7f040024;
- public static int abs__textButton=0x7f040013;
- public static int abs__title=0x7f04001b;
- public static int abs__titleDivider=0x7f04001c;
- public static int abs__up=0x7f04000b;
- public static int disableHome=0x7f040009;
- public static int homeAsUp=0x7f040006;
- public static int listMode=0x7f040002;
- public static int normal=0x7f040001;
- public static int showCustom=0x7f040008;
- public static int showHome=0x7f040005;
- public static int showTitle=0x7f040007;
- public static int tabMode=0x7f040003;
- public static int useLogo=0x7f040004;
- public static int wrap_content=0x7f040000;
- }
- public static final class integer {
- public static int abs__max_action_buttons=0x7f080000;
- }
- public static final class layout {
- public static int abs__action_bar_home=0x7f030000;
- public static int abs__action_bar_tab=0x7f030001;
- public static int abs__action_bar_tab_bar_view=0x7f030002;
- public static int abs__action_bar_title_item=0x7f030003;
- public static int abs__action_menu_item_layout=0x7f030004;
- public static int abs__action_menu_layout=0x7f030005;
- public static int abs__action_mode_bar=0x7f030006;
- public static int abs__action_mode_close_item=0x7f030007;
- public static int abs__activity_chooser_view=0x7f030008;
- public static int abs__activity_chooser_view_list_item=0x7f030009;
- public static int abs__dialog_title_holo=0x7f03000a;
- public static int abs__list_menu_item_checkbox=0x7f03000b;
- public static int abs__list_menu_item_icon=0x7f03000c;
- public static int abs__list_menu_item_layout=0x7f03000d;
- public static int abs__list_menu_item_radio=0x7f03000e;
- public static int abs__popup_menu_item_layout=0x7f03000f;
- public static int abs__screen_action_bar=0x7f030010;
- public static int abs__screen_action_bar_overlay=0x7f030011;
- public static int abs__screen_simple=0x7f030012;
- public static int abs__screen_simple_overlay_action_mode=0x7f030013;
- public static int main=0x7f030014;
- public static int sherlock_spinner_dropdown_item=0x7f030015;
- public static int sherlock_spinner_item=0x7f030016;
- }
- public static final class string {
- /** Content description for the action bar "home" affordance. [CHAR LIMIT=NONE]
- */
- public static int abs__action_bar_home_description=0x7f090000;
- /** Content description for the action bar "up" affordance. [CHAR LIMIT=NONE]
- */
- public static int abs__action_bar_up_description=0x7f090001;
- /** Content description for the action menu overflow button. [CHAR LIMIT=NONE]
- */
- public static int abs__action_menu_overflow_description=0x7f090002;
- /** Label for the "Done" button on the far left of action mode toolbars.
- */
- public static int abs__action_mode_done=0x7f090003;
- /** Title default for a dialog showing possible activities in ActivityChooserView [CHAR LIMIT=25]
- */
- public static int abs__activity_chooser_view_dialog_title_default=0x7f090005;
- /** Title for a button to expand the list of activities in ActivityChooserView [CHAR LIMIT=25]
- */
- public static int abs__activity_chooser_view_see_all=0x7f090004;
- /** Description of the shwoing of a popup window with activities to choose from. [CHAR LIMIT=NONE]
- */
- public static int abs__activitychooserview_choose_application=0x7f090007;
- /** Title for a dialog showing possible activities for sharing in ShareActionProvider [CHAR LIMIT=25]
- */
- public static int abs__share_action_provider_share_with=0x7f090006;
- /** Description of the choose target button in a ShareActionProvider (share UI). [CHAR LIMIT=NONE]
- */
- public static int abs__shareactionprovider_share_with=0x7f090008;
- /** Description of a share target (both in the list of such or the default share button) in a ShareActionProvider (share UI). [CHAR LIMIT=NONE]
- */
- public static int abs__shareactionprovider_share_with_application=0x7f090009;
- public static int app_name=0x7f09000b;
- public static int hello=0x7f09000a;
- }
- public static final class style {
- public static int DialogWindowTitle_Sherlock=0x7f0a0033;
- public static int DialogWindowTitle_Sherlock_Light=0x7f0a0034;
- public static int Sherlock___TextAppearance_Small=0x7f0a0047;
- public static int Sherlock___Theme=0x7f0a004a;
- public static int Sherlock___Theme_DarkActionBar=0x7f0a004c;
- public static int Sherlock___Theme_Dialog=0x7f0a004d;
- public static int Sherlock___Theme_Light=0x7f0a004b;
- public static int Sherlock___Widget_ActionBar=0x7f0a0001;
- public static int Sherlock___Widget_ActionMode=0x7f0a0016;
- public static int Sherlock___Widget_ActivityChooserView=0x7f0a001e;
- public static int Sherlock___Widget_Holo_DropDownItem=0x7f0a0029;
- public static int Sherlock___Widget_Holo_ListView=0x7f0a0026;
- public static int Sherlock___Widget_Holo_Spinner=0x7f0a0023;
- public static int TextAppearance_Sherlock_DialogWindowTitle=0x7f0a0045;
- public static int TextAppearance_Sherlock_Light_DialogWindowTitle=0x7f0a0046;
- public static int TextAppearance_Sherlock_Light_Small=0x7f0a0049;
- public static int TextAppearance_Sherlock_Light_Widget_PopupMenu_Large=0x7f0a0040;
- public static int TextAppearance_Sherlock_Light_Widget_PopupMenu_Small=0x7f0a0042;
- public static int TextAppearance_Sherlock_Small=0x7f0a0048;
- public static int TextAppearance_Sherlock_Widget_ActionBar_Menu=0x7f0a0035;
- public static int TextAppearance_Sherlock_Widget_ActionBar_Subtitle=0x7f0a0038;
- public static int TextAppearance_Sherlock_Widget_ActionBar_Subtitle_Inverse=0x7f0a0039;
- public static int TextAppearance_Sherlock_Widget_ActionBar_Title=0x7f0a0036;
- public static int TextAppearance_Sherlock_Widget_ActionBar_Title_Inverse=0x7f0a0037;
- public static int TextAppearance_Sherlock_Widget_ActionMode_Subtitle=0x7f0a003c;
- public static int TextAppearance_Sherlock_Widget_ActionMode_Subtitle_Inverse=0x7f0a003d;
- public static int TextAppearance_Sherlock_Widget_ActionMode_Title=0x7f0a003a;
- public static int TextAppearance_Sherlock_Widget_ActionMode_Title_Inverse=0x7f0a003b;
- public static int TextAppearance_Sherlock_Widget_DropDownItem=0x7f0a0044;
- public static int TextAppearance_Sherlock_Widget_PopupMenu=0x7f0a003e;
- public static int TextAppearance_Sherlock_Widget_PopupMenu_Large=0x7f0a003f;
- public static int TextAppearance_Sherlock_Widget_PopupMenu_Small=0x7f0a0041;
- public static int TextAppearance_Sherlock_Widget_TextView_SpinnerItem=0x7f0a0043;
- public static int Theme_Sherlock=0x7f0a004e;
- public static int Theme_Sherlock_Dialog=0x7f0a0056;
- public static int Theme_Sherlock_ForceOverflow=0x7f0a0053;
- public static int Theme_Sherlock_Light=0x7f0a004f;
- public static int Theme_Sherlock_Light_DarkActionBar=0x7f0a0050;
- public static int Theme_Sherlock_Light_DarkActionBar_ForceOverflow=0x7f0a0055;
- public static int Theme_Sherlock_Light_Dialog=0x7f0a0057;
- public static int Theme_Sherlock_Light_ForceOverflow=0x7f0a0054;
- public static int Theme_Sherlock_Light_NoActionBar=0x7f0a0052;
- public static int Theme_Sherlock_NoActionBar=0x7f0a0051;
- public static int Widget=0x7f0a0000;
- public static int Widget_Sherlock_ActionBar=0x7f0a0002;
- public static int Widget_Sherlock_ActionBar_Solid=0x7f0a0003;
- public static int Widget_Sherlock_ActionBar_TabBar=0x7f0a000a;
- public static int Widget_Sherlock_ActionBar_TabText=0x7f0a000d;
- public static int Widget_Sherlock_ActionBar_TabView=0x7f0a0007;
- public static int Widget_Sherlock_ActionButton=0x7f0a0010;
- public static int Widget_Sherlock_ActionButton_CloseMode=0x7f0a0012;
- public static int Widget_Sherlock_ActionButton_Overflow=0x7f0a0014;
- public static int Widget_Sherlock_ActionMode=0x7f0a0017;
- public static int Widget_Sherlock_ActivityChooserView=0x7f0a001f;
- public static int Widget_Sherlock_Button_Small=0x7f0a0021;
- public static int Widget_Sherlock_DropDownItem_Spinner=0x7f0a002a;
- public static int Widget_Sherlock_Light_ActionBar=0x7f0a0004;
- public static int Widget_Sherlock_Light_ActionBar_Solid=0x7f0a0005;
- public static int Widget_Sherlock_Light_ActionBar_Solid_Inverse=0x7f0a0006;
- public static int Widget_Sherlock_Light_ActionBar_TabBar=0x7f0a000b;
- public static int Widget_Sherlock_Light_ActionBar_TabBar_Inverse=0x7f0a000c;
- public static int Widget_Sherlock_Light_ActionBar_TabText=0x7f0a000e;
- public static int Widget_Sherlock_Light_ActionBar_TabText_Inverse=0x7f0a000f;
- public static int Widget_Sherlock_Light_ActionBar_TabView=0x7f0a0008;
- public static int Widget_Sherlock_Light_ActionBar_TabView_Inverse=0x7f0a0009;
- public static int Widget_Sherlock_Light_ActionButton=0x7f0a0011;
- public static int Widget_Sherlock_Light_ActionButton_CloseMode=0x7f0a0013;
- public static int Widget_Sherlock_Light_ActionButton_Overflow=0x7f0a0015;
- public static int Widget_Sherlock_Light_ActionMode=0x7f0a0018;
- public static int Widget_Sherlock_Light_ActionMode_Inverse=0x7f0a0019;
- public static int Widget_Sherlock_Light_ActivityChooserView=0x7f0a0020;
- public static int Widget_Sherlock_Light_Button_Small=0x7f0a0022;
- public static int Widget_Sherlock_Light_DropDownItem_Spinner=0x7f0a002b;
- public static int Widget_Sherlock_Light_ListPopupWindow=0x7f0a001b;
- public static int Widget_Sherlock_Light_ListView_DropDown=0x7f0a0028;
- public static int Widget_Sherlock_Light_PopupMenu=0x7f0a001d;
- public static int Widget_Sherlock_Light_PopupWindow_ActionMode=0x7f0a002d;
- public static int Widget_Sherlock_Light_ProgressBar=0x7f0a002f;
- public static int Widget_Sherlock_Light_ProgressBar_Horizontal=0x7f0a0031;
- public static int Widget_Sherlock_Light_Spinner_DropDown_ActionBar=0x7f0a0025;
- public static int Widget_Sherlock_ListPopupWindow=0x7f0a001a;
- public static int Widget_Sherlock_ListView_DropDown=0x7f0a0027;
- public static int Widget_Sherlock_PopupMenu=0x7f0a001c;
- public static int Widget_Sherlock_PopupWindow_ActionMode=0x7f0a002c;
- public static int Widget_Sherlock_ProgressBar=0x7f0a002e;
- public static int Widget_Sherlock_ProgressBar_Horizontal=0x7f0a0030;
- public static int Widget_Sherlock_Spinner_DropDown_ActionBar=0x7f0a0024;
- public static int Widget_Sherlock_TextView_SpinnerItem=0x7f0a0032;
- }
- public static final class styleable {
- /** Attributes used to style the Action Bar.
-
- @attr description
- Specifies a background drawable for the action bar.
-
-
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
-
This is a private symbol.
- @attr name android:background
- */
- public static final int SherlockActionBar_background = 2;
- /**
-
- @attr description
- Specifies a background drawable for the bottom component of a split action bar.
-
-
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
-
This is a private symbol.
- @attr name android:backgroundSplit
- */
- public static final int SherlockActionBar_backgroundSplit = 3;
- /**
-
- @attr description
- Specifies a background drawable for a second stacked row of the action bar.
-
-
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
-
This is a private symbol.
- @attr name android:backgroundStacked
- */
- public static final int SherlockActionBar_backgroundStacked = 12;
- /**
-
- @attr description
- Specifies a layout for custom navigation. Overrides navigationMode.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:customNavigationLayout
- */
- public static final int SherlockActionBar_customNavigationLayout = 13;
- /**
-
- @attr description
- Options affecting how the action bar is displayed.
-
-
-
Must be one or more (separated by '|') of the following constant values.
-
-
-
-
-
Constant
Value
Description
-
useLogo
0x1
-
showHome
0x2
-
homeAsUp
0x4
-
showTitle
0x8
-
showCustom
0x10
-
disableHome
0x20
-
-
This is a private symbol.
- @attr name android:displayOptions
- */
- public static final int SherlockActionBar_displayOptions = 7;
- /**
-
- @attr description
- Specifies the drawable used for item dividers.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:divider
- */
- public static final int SherlockActionBar_divider = 5;
- /**
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
-
This is a private symbol.
- @attr name android:height
- */
- public static final int SherlockActionBar_height = 4;
- /**
-
- @attr description
- Specifies a layout to use for the "home" section of the action bar.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:homeLayout
- */
- public static final int SherlockActionBar_homeLayout = 14;
- /**
-
- @attr description
- Specifies the drawable used for the application icon.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:icon
- */
- public static final int SherlockActionBar_icon = 10;
- /**
-
- @attr description
- Specifies a style resource to use for an indeterminate progress spinner.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:indeterminateProgressStyle
- */
- public static final int SherlockActionBar_indeterminateProgressStyle = 16;
- /**
-
- @attr description
- Specifies padding that should be applied to the left and right sides of
- system-provided items in the bar.
-
-
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
-
This is a private symbol.
- @attr name android:itemPadding
- */
- public static final int SherlockActionBar_itemPadding = 18;
- /**
-
- @attr description
- Specifies the drawable used for the application logo.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:logo
- */
- public static final int SherlockActionBar_logo = 11;
- /**
-
- @attr description
- The type of navigation to use.
-
-
-
Must be one of the following constant values.
-
-
-
-
-
Constant
Value
Description
-
normal
0
Normal static title text
-
listMode
1
The action bar will use a selection list for navigation.
-
tabMode
2
The action bar will use a series of horizontal tabs for navigation.
-
-
This is a private symbol.
- @attr name android:navigationMode
- */
- public static final int SherlockActionBar_navigationMode = 6;
- /**
-
- @attr description
- Specifies the horizontal padding on either end for an embedded progress bar.
-
-
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
-
This is a private symbol.
- @attr name android:progressBarPadding
- */
- public static final int SherlockActionBar_progressBarPadding = 17;
- /**
-
- @attr description
- Specifies a style resource to use for an embedded progress bar.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:progressBarStyle
- */
- public static final int SherlockActionBar_progressBarStyle = 15;
- /**
-
- @attr description
- Specifies subtitle text used for navigationMode="normal"
-
-
-
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
-
This is a private symbol.
- @attr name android:subtitle
- */
- public static final int SherlockActionBar_subtitle = 9;
- /**
-
- @attr description
- Specifies a style to use for subtitle text.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:subtitleTextStyle
- */
- public static final int SherlockActionBar_subtitleTextStyle = 1;
- /**
-
- @attr description
- Specifies title text used for navigationMode="normal"
-
-
-
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
-
This is a private symbol.
- @attr name android:title
- */
- public static final int SherlockActionBar_title = 8;
- /**
-
- @attr description
- Specifies a style to use for title text.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:titleTextStyle
- */
- public static final int SherlockActionBar_titleTextStyle = 0;
- /** Attributes that can be used with a SherlockActionMenuItemView.
-
- @see #SherlockActionMenuItemView_android_minWidth
- */
- public static final int[] SherlockActionMenuItemView = {
- 0x0101013f
- };
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#android_minWidth}
- attribute's value can be found in the {@link #SherlockActionMenuItemView} array.
- @attr name android:android_minWidth
- */
- public static final int SherlockActionMenuItemView_android_minWidth = 0;
- /** Attributes that can be used with a SherlockActionMode.
-
- @attr description
- Specifies a background for the action mode bar.
-
-
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
-
This is a private symbol.
- @attr name android:background
- */
- public static final int SherlockActionMode_background = 2;
- /**
-
- @attr description
- Specifies a background for the split action mode bar.
-
-
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
-
This is a private symbol.
- @attr name android:backgroundSplit
- */
- public static final int SherlockActionMode_backgroundSplit = 3;
- /**
-
- @attr description
- Specifies a fixed height for the action mode bar.
-
-
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
-
This is a private symbol.
- @attr name android:height
- */
- public static final int SherlockActionMode_height = 4;
- /**
-
- @attr description
- Specifies a style to use for subtitle text.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:subtitleTextStyle
- */
- public static final int SherlockActionMode_subtitleTextStyle = 1;
- /**
-
- @attr description
- Specifies a style to use for title text.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:titleTextStyle
- */
- public static final int SherlockActionMode_titleTextStyle = 0;
- /** Attributes that can be used with a SherlockActivityChooserView.
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#android_background}
- attribute's value can be found in the {@link #SherlockActivityChooserView} array.
- @attr name android:android_background
- */
- public static final int SherlockActivityChooserView_android_background = 0;
- /**
-
- @attr description
- The drawable to show in the button for expanding the activities overflow popup.
- Note: Clients would like to set this drawable
- as a clue about the action the chosen activity will perform. For
- example, if share activity is to be chosen the drawable should
- give a clue that sharing is to be performed.
-
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:expandActivityOverflowButtonDrawable
- */
- public static final int SherlockActivityChooserView_expandActivityOverflowButtonDrawable = 2;
- /**
-
- @attr description
- The maximal number of items initially shown in the activity list.
-
-
-
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
-
This is a private symbol.
- @attr name android:initialActivityCount
- */
- public static final int SherlockActivityChooserView_initialActivityCount = 1;
- /** Base attributes that are available to all groups.
-
- @attr description
- Whether the items are capable of displaying a check mark.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_checkableBehavior}.
- @attr name android:android_checkableBehavior
- */
- public static final int SherlockMenuGroup_android_checkableBehavior = 5;
- /**
-
- @attr description
- Whether the items are enabled.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_enabled}.
- @attr name android:android_enabled
- */
- public static final int SherlockMenuGroup_android_enabled = 0;
- /**
-
- @attr description
- The ID of the group.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_id}.
- @attr name android:android_id
- */
- public static final int SherlockMenuGroup_android_id = 1;
- /**
-
- @attr description
- The category applied to all items within this group.
- (This will be or'ed with the orderInCategory attribute.)
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_menuCategory}.
- @attr name android:android_menuCategory
- */
- public static final int SherlockMenuGroup_android_menuCategory = 3;
- /**
-
- @attr description
- The order within the category applied to all items within this group.
- (This will be or'ed with the category attribute.)
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_orderInCategory}.
- @attr name android:android_orderInCategory
- */
- public static final int SherlockMenuGroup_android_orderInCategory = 4;
- /**
-
- @attr description
- Whether the items are shown/visible.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_visible}.
- @attr name android:android_visible
- */
- public static final int SherlockMenuGroup_android_visible = 2;
- /** Base attributes that are available to all Item objects.
-
- @attr description
- An optional layout to be used as an action view.
- See {@link android.view.MenuItem#setActionView(android.view.View)}
- for more info.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_actionLayout}.
- @attr name android:android_actionLayout
- */
- public static final int SherlockMenuItem_android_actionLayout = 14;
- /**
-
- @attr description
- The name of an optional ActionProvider class to instantiate an action view
- and perform operations such as default action for that menu item.
- See {@link android.view.MenuItem#setActionProvider(android.view.ActionProvider)}
- for more info.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_actionProviderClass}.
- @attr name android:android_actionProviderClass
- */
- public static final int SherlockMenuItem_android_actionProviderClass = 16;
- /**
-
- @attr description
- The name of an optional View class to instantiate and use as an
- action view. See {@link android.view.MenuItem#setActionView(android.view.View)}
- for more info.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_actionViewClass}.
- @attr name android:android_actionViewClass
- */
- public static final int SherlockMenuItem_android_actionViewClass = 15;
- /**
-
- @attr description
- The alphabetic shortcut key. This is the shortcut when using a keyboard
- with alphabetic keys.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_alphabeticShortcut}.
- @attr name android:android_alphabeticShortcut
- */
- public static final int SherlockMenuItem_android_alphabeticShortcut = 9;
- /**
-
- @attr description
- Whether the item is capable of displaying a check mark.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_checkable}.
- @attr name android:android_checkable
- */
- public static final int SherlockMenuItem_android_checkable = 11;
- /**
-
- @attr description
- Whether the item is checked. Note that you must first have enabled checking with
- the checkable attribute or else the check mark will not appear.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_checked}.
- @attr name android:android_checked
- */
- public static final int SherlockMenuItem_android_checked = 3;
- /**
-
- @attr description
- Whether the item is enabled.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_enabled}.
- @attr name android:android_enabled
- */
- public static final int SherlockMenuItem_android_enabled = 1;
- /**
-
- @attr description
- The icon associated with this item. This icon will not always be shown, so
- the title should be sufficient in describing this item.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_icon}.
- @attr name android:android_icon
- */
- public static final int SherlockMenuItem_android_icon = 0;
- /**
-
- @attr description
- The ID of the item.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_id}.
- @attr name android:android_id
- */
- public static final int SherlockMenuItem_android_id = 2;
- /**
-
- @attr description
- The category applied to the item.
- (This will be or'ed with the orderInCategory attribute.)
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_menuCategory}.
- @attr name android:android_menuCategory
- */
- public static final int SherlockMenuItem_android_menuCategory = 5;
- /**
-
- @attr description
- The numeric shortcut key. This is the shortcut when using a numeric (e.g., 12-key)
- keyboard.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_numericShortcut}.
- @attr name android:android_numericShortcut
- */
- public static final int SherlockMenuItem_android_numericShortcut = 10;
- /**
-
- @attr description
- Name of a method on the Context used to inflate the menu that will be
- called when the item is clicked.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_onClick}.
- @attr name android:android_onClick
- */
- public static final int SherlockMenuItem_android_onClick = 12;
- /**
-
- @attr description
- The order within the category applied to the item.
- (This will be or'ed with the category attribute.)
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_orderInCategory}.
- @attr name android:android_orderInCategory
- */
- public static final int SherlockMenuItem_android_orderInCategory = 6;
- /**
-
- @attr description
- How this item should display in the Action Bar, if present.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_showAsAction}.
- @attr name android:android_showAsAction
- */
- public static final int SherlockMenuItem_android_showAsAction = 13;
- /**
-
- @attr description
- The title associated with the item.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_title}.
- @attr name android:android_title
- */
- public static final int SherlockMenuItem_android_title = 7;
- /**
-
- @attr description
- The condensed title associated with the item. This is used in situations where the
- normal title may be too long to be displayed.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_titleCondensed}.
- @attr name android:android_titleCondensed
- */
- public static final int SherlockMenuItem_android_titleCondensed = 8;
- /**
-
- @attr description
- Whether the item is shown/visible.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_visible}.
- @attr name android:android_visible
- */
- public static final int SherlockMenuItem_android_visible = 4;
- /** Attributes that can be used with a SherlockMenuView.
-
- @attr description
- Default background for the menu header.
-
-
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
-
This is a private symbol.
- @attr name android:headerBackground
- */
- public static final int SherlockMenuView_headerBackground = 3;
- /**
-
- @attr description
- Default horizontal divider between rows of menu items.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:horizontalDivider
- */
- public static final int SherlockMenuView_horizontalDivider = 1;
- /**
-
- @attr description
- Default background for each menu item.
-
-
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
-
This is a private symbol.
- @attr name android:itemBackground
- */
- public static final int SherlockMenuView_itemBackground = 4;
- /**
-
- @attr description
- Default disabled icon alpha for each menu item that shows an icon.
-
-
-
Must be a floating point value, such as "1.2".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
-
This is a private symbol.
- @attr name android:itemIconDisabledAlpha
- */
- public static final int SherlockMenuView_itemIconDisabledAlpha = 6;
- /**
-
- @attr description
- Default appearance of menu item text.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:itemTextAppearance
- */
- public static final int SherlockMenuView_itemTextAppearance = 0;
- /**
-
- @attr description
- Whether space should be reserved in layout when an icon is missing.
-
-
-
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
-
This is a private symbol.
- @attr name android:preserveIconSpacing
- */
- public static final int SherlockMenuView_preserveIconSpacing = 7;
- /**
-
- @attr description
- Default vertical divider between menu items.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:verticalDivider
- */
- public static final int SherlockMenuView_verticalDivider = 2;
- /**
-
- @attr description
- Default animations for the menu.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:windowAnimationStyle
- */
- public static final int SherlockMenuView_windowAnimationStyle = 5;
- /** Attributes that can be used with a SherlockSpinner.
-
- @attr description
- Horizontal offset from the spinner widget for positioning the dropdown
- in spinnerMode="dropdown".
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_dropDownHorizontalOffset}.
- @attr name android:android_dropDownHorizontalOffset
- */
- public static final int SherlockSpinner_android_dropDownHorizontalOffset = 5;
- /**
-
- @attr description
- List selector to use for spinnerMode="dropdown" display.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_dropDownSelector}.
- @attr name android:android_dropDownSelector
- */
- public static final int SherlockSpinner_android_dropDownSelector = 1;
- /**
-
- @attr description
- Vertical offset from the spinner widget for positioning the dropdown in
- spinnerMode="dropdown".
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_dropDownVerticalOffset}.
- @attr name android:android_dropDownVerticalOffset
- */
- public static final int SherlockSpinner_android_dropDownVerticalOffset = 6;
- /**
-
- @attr description
- Width of the dropdown in spinnerMode="dropdown".
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_dropDownWidth}.
- @attr name android:android_dropDownWidth
- */
- public static final int SherlockSpinner_android_dropDownWidth = 4;
- /**
-
- @attr description
- Gravity setting for positioning the currently selected item.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_gravity}.
- @attr name android:android_gravity
- */
- public static final int SherlockSpinner_android_gravity = 0;
- /**
-
- @attr description
- Background drawable to use for the dropdown in spinnerMode="dropdown".
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_popupBackground}.
- @attr name android:android_popupBackground
- */
- public static final int SherlockSpinner_android_popupBackground = 2;
- /**
-
- @attr description
- Reference to a layout to use for displaying a prompt in the dropdown for
- spinnerMode="dropdown". This layout must contain a TextView with the id
- @android:id/text1 to be populated with the prompt text.
-
This is a private symbol.
- @attr name android:android_popupPromptView
- */
- public static final int SherlockSpinner_android_popupPromptView = 7;
- /**
-
- @attr description
- The prompt to display when the spinner's dialog is shown.
-
This corresponds to the global attribute resource symbol {@link com.actionbarsherlock.R.attr#android_prompt}.
- @attr name android:android_prompt
- */
- public static final int SherlockSpinner_android_prompt = 3;
- /** Attributes that can be used with a SherlockTheme.
-
- @attr description
- Specified if we are forcing an action item overflow menu.
-
-
-
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
-
This is a private symbol.
- @attr name android:absForceOverflow
- */
- public static final int SherlockTheme_absForceOverflow = 52;
- /**
-
- @attr description
- Custom divider drawable to use for elements in the action bar.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:actionBarDivider
- */
- public static final int SherlockTheme_actionBarDivider = 9;
- /**
-
- @attr description
- Custom item state list drawable background for action bar items.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:actionBarItemBackground
- */
- public static final int SherlockTheme_actionBarItemBackground = 10;
- /**
-
- @attr description
- Size of the Action Bar, including the contextual
- bar used to present Action Modes.
-
-
-
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
-
May be one of the following constant values.
-
-
-
-
-
Constant
Value
Description
-
wrap_content
0
-
-
This is a private symbol.
- @attr name android:actionBarSize
- */
- public static final int SherlockTheme_actionBarSize = 8;
- /**
-
- @attr description
- Reference to a style for the split Action Bar. This style
- controls the split component that holds the menu/action
- buttons. actionBarStyle is still used for the primary
- bar.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:actionBarSplitStyle
- */
- public static final int SherlockTheme_actionBarSplitStyle = 6;
- /**
-
- @attr description
- Reference to a style for the Action Bar
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:actionBarStyle
- */
- public static final int SherlockTheme_actionBarStyle = 5;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#actionBarTabBarStyle}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- @attr name android:actionBarTabBarStyle
- */
- public static final int SherlockTheme_actionBarTabBarStyle = 2;
- /**
-
- @attr description
- Default style for tabs within an action bar
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:actionBarTabStyle
- */
- public static final int SherlockTheme_actionBarTabStyle = 1;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#actionBarTabTextStyle}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- @attr name android:actionBarTabTextStyle
- */
- public static final int SherlockTheme_actionBarTabTextStyle = 3;
- /**
-
- @attr description
- Reference to a theme that should be used to inflate widgets
- and layouts destined for the action bar. Most of the time
- this will be a reference to the current theme, but when
- the action bar has a significantly different contrast
- profile than the rest of the activity the difference
- can become important. If this is set to @null the current
- theme will be used.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:actionBarWidgetTheme
- */
- public static final int SherlockTheme_actionBarWidgetTheme = 7;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#actionButtonStyle}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- @attr name android:actionButtonStyle
- */
- public static final int SherlockTheme_actionButtonStyle = 38;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#actionDropDownStyle}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- @attr name android:actionDropDownStyle
- */
- public static final int SherlockTheme_actionDropDownStyle = 37;
- /**
-
- @attr description
- TextAppearance style that will be applied to text that
- appears within action menu items.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:actionMenuTextAppearance
- */
- public static final int SherlockTheme_actionMenuTextAppearance = 11;
- /**
-
- @attr description
- Color for text that appears within action menu items.
-
-
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
-
This is a private symbol.
- @attr name android:actionMenuTextColor
- */
- public static final int SherlockTheme_actionMenuTextColor = 12;
- /**
-
- @attr description
- Background drawable to use for action mode UI
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:actionModeBackground
- */
- public static final int SherlockTheme_actionModeBackground = 15;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#actionModeCloseButtonStyle}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- @attr name android:actionModeCloseButtonStyle
- */
- public static final int SherlockTheme_actionModeCloseButtonStyle = 14;
- /**
-
- @attr description
- Drawable to use for the close action mode button
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:actionModeCloseDrawable
- */
- public static final int SherlockTheme_actionModeCloseDrawable = 17;
- /**
-
- @attr description
- PopupWindow style to use for action modes when showing as a window overlay.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:actionModePopupWindowStyle
- */
- public static final int SherlockTheme_actionModePopupWindowStyle = 19;
- /**
-
- @attr description
- Drawable to use for the Share action button in WebView selection action modes
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:actionModeShareDrawable
- */
- public static final int SherlockTheme_actionModeShareDrawable = 18;
- /**
-
- @attr description
- Background drawable to use for action mode UI in the lower split bar
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:actionModeSplitBackground
- */
- public static final int SherlockTheme_actionModeSplitBackground = 16;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#actionModeStyle}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- @attr name android:actionModeStyle
- */
- public static final int SherlockTheme_actionModeStyle = 13;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#actionOverflowButtonStyle}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- @attr name android:actionOverflowButtonStyle
- */
- public static final int SherlockTheme_actionOverflowButtonStyle = 4;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#actionSpinnerItemStyle}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- @attr name android:actionSpinnerItemStyle
- */
- public static final int SherlockTheme_actionSpinnerItemStyle = 43;
- /**
-
- @attr description
- Drawable used as a background for activated items.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:activatedBackgroundIndicator
- */
- public static final int SherlockTheme_activatedBackgroundIndicator = 51;
- /**
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:activityChooserViewStyle
- */
- public static final int SherlockTheme_activityChooserViewStyle = 50;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#android_windowIsFloating}
- attribute's value can be found in the {@link #SherlockTheme} array.
- @attr name android:android_windowIsFloating
- */
- public static final int SherlockTheme_android_windowIsFloating = 0;
- /**
-
- @attr description
- Small Button style.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:buttonStyleSmall
- */
- public static final int SherlockTheme_buttonStyleSmall = 20;
- /**
-
- @attr description
- Drawable to use for generic vertical dividers.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:dividerVertical
- */
- public static final int SherlockTheme_dividerVertical = 36;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#dropDownListViewStyle}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- @attr name android:dropDownListViewStyle
- */
- public static final int SherlockTheme_dropDownListViewStyle = 40;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#dropdownListPreferredItemHeight}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- @attr name android:dropdownListPreferredItemHeight
- */
- public static final int SherlockTheme_dropdownListPreferredItemHeight = 42;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#homeAsUpIndicator}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- @attr name android:homeAsUpIndicator
- */
- public static final int SherlockTheme_homeAsUpIndicator = 39;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#listPopupWindowStyle}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- @attr name android:listPopupWindowStyle
- */
- public static final int SherlockTheme_listPopupWindowStyle = 49;
- /**
-
- @attr description
- A smaller, sleeker list item height.
-
-
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
-
This is a private symbol.
- @attr name android:listPreferredItemHeightSmall
- */
- public static final int SherlockTheme_listPreferredItemHeightSmall = 30;
- /**
-
- @attr description
- The preferred padding along the left edge of list items.
-
-
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
-
This is a private symbol.
- @attr name android:listPreferredItemPaddingLeft
- */
- public static final int SherlockTheme_listPreferredItemPaddingLeft = 31;
- /**
-
- @attr description
- The preferred padding along the right edge of list items.
-
-
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
-
This is a private symbol.
- @attr name android:listPreferredItemPaddingRight
- */
- public static final int SherlockTheme_listPreferredItemPaddingRight = 32;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#popupMenuStyle}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- @attr name android:popupMenuStyle
- */
- public static final int SherlockTheme_popupMenuStyle = 41;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#spinnerDropDownItemStyle}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- @attr name android:spinnerDropDownItemStyle
- */
- public static final int SherlockTheme_spinnerDropDownItemStyle = 29;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#spinnerItemStyle}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
- @attr name android:spinnerItemStyle
- */
- public static final int SherlockTheme_spinnerItemStyle = 28;
- /**
-
- @attr description
- Text color, typeface, size, and style for the text inside of a popup menu.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:textAppearanceLargePopupMenu
- */
- public static final int SherlockTheme_textAppearanceLargePopupMenu = 22;
- /**
-
- @attr description
- The preferred TextAppearance for the primary text of small list items.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:textAppearanceListItemSmall
- */
- public static final int SherlockTheme_textAppearanceListItemSmall = 33;
- /**
-
- @attr description
- Text color, typeface, size, and style for "small" text. Defaults to secondary text color.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:textAppearanceSmall
- */
- public static final int SherlockTheme_textAppearanceSmall = 24;
- /**
-
- @attr description
- Text color, typeface, size, and style for small text inside of a popup menu.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:textAppearanceSmallPopupMenu
- */
- public static final int SherlockTheme_textAppearanceSmallPopupMenu = 23;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#textColorPrimary}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- @attr name android:textColorPrimary
- */
- public static final int SherlockTheme_textColorPrimary = 25;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#textColorPrimaryDisableOnly}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- @attr name android:textColorPrimaryDisableOnly
- */
- public static final int SherlockTheme_textColorPrimaryDisableOnly = 26;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#textColorPrimaryInverse}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- @attr name android:textColorPrimaryInverse
- */
- public static final int SherlockTheme_textColorPrimaryInverse = 27;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#windowActionBar}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- @attr name android:windowActionBar
- */
- public static final int SherlockTheme_windowActionBar = 45;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#windowActionBarOverlay}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- @attr name android:windowActionBarOverlay
- */
- public static final int SherlockTheme_windowActionBarOverlay = 46;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#windowActionModeOverlay}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- @attr name android:windowActionModeOverlay
- */
- public static final int SherlockTheme_windowActionModeOverlay = 47;
- /**
-
- @attr description
- This Drawable is overlaid over the foreground of the Window's content area, usually
- to place a shadow below the title.
-
-
-
Must be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
This is a private symbol.
- @attr name android:windowContentOverlay
- */
- public static final int SherlockTheme_windowContentOverlay = 21;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#windowMinWidthMajor}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- @attr name android:windowMinWidthMajor
- */
- public static final int SherlockTheme_windowMinWidthMajor = 34;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#windowMinWidthMinor}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- @attr name android:windowMinWidthMinor
- */
- public static final int SherlockTheme_windowMinWidthMinor = 35;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#windowNoTitle}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- @attr name android:windowNoTitle
- */
- public static final int SherlockTheme_windowNoTitle = 44;
- /**
-
This symbol is the offset where the {@link com.actionbarsherlock.R.attr#windowSplitActionBar}
- attribute's value can be found in the {@link #SherlockTheme} array.
-
-
-
Must be a boolean value, either "true" or "false".
-
Helper for implementing the action bar design pattern across all versions
- * of Android.
- *
- *
This class will manage interaction with a custom action bar based on the
- * Android 4.0 source code. The exposed API mirrors that of its native
- * counterpart and you should refer to its documentation for instruction.
- *
- * @author Jake Wharton
- */
-public abstract class ActionBarSherlock {
- protected static final String TAG = "ActionBarSherlock";
- protected static final boolean DEBUG = false;
-
- private static final Class>[] CONSTRUCTOR_ARGS = new Class[] { Activity.class, int.class };
- private static final HashMap> IMPLEMENTATIONS =
- new HashMap>();
-
- static {
- //Register our two built-in implementations
- registerImplementation(ActionBarSherlockCompat.class);
- registerImplementation(ActionBarSherlockNative.class);
- }
-
-
- /**
- *
Denotes an implementation of ActionBarSherlock which provides an
- * action bar-enhanced experience.
- */
- @Target(ElementType.TYPE)
- @Retention(RetentionPolicy.RUNTIME)
- public @interface Implementation {
- static final int DEFAULT_API = -1;
- static final int DEFAULT_DPI = -1;
-
- int api() default DEFAULT_API;
- int dpi() default DEFAULT_DPI;
- }
-
-
- /** Activity interface for menu creation callback. */
- public interface OnCreatePanelMenuListener {
- public boolean onCreatePanelMenu(int featureId, Menu menu);
- }
- /** Activity interface for menu creation callback. */
- public interface OnCreateOptionsMenuListener {
- public boolean onCreateOptionsMenu(Menu menu);
- }
- /** Activity interface for menu item selection callback. */
- public interface OnMenuItemSelectedListener {
- public boolean onMenuItemSelected(int featureId, MenuItem item);
- }
- /** Activity interface for menu item selection callback. */
- public interface OnOptionsItemSelectedListener {
- public boolean onOptionsItemSelected(MenuItem item);
- }
- /** Activity interface for menu preparation callback. */
- public interface OnPreparePanelListener {
- public boolean onPreparePanel(int featureId, View view, Menu menu);
- }
- /** Activity interface for menu preparation callback. */
- public interface OnPrepareOptionsMenuListener {
- public boolean onPrepareOptionsMenu(Menu menu);
- }
- /** Activity interface for action mode finished callback. */
- public interface OnActionModeFinishedListener {
- public void onActionModeFinished(ActionMode mode);
- }
- /** Activity interface for action mode started callback. */
- public interface OnActionModeStartedListener {
- public void onActionModeStarted(ActionMode mode);
- }
-
-
- /**
- * If set, the logic in these classes will assume that an {@link Activity}
- * is dispatching all of the required events to the class. This flag should
- * only be used internally or if you are creating your own base activity
- * modeled after one of the included types (e.g., {@code SherlockActivity}).
- */
- public static final int FLAG_DELEGATE = 1;
-
-
- /**
- * Register an ActionBarSherlock implementation.
- *
- * @param implementationClass Target implementation class which extends
- * {@link ActionBarSherlock}. This class must also be annotated with
- * {@link Implementation}.
- */
- public static void registerImplementation(Class extends ActionBarSherlock> implementationClass) {
- if (!implementationClass.isAnnotationPresent(Implementation.class)) {
- throw new IllegalArgumentException("Class " + implementationClass.getSimpleName() + " is not annotated with @Implementation");
- } else if (IMPLEMENTATIONS.containsValue(implementationClass)) {
- if (DEBUG) Log.w(TAG, "Class " + implementationClass.getSimpleName() + " already registered");
- return;
- }
-
- Implementation impl = implementationClass.getAnnotation(Implementation.class);
- if (DEBUG) Log.i(TAG, "Registering " + implementationClass.getSimpleName() + " with qualifier " + impl);
- IMPLEMENTATIONS.put(impl, implementationClass);
- }
-
- /**
- * Unregister an ActionBarSherlock implementation. This should be
- * considered very volatile and you should only use it if you know what
- * you are doing. You have been warned.
- *
- * @param implementationClass Target implementation class.
- * @return Boolean indicating whether the class was removed.
- */
- public static boolean unregisterImplementation(Class extends ActionBarSherlock> implementationClass) {
- return IMPLEMENTATIONS.values().remove(implementationClass);
- }
-
- /**
- * Wrap an activity with an action bar abstraction which will enable the
- * use of a custom implementation on platforms where a native version does
- * not exist.
- *
- * @param activity Activity to wrap.
- * @return Instance to interact with the action bar.
- */
- public static ActionBarSherlock wrap(Activity activity) {
- return wrap(activity, 0);
- }
-
- /**
- * Wrap an activity with an action bar abstraction which will enable the
- * use of a custom implementation on platforms where a native version does
- * not exist.
- *
- * @param activity Owning activity.
- * @param flags Option flags to control behavior.
- * @return Instance to interact with the action bar.
- */
- public static ActionBarSherlock wrap(Activity activity, int flags) {
- //Create a local implementation map we can modify
- HashMap> impls =
- new HashMap>(IMPLEMENTATIONS);
- boolean hasQualfier;
-
- /* DPI FILTERING */
- hasQualfier = false;
- for (Implementation key : impls.keySet()) {
- //Only honor TVDPI as a specific qualifier
- if (key.dpi() == DisplayMetrics.DENSITY_TV) {
- hasQualfier = true;
- break;
- }
- }
- if (hasQualfier) {
- final boolean isTvDpi = activity.getResources().getDisplayMetrics().densityDpi == DisplayMetrics.DENSITY_TV;
- for (Iterator keys = impls.keySet().iterator(); keys.hasNext(); ) {
- int keyDpi = keys.next().dpi();
- if ((isTvDpi && keyDpi != DisplayMetrics.DENSITY_TV)
- || (!isTvDpi && keyDpi == DisplayMetrics.DENSITY_TV)) {
- keys.remove();
- }
- }
- }
-
- /* API FILTERING */
- hasQualfier = false;
- for (Implementation key : impls.keySet()) {
- if (key.api() != Implementation.DEFAULT_API) {
- hasQualfier = true;
- break;
- }
- }
- if (hasQualfier) {
- final int runtimeApi = Build.VERSION.SDK_INT;
- int bestApi = 0;
- for (Iterator keys = impls.keySet().iterator(); keys.hasNext(); ) {
- int keyApi = keys.next().api();
- if (keyApi > runtimeApi) {
- keys.remove();
- } else if (keyApi > bestApi) {
- bestApi = keyApi;
- }
- }
- for (Iterator keys = impls.keySet().iterator(); keys.hasNext(); ) {
- if (keys.next().api() != bestApi) {
- keys.remove();
- }
- }
- }
-
- if (impls.size() > 1) {
- throw new IllegalStateException("More than one implementation matches configuration.");
- }
- if (impls.isEmpty()) {
- throw new IllegalStateException("No implementations match configuration.");
- }
- Class extends ActionBarSherlock> impl = impls.values().iterator().next();
- if (DEBUG) Log.i(TAG, "Using implementation: " + impl.getSimpleName());
-
- try {
- Constructor extends ActionBarSherlock> ctor = impl.getConstructor(CONSTRUCTOR_ARGS);
- return ctor.newInstance(activity, flags);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (IllegalArgumentException e) {
- throw new RuntimeException(e);
- } catch (InstantiationException e) {
- throw new RuntimeException(e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- } catch (InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
-
- /** Activity which is displaying the action bar. Also used for context. */
- protected final Activity mActivity;
- /** Whether delegating actions for the activity or managing ourselves. */
- protected final boolean mIsDelegate;
-
- /** Reference to our custom menu inflater which supports action items. */
- protected MenuInflater mMenuInflater;
-
-
-
- protected ActionBarSherlock(Activity activity, int flags) {
- if (DEBUG) Log.d(TAG, "[] activity: " + activity + ", flags: " + flags);
-
- mActivity = activity;
- mIsDelegate = (flags & FLAG_DELEGATE) != 0;
- }
-
-
- /**
- * Get the current action bar instance.
- *
- * @return Action bar instance.
- */
- public abstract ActionBar getActionBar();
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Lifecycle and interaction callbacks when delegating
- ///////////////////////////////////////////////////////////////////////////
-
- /**
- * Notify action bar of a configuration change event. Should be dispatched
- * after the call to the superclass implementation.
- *
- *
- *
- * @param newConfig The new device configuration.
- */
- public void dispatchConfigurationChanged(Configuration newConfig) {}
-
- /**
- * Notify the action bar that the activity has finished its resuming. This
- * should be dispatched after the call to the superclass implementation.
- *
- *
- */
- public void dispatchPostResume() {}
-
- /**
- * Notify the action bar that the activity is pausing. This should be
- * dispatched before the call to the superclass implementation.
- *
- *
- */
- public void dispatchPause() {}
-
- /**
- * Notify the action bar that the activity is stopping. This should be
- * called before the superclass implementation.
- *
- *
- */
- public void dispatchStop() {}
-
- /**
- * Indicate that the menu should be recreated by calling
- * {@link OnCreateOptionsMenuListener#onCreateOptionsMenu(com.actionbarsherlock.view.Menu)}.
- */
- public abstract void dispatchInvalidateOptionsMenu();
-
- /**
- * Notify the action bar that it should display its overflow menu if it is
- * appropriate for the device. The implementation should conditionally
- * call the superclass method only if this method returns {@code false}.
- *
- *
- *
- * @return {@code true} if the opening of the menu was handled internally.
- */
- public boolean dispatchOpenOptionsMenu() {
- return false;
- }
-
- /**
- * Notify the action bar that it should close its overflow menu if it is
- * appropriate for the device. This implementation should conditionally
- * call the superclass method only if this method returns {@code false}.
- *
- *
- *
- * @return {@code true} if the closing of the menu was handled internally.
- */
- public boolean dispatchCloseOptionsMenu() {
- return false;
- }
-
- /**
- * Notify the class that the activity has finished its creation. This
- * should be called after the superclass implementation.
- *
- *
- *
- * @param savedInstanceState If the activity is being re-initialized after
- * previously being shut down then this Bundle
- * contains the data it most recently supplied in
- * {@link Activity#}onSaveInstanceState(Bundle)}.
- * Note: Otherwise it is null.
- */
- public void dispatchPostCreate(Bundle savedInstanceState) {}
-
- /**
- * Notify the action bar that the title has changed and the action bar
- * should be updated to reflect the change. This should be called before
- * the superclass implementation.
- *
- *
- *
- * @param title New activity title.
- * @param color New activity color.
- */
- public void dispatchTitleChanged(CharSequence title, int color) {}
-
- /**
- * Notify the action bar the user has created a key event. This is used to
- * toggle the display of the overflow action item with the menu key and to
- * close the action mode or expanded action item with the back key.
- *
- *
- *
- * @param event Description of the key event.
- * @return {@code true} if the event was handled.
- */
- public boolean dispatchKeyEvent(KeyEvent event) {
- return false;
- }
-
- /**
- * Notify the action bar that the Activity has triggered a menu creation
- * which should happen on the conclusion of {@link Activity#onCreate}. This
- * will be used to gain a reference to the native menu for native and
- * overflow binding as well as to indicate when compatibility create should
- * occur for the first time.
- *
- * @param menu Activity native menu.
- * @return {@code true} since we always want to say that we have a native
- */
- public abstract boolean dispatchCreateOptionsMenu(android.view.Menu menu);
-
- /**
- * Notify the action bar that the Activity has triggered a menu preparation
- * which usually means that the user has requested the overflow menu via a
- * hardware menu key. You should return the result of this method call and
- * not call the superclass implementation.
- *
- *
- * @Override
- * public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
- * return mSherlock.dispatchPrepareOptionsMenu(menu);
- * }
- *
- *
- * @param menu Activity native menu.
- * @return {@code true} if menu display should proceed.
- */
- public abstract boolean dispatchPrepareOptionsMenu(android.view.Menu menu);
-
- /**
- * Notify the action bar that a native options menu item has been selected.
- * The implementation should return the result of this method call.
- *
- *
- * @Override
- * public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- * return mSherlock.dispatchOptionsItemSelected(item);
- * }
- *
- *
- * @param item Options menu item.
- * @return @{code true} if the selection was handled.
- */
- public abstract boolean dispatchOptionsItemSelected(android.view.MenuItem item);
-
- /**
- * Notify the action bar that the overflow menu has been opened. The
- * implementation should conditionally return {@code true} if this method
- * returns {@code true}, otherwise return the result of the superclass
- * method.
- *
- *
- *
- * @param featureId Window feature which triggered the event.
- * @param menu Activity native menu.
- * @return {@code true} if the event was handled by this method.
- */
- public boolean dispatchMenuOpened(int featureId, android.view.Menu menu) {
- return false;
- }
-
- /**
- * Notify the action bar that the overflow menu has been closed. This
- * method should be called before the superclass implementation.
- *
- *
- *
- * @param featureId
- * @param menu
- */
- public void dispatchPanelClosed(int featureId, android.view.Menu menu) {}
-
- /**
- * Notify the action bar that the activity has been destroyed. This method
- * should be called before the superclass implementation.
- *
- *
- */
- public void dispatchDestroy() {}
-
-
- ///////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////
-
-
- /**
- * Internal method to trigger the menu creation process.
- *
- * @return {@code true} if menu creation should proceed.
- */
- protected final boolean callbackCreateOptionsMenu(Menu menu) {
- if (DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] menu: " + menu);
-
- boolean result = true;
- if (mActivity instanceof OnCreatePanelMenuListener) {
- OnCreatePanelMenuListener listener = (OnCreatePanelMenuListener)mActivity;
- result = listener.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, menu);
- } else if (mActivity instanceof OnCreateOptionsMenuListener) {
- OnCreateOptionsMenuListener listener = (OnCreateOptionsMenuListener)mActivity;
- result = listener.onCreateOptionsMenu(menu);
- }
-
- if (DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] returning " + result);
- return result;
- }
-
- /**
- * Internal method to trigger the menu preparation process.
- *
- * @return {@code true} if menu preparation should proceed.
- */
- protected final boolean callbackPrepareOptionsMenu(Menu menu) {
- if (DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] menu: " + menu);
-
- boolean result = true;
- if (mActivity instanceof OnPreparePanelListener) {
- OnPreparePanelListener listener = (OnPreparePanelListener)mActivity;
- result = listener.onPreparePanel(Window.FEATURE_OPTIONS_PANEL, null, menu);
- } else if (mActivity instanceof OnPrepareOptionsMenuListener) {
- OnPrepareOptionsMenuListener listener = (OnPrepareOptionsMenuListener)mActivity;
- result = listener.onPrepareOptionsMenu(menu);
- }
-
- if (DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] returning " + result);
- return result;
- }
-
- /**
- * Internal method for dispatching options menu selection to the owning
- * activity callback.
- *
- * @param item Selected options menu item.
- * @return {@code true} if the item selection was handled in the callback.
- */
- protected final boolean callbackOptionsItemSelected(MenuItem item) {
- if (DEBUG) Log.d(TAG, "[callbackOptionsItemSelected] item: " + item.getTitleCondensed());
-
- boolean result = false;
- if (mActivity instanceof OnMenuItemSelectedListener) {
- OnMenuItemSelectedListener listener = (OnMenuItemSelectedListener)mActivity;
- result = listener.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
- } else if (mActivity instanceof OnOptionsItemSelectedListener) {
- OnOptionsItemSelectedListener listener = (OnOptionsItemSelectedListener)mActivity;
- result = listener.onOptionsItemSelected(item);
- }
-
- if (DEBUG) Log.d(TAG, "[callbackOptionsItemSelected] returning " + result);
- return result;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////
-
-
- /**
- * Query for the availability of a certain feature.
- *
- * @param featureId The feature ID to check.
- * @return {@code true} if feature is enabled, {@code false} otherwise.
- */
- public abstract boolean hasFeature(int featureId);
-
- /**
- * Enable extended screen features. This must be called before
- * {@code setContentView()}. May be called as many times as desired as long
- * as it is before {@code setContentView()}. If not called, no extended
- * features will be available. You can not turn off a feature once it is
- * requested.
- *
- * @param featureId The desired features, defined as constants by Window.
- * @return Returns true if the requested feature is supported and now
- * enabled.
- */
- public abstract boolean requestFeature(int featureId);
-
- /**
- * Set extra options that will influence the UI for this window.
- *
- * @param uiOptions Flags specifying extra options for this window.
- */
- public abstract void setUiOptions(int uiOptions);
-
- /**
- * Set extra options that will influence the UI for this window. Only the
- * bits filtered by mask will be modified.
- *
- * @param uiOptions Flags specifying extra options for this window.
- * @param mask Flags specifying which options should be modified. Others
- * will remain unchanged.
- */
- public abstract void setUiOptions(int uiOptions, int mask);
-
- /**
- * Set the content of the activity inside the action bar.
- *
- * @param layoutResId Layout resource ID.
- */
- public abstract void setContentView(int layoutResId);
-
- /**
- * Set the content of the activity inside the action bar.
- *
- * @param view The desired content to display.
- */
- public void setContentView(View view) {
- if (DEBUG) Log.d(TAG, "[setContentView] view: " + view);
-
- setContentView(view, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
- }
-
- /**
- * Set the content of the activity inside the action bar.
- *
- * @param view The desired content to display.
- * @param params Layout parameters to apply to the view.
- */
- public abstract void setContentView(View view, ViewGroup.LayoutParams params);
-
- /**
- * Variation on {@link #setContentView(android.view.View, android.view.ViewGroup.LayoutParams)}
- * to add an additional content view to the screen. Added after any
- * existing ones on the screen -- existing views are NOT removed.
- *
- * @param view The desired content to display.
- * @param params Layout parameters for the view.
- */
- public abstract void addContentView(View view, ViewGroup.LayoutParams params);
-
- /**
- * Change the title associated with this activity.
- */
- public abstract void setTitle(CharSequence title);
-
- /**
- * Change the title associated with this activity.
- */
- public void setTitle(int resId) {
- if (DEBUG) Log.d(TAG, "[setTitle] resId: " + resId);
-
- setTitle(mActivity.getString(resId));
- }
-
- /**
- * Sets the visibility of the progress bar in the title.
- *
- * In order for the progress bar to be shown, the feature must be requested
- * via {@link #requestWindowFeature(int)}.
- *
- * @param visible Whether to show the progress bars in the title.
- */
- public abstract void setProgressBarVisibility(boolean visible);
-
- /**
- * Sets the visibility of the indeterminate progress bar in the title.
- *
- * In order for the progress bar to be shown, the feature must be requested
- * via {@link #requestWindowFeature(int)}.
- *
- * @param visible Whether to show the progress bars in the title.
- */
- public abstract void setProgressBarIndeterminateVisibility(boolean visible);
-
- /**
- * Sets whether the horizontal progress bar in the title should be indeterminate (the circular
- * is always indeterminate).
- *
- * In order for the progress bar to be shown, the feature must be requested
- * via {@link #requestWindowFeature(int)}.
- *
- * @param indeterminate Whether the horizontal progress bar should be indeterminate.
- */
- public abstract void setProgressBarIndeterminate(boolean indeterminate);
-
- /**
- * Sets the progress for the progress bars in the title.
- *
- * In order for the progress bar to be shown, the feature must be requested
- * via {@link #requestWindowFeature(int)}.
- *
- * @param progress The progress for the progress bar. Valid ranges are from
- * 0 to 10000 (both inclusive). If 10000 is given, the progress
- * bar will be completely filled and will fade out.
- */
- public abstract void setProgress(int progress);
-
- /**
- * Sets the secondary progress for the progress bar in the title. This
- * progress is drawn between the primary progress (set via
- * {@link #setProgress(int)} and the background. It can be ideal for media
- * scenarios such as showing the buffering progress while the default
- * progress shows the play progress.
- *
- * In order for the progress bar to be shown, the feature must be requested
- * via {@link #requestWindowFeature(int)}.
- *
- * @param secondaryProgress The secondary progress for the progress bar. Valid ranges are from
- * 0 to 10000 (both inclusive).
- */
- public abstract void setSecondaryProgress(int secondaryProgress);
-
- /**
- * Get a menu inflater instance which supports the newer menu attributes.
- *
- * @return Menu inflater instance.
- */
- public MenuInflater getMenuInflater() {
- if (DEBUG) Log.d(TAG, "[getMenuInflater]");
-
- // Make sure that action views can get an appropriate theme.
- if (mMenuInflater == null) {
- if (getActionBar() != null) {
- mMenuInflater = new MenuInflater(getThemedContext());
- } else {
- mMenuInflater = new MenuInflater(mActivity);
- }
- }
- return mMenuInflater;
- }
-
- protected abstract Context getThemedContext();
-
- /**
- * Start an action mode.
- *
- * @param callback Callback that will manage lifecycle events for this
- * context mode.
- * @return The ContextMode that was started, or null if it was canceled.
- * @see ActionMode
- */
- public abstract ActionMode startActionMode(ActionMode.Callback callback);
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/ActionBar.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/ActionBar.java
deleted file mode 100644
index 2497d24ff0..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/ActionBar.java
+++ /dev/null
@@ -1,947 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.app;
-
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.support.v4.app.FragmentTransaction;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewDebug;
-import android.view.ViewGroup;
-import android.view.ViewGroup.MarginLayoutParams;
-import android.widget.SpinnerAdapter;
-
-/**
- * A window feature at the top of the activity that may display the activity title, navigation
- * modes, and other interactive items.
- *
Beginning with Android 3.0 (API level 11), the action bar appears at the top of an
- * activity's window when the activity uses the system's {@link
- * android.R.style#Theme_Holo Holo} theme (or one of its descendant themes), which is the default.
- * You may otherwise add the action bar by calling {@link
- * android.view.Window#requestFeature requestFeature(FEATURE_ACTION_BAR)} or by declaring it in a
- * custom theme with the {@link android.R.styleable#Theme_windowActionBar windowActionBar} property.
- *
By default, the action bar shows the application icon on
- * the left, followed by the activity title. If your activity has an options menu, you can make
- * select items accessible directly from the action bar as "action items". You can also
- * modify various characteristics of the action bar or remove it completely.
- *
From your activity, you can retrieve an instance of {@link ActionBar} by calling {@link
- * android.app.Activity#getActionBar getActionBar()}.
- *
In some cases, the action bar may be overlayed by another bar that enables contextual actions,
- * using an {@link android.view.ActionMode}. For example, when the user selects one or more items in
- * your activity, you can enable an action mode that offers actions specific to the selected
- * items, with a UI that temporarily replaces the action bar. Although the UI may occupy the
- * same space, the {@link android.view.ActionMode} APIs are distinct and independent from those for
- * {@link ActionBar}.
- *
- *
Developer Guides
- *
For information about how to use the action bar, including how to add action items, navigation
- * modes and more, read the Action
- * Bar developer guide.
- *
- */
-public abstract class ActionBar {
- /**
- * Standard navigation mode. Consists of either a logo or icon
- * and title text with an optional subtitle. Clicking any of these elements
- * will dispatch onOptionsItemSelected to the host Activity with
- * a MenuItem with item ID android.R.id.home.
- */
- public static final int NAVIGATION_MODE_STANDARD = android.app.ActionBar.NAVIGATION_MODE_STANDARD;
-
- /**
- * List navigation mode. Instead of static title text this mode
- * presents a list menu for navigation within the activity.
- * e.g. this might be presented to the user as a dropdown list.
- */
- public static final int NAVIGATION_MODE_LIST = android.app.ActionBar.NAVIGATION_MODE_LIST;
-
- /**
- * Tab navigation mode. Instead of static title text this mode
- * presents a series of tabs for navigation within the activity.
- */
- public static final int NAVIGATION_MODE_TABS = android.app.ActionBar.NAVIGATION_MODE_TABS;
-
- /**
- * Use logo instead of icon if available. This flag will cause appropriate
- * navigation modes to use a wider logo in place of the standard icon.
- *
- * @see #setDisplayOptions(int)
- * @see #setDisplayOptions(int, int)
- */
- public static final int DISPLAY_USE_LOGO = android.app.ActionBar.DISPLAY_USE_LOGO;
-
- /**
- * Show 'home' elements in this action bar, leaving more space for other
- * navigation elements. This includes logo and icon.
- *
- * @see #setDisplayOptions(int)
- * @see #setDisplayOptions(int, int)
- */
- public static final int DISPLAY_SHOW_HOME = android.app.ActionBar.DISPLAY_SHOW_HOME;
-
- /**
- * Display the 'home' element such that it appears as an 'up' affordance.
- * e.g. show an arrow to the left indicating the action that will be taken.
- *
- * Set this flag if selecting the 'home' button in the action bar to return
- * up by a single level in your UI rather than back to the top level or front page.
- *
- *
Setting this option will implicitly enable interaction with the home/up
- * button. See {@link #setHomeButtonEnabled(boolean)}.
- *
- * @see #setDisplayOptions(int)
- * @see #setDisplayOptions(int, int)
- */
- public static final int DISPLAY_HOME_AS_UP = android.app.ActionBar.DISPLAY_HOME_AS_UP;
-
- /**
- * Show the activity title and subtitle, if present.
- *
- * @see #setTitle(CharSequence)
- * @see #setTitle(int)
- * @see #setSubtitle(CharSequence)
- * @see #setSubtitle(int)
- * @see #setDisplayOptions(int)
- * @see #setDisplayOptions(int, int)
- */
- public static final int DISPLAY_SHOW_TITLE = android.app.ActionBar.DISPLAY_SHOW_TITLE;
-
- /**
- * Show the custom view if one has been set.
- * @see #setCustomView(View)
- * @see #setDisplayOptions(int)
- * @see #setDisplayOptions(int, int)
- */
- public static final int DISPLAY_SHOW_CUSTOM = android.app.ActionBar.DISPLAY_SHOW_CUSTOM;
-
- /**
- * Set the action bar into custom navigation mode, supplying a view
- * for custom navigation.
- *
- * Custom navigation views appear between the application icon and
- * any action buttons and may use any space available there. Common
- * use cases for custom navigation views might include an auto-suggesting
- * address bar for a browser or other navigation mechanisms that do not
- * translate well to provided navigation modes.
- *
- * @param view Custom navigation view to place in the ActionBar.
- */
- public abstract void setCustomView(View view);
-
- /**
- * Set the action bar into custom navigation mode, supplying a view
- * for custom navigation.
- *
- *
Custom navigation views appear between the application icon and
- * any action buttons and may use any space available there. Common
- * use cases for custom navigation views might include an auto-suggesting
- * address bar for a browser or other navigation mechanisms that do not
- * translate well to provided navigation modes.
- *
- *
The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
- * the custom view to be displayed.
- *
- * @param view Custom navigation view to place in the ActionBar.
- * @param layoutParams How this custom view should layout in the bar.
- *
- * @see #setDisplayOptions(int, int)
- */
- public abstract void setCustomView(View view, LayoutParams layoutParams);
-
- /**
- * Set the action bar into custom navigation mode, supplying a view
- * for custom navigation.
- *
- *
Custom navigation views appear between the application icon and
- * any action buttons and may use any space available there. Common
- * use cases for custom navigation views might include an auto-suggesting
- * address bar for a browser or other navigation mechanisms that do not
- * translate well to provided navigation modes.
- *
- *
The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
- * the custom view to be displayed.
- *
- * @param resId Resource ID of a layout to inflate into the ActionBar.
- *
- * @see #setDisplayOptions(int, int)
- */
- public abstract void setCustomView(int resId);
-
- /**
- * Set the icon to display in the 'home' section of the action bar.
- * The action bar will use an icon specified by its style or the
- * activity icon by default.
- *
- * Whether the home section shows an icon or logo is controlled
- * by the display option {@link #DISPLAY_USE_LOGO}.
- *
- * @param resId Resource ID of a drawable to show as an icon.
- *
- * @see #setDisplayUseLogoEnabled(boolean)
- * @see #setDisplayShowHomeEnabled(boolean)
- */
- public abstract void setIcon(int resId);
-
- /**
- * Set the icon to display in the 'home' section of the action bar.
- * The action bar will use an icon specified by its style or the
- * activity icon by default.
- *
- * Whether the home section shows an icon or logo is controlled
- * by the display option {@link #DISPLAY_USE_LOGO}.
- *
- * @param icon Drawable to show as an icon.
- *
- * @see #setDisplayUseLogoEnabled(boolean)
- * @see #setDisplayShowHomeEnabled(boolean)
- */
- public abstract void setIcon(Drawable icon);
-
- /**
- * Set the logo to display in the 'home' section of the action bar.
- * The action bar will use a logo specified by its style or the
- * activity logo by default.
- *
- * Whether the home section shows an icon or logo is controlled
- * by the display option {@link #DISPLAY_USE_LOGO}.
- *
- * @param resId Resource ID of a drawable to show as a logo.
- *
- * @see #setDisplayUseLogoEnabled(boolean)
- * @see #setDisplayShowHomeEnabled(boolean)
- */
- public abstract void setLogo(int resId);
-
- /**
- * Set the logo to display in the 'home' section of the action bar.
- * The action bar will use a logo specified by its style or the
- * activity logo by default.
- *
- * Whether the home section shows an icon or logo is controlled
- * by the display option {@link #DISPLAY_USE_LOGO}.
- *
- * @param logo Drawable to show as a logo.
- *
- * @see #setDisplayUseLogoEnabled(boolean)
- * @see #setDisplayShowHomeEnabled(boolean)
- */
- public abstract void setLogo(Drawable logo);
-
- /**
- * Set the adapter and navigation callback for list navigation mode.
- *
- * The supplied adapter will provide views for the expanded list as well as
- * the currently selected item. (These may be displayed differently.)
- *
- * The supplied OnNavigationListener will alert the application when the user
- * changes the current list selection.
- *
- * @param adapter An adapter that will provide views both to display
- * the current navigation selection and populate views
- * within the dropdown navigation menu.
- * @param callback An OnNavigationListener that will receive events when the user
- * selects a navigation item.
- */
- public abstract void setListNavigationCallbacks(SpinnerAdapter adapter,
- OnNavigationListener callback);
-
- /**
- * Set the selected navigation item in list or tabbed navigation modes.
- *
- * @param position Position of the item to select.
- */
- public abstract void setSelectedNavigationItem(int position);
-
- /**
- * Get the position of the selected navigation item in list or tabbed navigation modes.
- *
- * @return Position of the selected item.
- */
- public abstract int getSelectedNavigationIndex();
-
- /**
- * Get the number of navigation items present in the current navigation mode.
- *
- * @return Number of navigation items.
- */
- public abstract int getNavigationItemCount();
-
- /**
- * Set the action bar's title. This will only be displayed if
- * {@link #DISPLAY_SHOW_TITLE} is set.
- *
- * @param title Title to set
- *
- * @see #setTitle(int)
- * @see #setDisplayOptions(int, int)
- */
- public abstract void setTitle(CharSequence title);
-
- /**
- * Set the action bar's title. This will only be displayed if
- * {@link #DISPLAY_SHOW_TITLE} is set.
- *
- * @param resId Resource ID of title string to set
- *
- * @see #setTitle(CharSequence)
- * @see #setDisplayOptions(int, int)
- */
- public abstract void setTitle(int resId);
-
- /**
- * Set the action bar's subtitle. This will only be displayed if
- * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the
- * subtitle entirely.
- *
- * @param subtitle Subtitle to set
- *
- * @see #setSubtitle(int)
- * @see #setDisplayOptions(int, int)
- */
- public abstract void setSubtitle(CharSequence subtitle);
-
- /**
- * Set the action bar's subtitle. This will only be displayed if
- * {@link #DISPLAY_SHOW_TITLE} is set.
- *
- * @param resId Resource ID of subtitle string to set
- *
- * @see #setSubtitle(CharSequence)
- * @see #setDisplayOptions(int, int)
- */
- public abstract void setSubtitle(int resId);
-
- /**
- * Set display options. This changes all display option bits at once. To change
- * a limited subset of display options, see {@link #setDisplayOptions(int, int)}.
- *
- * @param options A combination of the bits defined by the DISPLAY_ constants
- * defined in ActionBar.
- */
- public abstract void setDisplayOptions(int options);
-
- /**
- * Set selected display options. Only the options specified by mask will be changed.
- * To change all display option bits at once, see {@link #setDisplayOptions(int)}.
- *
- *
Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the
- * {@link #DISPLAY_SHOW_HOME} option.
- * setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO)
- * will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}.
- *
- * @param options A combination of the bits defined by the DISPLAY_ constants
- * defined in ActionBar.
- * @param mask A bit mask declaring which display options should be changed.
- */
- public abstract void setDisplayOptions(int options, int mask);
-
- /**
- * Set whether to display the activity logo rather than the activity icon.
- * A logo is often a wider, more detailed image.
- *
- *
To set several display options at once, see the setDisplayOptions methods.
- *
- * @param useLogo true to use the activity logo, false to use the activity icon.
- *
- * @see #setDisplayOptions(int)
- * @see #setDisplayOptions(int, int)
- */
- public abstract void setDisplayUseLogoEnabled(boolean useLogo);
-
- /**
- * Set whether to include the application home affordance in the action bar.
- * Home is presented as either an activity icon or logo.
- *
- *
To set several display options at once, see the setDisplayOptions methods.
- *
- * @param showHome true to show home, false otherwise.
- *
- * @see #setDisplayOptions(int)
- * @see #setDisplayOptions(int, int)
- */
- public abstract void setDisplayShowHomeEnabled(boolean showHome);
-
- /**
- * Set whether home should be displayed as an "up" affordance.
- * Set this to true if selecting "home" returns up by a single level in your UI
- * rather than back to the top level or front page.
- *
- *
To set several display options at once, see the setDisplayOptions methods.
- *
- * @param showHomeAsUp true to show the user that selecting home will return one
- * level up rather than to the top level of the app.
- *
- * @see #setDisplayOptions(int)
- * @see #setDisplayOptions(int, int)
- */
- public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);
-
- /**
- * Set whether an activity title/subtitle should be displayed.
- *
- *
To set several display options at once, see the setDisplayOptions methods.
- *
- * @param showTitle true to display a title/subtitle if present.
- *
- * @see #setDisplayOptions(int)
- * @see #setDisplayOptions(int, int)
- */
- public abstract void setDisplayShowTitleEnabled(boolean showTitle);
-
- /**
- * Set whether a custom view should be displayed, if set.
- *
- *
To set several display options at once, see the setDisplayOptions methods.
- *
- * @param showCustom true if the currently set custom view should be displayed, false otherwise.
- *
- * @see #setDisplayOptions(int)
- * @see #setDisplayOptions(int, int)
- */
- public abstract void setDisplayShowCustomEnabled(boolean showCustom);
-
- /**
- * Set the ActionBar's background. This will be used for the primary
- * action bar.
- *
- * @param d Background drawable
- * @see #setStackedBackgroundDrawable(Drawable)
- * @see #setSplitBackgroundDrawable(Drawable)
- */
- public abstract void setBackgroundDrawable(Drawable d);
-
- /**
- * Set the ActionBar's stacked background. This will appear
- * in the second row/stacked bar on some devices and configurations.
- *
- * @param d Background drawable for the stacked row
- */
- public void setStackedBackgroundDrawable(Drawable d) { }
-
- /**
- * Set the ActionBar's split background. This will appear in
- * the split action bar containing menu-provided action buttons
- * on some devices and configurations.
- *
You can enable split action bar with {@link android.R.attr#uiOptions}
- *
- * @param d Background drawable for the split bar
- */
- public void setSplitBackgroundDrawable(Drawable d) { }
-
- /**
- * @return The current custom view.
- */
- public abstract View getCustomView();
-
- /**
- * Returns the current ActionBar title in standard mode.
- * Returns null if {@link #getNavigationMode()} would not return
- * {@link #NAVIGATION_MODE_STANDARD}.
- *
- * @return The current ActionBar title or null.
- */
- public abstract CharSequence getTitle();
-
- /**
- * Returns the current ActionBar subtitle in standard mode.
- * Returns null if {@link #getNavigationMode()} would not return
- * {@link #NAVIGATION_MODE_STANDARD}.
- *
- * @return The current ActionBar subtitle or null.
- */
- public abstract CharSequence getSubtitle();
-
- /**
- * Returns the current navigation mode. The result will be one of:
- *
- *
{@link #NAVIGATION_MODE_STANDARD}
- *
{@link #NAVIGATION_MODE_LIST}
- *
{@link #NAVIGATION_MODE_TABS}
- *
- *
- * @return The current navigation mode.
- */
- public abstract int getNavigationMode();
-
- /**
- * Set the current navigation mode.
- *
- * @param mode The new mode to set.
- * @see #NAVIGATION_MODE_STANDARD
- * @see #NAVIGATION_MODE_LIST
- * @see #NAVIGATION_MODE_TABS
- */
- public abstract void setNavigationMode(int mode);
-
- /**
- * @return The current set of display options.
- */
- public abstract int getDisplayOptions();
-
- /**
- * Create and return a new {@link Tab}.
- * This tab will not be included in the action bar until it is added.
- *
- *
Very often tabs will be used to switch between {@link Fragment}
- * objects. Here is a typical implementation of such tabs:
- *
- * {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java
- * complete}
- *
- * @return A new Tab
- *
- * @see #addTab(Tab)
- */
- public abstract Tab newTab();
-
- /**
- * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.
- * If this is the first tab to be added it will become the selected tab.
- *
- * @param tab Tab to add
- */
- public abstract void addTab(Tab tab);
-
- /**
- * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.
- *
- * @param tab Tab to add
- * @param setSelected True if the added tab should become the selected tab.
- */
- public abstract void addTab(Tab tab, boolean setSelected);
-
- /**
- * Add a tab for use in tabbed navigation mode. The tab will be inserted at
- * position. If this is the first tab to be added it will become
- * the selected tab.
- *
- * @param tab The tab to add
- * @param position The new position of the tab
- */
- public abstract void addTab(Tab tab, int position);
-
- /**
- * Add a tab for use in tabbed navigation mode. The tab will be insterted at
- * position.
- *
- * @param tab The tab to add
- * @param position The new position of the tab
- * @param setSelected True if the added tab should become the selected tab.
- */
- public abstract void addTab(Tab tab, int position, boolean setSelected);
-
- /**
- * Remove a tab from the action bar. If the removed tab was selected it will be deselected
- * and another tab will be selected if present.
- *
- * @param tab The tab to remove
- */
- public abstract void removeTab(Tab tab);
-
- /**
- * Remove a tab from the action bar. If the removed tab was selected it will be deselected
- * and another tab will be selected if present.
- *
- * @param position Position of the tab to remove
- */
- public abstract void removeTabAt(int position);
-
- /**
- * Remove all tabs from the action bar and deselect the current tab.
- */
- public abstract void removeAllTabs();
-
- /**
- * Select the specified tab. If it is not a child of this action bar it will be added.
- *
- *
Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.
- *
- * @param tab Tab to select
- */
- public abstract void selectTab(Tab tab);
-
- /**
- * Returns the currently selected tab if in tabbed navigation mode and there is at least
- * one tab present.
- *
- * @return The currently selected tab or null
- */
- public abstract Tab getSelectedTab();
-
- /**
- * Returns the tab at the specified index.
- *
- * @param index Index value in the range 0-get
- * @return
- */
- public abstract Tab getTabAt(int index);
-
- /**
- * Returns the number of tabs currently registered with the action bar.
- * @return Tab count
- */
- public abstract int getTabCount();
-
- /**
- * Retrieve the current height of the ActionBar.
- *
- * @return The ActionBar's height
- */
- public abstract int getHeight();
-
- /**
- * Show the ActionBar if it is not currently showing.
- * If the window hosting the ActionBar does not have the feature
- * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
- * content to fit the new space available.
- */
- public abstract void show();
-
- /**
- * Hide the ActionBar if it is currently showing.
- * If the window hosting the ActionBar does not have the feature
- * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
- * content to fit the new space available.
- */
- public abstract void hide();
-
- /**
- * @return true if the ActionBar is showing, false otherwise.
- */
- public abstract boolean isShowing();
-
- /**
- * Add a listener that will respond to menu visibility change events.
- *
- * @param listener The new listener to add
- */
- public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener);
-
- /**
- * Remove a menu visibility listener. This listener will no longer receive menu
- * visibility change events.
- *
- * @param listener A listener to remove that was previously added
- */
- public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener);
-
- /**
- * Enable or disable the "home" button in the corner of the action bar. (Note that this
- * is the application home/up affordance on the action bar, not the systemwide home
- * button.)
- *
- *
This defaults to true for packages targeting < API 14. For packages targeting
- * API 14 or greater, the application should call this method to enable interaction
- * with the home/up affordance.
- *
- *
Setting the {@link #DISPLAY_HOME_AS_UP} display option will automatically enable
- * the home button.
- *
- * @param enabled true to enable the home button, false to disable the home button.
- */
- public void setHomeButtonEnabled(boolean enabled) { }
-
- /**
- * Returns a {@link Context} with an appropriate theme for creating views that
- * will appear in the action bar. If you are inflating or instantiating custom views
- * that will appear in an action bar, you should use the Context returned by this method.
- * (This includes adapters used for list navigation mode.)
- * This will ensure that views contrast properly against the action bar.
- *
- * @return A themed Context for creating views
- */
- public Context getThemedContext() { return null; }
-
- /**
- * Listener interface for ActionBar navigation events.
- */
- public interface OnNavigationListener {
- /**
- * This method is called whenever a navigation item in your action bar
- * is selected.
- *
- * @param itemPosition Position of the item clicked.
- * @param itemId ID of the item clicked.
- * @return True if the event was handled, false otherwise.
- */
- public boolean onNavigationItemSelected(int itemPosition, long itemId);
- }
-
- /**
- * Listener for receiving events when action bar menus are shown or hidden.
- */
- public interface OnMenuVisibilityListener {
- /**
- * Called when an action bar menu is shown or hidden. Applications may want to use
- * this to tune auto-hiding behavior for the action bar or pause/resume video playback,
- * gameplay, or other activity within the main content area.
- *
- * @param isVisible True if an action bar menu is now visible, false if no action bar
- * menus are visible.
- */
- public void onMenuVisibilityChanged(boolean isVisible);
- }
-
- /**
- * A tab in the action bar.
- *
- *
Tabs manage the hiding and showing of {@link Fragment}s.
- */
- public static abstract class Tab {
- /**
- * An invalid position for a tab.
- *
- * @see #getPosition()
- */
- public static final int INVALID_POSITION = -1;
-
- /**
- * Return the current position of this tab in the action bar.
- *
- * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in
- * the action bar.
- */
- public abstract int getPosition();
-
- /**
- * Return the icon associated with this tab.
- *
- * @return The tab's icon
- */
- public abstract Drawable getIcon();
-
- /**
- * Return the text of this tab.
- *
- * @return The tab's text
- */
- public abstract CharSequence getText();
-
- /**
- * Set the icon displayed on this tab.
- *
- * @param icon The drawable to use as an icon
- * @return The current instance for call chaining
- */
- public abstract Tab setIcon(Drawable icon);
-
- /**
- * Set the icon displayed on this tab.
- *
- * @param resId Resource ID referring to the drawable to use as an icon
- * @return The current instance for call chaining
- */
- public abstract Tab setIcon(int resId);
-
- /**
- * Set the text displayed on this tab. Text may be truncated if there is not
- * room to display the entire string.
- *
- * @param text The text to display
- * @return The current instance for call chaining
- */
- public abstract Tab setText(CharSequence text);
-
- /**
- * Set the text displayed on this tab. Text may be truncated if there is not
- * room to display the entire string.
- *
- * @param resId A resource ID referring to the text that should be displayed
- * @return The current instance for call chaining
- */
- public abstract Tab setText(int resId);
-
- /**
- * Set a custom view to be used for this tab. This overrides values set by
- * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
- *
- * @param view Custom view to be used as a tab.
- * @return The current instance for call chaining
- */
- public abstract Tab setCustomView(View view);
-
- /**
- * Set a custom view to be used for this tab. This overrides values set by
- * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
- *
- * @param layoutResId A layout resource to inflate and use as a custom tab view
- * @return The current instance for call chaining
- */
- public abstract Tab setCustomView(int layoutResId);
-
- /**
- * Retrieve a previously set custom view for this tab.
- *
- * @return The custom view set by {@link #setCustomView(View)}.
- */
- public abstract View getCustomView();
-
- /**
- * Give this Tab an arbitrary object to hold for later use.
- *
- * @param obj Object to store
- * @return The current instance for call chaining
- */
- public abstract Tab setTag(Object obj);
-
- /**
- * @return This Tab's tag object.
- */
- public abstract Object getTag();
-
- /**
- * Set the {@link TabListener} that will handle switching to and from this tab.
- * All tabs must have a TabListener set before being added to the ActionBar.
- *
- * @param listener Listener to handle tab selection events
- * @return The current instance for call chaining
- */
- public abstract Tab setTabListener(TabListener listener);
-
- /**
- * Select this tab. Only valid if the tab has been added to the action bar.
- */
- public abstract void select();
-
- /**
- * Set a description of this tab's content for use in accessibility support.
- * If no content description is provided the title will be used.
- *
- * @param resId A resource ID referring to the description text
- * @return The current instance for call chaining
- * @see #setContentDescription(CharSequence)
- * @see #getContentDescription()
- */
- public abstract Tab setContentDescription(int resId);
-
- /**
- * Set a description of this tab's content for use in accessibility support.
- * If no content description is provided the title will be used.
- *
- * @param contentDesc Description of this tab's content
- * @return The current instance for call chaining
- * @see #setContentDescription(int)
- * @see #getContentDescription()
- */
- public abstract Tab setContentDescription(CharSequence contentDesc);
-
- /**
- * Gets a brief description of this tab's content for use in accessibility support.
- *
- * @return Description of this tab's content
- * @see #setContentDescription(CharSequence)
- * @see #setContentDescription(int)
- */
- public abstract CharSequence getContentDescription();
- }
-
- /**
- * Callback interface invoked when a tab is focused, unfocused, added, or removed.
- */
- public interface TabListener {
- /**
- * Called when a tab enters the selected state.
- *
- * @param tab The tab that was selected
- * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
- * during a tab switch. The previous tab's unselect and this tab's select will be
- * executed in a single transaction. This FragmentTransaction does not support
- * being added to the back stack.
- */
- public void onTabSelected(Tab tab, FragmentTransaction ft);
-
- /**
- * Called when a tab exits the selected state.
- *
- * @param tab The tab that was unselected
- * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
- * during a tab switch. This tab's unselect and the newly selected tab's select
- * will be executed in a single transaction. This FragmentTransaction does not
- * support being added to the back stack.
- */
- public void onTabUnselected(Tab tab, FragmentTransaction ft);
-
- /**
- * Called when a tab that is already selected is chosen again by the user.
- * Some applications may use this action to return to the top level of a category.
- *
- * @param tab The tab that was reselected.
- * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
- * once this method returns. This FragmentTransaction does not support
- * being added to the back stack.
- */
- public void onTabReselected(Tab tab, FragmentTransaction ft);
- }
-
- /**
- * Per-child layout information associated with action bar custom views.
- *
- * @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity
- */
- public static class LayoutParams extends MarginLayoutParams {
- /**
- * Gravity for the view associated with these LayoutParams.
- *
- * @see android.view.Gravity
- */
- @ViewDebug.ExportedProperty(mapping = {
- @ViewDebug.IntToString(from = -1, to = "NONE"),
- @ViewDebug.IntToString(from = Gravity.NO_GRAVITY, to = "NONE"),
- @ViewDebug.IntToString(from = Gravity.TOP, to = "TOP"),
- @ViewDebug.IntToString(from = Gravity.BOTTOM, to = "BOTTOM"),
- @ViewDebug.IntToString(from = Gravity.LEFT, to = "LEFT"),
- @ViewDebug.IntToString(from = Gravity.RIGHT, to = "RIGHT"),
- @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL, to = "CENTER_VERTICAL"),
- @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL, to = "FILL_VERTICAL"),
- @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"),
- @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL, to = "FILL_HORIZONTAL"),
- @ViewDebug.IntToString(from = Gravity.CENTER, to = "CENTER"),
- @ViewDebug.IntToString(from = Gravity.FILL, to = "FILL")
- })
- public int gravity = -1;
-
- public LayoutParams(Context c, AttributeSet attrs) {
- super(c, attrs);
- }
-
- public LayoutParams(int width, int height) {
- super(width, height);
- this.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
- }
-
- public LayoutParams(int width, int height, int gravity) {
- super(width, height);
- this.gravity = gravity;
- }
-
- public LayoutParams(int gravity) {
- this(WRAP_CONTENT, FILL_PARENT, gravity);
- }
-
- public LayoutParams(LayoutParams source) {
- super(source);
-
- this.gravity = source.gravity;
- }
-
- public LayoutParams(ViewGroup.LayoutParams source) {
- super(source);
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockActivity.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockActivity.java
deleted file mode 100644
index 9cb57e95a2..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockActivity.java
+++ /dev/null
@@ -1,259 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.app.Activity;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.Window;
-import android.view.ViewGroup.LayoutParams;
-import com.actionbarsherlock.ActionBarSherlock;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener;
-import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener;
-import com.actionbarsherlock.view.ActionMode;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-public abstract class SherlockActivity extends Activity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener {
- private ActionBarSherlock mSherlock;
-
- protected final ActionBarSherlock getSherlock() {
- if (mSherlock == null) {
- mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE);
- }
- return mSherlock;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Action bar and mode
- ///////////////////////////////////////////////////////////////////////////
-
- public ActionBar getSupportActionBar() {
- return getSherlock().getActionBar();
- }
-
- public ActionMode startActionMode(ActionMode.Callback callback) {
- return getSherlock().startActionMode(callback);
- }
-
- @Override
- public void onActionModeStarted(ActionMode mode) {}
-
- @Override
- public void onActionModeFinished(ActionMode mode) {}
-
-
- ///////////////////////////////////////////////////////////////////////////
- // General lifecycle/callback dispatching
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- getSherlock().dispatchConfigurationChanged(newConfig);
- }
-
- @Override
- protected void onPostResume() {
- super.onPostResume();
- getSherlock().dispatchPostResume();
- }
-
- @Override
- protected void onPause() {
- getSherlock().dispatchPause();
- super.onPause();
- }
-
- @Override
- protected void onStop() {
- getSherlock().dispatchStop();
- super.onStop();
- }
-
- @Override
- protected void onDestroy() {
- getSherlock().dispatchDestroy();
- super.onDestroy();
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- getSherlock().dispatchPostCreate(savedInstanceState);
- super.onPostCreate(savedInstanceState);
- }
-
- @Override
- protected void onTitleChanged(CharSequence title, int color) {
- getSherlock().dispatchTitleChanged(title, color);
- super.onTitleChanged(title, color);
- }
-
- @Override
- public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
- if (getSherlock().dispatchMenuOpened(featureId, menu)) {
- return true;
- }
- return super.onMenuOpened(featureId, menu);
- }
-
- @Override
- public void onPanelClosed(int featureId, android.view.Menu menu) {
- getSherlock().dispatchPanelClosed(featureId, menu);
- super.onPanelClosed(featureId, menu);
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (getSherlock().dispatchKeyEvent(event)) {
- return true;
- }
- return super.dispatchKeyEvent(event);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Native menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- public MenuInflater getSupportMenuInflater() {
- return getSherlock().getMenuInflater();
- }
-
- public void invalidateOptionsMenu() {
- getSherlock().dispatchInvalidateOptionsMenu();
- }
-
- public void supportInvalidateOptionsMenu() {
- invalidateOptionsMenu();
- }
-
- @Override
- public final boolean onCreateOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchCreateOptionsMenu(menu);
- }
-
- @Override
- public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchPrepareOptionsMenu(menu);
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return getSherlock().dispatchOptionsItemSelected(item);
- }
-
- @Override
- public void openOptionsMenu() {
- if (!getSherlock().dispatchOpenOptionsMenu()) {
- super.openOptionsMenu();
- }
- }
-
- @Override
- public void closeOptionsMenu() {
- if (!getSherlock().dispatchCloseOptionsMenu()) {
- super.closeOptionsMenu();
- }
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Sherlock menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public boolean onCreatePanelMenu(int featureId, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onCreateOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onCreateOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onPreparePanel(int featureId, View view, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onPrepareOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onPrepareOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onMenuItemSelected(int featureId, MenuItem item) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onOptionsItemSelected(item);
- }
- return false;
- }
-
- public boolean onOptionsItemSelected(MenuItem item) {
- return false;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Content
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void addContentView(View view, LayoutParams params) {
- getSherlock().addContentView(view, params);
- }
-
- @Override
- public void setContentView(int layoutResId) {
- getSherlock().setContentView(layoutResId);
- }
-
- @Override
- public void setContentView(View view, LayoutParams params) {
- getSherlock().setContentView(view, params);
- }
-
- @Override
- public void setContentView(View view) {
- getSherlock().setContentView(view);
- }
-
- public void requestWindowFeature(long featureId) {
- getSherlock().requestFeature((int)featureId);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Progress Indication
- ///////////////////////////////////////////////////////////////////////////
-
- public void setSupportProgress(int progress) {
- getSherlock().setProgress(progress);
- }
-
- public void setSupportProgressBarIndeterminate(boolean indeterminate) {
- getSherlock().setProgressBarIndeterminate(indeterminate);
- }
-
- public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
- getSherlock().setProgressBarIndeterminateVisibility(visible);
- }
-
- public void setSupportProgressBarVisibility(boolean visible) {
- getSherlock().setProgressBarVisibility(visible);
- }
-
- public void setSupportSecondaryProgress(int secondaryProgress) {
- getSherlock().setSecondaryProgress(secondaryProgress);
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java
deleted file mode 100644
index a7c856bf02..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.app.Activity;
-import android.support.v4.app.DialogFragment;
-import com.actionbarsherlock.internal.view.menu.MenuItemWrapper;
-import com.actionbarsherlock.internal.view.menu.MenuWrapper;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener;
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener;
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener;
-
-public class SherlockDialogFragment extends DialogFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener {
- private SherlockFragmentActivity mActivity;
-
- public SherlockFragmentActivity getSherlockActivity() {
- return mActivity;
- }
-
- @Override
- public void onAttach(Activity activity) {
- if (!(activity instanceof SherlockFragmentActivity)) {
- throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
- }
- mActivity = (SherlockFragmentActivity)activity;
-
- super.onAttach(activity);
- }
-
- @Override
- public void onDetach() {
- mActivity = null;
- super.onDetach();
- }
-
- @Override
- public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) {
- onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater());
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- //Nothing to see here.
- }
-
- @Override
- public final void onPrepareOptionsMenu(android.view.Menu menu) {
- onPrepareOptionsMenu(new MenuWrapper(menu));
- }
-
- @Override
- public void onPrepareOptionsMenu(Menu menu) {
- //Nothing to see here.
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return onOptionsItemSelected(new MenuItemWrapper(item));
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- //Nothing to see here.
- return false;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java
deleted file mode 100644
index 078f9b0ca1..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java
+++ /dev/null
@@ -1,259 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.app.ExpandableListActivity;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewGroup.LayoutParams;
-import android.view.Window;
-import com.actionbarsherlock.ActionBarSherlock;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener;
-import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener;
-import com.actionbarsherlock.view.ActionMode;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-public abstract class SherlockExpandableListActivity extends ExpandableListActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener {
- private ActionBarSherlock mSherlock;
-
- protected final ActionBarSherlock getSherlock() {
- if (mSherlock == null) {
- mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE);
- }
- return mSherlock;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Action bar and mode
- ///////////////////////////////////////////////////////////////////////////
-
- public ActionBar getSupportActionBar() {
- return getSherlock().getActionBar();
- }
-
- public ActionMode startActionMode(ActionMode.Callback callback) {
- return getSherlock().startActionMode(callback);
- }
-
- @Override
- public void onActionModeStarted(ActionMode mode) {}
-
- @Override
- public void onActionModeFinished(ActionMode mode) {}
-
-
- ///////////////////////////////////////////////////////////////////////////
- // General lifecycle/callback dispatching
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- getSherlock().dispatchConfigurationChanged(newConfig);
- }
-
- @Override
- protected void onPostResume() {
- super.onPostResume();
- getSherlock().dispatchPostResume();
- }
-
- @Override
- protected void onPause() {
- getSherlock().dispatchPause();
- super.onPause();
- }
-
- @Override
- protected void onStop() {
- getSherlock().dispatchStop();
- super.onStop();
- }
-
- @Override
- protected void onDestroy() {
- getSherlock().dispatchDestroy();
- super.onDestroy();
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- getSherlock().dispatchPostCreate(savedInstanceState);
- super.onPostCreate(savedInstanceState);
- }
-
- @Override
- protected void onTitleChanged(CharSequence title, int color) {
- getSherlock().dispatchTitleChanged(title, color);
- super.onTitleChanged(title, color);
- }
-
- @Override
- public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
- if (getSherlock().dispatchMenuOpened(featureId, menu)) {
- return true;
- }
- return super.onMenuOpened(featureId, menu);
- }
-
- @Override
- public void onPanelClosed(int featureId, android.view.Menu menu) {
- getSherlock().dispatchPanelClosed(featureId, menu);
- super.onPanelClosed(featureId, menu);
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (getSherlock().dispatchKeyEvent(event)) {
- return true;
- }
- return super.dispatchKeyEvent(event);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Native menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- public MenuInflater getSupportMenuInflater() {
- return getSherlock().getMenuInflater();
- }
-
- public void invalidateOptionsMenu() {
- getSherlock().dispatchInvalidateOptionsMenu();
- }
-
- public void supportInvalidateOptionsMenu() {
- invalidateOptionsMenu();
- }
-
- @Override
- public final boolean onCreateOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchCreateOptionsMenu(menu);
- }
-
- @Override
- public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchPrepareOptionsMenu(menu);
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return getSherlock().dispatchOptionsItemSelected(item);
- }
-
- @Override
- public void openOptionsMenu() {
- if (!getSherlock().dispatchOpenOptionsMenu()) {
- super.openOptionsMenu();
- }
- }
-
- @Override
- public void closeOptionsMenu() {
- if (!getSherlock().dispatchCloseOptionsMenu()) {
- super.closeOptionsMenu();
- }
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Sherlock menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public boolean onCreatePanelMenu(int featureId, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onCreateOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onCreateOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onPreparePanel(int featureId, View view, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onPrepareOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onPrepareOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onMenuItemSelected(int featureId, MenuItem item) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onOptionsItemSelected(item);
- }
- return false;
- }
-
- public boolean onOptionsItemSelected(MenuItem item) {
- return false;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Content
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void addContentView(View view, LayoutParams params) {
- getSherlock().addContentView(view, params);
- }
-
- @Override
- public void setContentView(int layoutResId) {
- getSherlock().setContentView(layoutResId);
- }
-
- @Override
- public void setContentView(View view, LayoutParams params) {
- getSherlock().setContentView(view, params);
- }
-
- @Override
- public void setContentView(View view) {
- getSherlock().setContentView(view);
- }
-
- public void requestWindowFeature(long featureId) {
- getSherlock().requestFeature((int)featureId);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Progress Indication
- ///////////////////////////////////////////////////////////////////////////
-
- public void setSupportProgress(int progress) {
- getSherlock().setProgress(progress);
- }
-
- public void setSupportProgressBarIndeterminate(boolean indeterminate) {
- getSherlock().setProgressBarIndeterminate(indeterminate);
- }
-
- public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
- getSherlock().setProgressBarIndeterminateVisibility(visible);
- }
-
- public void setSupportProgressBarVisibility(boolean visible) {
- getSherlock().setProgressBarVisibility(visible);
- }
-
- public void setSupportSecondaryProgress(int secondaryProgress) {
- getSherlock().setSecondaryProgress(secondaryProgress);
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragment.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragment.java
deleted file mode 100644
index 0f24e9c856..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragment.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.app.Activity;
-import android.support.v4.app.Fragment;
-import com.actionbarsherlock.internal.view.menu.MenuItemWrapper;
-import com.actionbarsherlock.internal.view.menu.MenuWrapper;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener;
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener;
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener;
-
-public class SherlockFragment extends Fragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener {
- private SherlockFragmentActivity mActivity;
-
- public SherlockFragmentActivity getSherlockActivity() {
- return mActivity;
- }
-
- @Override
- public void onAttach(Activity activity) {
- if (!(activity instanceof SherlockFragmentActivity)) {
- throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
- }
- mActivity = (SherlockFragmentActivity)activity;
-
- super.onAttach(activity);
- }
-
- @Override
- public void onDetach() {
- mActivity = null;
- super.onDetach();
- }
-
- @Override
- public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) {
- onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater());
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- //Nothing to see here.
- }
-
- @Override
- public final void onPrepareOptionsMenu(android.view.Menu menu) {
- onPrepareOptionsMenu(new MenuWrapper(menu));
- }
-
- @Override
- public void onPrepareOptionsMenu(Menu menu) {
- //Nothing to see here.
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return onOptionsItemSelected(new MenuItemWrapper(item));
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- //Nothing to see here.
- return false;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java
deleted file mode 100644
index 5cd13ba7cb..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java
+++ /dev/null
@@ -1,292 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.support.v4.app._ActionBarSherlockTrojanHorse;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewGroup.LayoutParams;
-import android.view.Window;
-import com.actionbarsherlock.ActionBarSherlock;
-import com.actionbarsherlock.view.ActionMode;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-import static com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener;
-import static com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener;
-
-/** @see {@link _ActionBarSherlockTrojanHorse} */
-public class SherlockFragmentActivity extends _ActionBarSherlockTrojanHorse implements OnActionModeStartedListener, OnActionModeFinishedListener {
- private static final boolean DEBUG = false;
- private static final String TAG = "SherlockFragmentActivity";
-
- private ActionBarSherlock mSherlock;
- private boolean mIgnoreNativeCreate = false;
- private boolean mIgnoreNativePrepare = false;
- private boolean mIgnoreNativeSelected = false;
-
- protected final ActionBarSherlock getSherlock() {
- if (mSherlock == null) {
- mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE);
- }
- return mSherlock;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Action bar and mode
- ///////////////////////////////////////////////////////////////////////////
-
- public ActionBar getSupportActionBar() {
- return getSherlock().getActionBar();
- }
-
- public ActionMode startActionMode(ActionMode.Callback callback) {
- return getSherlock().startActionMode(callback);
- }
-
- @Override
- public void onActionModeStarted(ActionMode mode) {}
-
- @Override
- public void onActionModeFinished(ActionMode mode) {}
-
-
- ///////////////////////////////////////////////////////////////////////////
- // General lifecycle/callback dispatching
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- getSherlock().dispatchConfigurationChanged(newConfig);
- }
-
- @Override
- protected void onPostResume() {
- super.onPostResume();
- getSherlock().dispatchPostResume();
- }
-
- @Override
- protected void onPause() {
- getSherlock().dispatchPause();
- super.onPause();
- }
-
- @Override
- protected void onStop() {
- getSherlock().dispatchStop();
- super.onStop();
- }
-
- @Override
- protected void onDestroy() {
- getSherlock().dispatchDestroy();
- super.onDestroy();
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- getSherlock().dispatchPostCreate(savedInstanceState);
- super.onPostCreate(savedInstanceState);
- }
-
- @Override
- protected void onTitleChanged(CharSequence title, int color) {
- getSherlock().dispatchTitleChanged(title, color);
- super.onTitleChanged(title, color);
- }
-
- @Override
- public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
- if (getSherlock().dispatchMenuOpened(featureId, menu)) {
- return true;
- }
- return super.onMenuOpened(featureId, menu);
- }
-
- @Override
- public void onPanelClosed(int featureId, android.view.Menu menu) {
- getSherlock().dispatchPanelClosed(featureId, menu);
- super.onPanelClosed(featureId, menu);
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (getSherlock().dispatchKeyEvent(event)) {
- return true;
- }
- return super.dispatchKeyEvent(event);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Native menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- public MenuInflater getSupportMenuInflater() {
- if (DEBUG) Log.d(TAG, "[getSupportMenuInflater]");
-
- return getSherlock().getMenuInflater();
- }
-
- public void invalidateOptionsMenu() {
- if (DEBUG) Log.d(TAG, "[invalidateOptionsMenu]");
-
- getSherlock().dispatchInvalidateOptionsMenu();
- }
-
- public void supportInvalidateOptionsMenu() {
- if (DEBUG) Log.d(TAG, "[supportInvalidateOptionsMenu]");
-
- invalidateOptionsMenu();
- }
-
- @Override
- public final boolean onCreatePanelMenu(int featureId, android.view.Menu menu) {
- if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] featureId: " + featureId + ", menu: " + menu);
-
- if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativeCreate) {
- mIgnoreNativeCreate = true;
- boolean result = getSherlock().dispatchCreateOptionsMenu(menu);
- mIgnoreNativeCreate = false;
-
- if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] returning " + result);
- return result;
- }
- return super.onCreatePanelMenu(featureId, menu);
- }
-
- @Override
- public final boolean onCreateOptionsMenu(android.view.Menu menu) {
- return true;
- }
-
- @Override
- public final boolean onPreparePanel(int featureId, View view, android.view.Menu menu) {
- if (DEBUG) Log.d(TAG, "[onPreparePanel] featureId: " + featureId + ", view: " + view + ", menu: " + menu);
-
- if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativePrepare) {
- mIgnoreNativePrepare = true;
- boolean result = getSherlock().dispatchPrepareOptionsMenu(menu);
- mIgnoreNativePrepare = false;
-
- if (DEBUG) Log.d(TAG, "[onPreparePanel] returning " + result);
- return result;
- }
- return super.onPreparePanel(featureId, view, menu);
- }
-
- @Override
- public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
- return true;
- }
-
- @Override
- public final boolean onMenuItemSelected(int featureId, android.view.MenuItem item) {
- if (DEBUG) Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item);
-
- if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativeSelected) {
- mIgnoreNativeSelected = true;
- boolean result = getSherlock().dispatchOptionsItemSelected(item);
- mIgnoreNativeSelected = false;
-
- if (DEBUG) Log.d(TAG, "[onMenuItemSelected] returning " + result);
- return result;
- }
- return super.onMenuItemSelected(featureId, item);
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return false;
- }
-
- @Override
- public void openOptionsMenu() {
- if (!getSherlock().dispatchOpenOptionsMenu()) {
- super.openOptionsMenu();
- }
- }
-
- @Override
- public void closeOptionsMenu() {
- if (!getSherlock().dispatchCloseOptionsMenu()) {
- super.closeOptionsMenu();
- }
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Sherlock menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- public boolean onCreateOptionsMenu(Menu menu) {
- return true;
- }
-
- public boolean onPrepareOptionsMenu(Menu menu) {
- return true;
- }
-
- public boolean onOptionsItemSelected(MenuItem item) {
- return false;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Content
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void addContentView(View view, LayoutParams params) {
- getSherlock().addContentView(view, params);
- }
-
- @Override
- public void setContentView(int layoutResId) {
- getSherlock().setContentView(layoutResId);
- }
-
- @Override
- public void setContentView(View view, LayoutParams params) {
- getSherlock().setContentView(view, params);
- }
-
- @Override
- public void setContentView(View view) {
- getSherlock().setContentView(view);
- }
-
- public void requestWindowFeature(long featureId) {
- getSherlock().requestFeature((int)featureId);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Progress Indication
- ///////////////////////////////////////////////////////////////////////////
-
- public void setSupportProgress(int progress) {
- getSherlock().setProgress(progress);
- }
-
- public void setSupportProgressBarIndeterminate(boolean indeterminate) {
- getSherlock().setProgressBarIndeterminate(indeterminate);
- }
-
- public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
- getSherlock().setProgressBarIndeterminateVisibility(visible);
- }
-
- public void setSupportProgressBarVisibility(boolean visible) {
- getSherlock().setProgressBarVisibility(visible);
- }
-
- public void setSupportSecondaryProgress(int secondaryProgress) {
- getSherlock().setSecondaryProgress(secondaryProgress);
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListActivity.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListActivity.java
deleted file mode 100644
index 00c00fee52..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListActivity.java
+++ /dev/null
@@ -1,259 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.app.ListActivity;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.Window;
-import android.view.ViewGroup.LayoutParams;
-import com.actionbarsherlock.ActionBarSherlock;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener;
-import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener;
-import com.actionbarsherlock.view.ActionMode;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-public abstract class SherlockListActivity extends ListActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener {
- private ActionBarSherlock mSherlock;
-
- protected final ActionBarSherlock getSherlock() {
- if (mSherlock == null) {
- mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE);
- }
- return mSherlock;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Action bar and mode
- ///////////////////////////////////////////////////////////////////////////
-
- public ActionBar getSupportActionBar() {
- return getSherlock().getActionBar();
- }
-
- public ActionMode startActionMode(ActionMode.Callback callback) {
- return getSherlock().startActionMode(callback);
- }
-
- @Override
- public void onActionModeStarted(ActionMode mode) {}
-
- @Override
- public void onActionModeFinished(ActionMode mode) {}
-
-
- ///////////////////////////////////////////////////////////////////////////
- // General lifecycle/callback dispatching
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- getSherlock().dispatchConfigurationChanged(newConfig);
- }
-
- @Override
- protected void onPostResume() {
- super.onPostResume();
- getSherlock().dispatchPostResume();
- }
-
- @Override
- protected void onPause() {
- getSherlock().dispatchPause();
- super.onPause();
- }
-
- @Override
- protected void onStop() {
- getSherlock().dispatchStop();
- super.onStop();
- }
-
- @Override
- protected void onDestroy() {
- getSherlock().dispatchDestroy();
- super.onDestroy();
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- getSherlock().dispatchPostCreate(savedInstanceState);
- super.onPostCreate(savedInstanceState);
- }
-
- @Override
- protected void onTitleChanged(CharSequence title, int color) {
- getSherlock().dispatchTitleChanged(title, color);
- super.onTitleChanged(title, color);
- }
-
- @Override
- public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
- if (getSherlock().dispatchMenuOpened(featureId, menu)) {
- return true;
- }
- return super.onMenuOpened(featureId, menu);
- }
-
- @Override
- public void onPanelClosed(int featureId, android.view.Menu menu) {
- getSherlock().dispatchPanelClosed(featureId, menu);
- super.onPanelClosed(featureId, menu);
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (getSherlock().dispatchKeyEvent(event)) {
- return true;
- }
- return super.dispatchKeyEvent(event);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Native menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- public MenuInflater getSupportMenuInflater() {
- return getSherlock().getMenuInflater();
- }
-
- public void invalidateOptionsMenu() {
- getSherlock().dispatchInvalidateOptionsMenu();
- }
-
- public void supportInvalidateOptionsMenu() {
- invalidateOptionsMenu();
- }
-
- @Override
- public final boolean onCreateOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchCreateOptionsMenu(menu);
- }
-
- @Override
- public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchPrepareOptionsMenu(menu);
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return getSherlock().dispatchOptionsItemSelected(item);
- }
-
- @Override
- public void openOptionsMenu() {
- if (!getSherlock().dispatchOpenOptionsMenu()) {
- super.openOptionsMenu();
- }
- }
-
- @Override
- public void closeOptionsMenu() {
- if (!getSherlock().dispatchCloseOptionsMenu()) {
- super.closeOptionsMenu();
- }
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Sherlock menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public boolean onCreatePanelMenu(int featureId, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onCreateOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onCreateOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onPreparePanel(int featureId, View view, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onPrepareOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onPrepareOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onMenuItemSelected(int featureId, MenuItem item) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onOptionsItemSelected(item);
- }
- return false;
- }
-
- public boolean onOptionsItemSelected(MenuItem item) {
- return false;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Content
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void addContentView(View view, LayoutParams params) {
- getSherlock().addContentView(view, params);
- }
-
- @Override
- public void setContentView(int layoutResId) {
- getSherlock().setContentView(layoutResId);
- }
-
- @Override
- public void setContentView(View view, LayoutParams params) {
- getSherlock().setContentView(view, params);
- }
-
- @Override
- public void setContentView(View view) {
- getSherlock().setContentView(view);
- }
-
- public void requestWindowFeature(long featureId) {
- getSherlock().requestFeature((int)featureId);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Progress Indication
- ///////////////////////////////////////////////////////////////////////////
-
- public void setSupportProgress(int progress) {
- getSherlock().setProgress(progress);
- }
-
- public void setSupportProgressBarIndeterminate(boolean indeterminate) {
- getSherlock().setProgressBarIndeterminate(indeterminate);
- }
-
- public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
- getSherlock().setProgressBarIndeterminateVisibility(visible);
- }
-
- public void setSupportProgressBarVisibility(boolean visible) {
- getSherlock().setProgressBarVisibility(visible);
- }
-
- public void setSupportSecondaryProgress(int secondaryProgress) {
- getSherlock().setSecondaryProgress(secondaryProgress);
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListFragment.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListFragment.java
deleted file mode 100644
index 13ca3c49fb..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListFragment.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.app.Activity;
-import android.support.v4.app.ListFragment;
-import com.actionbarsherlock.internal.view.menu.MenuItemWrapper;
-import com.actionbarsherlock.internal.view.menu.MenuWrapper;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener;
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener;
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener;
-
-public class SherlockListFragment extends ListFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener {
- private SherlockFragmentActivity mActivity;
-
- public SherlockFragmentActivity getSherlockActivity() {
- return mActivity;
- }
-
- @Override
- public void onAttach(Activity activity) {
- if (!(activity instanceof SherlockFragmentActivity)) {
- throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
- }
- mActivity = (SherlockFragmentActivity)activity;
-
- super.onAttach(activity);
- }
-
- @Override
- public void onDetach() {
- mActivity = null;
- super.onDetach();
- }
-
- @Override
- public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) {
- onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater());
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- //Nothing to see here.
- }
-
- @Override
- public final void onPrepareOptionsMenu(android.view.Menu menu) {
- onPrepareOptionsMenu(new MenuWrapper(menu));
- }
-
- @Override
- public void onPrepareOptionsMenu(Menu menu) {
- //Nothing to see here.
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return onOptionsItemSelected(new MenuItemWrapper(item));
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- //Nothing to see here.
- return false;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java
deleted file mode 100644
index 4f80be5152..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java
+++ /dev/null
@@ -1,259 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.preference.PreferenceActivity;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewGroup.LayoutParams;
-import android.view.Window;
-import com.actionbarsherlock.ActionBarSherlock;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener;
-import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener;
-import com.actionbarsherlock.view.ActionMode;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-public abstract class SherlockPreferenceActivity extends PreferenceActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener {
- private ActionBarSherlock mSherlock;
-
- protected final ActionBarSherlock getSherlock() {
- if (mSherlock == null) {
- mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE);
- }
- return mSherlock;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Action bar and mode
- ///////////////////////////////////////////////////////////////////////////
-
- public ActionBar getSupportActionBar() {
- return getSherlock().getActionBar();
- }
-
- public ActionMode startActionMode(ActionMode.Callback callback) {
- return getSherlock().startActionMode(callback);
- }
-
- @Override
- public void onActionModeStarted(ActionMode mode) {}
-
- @Override
- public void onActionModeFinished(ActionMode mode) {}
-
-
- ///////////////////////////////////////////////////////////////////////////
- // General lifecycle/callback dispatching
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- getSherlock().dispatchConfigurationChanged(newConfig);
- }
-
- @Override
- protected void onPostResume() {
- super.onPostResume();
- getSherlock().dispatchPostResume();
- }
-
- @Override
- protected void onPause() {
- getSherlock().dispatchPause();
- super.onPause();
- }
-
- @Override
- protected void onStop() {
- getSherlock().dispatchStop();
- super.onStop();
- }
-
- @Override
- protected void onDestroy() {
- getSherlock().dispatchDestroy();
- super.onDestroy();
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- getSherlock().dispatchPostCreate(savedInstanceState);
- super.onPostCreate(savedInstanceState);
- }
-
- @Override
- protected void onTitleChanged(CharSequence title, int color) {
- getSherlock().dispatchTitleChanged(title, color);
- super.onTitleChanged(title, color);
- }
-
- @Override
- public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
- if (getSherlock().dispatchMenuOpened(featureId, menu)) {
- return true;
- }
- return super.onMenuOpened(featureId, menu);
- }
-
- @Override
- public void onPanelClosed(int featureId, android.view.Menu menu) {
- getSherlock().dispatchPanelClosed(featureId, menu);
- super.onPanelClosed(featureId, menu);
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (getSherlock().dispatchKeyEvent(event)) {
- return true;
- }
- return super.dispatchKeyEvent(event);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Native menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- public MenuInflater getSupportMenuInflater() {
- return getSherlock().getMenuInflater();
- }
-
- public void invalidateOptionsMenu() {
- getSherlock().dispatchInvalidateOptionsMenu();
- }
-
- public void supportInvalidateOptionsMenu() {
- invalidateOptionsMenu();
- }
-
- @Override
- public final boolean onCreateOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchCreateOptionsMenu(menu);
- }
-
- @Override
- public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchPrepareOptionsMenu(menu);
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return getSherlock().dispatchOptionsItemSelected(item);
- }
-
- @Override
- public void openOptionsMenu() {
- if (!getSherlock().dispatchOpenOptionsMenu()) {
- super.openOptionsMenu();
- }
- }
-
- @Override
- public void closeOptionsMenu() {
- if (!getSherlock().dispatchCloseOptionsMenu()) {
- super.closeOptionsMenu();
- }
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Sherlock menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public boolean onCreatePanelMenu(int featureId, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onCreateOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onCreateOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onPreparePanel(int featureId, View view, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onPrepareOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onPrepareOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onMenuItemSelected(int featureId, MenuItem item) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onOptionsItemSelected(item);
- }
- return false;
- }
-
- public boolean onOptionsItemSelected(MenuItem item) {
- return false;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Content
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void addContentView(View view, LayoutParams params) {
- getSherlock().addContentView(view, params);
- }
-
- @Override
- public void setContentView(int layoutResId) {
- getSherlock().setContentView(layoutResId);
- }
-
- @Override
- public void setContentView(View view, LayoutParams params) {
- getSherlock().setContentView(view, params);
- }
-
- @Override
- public void setContentView(View view) {
- getSherlock().setContentView(view);
- }
-
- public void requestWindowFeature(long featureId) {
- getSherlock().requestFeature((int)featureId);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Progress Indication
- ///////////////////////////////////////////////////////////////////////////
-
- public void setSupportProgress(int progress) {
- getSherlock().setProgress(progress);
- }
-
- public void setSupportProgressBarIndeterminate(boolean indeterminate) {
- getSherlock().setProgressBarIndeterminate(indeterminate);
- }
-
- public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
- getSherlock().setProgressBarIndeterminateVisibility(visible);
- }
-
- public void setSupportProgressBarVisibility(boolean visible) {
- getSherlock().setProgressBarVisibility(visible);
- }
-
- public void setSupportSecondaryProgress(int secondaryProgress) {
- getSherlock().setSecondaryProgress(secondaryProgress);
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java
deleted file mode 100644
index 05353d28ca..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java
+++ /dev/null
@@ -1,1207 +0,0 @@
-package com.actionbarsherlock.internal;
-
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
-import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import org.xmlpull.v1.XmlPullParser;
-import android.app.Activity;
-import android.content.Context;
-import android.content.pm.ActivityInfo;
-import android.content.res.AssetManager;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.content.res.XmlResourceParser;
-import android.os.Bundle;
-import android.util.AndroidRuntimeException;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.ContextThemeWrapper;
-import android.view.KeyCharacterMap;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.ViewStub;
-import android.view.Window;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
-import android.widget.FrameLayout;
-import android.widget.TextView;
-import com.actionbarsherlock.ActionBarSherlock;
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.internal.app.ActionBarImpl;
-import com.actionbarsherlock.internal.view.StandaloneActionMode;
-import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter;
-import com.actionbarsherlock.internal.view.menu.MenuBuilder;
-import com.actionbarsherlock.internal.view.menu.MenuItemImpl;
-import com.actionbarsherlock.internal.view.menu.MenuPresenter;
-import com.actionbarsherlock.internal.widget.ActionBarContainer;
-import com.actionbarsherlock.internal.widget.ActionBarContextView;
-import com.actionbarsherlock.internal.widget.ActionBarView;
-import com.actionbarsherlock.internal.widget.IcsProgressBar;
-import com.actionbarsherlock.view.ActionMode;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuItem;
-
-@ActionBarSherlock.Implementation(api = 7)
-public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBuilder.Callback, com.actionbarsherlock.view.Window.Callback, MenuPresenter.Callback, android.view.MenuItem.OnMenuItemClickListener {
- /** Window features which are enabled by default. */
- protected static final int DEFAULT_FEATURES = 0;
-
-
- public ActionBarSherlockCompat(Activity activity, int flags) {
- super(activity, flags);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Properties
- ///////////////////////////////////////////////////////////////////////////
-
- /** Whether or not the device has a dedicated menu key button. */
- private boolean mReserveOverflow;
- /** Lazy-load indicator for {@link #mReserveOverflow}. */
- private boolean mReserveOverflowSet = false;
-
- /** Current menu instance for managing action items. */
- private MenuBuilder mMenu;
- /** Map between native options items and sherlock items. */
- protected HashMap mNativeItemMap;
- /** Indication of a long-press on the hardware menu key. */
- private boolean mMenuKeyIsLongPress = false;
-
- /** Parent view of the window decoration (action bar, mode, etc.). */
- private ViewGroup mDecor;
- /** Parent view of the activity content. */
- private ViewGroup mContentParent;
-
- /** Whether or not the title is stable and can be displayed. */
- private boolean mIsTitleReady = false;
- /** Whether or not the parent activity has been destroyed. */
- private boolean mIsDestroyed = false;
-
- /* Emulate PanelFeatureState */
- private boolean mClosingActionMenu;
- private boolean mMenuIsPrepared;
- private boolean mMenuRefreshContent;
- private Bundle mMenuFrozenActionViewState;
-
- /** Implementation which backs the action bar interface API. */
- private ActionBarImpl aActionBar;
- /** Main action bar view which displays the core content. */
- private ActionBarView wActionBar;
- /** Relevant window and action bar features flags. */
- private int mFeatures = DEFAULT_FEATURES;
- /** Relevant user interface option flags. */
- private int mUiOptions = 0;
-
- /** Decor indeterminate progress indicator. */
- private IcsProgressBar mCircularProgressBar;
- /** Decor progress indicator. */
- private IcsProgressBar mHorizontalProgressBar;
-
- /** Current displayed context action bar, if any. */
- private ActionMode mActionMode;
- /** Parent view in which the context action bar is displayed. */
- private ActionBarContextView mActionModeView;
-
- /** Title view used with dialogs. */
- private TextView mTitleView;
- /** Current activity title. */
- private CharSequence mTitle = null;
- /** Whether or not this "activity" is floating (i.e., a dialog) */
- private boolean mIsFloating;
-
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Instance methods
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public ActionBar getActionBar() {
- if (DEBUG) Log.d(TAG, "[getActionBar]");
-
- initActionBar();
- return aActionBar;
- }
-
- private void initActionBar() {
- if (DEBUG) Log.d(TAG, "[initActionBar]");
-
- // Initializing the window decor can change window feature flags.
- // Make sure that we have the correct set before performing the test below.
- if (mDecor == null) {
- installDecor();
- }
-
- if ((aActionBar != null) || !hasFeature(Window.FEATURE_ACTION_BAR) || hasFeature(Window.FEATURE_NO_TITLE) || mActivity.isChild()) {
- return;
- }
-
- aActionBar = new ActionBarImpl(mActivity, mFeatures);
-
- if (!mIsDelegate) {
- //We may never get another chance to set the title
- wActionBar.setWindowTitle(mActivity.getTitle());
- }
- }
-
- @Override
- protected Context getThemedContext() {
- return aActionBar.getThemedContext();
- }
-
- @Override
- public void setTitle(CharSequence title) {
- if (DEBUG) Log.d(TAG, "[setTitle] title: " + title);
-
- dispatchTitleChanged(title, 0);
- }
-
- @Override
- public ActionMode startActionMode(ActionMode.Callback callback) {
- if (DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback);
-
- if (mActionMode != null) {
- mActionMode.finish();
- }
-
- final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback);
- ActionMode mode = null;
-
- //Emulate Activity's onWindowStartingActionMode:
- initActionBar();
- if (aActionBar != null) {
- mode = aActionBar.startActionMode(wrappedCallback);
- }
-
- if (mode != null) {
- mActionMode = mode;
- } else {
- if (mActionModeView == null) {
- ViewStub stub = (ViewStub)mDecor.findViewById(R.id.abs__action_mode_bar_stub);
- if (stub != null) {
- mActionModeView = (ActionBarContextView)stub.inflate();
- }
- }
- if (mActionModeView != null) {
- mActionModeView.killMode();
- mode = new StandaloneActionMode(mActivity, mActionModeView, wrappedCallback, true);
- if (callback.onCreateActionMode(mode, mode.getMenu())) {
- mode.invalidate();
- mActionModeView.initForMode(mode);
- mActionModeView.setVisibility(View.VISIBLE);
- mActionMode = mode;
- mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
- } else {
- mActionMode = null;
- }
- }
- }
- if (mActionMode != null && mActivity instanceof OnActionModeStartedListener) {
- ((OnActionModeStartedListener)mActivity).onActionModeStarted(mActionMode);
- }
- return mActionMode;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Lifecycle and interaction callbacks for delegation
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void dispatchConfigurationChanged(Configuration newConfig) {
- if (DEBUG) Log.d(TAG, "[dispatchConfigurationChanged] newConfig: " + newConfig);
-
- if (aActionBar != null) {
- aActionBar.onConfigurationChanged(newConfig);
- }
- }
-
- @Override
- public void dispatchPostResume() {
- if (DEBUG) Log.d(TAG, "[dispatchPostResume]");
-
- if (aActionBar != null) {
- aActionBar.setShowHideAnimationEnabled(true);
- }
- }
-
- @Override
- public void dispatchPause() {
- if (DEBUG) Log.d(TAG, "[dispatchPause]");
-
- if (wActionBar != null && wActionBar.isOverflowMenuShowing()) {
- wActionBar.hideOverflowMenu();
- }
- }
-
- @Override
- public void dispatchStop() {
- if (DEBUG) Log.d(TAG, "[dispatchStop]");
-
- if (aActionBar != null) {
- aActionBar.setShowHideAnimationEnabled(false);
- }
- }
-
- @Override
- public void dispatchInvalidateOptionsMenu() {
- if (DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu]");
-
- Bundle savedActionViewStates = null;
- if (mMenu != null) {
- savedActionViewStates = new Bundle();
- mMenu.saveActionViewStates(savedActionViewStates);
- if (savedActionViewStates.size() > 0) {
- mMenuFrozenActionViewState = savedActionViewStates;
- }
- // This will be started again when the panel is prepared.
- mMenu.stopDispatchingItemsChanged();
- mMenu.clear();
- }
- mMenuRefreshContent = true;
-
- // Prepare the options panel if we have an action bar
- if (wActionBar != null) {
- mMenuIsPrepared = false;
- preparePanel();
- }
- }
-
- @Override
- public boolean dispatchOpenOptionsMenu() {
- if (DEBUG) Log.d(TAG, "[dispatchOpenOptionsMenu]");
-
- if (!isReservingOverflow()) {
- return false;
- }
-
- return wActionBar.showOverflowMenu();
- }
-
- @Override
- public boolean dispatchCloseOptionsMenu() {
- if (DEBUG) Log.d(TAG, "[dispatchCloseOptionsMenu]");
-
- if (!isReservingOverflow()) {
- return false;
- }
-
- return wActionBar.hideOverflowMenu();
- }
-
- @Override
- public void dispatchPostCreate(Bundle savedInstanceState) {
- if (DEBUG) Log.d(TAG, "[dispatchOnPostCreate]");
-
- if (mIsDelegate) {
- mIsTitleReady = true;
- }
-
- if (mDecor == null) {
- initActionBar();
- }
- }
-
- @Override
- public boolean dispatchCreateOptionsMenu(android.view.Menu menu) {
- if (DEBUG) {
- Log.d(TAG, "[dispatchCreateOptionsMenu] android.view.Menu: " + menu);
- Log.d(TAG, "[dispatchCreateOptionsMenu] returning true");
- }
- return true;
- }
-
- @Override
- public boolean dispatchPrepareOptionsMenu(android.view.Menu menu) {
- if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] android.view.Menu: " + menu);
-
- if (mActionMode != null) {
- return false;
- }
-
- mMenuIsPrepared = false;
- if (!preparePanel()) {
- return false;
- }
-
- if (isReservingOverflow()) {
- return false;
- }
-
- if (mNativeItemMap == null) {
- mNativeItemMap = new HashMap();
- } else {
- mNativeItemMap.clear();
- }
-
- if (mMenu == null) {
- return false;
- }
-
- boolean result = mMenu.bindNativeOverflow(menu, this, mNativeItemMap);
- if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] returning " + result);
- return result;
- }
-
- @Override
- public boolean dispatchOptionsItemSelected(android.view.MenuItem item) {
- throw new IllegalStateException("Native callback invoked. Create a test case and report!");
- }
-
- @Override
- public boolean dispatchMenuOpened(int featureId, android.view.Menu menu) {
- if (DEBUG) Log.d(TAG, "[dispatchMenuOpened] featureId: " + featureId + ", menu: " + menu);
-
- if (featureId == Window.FEATURE_ACTION_BAR || featureId == Window.FEATURE_OPTIONS_PANEL) {
- if (aActionBar != null) {
- aActionBar.dispatchMenuVisibilityChanged(true);
- }
- return true;
- }
-
- return false;
- }
-
- @Override
- public void dispatchPanelClosed(int featureId, android.view.Menu menu){
- if (DEBUG) Log.d(TAG, "[dispatchPanelClosed] featureId: " + featureId + ", menu: " + menu);
-
- if (featureId == Window.FEATURE_ACTION_BAR || featureId == Window.FEATURE_OPTIONS_PANEL) {
- if (aActionBar != null) {
- aActionBar.dispatchMenuVisibilityChanged(false);
- }
- }
- }
-
- @Override
- public void dispatchTitleChanged(CharSequence title, int color) {
- if (DEBUG) Log.d(TAG, "[dispatchTitleChanged] title: " + title + ", color: " + color);
-
- if (!mIsDelegate || mIsTitleReady) {
- if (mTitleView != null) {
- mTitleView.setText(title);
- } else if (wActionBar != null) {
- wActionBar.setWindowTitle(title);
- }
- }
-
- mTitle = title;
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] event: " + event);
-
- final int keyCode = event.getKeyCode();
-
- // Not handled by the view hierarchy, does the action bar want it
- // to cancel out of something special?
- if (keyCode == KeyEvent.KEYCODE_BACK) {
- final int action = event.getAction();
- // Back cancels action modes first.
- if (mActionMode != null) {
- if (action == KeyEvent.ACTION_UP) {
- mActionMode.finish();
- }
- if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true");
- return true;
- }
-
- // Next collapse any expanded action views.
- if (wActionBar != null && wActionBar.hasExpandedActionView()) {
- if (action == KeyEvent.ACTION_UP) {
- wActionBar.collapseActionView();
- }
- if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true");
- return true;
- }
- }
-
- boolean result = false;
- if (keyCode == KeyEvent.KEYCODE_MENU && isReservingOverflow()) {
- if (event.getAction() == KeyEvent.ACTION_DOWN && event.isLongPress()) {
- mMenuKeyIsLongPress = true;
- } else if (event.getAction() == KeyEvent.ACTION_UP) {
- if (!mMenuKeyIsLongPress) {
- if (mActionMode == null && wActionBar != null) {
- if (wActionBar.isOverflowMenuShowing()) {
- wActionBar.hideOverflowMenu();
- } else {
- wActionBar.showOverflowMenu();
- }
- }
- result = true;
- }
- mMenuKeyIsLongPress = false;
- }
- }
-
- if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning " + result);
- return result;
- }
-
- @Override
- public void dispatchDestroy() {
- mIsDestroyed = true;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Menu callback lifecycle and creation
- ///////////////////////////////////////////////////////////////////////////
-
- private boolean preparePanel() {
- // Already prepared (isPrepared will be reset to false later)
- if (mMenuIsPrepared) {
- return true;
- }
-
- // Init the panel state's menu--return false if init failed
- if (mMenu == null || mMenuRefreshContent) {
- if (mMenu == null) {
- if (!initializePanelMenu() || (mMenu == null)) {
- return false;
- }
- }
-
- if (wActionBar != null) {
- wActionBar.setMenu(mMenu, this);
- }
-
- // Call callback, and return if it doesn't want to display menu.
-
- // Creating the panel menu will involve a lot of manipulation;
- // don't dispatch change events to presenters until we're done.
- mMenu.stopDispatchingItemsChanged();
- if (!callbackCreateOptionsMenu(mMenu)) {
- // Ditch the menu created above
- mMenu = null;
-
- if (wActionBar != null) {
- // Don't show it in the action bar either
- wActionBar.setMenu(null, this);
- }
-
- return false;
- }
-
- mMenuRefreshContent = false;
- }
-
- // Callback and return if the callback does not want to show the menu
-
- // Preparing the panel menu can involve a lot of manipulation;
- // don't dispatch change events to presenters until we're done.
- mMenu.stopDispatchingItemsChanged();
-
- // Restore action view state before we prepare. This gives apps
- // an opportunity to override frozen/restored state in onPrepare.
- if (mMenuFrozenActionViewState != null) {
- mMenu.restoreActionViewStates(mMenuFrozenActionViewState);
- mMenuFrozenActionViewState = null;
- }
-
- if (!callbackPrepareOptionsMenu(mMenu)) {
- if (wActionBar != null) {
- // The app didn't want to show the menu for now but it still exists.
- // Clear it out of the action bar.
- wActionBar.setMenu(null, this);
- }
- mMenu.startDispatchingItemsChanged();
- return false;
- }
-
- // Set the proper keymap
- KeyCharacterMap kmap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
- mMenu.setQwertyMode(kmap.getKeyboardType() != KeyCharacterMap.NUMERIC);
- mMenu.startDispatchingItemsChanged();
-
- // Set other state
- mMenuIsPrepared = true;
-
- return true;
- }
-
- public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
- return callbackOptionsItemSelected(item);
- }
-
- public void onMenuModeChange(MenuBuilder menu) {
- reopenMenu(true);
- }
-
- private void reopenMenu(boolean toggleMenuMode) {
- if (wActionBar != null && wActionBar.isOverflowReserved()) {
- if (!wActionBar.isOverflowMenuShowing() || !toggleMenuMode) {
- if (wActionBar.getVisibility() == View.VISIBLE) {
- if (callbackPrepareOptionsMenu(mMenu)) {
- wActionBar.showOverflowMenu();
- }
- }
- } else {
- wActionBar.hideOverflowMenu();
- }
- return;
- }
- }
-
- private boolean initializePanelMenu() {
- Context context = mActivity;//getContext();
-
- // If we have an action bar, initialize the menu with a context themed for it.
- if (wActionBar != null) {
- TypedValue outValue = new TypedValue();
- Resources.Theme currentTheme = context.getTheme();
- currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme,
- outValue, true);
- final int targetThemeRes = outValue.resourceId;
-
- if (targetThemeRes != 0 /*&& context.getThemeResId() != targetThemeRes*/) {
- context = new ContextThemeWrapper(context, targetThemeRes);
- }
- }
-
- mMenu = new MenuBuilder(context);
- mMenu.setCallback(this);
-
- return true;
- }
-
- void checkCloseActionMenu(Menu menu) {
- if (mClosingActionMenu) {
- return;
- }
-
- mClosingActionMenu = true;
- wActionBar.dismissPopupMenus();
- //Callback cb = getCallback();
- //if (cb != null && !isDestroyed()) {
- // cb.onPanelClosed(FEATURE_ACTION_BAR, menu);
- //}
- mClosingActionMenu = false;
- }
-
- @Override
- public boolean onOpenSubMenu(MenuBuilder subMenu) {
- return true;
- }
-
- @Override
- public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
- checkCloseActionMenu(menu);
- }
-
- @Override
- public boolean onMenuItemClick(android.view.MenuItem item) {
- if (DEBUG) Log.d(TAG, "[mNativeItemListener.onMenuItemClick] item: " + item);
-
- final MenuItemImpl sherlockItem = mNativeItemMap.get(item);
- if (sherlockItem != null) {
- sherlockItem.invoke();
- } else {
- Log.e(TAG, "Options item \"" + item + "\" not found in mapping");
- }
-
- return true; //Do not allow continuation of native handling
- }
-
- @Override
- public boolean onMenuItemSelected(int featureId, MenuItem item) {
- return callbackOptionsItemSelected(item);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Progress bar interaction and internal handling
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void setProgressBarVisibility(boolean visible) {
- if (DEBUG) Log.d(TAG, "[setProgressBarVisibility] visible: " + visible);
-
- setFeatureInt(Window.FEATURE_PROGRESS, visible ? Window.PROGRESS_VISIBILITY_ON :
- Window.PROGRESS_VISIBILITY_OFF);
- }
-
- @Override
- public void setProgressBarIndeterminateVisibility(boolean visible) {
- if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminateVisibility] visible: " + visible);
-
- setFeatureInt(Window.FEATURE_INDETERMINATE_PROGRESS,
- visible ? Window.PROGRESS_VISIBILITY_ON : Window.PROGRESS_VISIBILITY_OFF);
- }
-
- @Override
- public void setProgressBarIndeterminate(boolean indeterminate) {
- if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminate] indeterminate: " + indeterminate);
-
- setFeatureInt(Window.FEATURE_PROGRESS,
- indeterminate ? Window.PROGRESS_INDETERMINATE_ON : Window.PROGRESS_INDETERMINATE_OFF);
- }
-
- @Override
- public void setProgress(int progress) {
- if (DEBUG) Log.d(TAG, "[setProgress] progress: " + progress);
-
- setFeatureInt(Window.FEATURE_PROGRESS, progress + Window.PROGRESS_START);
- }
-
- @Override
- public void setSecondaryProgress(int secondaryProgress) {
- if (DEBUG) Log.d(TAG, "[setSecondaryProgress] secondaryProgress: " + secondaryProgress);
-
- setFeatureInt(Window.FEATURE_PROGRESS,
- secondaryProgress + Window.PROGRESS_SECONDARY_START);
- }
-
- private void setFeatureInt(int featureId, int value) {
- updateInt(featureId, value, false);
- }
-
- private void updateInt(int featureId, int value, boolean fromResume) {
- // Do nothing if the decor is not yet installed... an update will
- // need to be forced when we eventually become active.
- if (mContentParent == null) {
- return;
- }
-
- final int featureMask = 1 << featureId;
-
- if ((getFeatures() & featureMask) == 0 && !fromResume) {
- return;
- }
-
- onIntChanged(featureId, value);
- }
-
- private void onIntChanged(int featureId, int value) {
- if (featureId == Window.FEATURE_PROGRESS || featureId == Window.FEATURE_INDETERMINATE_PROGRESS) {
- updateProgressBars(value);
- }
- }
-
- private void updateProgressBars(int value) {
- IcsProgressBar circularProgressBar = getCircularProgressBar(true);
- IcsProgressBar horizontalProgressBar = getHorizontalProgressBar(true);
-
- final int features = mFeatures;//getLocalFeatures();
- if (value == Window.PROGRESS_VISIBILITY_ON) {
- if ((features & (1 << Window.FEATURE_PROGRESS)) != 0) {
- int level = horizontalProgressBar.getProgress();
- int visibility = (horizontalProgressBar.isIndeterminate() || level < 10000) ?
- View.VISIBLE : View.INVISIBLE;
- horizontalProgressBar.setVisibility(visibility);
- }
- if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0) {
- circularProgressBar.setVisibility(View.VISIBLE);
- }
- } else if (value == Window.PROGRESS_VISIBILITY_OFF) {
- if ((features & (1 << Window.FEATURE_PROGRESS)) != 0) {
- horizontalProgressBar.setVisibility(View.GONE);
- }
- if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0) {
- circularProgressBar.setVisibility(View.GONE);
- }
- } else if (value == Window.PROGRESS_INDETERMINATE_ON) {
- horizontalProgressBar.setIndeterminate(true);
- } else if (value == Window.PROGRESS_INDETERMINATE_OFF) {
- horizontalProgressBar.setIndeterminate(false);
- } else if (Window.PROGRESS_START <= value && value <= Window.PROGRESS_END) {
- // We want to set the progress value before testing for visibility
- // so that when the progress bar becomes visible again, it has the
- // correct level.
- horizontalProgressBar.setProgress(value - Window.PROGRESS_START);
-
- if (value < Window.PROGRESS_END) {
- showProgressBars(horizontalProgressBar, circularProgressBar);
- } else {
- hideProgressBars(horizontalProgressBar, circularProgressBar);
- }
- } else if (Window.PROGRESS_SECONDARY_START <= value && value <= Window.PROGRESS_SECONDARY_END) {
- horizontalProgressBar.setSecondaryProgress(value - Window.PROGRESS_SECONDARY_START);
-
- showProgressBars(horizontalProgressBar, circularProgressBar);
- }
- }
-
- private void showProgressBars(IcsProgressBar horizontalProgressBar, IcsProgressBar spinnyProgressBar) {
- final int features = mFeatures;//getLocalFeatures();
- if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0 &&
- spinnyProgressBar.getVisibility() == View.INVISIBLE) {
- spinnyProgressBar.setVisibility(View.VISIBLE);
- }
- // Only show the progress bars if the primary progress is not complete
- if ((features & (1 << Window.FEATURE_PROGRESS)) != 0 &&
- horizontalProgressBar.getProgress() < 10000) {
- horizontalProgressBar.setVisibility(View.VISIBLE);
- }
- }
-
- private void hideProgressBars(IcsProgressBar horizontalProgressBar, IcsProgressBar spinnyProgressBar) {
- final int features = mFeatures;//getLocalFeatures();
- Animation anim = AnimationUtils.loadAnimation(mActivity, android.R.anim.fade_out);
- anim.setDuration(1000);
- if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0 &&
- spinnyProgressBar.getVisibility() == View.VISIBLE) {
- spinnyProgressBar.startAnimation(anim);
- spinnyProgressBar.setVisibility(View.INVISIBLE);
- }
- if ((features & (1 << Window.FEATURE_PROGRESS)) != 0 &&
- horizontalProgressBar.getVisibility() == View.VISIBLE) {
- horizontalProgressBar.startAnimation(anim);
- horizontalProgressBar.setVisibility(View.INVISIBLE);
- }
- }
-
- private IcsProgressBar getCircularProgressBar(boolean shouldInstallDecor) {
- if (mCircularProgressBar != null) {
- return mCircularProgressBar;
- }
- if (mContentParent == null && shouldInstallDecor) {
- installDecor();
- }
- mCircularProgressBar = (IcsProgressBar)mDecor.findViewById(R.id.abs__progress_circular);
- if (mCircularProgressBar != null) {
- mCircularProgressBar.setVisibility(View.INVISIBLE);
- }
- return mCircularProgressBar;
- }
-
- private IcsProgressBar getHorizontalProgressBar(boolean shouldInstallDecor) {
- if (mHorizontalProgressBar != null) {
- return mHorizontalProgressBar;
- }
- if (mContentParent == null && shouldInstallDecor) {
- installDecor();
- }
- mHorizontalProgressBar = (IcsProgressBar)mDecor.findViewById(R.id.abs__progress_horizontal);
- if (mHorizontalProgressBar != null) {
- mHorizontalProgressBar.setVisibility(View.INVISIBLE);
- }
- return mHorizontalProgressBar;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Feature management and content interaction and creation
- ///////////////////////////////////////////////////////////////////////////
-
- private int getFeatures() {
- if (DEBUG) Log.d(TAG, "[getFeatures] returning " + mFeatures);
-
- return mFeatures;
- }
-
- @Override
- public boolean hasFeature(int featureId) {
- if (DEBUG) Log.d(TAG, "[hasFeature] featureId: " + featureId);
-
- boolean result = (mFeatures & (1 << featureId)) != 0;
- if (DEBUG) Log.d(TAG, "[hasFeature] returning " + result);
- return result;
- }
-
- @Override
- public boolean requestFeature(int featureId) {
- if (DEBUG) Log.d(TAG, "[requestFeature] featureId: " + featureId);
-
- if (mContentParent != null) {
- throw new AndroidRuntimeException("requestFeature() must be called before adding content");
- }
-
- switch (featureId) {
- case Window.FEATURE_ACTION_BAR:
- case Window.FEATURE_ACTION_BAR_OVERLAY:
- case Window.FEATURE_ACTION_MODE_OVERLAY:
- case Window.FEATURE_INDETERMINATE_PROGRESS:
- case Window.FEATURE_NO_TITLE:
- case Window.FEATURE_PROGRESS:
- mFeatures |= (1 << featureId);
- return true;
-
- default:
- return false;
- }
- }
-
- @Override
- public void setUiOptions(int uiOptions) {
- if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions);
-
- mUiOptions = uiOptions;
- }
-
- @Override
- public void setUiOptions(int uiOptions, int mask) {
- if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions + ", mask: " + mask);
-
- mUiOptions = (mUiOptions & ~mask) | (uiOptions & mask);
- }
-
- @Override
- public void setContentView(int layoutResId) {
- if (DEBUG) Log.d(TAG, "[setContentView] layoutResId: " + layoutResId);
-
- if (mContentParent == null) {
- installDecor();
- } else {
- mContentParent.removeAllViews();
- }
- mActivity.getLayoutInflater().inflate(layoutResId, mContentParent);
-
- android.view.Window.Callback callback = mActivity.getWindow().getCallback();
- if (callback != null) {
- callback.onContentChanged();
- }
-
- initActionBar();
- }
-
- @Override
- public void setContentView(View view, ViewGroup.LayoutParams params) {
- if (DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params);
-
- if (mContentParent == null) {
- installDecor();
- } else {
- mContentParent.removeAllViews();
- }
- mContentParent.addView(view, params);
-
- android.view.Window.Callback callback = mActivity.getWindow().getCallback();
- if (callback != null) {
- callback.onContentChanged();
- }
-
- initActionBar();
- }
-
- @Override
- public void addContentView(View view, ViewGroup.LayoutParams params) {
- if (DEBUG) Log.d(TAG, "[addContentView] view: " + view + ", params: " + params);
-
- if (mContentParent == null) {
- installDecor();
- }
- mContentParent.addView(view, params);
-
- initActionBar();
- }
-
- private void installDecor() {
- if (DEBUG) Log.d(TAG, "[installDecor]");
-
- if (mDecor == null) {
- mDecor = (ViewGroup)mActivity.getWindow().getDecorView().findViewById(android.R.id.content);
- }
- if (mContentParent == null) {
- //Since we are not operating at the window level we need to take
- //into account the fact that the true decor may have already been
- //initialized and had content attached to it. If that is the case,
- //copy over its children to our new content container.
- List views = null;
- if (mDecor.getChildCount() > 0) {
- views = new ArrayList(1); //Usually there's only one child
- for (int i = 0, children = mDecor.getChildCount(); i < children; i++) {
- View child = mDecor.getChildAt(0);
- mDecor.removeView(child);
- views.add(child);
- }
- }
-
- mContentParent = generateLayout();
-
- //Copy over the old children. See above for explanation.
- if (views != null) {
- for (View child : views) {
- mContentParent.addView(child);
- }
- }
-
- mTitleView = (TextView)mDecor.findViewById(android.R.id.title);
- if (mTitleView != null) {
- if (hasFeature(Window.FEATURE_NO_TITLE)) {
- mTitleView.setVisibility(View.GONE);
- if (mContentParent instanceof FrameLayout) {
- ((FrameLayout)mContentParent).setForeground(null);
- }
- } else {
- mTitleView.setText(mTitle);
- }
- } else {
- wActionBar = (ActionBarView)mDecor.findViewById(R.id.abs__action_bar);
- if (wActionBar != null) {
- wActionBar.setWindowCallback(this);
- if (wActionBar.getTitle() == null) {
- wActionBar.setWindowTitle(mActivity.getTitle());
- }
- if (hasFeature(Window.FEATURE_PROGRESS)) {
- wActionBar.initProgress();
- }
- if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) {
- wActionBar.initIndeterminateProgress();
- }
-
- //Since we don't require onCreate dispatching, parse for uiOptions here
- int uiOptions = loadUiOptionsFromManifest(mActivity);
- if (uiOptions != 0) {
- mUiOptions = uiOptions;
- }
-
- boolean splitActionBar = false;
- final boolean splitWhenNarrow = (mUiOptions & ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW) != 0;
- if (splitWhenNarrow) {
- splitActionBar = getResources_getBoolean(mActivity, R.bool.abs__split_action_bar_is_narrow);
- } else {
- splitActionBar = mActivity.getTheme()
- .obtainStyledAttributes(R.styleable.SherlockTheme)
- .getBoolean(R.styleable.SherlockTheme_windowSplitActionBar, false);
- }
- final ActionBarContainer splitView = (ActionBarContainer)mDecor.findViewById(R.id.abs__split_action_bar);
- if (splitView != null) {
- wActionBar.setSplitView(splitView);
- wActionBar.setSplitActionBar(splitActionBar);
- wActionBar.setSplitWhenNarrow(splitWhenNarrow);
-
- mActionModeView = (ActionBarContextView)mDecor.findViewById(R.id.abs__action_context_bar);
- mActionModeView.setSplitView(splitView);
- mActionModeView.setSplitActionBar(splitActionBar);
- mActionModeView.setSplitWhenNarrow(splitWhenNarrow);
- } else if (splitActionBar) {
- Log.e(TAG, "Requested split action bar with incompatible window decor! Ignoring request.");
- }
-
- // Post the panel invalidate for later; avoid application onCreateOptionsMenu
- // being called in the middle of onCreate or similar.
- mDecor.post(new Runnable() {
- @Override
- public void run() {
- //Invalidate if the panel menu hasn't been created before this.
- if (!mIsDestroyed && !mActivity.isFinishing() && mMenu == null) {
- dispatchInvalidateOptionsMenu();
- }
- }
- });
- }
- }
- }
- }
-
- private ViewGroup generateLayout() {
- if (DEBUG) Log.d(TAG, "[generateLayout]");
-
- // Apply data from current theme.
-
- TypedArray a = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme);
-
- mIsFloating = a.getBoolean(R.styleable.SherlockTheme_android_windowIsFloating, false);
-
- if (!a.hasValue(R.styleable.SherlockTheme_windowActionBar)) {
- throw new IllegalStateException("You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.");
- }
-
- if (a.getBoolean(R.styleable.SherlockTheme_windowNoTitle, false)) {
- requestFeature(Window.FEATURE_NO_TITLE);
- } else if (a.getBoolean(R.styleable.SherlockTheme_windowActionBar, false)) {
- // Don't allow an action bar if there is no title.
- requestFeature(Window.FEATURE_ACTION_BAR);
- }
-
- if (a.getBoolean(R.styleable.SherlockTheme_windowActionBarOverlay, false)) {
- requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
- }
-
- if (a.getBoolean(R.styleable.SherlockTheme_windowActionModeOverlay, false)) {
- requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
- }
-
- a.recycle();
-
- int layoutResource;
- if (!hasFeature(Window.FEATURE_NO_TITLE)) {
- if (mIsFloating) {
- //Trash original dialog LinearLayout
- mDecor = (ViewGroup)mDecor.getParent();
- mDecor.removeAllViews();
-
- layoutResource = R.layout.abs__dialog_title_holo;
- } else {
- if (hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) {
- layoutResource = R.layout.abs__screen_action_bar_overlay;
- } else {
- layoutResource = R.layout.abs__screen_action_bar;
- }
- }
- } else if (hasFeature(Window.FEATURE_ACTION_MODE_OVERLAY) && !hasFeature(Window.FEATURE_NO_TITLE)) {
- layoutResource = R.layout.abs__screen_simple_overlay_action_mode;
- } else {
- layoutResource = R.layout.abs__screen_simple;
- }
-
- if (DEBUG) Log.d(TAG, "[generateLayout] using screen XML " + mActivity.getResources().getString(layoutResource));
- View in = mActivity.getLayoutInflater().inflate(layoutResource, null);
- mDecor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
-
- ViewGroup contentParent = (ViewGroup)mDecor.findViewById(R.id.abs__content);
- if (contentParent == null) {
- throw new RuntimeException("Couldn't find content container view");
- }
-
- //Make our new child the true content view (for fragments). VERY VOLATILE!
- mDecor.setId(View.NO_ID);
- contentParent.setId(android.R.id.content);
-
- if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) {
- IcsProgressBar progress = getCircularProgressBar(false);
- if (progress != null) {
- progress.setIndeterminate(true);
- }
- }
-
- return contentParent;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Miscellaneous
- ///////////////////////////////////////////////////////////////////////////
-
- /**
- * Determine whether or not the device has a dedicated menu key.
- *
- * @return {@code true} if native menu key is present.
- */
- private boolean isReservingOverflow() {
- if (!mReserveOverflowSet) {
- mReserveOverflow = ActionMenuPresenter.reserveOverflow(mActivity);
- mReserveOverflowSet = true;
- }
- return mReserveOverflow;
- }
-
- private static int loadUiOptionsFromManifest(Activity activity) {
- int uiOptions = 0;
- try {
- final String thisPackage = activity.getClass().getName();
- if (DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage);
-
- final String packageName = activity.getApplicationInfo().packageName;
- final AssetManager am = activity.createPackageContext(packageName, 0).getAssets();
- final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");
-
- int eventType = xml.getEventType();
- while (eventType != XmlPullParser.END_DOCUMENT) {
- if (eventType == XmlPullParser.START_TAG) {
- String name = xml.getName();
-
- if ("application".equals(name)) {
- //Check if the has the attribute
- if (DEBUG) Log.d(TAG, "Got ");
-
- for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
- if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));
-
- if ("uiOptions".equals(xml.getAttributeName(i))) {
- uiOptions = xml.getAttributeIntValue(i, 0);
- break; //out of for loop
- }
- }
- } else if ("activity".equals(name)) {
- //Check if the is us and has the attribute
- if (DEBUG) Log.d(TAG, "Got ");
- Integer activityUiOptions = null;
- String activityPackage = null;
- boolean isOurActivity = false;
-
- for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
- if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));
-
- //We need both uiOptions and name attributes
- String attrName = xml.getAttributeName(i);
- if ("uiOptions".equals(attrName)) {
- activityUiOptions = xml.getAttributeIntValue(i, 0);
- } else if ("name".equals(attrName)) {
- activityPackage = cleanActivityName(packageName, xml.getAttributeValue(i));
- if (!thisPackage.equals(activityPackage)) {
- break; //out of for loop
- }
- isOurActivity = true;
- }
-
- //Make sure we have both attributes before processing
- if ((activityUiOptions != null) && (activityPackage != null)) {
- //Our activity, uiOptions specified, override with our value
- uiOptions = activityUiOptions.intValue();
- }
- }
- if (isOurActivity) {
- //If we matched our activity but it had no logo don't
- //do any more processing of the manifest
- break;
- }
- }
- }
- eventType = xml.nextToken();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(uiOptions));
- return uiOptions;
- }
-
- public static String cleanActivityName(String manifestPackage, String activityName) {
- if (activityName.charAt(0) == '.') {
- //Relative activity name (e.g., android:name=".ui.SomeClass")
- return manifestPackage + activityName;
- }
- if (activityName.indexOf('.', 1) == -1) {
- //Unqualified activity name (e.g., android:name="SomeClass")
- return manifestPackage + "." + activityName;
- }
- //Fully-qualified activity name (e.g., "com.my.package.SomeClass")
- return activityName;
- }
-
- /**
- * Clears out internal reference when the action mode is destroyed.
- */
- private class ActionModeCallbackWrapper implements ActionMode.Callback {
- private final ActionMode.Callback mWrapped;
-
- public ActionModeCallbackWrapper(ActionMode.Callback wrapped) {
- mWrapped = wrapped;
- }
-
- public boolean onCreateActionMode(ActionMode mode, Menu menu) {
- return mWrapped.onCreateActionMode(mode, menu);
- }
-
- public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
- return mWrapped.onPrepareActionMode(mode, menu);
- }
-
- public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
- return mWrapped.onActionItemClicked(mode, item);
- }
-
- public void onDestroyActionMode(ActionMode mode) {
- mWrapped.onDestroyActionMode(mode);
- if (mActionModeView != null) {
- mActionModeView.setVisibility(View.GONE);
- mActionModeView.removeAllViews();
- }
- if (mActivity instanceof OnActionModeFinishedListener) {
- ((OnActionModeFinishedListener)mActivity).onActionModeFinished(mActionMode);
- }
- mActionMode = null;
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java
deleted file mode 100644
index 9afca185a5..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java
+++ /dev/null
@@ -1,328 +0,0 @@
-package com.actionbarsherlock.internal;
-
-import com.actionbarsherlock.ActionBarSherlock;
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.internal.app.ActionBarWrapper;
-import com.actionbarsherlock.internal.view.menu.MenuWrapper;
-import com.actionbarsherlock.view.ActionMode;
-import com.actionbarsherlock.view.MenuInflater;
-import android.app.Activity;
-import android.content.Context;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.ContextThemeWrapper;
-import android.view.View;
-import android.view.Window;
-import android.view.ViewGroup.LayoutParams;
-
-@ActionBarSherlock.Implementation(api = 14)
-public class ActionBarSherlockNative extends ActionBarSherlock {
- private ActionBarWrapper mActionBar;
- private ActionModeWrapper mActionMode;
- private MenuWrapper mMenu;
-
- public ActionBarSherlockNative(Activity activity, int flags) {
- super(activity, flags);
- }
-
-
- @Override
- public ActionBar getActionBar() {
- if (DEBUG) Log.d(TAG, "[getActionBar]");
-
- initActionBar();
- return mActionBar;
- }
-
- private void initActionBar() {
- if (mActionBar != null || mActivity.getActionBar() == null) {
- return;
- }
-
- mActionBar = new ActionBarWrapper(mActivity);
- }
-
- @Override
- public void dispatchInvalidateOptionsMenu() {
- if (DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu]");
-
- mActivity.getWindow().invalidatePanelMenu(Window.FEATURE_OPTIONS_PANEL);
- }
-
- @Override
- public boolean dispatchCreateOptionsMenu(android.view.Menu menu) {
- if (DEBUG) Log.d(TAG, "[dispatchCreateOptionsMenu] menu: " + menu);
-
- if (mMenu == null || menu != mMenu.unwrap()) {
- mMenu = new MenuWrapper(menu);
- }
-
- final boolean result = callbackCreateOptionsMenu(mMenu);
- if (DEBUG) Log.d(TAG, "[dispatchCreateOptionsMenu] returning " + result);
- return result;
- }
-
- @Override
- public boolean dispatchPrepareOptionsMenu(android.view.Menu menu) {
- if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] menu: " + menu);
-
- final boolean result = callbackPrepareOptionsMenu(mMenu);
- if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] returning " + result);
- return result;
- }
-
- @Override
- public boolean dispatchOptionsItemSelected(android.view.MenuItem item) {
- if (DEBUG) Log.d(TAG, "[dispatchOptionsItemSelected] item: " + item.getTitleCondensed());
-
- final boolean result = callbackOptionsItemSelected(mMenu.findItem(item));
- if (DEBUG) Log.d(TAG, "[dispatchOptionsItemSelected] returning " + result);
- return result;
- }
-
- @Override
- public boolean hasFeature(int feature) {
- if (DEBUG) Log.d(TAG, "[hasFeature] feature: " + feature);
-
- final boolean result = mActivity.getWindow().hasFeature(feature);
- if (DEBUG) Log.d(TAG, "[hasFeature] returning " + result);
- return result;
- }
-
- @Override
- public boolean requestFeature(int featureId) {
- if (DEBUG) Log.d(TAG, "[requestFeature] featureId: " + featureId);
-
- final boolean result = mActivity.getWindow().requestFeature(featureId);
- if (DEBUG) Log.d(TAG, "[requestFeature] returning " + result);
- return result;
- }
-
- @Override
- public void setUiOptions(int uiOptions) {
- if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions);
-
- mActivity.getWindow().setUiOptions(uiOptions);
- }
-
- @Override
- public void setUiOptions(int uiOptions, int mask) {
- if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions + ", mask: " + mask);
-
- mActivity.getWindow().setUiOptions(uiOptions, mask);
- }
-
- @Override
- public void setContentView(int layoutResId) {
- if (DEBUG) Log.d(TAG, "[setContentView] layoutResId: " + layoutResId);
-
- mActivity.getWindow().setContentView(layoutResId);
- initActionBar();
- }
-
- @Override
- public void setContentView(View view, LayoutParams params) {
- if (DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params);
-
- mActivity.getWindow().setContentView(view, params);
- initActionBar();
- }
-
- @Override
- public void addContentView(View view, LayoutParams params) {
- if (DEBUG) Log.d(TAG, "[addContentView] view: " + view + ", params: " + params);
-
- mActivity.getWindow().addContentView(view, params);
- initActionBar();
- }
-
- @Override
- public void setTitle(CharSequence title) {
- if (DEBUG) Log.d(TAG, "[setTitle] title: " + title);
-
- mActivity.getWindow().setTitle(title);
- }
-
- @Override
- public void setProgressBarVisibility(boolean visible) {
- if (DEBUG) Log.d(TAG, "[setProgressBarVisibility] visible: " + visible);
-
- mActivity.setProgressBarVisibility(visible);
- }
-
- @Override
- public void setProgressBarIndeterminateVisibility(boolean visible) {
- if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminateVisibility] visible: " + visible);
-
- mActivity.setProgressBarIndeterminateVisibility(visible);
- }
-
- @Override
- public void setProgressBarIndeterminate(boolean indeterminate) {
- if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminate] indeterminate: " + indeterminate);
-
- mActivity.setProgressBarIndeterminate(indeterminate);
- }
-
- @Override
- public void setProgress(int progress) {
- if (DEBUG) Log.d(TAG, "[setProgress] progress: " + progress);
-
- mActivity.setProgress(progress);
- }
-
- @Override
- public void setSecondaryProgress(int secondaryProgress) {
- if (DEBUG) Log.d(TAG, "[setSecondaryProgress] secondaryProgress: " + secondaryProgress);
-
- mActivity.setSecondaryProgress(secondaryProgress);
- }
-
- @Override
- protected Context getThemedContext() {
- Context context = mActivity;
- TypedValue outValue = new TypedValue();
- mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme, outValue, true);
- if (outValue.resourceId != 0) {
- //We are unable to test if this is the same as our current theme
- //so we just wrap it and hope that if the attribute was specified
- //then the user is intentionally specifying an alternate theme.
- context = new ContextThemeWrapper(context, outValue.resourceId);
- }
- return context;
- }
-
- @Override
- public ActionMode startActionMode(com.actionbarsherlock.view.ActionMode.Callback callback) {
- if (DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback);
-
- if (mActionMode != null) {
- mActionMode.finish();
- }
- ActionModeCallbackWrapper wrapped = null;
- if (callback != null) {
- wrapped = new ActionModeCallbackWrapper(callback);
- }
-
- //Calling this will trigger the callback wrapper's onCreate which
- //is where we will set the new instance to mActionMode since we need
- //to pass it through to the sherlock callbacks and the call below
- //will not have returned yet to store its value.
- mActivity.startActionMode(wrapped);
-
- return mActionMode;
- }
-
- private class ActionModeCallbackWrapper implements android.view.ActionMode.Callback {
- private final ActionMode.Callback mCallback;
-
- public ActionModeCallbackWrapper(ActionMode.Callback callback) {
- mCallback = callback;
- }
-
- @Override
- public boolean onCreateActionMode(android.view.ActionMode mode, android.view.Menu menu) {
- //See ActionBarSherlockNative#startActionMode
- mActionMode = new ActionModeWrapper(mode);
-
- return mCallback.onCreateActionMode(mActionMode, mActionMode.getMenu());
- }
-
- @Override
- public boolean onPrepareActionMode(android.view.ActionMode mode, android.view.Menu menu) {
- return mCallback.onPrepareActionMode(mActionMode, mActionMode.getMenu());
- }
-
- @Override
- public boolean onActionItemClicked(android.view.ActionMode mode, android.view.MenuItem item) {
- return mCallback.onActionItemClicked(mActionMode, mActionMode.getMenu().findItem(item));
- }
-
- @Override
- public void onDestroyActionMode(android.view.ActionMode mode) {
- mCallback.onDestroyActionMode(mActionMode);
- }
- }
-
- private class ActionModeWrapper extends ActionMode {
- private final android.view.ActionMode mActionMode;
- private MenuWrapper mMenu = null;
-
- ActionModeWrapper(android.view.ActionMode actionMode) {
- mActionMode = actionMode;
- }
-
- @Override
- public void setTitle(CharSequence title) {
- mActionMode.setTitle(title);
- }
-
- @Override
- public void setTitle(int resId) {
- mActionMode.setTitle(resId);
- }
-
- @Override
- public void setSubtitle(CharSequence subtitle) {
- mActionMode.setSubtitle(subtitle);
- }
-
- @Override
- public void setSubtitle(int resId) {
- mActionMode.setSubtitle(resId);
- }
-
- @Override
- public void setCustomView(View view) {
- mActionMode.setCustomView(view);
- }
-
- @Override
- public void invalidate() {
- mActionMode.invalidate();
- }
-
- @Override
- public void finish() {
- mActionMode.finish();
- }
-
- @Override
- public MenuWrapper getMenu() {
- if (mMenu == null) {
- mMenu = new MenuWrapper(mActionMode.getMenu());
- }
- return mMenu;
- }
-
- @Override
- public CharSequence getTitle() {
- return mActionMode.getTitle();
- }
-
- @Override
- public CharSequence getSubtitle() {
- return mActionMode.getSubtitle();
- }
-
- @Override
- public View getCustomView() {
- return mActionMode.getCustomView();
- }
-
- @Override
- public MenuInflater getMenuInflater() {
- return ActionBarSherlockNative.this.getMenuInflater();
- }
-
- @Override
- public void setTag(Object tag) {
- mActionMode.setTag(tag);
- }
-
- @Override
- public Object getTag() {
- return mActionMode.getTag();
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/ResourcesCompat.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/ResourcesCompat.java
deleted file mode 100644
index 8e1efe8c54..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/ResourcesCompat.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package com.actionbarsherlock.internal;
-
-import android.content.Context;
-import android.os.Build;
-import android.util.DisplayMetrics;
-import com.actionbarsherlock.R;
-
-public final class ResourcesCompat {
- //No instances
- private ResourcesCompat() {}
-
-
- /**
- * Support implementation of {@code getResources().getBoolean()} that we
- * can use to simulate filtering based on width and smallest width
- * qualifiers on pre-3.2.
- *
- * @param context Context to load booleans from on 3.2+ and to fetch the
- * display metrics.
- * @param id Id of boolean to load.
- * @return Associated boolean value as reflected by the current display
- * metrics.
- */
- public static boolean getResources_getBoolean(Context context, int id) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
- return context.getResources().getBoolean(id);
- }
-
- DisplayMetrics metrics = context.getResources().getDisplayMetrics();
- float widthDp = metrics.widthPixels / metrics.density;
- float heightDp = metrics.heightPixels / metrics.density;
- float smallestWidthDp = (widthDp < heightDp) ? widthDp : heightDp;
-
- if (id == R.bool.abs__action_bar_embed_tabs) {
- if (widthDp >= 480) {
- return true; //values-w480dp
- }
- return false; //values
- }
- if (id == R.bool.abs__split_action_bar_is_narrow) {
- if (widthDp >= 480) {
- return false; //values-w480dp
- }
- return true; //values
- }
- if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
- if (smallestWidthDp >= 600) {
- return false; //values-sw600dp
- }
- return true; //values
- }
- if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
- if (widthDp >= 480) {
- return true; //values-w480dp
- }
- return false; //values
- }
-
- throw new IllegalArgumentException("Unknown boolean resource ID " + id);
- }
-
- /**
- * Support implementation of {@code getResources().getInteger()} that we
- * can use to simulate filtering based on width qualifiers on pre-3.2.
- *
- * @param context Context to load integers from on 3.2+ and to fetch the
- * display metrics.
- * @param id Id of integer to load.
- * @return Associated integer value as reflected by the current display
- * metrics.
- */
- public static int getResources_getInteger(Context context, int id) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
- return context.getResources().getInteger(id);
- }
-
- DisplayMetrics metrics = context.getResources().getDisplayMetrics();
- float widthDp = metrics.widthPixels / metrics.density;
-
- if (id == R.integer.abs__max_action_buttons) {
- if (widthDp >= 600) {
- return 5; //values-w600dp
- }
- if (widthDp >= 500) {
- return 4; //values-w500dp
- }
- if (widthDp >= 360) {
- return 3; //values-w360dp
- }
- return 2; //values
- }
-
- throw new IllegalArgumentException("Unknown integer resource ID " + id);
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/app/ActionBarImpl.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/app/ActionBarImpl.java
deleted file mode 100644
index 6ae0402c0e..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/app/ActionBarImpl.java
+++ /dev/null
@@ -1,1026 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.app;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import android.app.Activity;
-import android.app.Dialog;
-import android.content.Context;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.os.Handler;
-import android.support.v4.app.FragmentTransaction;
-import android.util.TypedValue;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.Window;
-import android.view.accessibility.AccessibilityEvent;
-import android.widget.SpinnerAdapter;
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-import com.actionbarsherlock.internal.nineoldandroids.animation.Animator;
-import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorListenerAdapter;
-import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet;
-import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator;
-import com.actionbarsherlock.internal.nineoldandroids.animation.Animator.AnimatorListener;
-import com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout;
-import com.actionbarsherlock.internal.view.menu.MenuBuilder;
-import com.actionbarsherlock.internal.view.menu.MenuPopupHelper;
-import com.actionbarsherlock.internal.view.menu.SubMenuBuilder;
-import com.actionbarsherlock.internal.widget.ActionBarContainer;
-import com.actionbarsherlock.internal.widget.ActionBarContextView;
-import com.actionbarsherlock.internal.widget.ActionBarView;
-import com.actionbarsherlock.internal.widget.ScrollingTabContainerView;
-import com.actionbarsherlock.view.ActionMode;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean;
-
-/**
- * ActionBarImpl is the ActionBar implementation used
- * by devices of all screen sizes. If it detects a compatible decor,
- * it will split contextual modes across both the ActionBarView at
- * the top of the screen and a horizontal LinearLayout at the bottom
- * which is normally hidden.
- */
-public class ActionBarImpl extends ActionBar {
- //UNUSED private static final String TAG = "ActionBarImpl";
-
- private Context mContext;
- private Context mThemedContext;
- private Activity mActivity;
- //UNUSED private Dialog mDialog;
-
- private ActionBarContainer mContainerView;
- private ActionBarView mActionView;
- private ActionBarContextView mContextView;
- private ActionBarContainer mSplitView;
- private NineFrameLayout mContentView;
- private ScrollingTabContainerView mTabScrollView;
-
- private ArrayList mTabs = new ArrayList();
-
- private TabImpl mSelectedTab;
- private int mSavedTabPosition = INVALID_POSITION;
-
- ActionModeImpl mActionMode;
- ActionMode mDeferredDestroyActionMode;
- ActionMode.Callback mDeferredModeDestroyCallback;
-
- private boolean mLastMenuVisibility;
- private ArrayList mMenuVisibilityListeners =
- new ArrayList();
-
- private static final int CONTEXT_DISPLAY_NORMAL = 0;
- private static final int CONTEXT_DISPLAY_SPLIT = 1;
-
- private static final int INVALID_POSITION = -1;
-
- private int mContextDisplayMode;
- private boolean mHasEmbeddedTabs;
-
- final Handler mHandler = new Handler();
- Runnable mTabSelector;
-
- private Animator mCurrentShowAnim;
- private Animator mCurrentModeAnim;
- private boolean mShowHideAnimationEnabled;
- boolean mWasHiddenBeforeMode;
-
- final AnimatorListener mHideListener = new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- if (mContentView != null) {
- mContentView.setTranslationY(0);
- mContainerView.setTranslationY(0);
- }
- if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
- mSplitView.setVisibility(View.GONE);
- }
- mContainerView.setVisibility(View.GONE);
- mContainerView.setTransitioning(false);
- mCurrentShowAnim = null;
- completeDeferredDestroyActionMode();
- }
- };
-
- final AnimatorListener mShowListener = new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- mCurrentShowAnim = null;
- mContainerView.requestLayout();
- }
- };
-
- public ActionBarImpl(Activity activity, int features) {
- mActivity = activity;
- Window window = activity.getWindow();
- View decor = window.getDecorView();
- init(decor);
-
- //window.hasFeature() workaround for pre-3.0
- if ((features & (1 << Window.FEATURE_ACTION_BAR_OVERLAY)) == 0) {
- mContentView = (NineFrameLayout)decor.findViewById(android.R.id.content);
- }
- }
-
- public ActionBarImpl(Dialog dialog) {
- //UNUSED mDialog = dialog;
- init(dialog.getWindow().getDecorView());
- }
-
- private void init(View decor) {
- mContext = decor.getContext();
- mActionView = (ActionBarView) decor.findViewById(R.id.abs__action_bar);
- mContextView = (ActionBarContextView) decor.findViewById(
- R.id.abs__action_context_bar);
- mContainerView = (ActionBarContainer) decor.findViewById(
- R.id.abs__action_bar_container);
- mSplitView = (ActionBarContainer) decor.findViewById(
- R.id.abs__split_action_bar);
-
- if (mActionView == null || mContextView == null || mContainerView == null) {
- throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
- "with a compatible window decor layout");
- }
-
- mActionView.setContextView(mContextView);
- mContextDisplayMode = mActionView.isSplitActionBar() ?
- CONTEXT_DISPLAY_SPLIT : CONTEXT_DISPLAY_NORMAL;
-
- // Older apps get the home button interaction enabled by default.
- // Newer apps need to enable it explicitly.
- setHomeButtonEnabled(mContext.getApplicationInfo().targetSdkVersion < 14);
-
- setHasEmbeddedTabs(getResources_getBoolean(mContext,
- R.bool.abs__action_bar_embed_tabs));
- }
-
- public void onConfigurationChanged(Configuration newConfig) {
- setHasEmbeddedTabs(getResources_getBoolean(mContext,
- R.bool.abs__action_bar_embed_tabs));
-
- //Manually dispatch a configuration change to the action bar view on pre-2.2
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
- mActionView.onConfigurationChanged(newConfig);
- if (mContextView != null) {
- mContextView.onConfigurationChanged(newConfig);
- }
- }
- }
-
- private void setHasEmbeddedTabs(boolean hasEmbeddedTabs) {
- mHasEmbeddedTabs = hasEmbeddedTabs;
- // Switch tab layout configuration if needed
- if (!mHasEmbeddedTabs) {
- mActionView.setEmbeddedTabView(null);
- mContainerView.setTabContainer(mTabScrollView);
- } else {
- mContainerView.setTabContainer(null);
- mActionView.setEmbeddedTabView(mTabScrollView);
- }
- final boolean isInTabMode = getNavigationMode() == NAVIGATION_MODE_TABS;
- if (mTabScrollView != null) {
- mTabScrollView.setVisibility(isInTabMode ? View.VISIBLE : View.GONE);
- }
- mActionView.setCollapsable(!mHasEmbeddedTabs && isInTabMode);
- }
-
- private void ensureTabsExist() {
- if (mTabScrollView != null) {
- return;
- }
-
- ScrollingTabContainerView tabScroller = new ScrollingTabContainerView(mContext);
-
- if (mHasEmbeddedTabs) {
- tabScroller.setVisibility(View.VISIBLE);
- mActionView.setEmbeddedTabView(tabScroller);
- } else {
- tabScroller.setVisibility(getNavigationMode() == NAVIGATION_MODE_TABS ?
- View.VISIBLE : View.GONE);
- mContainerView.setTabContainer(tabScroller);
- }
- mTabScrollView = tabScroller;
- }
-
- void completeDeferredDestroyActionMode() {
- if (mDeferredModeDestroyCallback != null) {
- mDeferredModeDestroyCallback.onDestroyActionMode(mDeferredDestroyActionMode);
- mDeferredDestroyActionMode = null;
- mDeferredModeDestroyCallback = null;
- }
- }
-
- /**
- * Enables or disables animation between show/hide states.
- * If animation is disabled using this method, animations in progress
- * will be finished.
- *
- * @param enabled true to animate, false to not animate.
- */
- public void setShowHideAnimationEnabled(boolean enabled) {
- mShowHideAnimationEnabled = enabled;
- if (!enabled && mCurrentShowAnim != null) {
- mCurrentShowAnim.end();
- }
- }
-
- public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
- mMenuVisibilityListeners.add(listener);
- }
-
- public void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
- mMenuVisibilityListeners.remove(listener);
- }
-
- public void dispatchMenuVisibilityChanged(boolean isVisible) {
- if (isVisible == mLastMenuVisibility) {
- return;
- }
- mLastMenuVisibility = isVisible;
-
- final int count = mMenuVisibilityListeners.size();
- for (int i = 0; i < count; i++) {
- mMenuVisibilityListeners.get(i).onMenuVisibilityChanged(isVisible);
- }
- }
-
- @Override
- public void setCustomView(int resId) {
- setCustomView(LayoutInflater.from(getThemedContext()).inflate(resId, mActionView, false));
- }
-
- @Override
- public void setDisplayUseLogoEnabled(boolean useLogo) {
- setDisplayOptions(useLogo ? DISPLAY_USE_LOGO : 0, DISPLAY_USE_LOGO);
- }
-
- @Override
- public void setDisplayShowHomeEnabled(boolean showHome) {
- setDisplayOptions(showHome ? DISPLAY_SHOW_HOME : 0, DISPLAY_SHOW_HOME);
- }
-
- @Override
- public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) {
- setDisplayOptions(showHomeAsUp ? DISPLAY_HOME_AS_UP : 0, DISPLAY_HOME_AS_UP);
- }
-
- @Override
- public void setDisplayShowTitleEnabled(boolean showTitle) {
- setDisplayOptions(showTitle ? DISPLAY_SHOW_TITLE : 0, DISPLAY_SHOW_TITLE);
- }
-
- @Override
- public void setDisplayShowCustomEnabled(boolean showCustom) {
- setDisplayOptions(showCustom ? DISPLAY_SHOW_CUSTOM : 0, DISPLAY_SHOW_CUSTOM);
- }
-
- @Override
- public void setHomeButtonEnabled(boolean enable) {
- mActionView.setHomeButtonEnabled(enable);
- }
-
- @Override
- public void setTitle(int resId) {
- setTitle(mContext.getString(resId));
- }
-
- @Override
- public void setSubtitle(int resId) {
- setSubtitle(mContext.getString(resId));
- }
-
- public void setSelectedNavigationItem(int position) {
- switch (mActionView.getNavigationMode()) {
- case NAVIGATION_MODE_TABS:
- selectTab(mTabs.get(position));
- break;
- case NAVIGATION_MODE_LIST:
- mActionView.setDropdownSelectedPosition(position);
- break;
- default:
- throw new IllegalStateException(
- "setSelectedNavigationIndex not valid for current navigation mode");
- }
- }
-
- public void removeAllTabs() {
- cleanupTabs();
- }
-
- private void cleanupTabs() {
- if (mSelectedTab != null) {
- selectTab(null);
- }
- mTabs.clear();
- if (mTabScrollView != null) {
- mTabScrollView.removeAllTabs();
- }
- mSavedTabPosition = INVALID_POSITION;
- }
-
- public void setTitle(CharSequence title) {
- mActionView.setTitle(title);
- }
-
- public void setSubtitle(CharSequence subtitle) {
- mActionView.setSubtitle(subtitle);
- }
-
- public void setDisplayOptions(int options) {
- mActionView.setDisplayOptions(options);
- }
-
- public void setDisplayOptions(int options, int mask) {
- final int current = mActionView.getDisplayOptions();
- mActionView.setDisplayOptions((options & mask) | (current & ~mask));
- }
-
- public void setBackgroundDrawable(Drawable d) {
- mContainerView.setPrimaryBackground(d);
- }
-
- public void setStackedBackgroundDrawable(Drawable d) {
- mContainerView.setStackedBackground(d);
- }
-
- public void setSplitBackgroundDrawable(Drawable d) {
- if (mSplitView != null) {
- mSplitView.setSplitBackground(d);
- }
- }
-
- public View getCustomView() {
- return mActionView.getCustomNavigationView();
- }
-
- public CharSequence getTitle() {
- return mActionView.getTitle();
- }
-
- public CharSequence getSubtitle() {
- return mActionView.getSubtitle();
- }
-
- public int getNavigationMode() {
- return mActionView.getNavigationMode();
- }
-
- public int getDisplayOptions() {
- return mActionView.getDisplayOptions();
- }
-
- public ActionMode startActionMode(ActionMode.Callback callback) {
- boolean wasHidden = false;
- if (mActionMode != null) {
- wasHidden = mWasHiddenBeforeMode;
- mActionMode.finish();
- }
-
- mContextView.killMode();
- ActionModeImpl mode = new ActionModeImpl(callback);
- if (mode.dispatchOnCreate()) {
- mWasHiddenBeforeMode = !isShowing() || wasHidden;
- mode.invalidate();
- mContextView.initForMode(mode);
- animateToMode(true);
- if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
- // TODO animate this
- mSplitView.setVisibility(View.VISIBLE);
- }
- mContextView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
- mActionMode = mode;
- return mode;
- }
- return null;
- }
-
- private void configureTab(Tab tab, int position) {
- final TabImpl tabi = (TabImpl) tab;
- final ActionBar.TabListener callback = tabi.getCallback();
-
- if (callback == null) {
- throw new IllegalStateException("Action Bar Tab must have a Callback");
- }
-
- tabi.setPosition(position);
- mTabs.add(position, tabi);
-
- final int count = mTabs.size();
- for (int i = position + 1; i < count; i++) {
- mTabs.get(i).setPosition(i);
- }
- }
-
- @Override
- public void addTab(Tab tab) {
- addTab(tab, mTabs.isEmpty());
- }
-
- @Override
- public void addTab(Tab tab, int position) {
- addTab(tab, position, mTabs.isEmpty());
- }
-
- @Override
- public void addTab(Tab tab, boolean setSelected) {
- ensureTabsExist();
- mTabScrollView.addTab(tab, setSelected);
- configureTab(tab, mTabs.size());
- if (setSelected) {
- selectTab(tab);
- }
- }
-
- @Override
- public void addTab(Tab tab, int position, boolean setSelected) {
- ensureTabsExist();
- mTabScrollView.addTab(tab, position, setSelected);
- configureTab(tab, position);
- if (setSelected) {
- selectTab(tab);
- }
- }
-
- @Override
- public Tab newTab() {
- return new TabImpl();
- }
-
- @Override
- public void removeTab(Tab tab) {
- removeTabAt(tab.getPosition());
- }
-
- @Override
- public void removeTabAt(int position) {
- if (mTabScrollView == null) {
- // No tabs around to remove
- return;
- }
-
- int selectedTabPosition = mSelectedTab != null
- ? mSelectedTab.getPosition() : mSavedTabPosition;
- mTabScrollView.removeTabAt(position);
- TabImpl removedTab = mTabs.remove(position);
- if (removedTab != null) {
- removedTab.setPosition(-1);
- }
-
- final int newTabCount = mTabs.size();
- for (int i = position; i < newTabCount; i++) {
- mTabs.get(i).setPosition(i);
- }
-
- if (selectedTabPosition == position) {
- selectTab(mTabs.isEmpty() ? null : mTabs.get(Math.max(0, position - 1)));
- }
- }
-
- @Override
- public void selectTab(Tab tab) {
- if (getNavigationMode() != NAVIGATION_MODE_TABS) {
- mSavedTabPosition = tab != null ? tab.getPosition() : INVALID_POSITION;
- return;
- }
-
- FragmentTransaction trans = null;
- if (mActivity instanceof SherlockFragmentActivity) {
- trans = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction()
- .disallowAddToBackStack();
- }
-
- if (mSelectedTab == tab) {
- if (mSelectedTab != null) {
- mSelectedTab.getCallback().onTabReselected(mSelectedTab, trans);
- mTabScrollView.animateToTab(tab.getPosition());
- }
- } else {
- mTabScrollView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION);
- if (mSelectedTab != null) {
- mSelectedTab.getCallback().onTabUnselected(mSelectedTab, trans);
- }
- mSelectedTab = (TabImpl) tab;
- if (mSelectedTab != null) {
- mSelectedTab.getCallback().onTabSelected(mSelectedTab, trans);
- }
- }
-
- if (trans != null && !trans.isEmpty()) {
- trans.commit();
- }
- }
-
- @Override
- public Tab getSelectedTab() {
- return mSelectedTab;
- }
-
- @Override
- public int getHeight() {
- return mContainerView.getHeight();
- }
-
- @Override
- public void show() {
- show(true);
- }
-
- void show(boolean markHiddenBeforeMode) {
- if (mCurrentShowAnim != null) {
- mCurrentShowAnim.end();
- }
- if (mContainerView.getVisibility() == View.VISIBLE) {
- if (markHiddenBeforeMode) mWasHiddenBeforeMode = false;
- return;
- }
- mContainerView.setVisibility(View.VISIBLE);
-
- if (mShowHideAnimationEnabled) {
- mContainerView.setAlpha(0);
- AnimatorSet anim = new AnimatorSet();
- AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mContainerView, "alpha", 1));
- if (mContentView != null) {
- b.with(ObjectAnimator.ofFloat(mContentView, "translationY",
- -mContainerView.getHeight(), 0));
- mContainerView.setTranslationY(-mContainerView.getHeight());
- b.with(ObjectAnimator.ofFloat(mContainerView, "translationY", 0));
- }
- if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
- mSplitView.setAlpha(0);
- mSplitView.setVisibility(View.VISIBLE);
- b.with(ObjectAnimator.ofFloat(mSplitView, "alpha", 1));
- }
- anim.addListener(mShowListener);
- mCurrentShowAnim = anim;
- anim.start();
- } else {
- mContainerView.setAlpha(1);
- mContainerView.setTranslationY(0);
- mShowListener.onAnimationEnd(null);
- }
- }
-
- @Override
- public void hide() {
- if (mCurrentShowAnim != null) {
- mCurrentShowAnim.end();
- }
- if (mContainerView.getVisibility() == View.GONE) {
- return;
- }
-
- if (mShowHideAnimationEnabled) {
- mContainerView.setAlpha(1);
- mContainerView.setTransitioning(true);
- AnimatorSet anim = new AnimatorSet();
- AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mContainerView, "alpha", 0));
- if (mContentView != null) {
- b.with(ObjectAnimator.ofFloat(mContentView, "translationY",
- 0, -mContainerView.getHeight()));
- b.with(ObjectAnimator.ofFloat(mContainerView, "translationY",
- -mContainerView.getHeight()));
- }
- if (mSplitView != null && mSplitView.getVisibility() == View.VISIBLE) {
- mSplitView.setAlpha(1);
- b.with(ObjectAnimator.ofFloat(mSplitView, "alpha", 0));
- }
- anim.addListener(mHideListener);
- mCurrentShowAnim = anim;
- anim.start();
- } else {
- mHideListener.onAnimationEnd(null);
- }
- }
-
- public boolean isShowing() {
- return mContainerView.getVisibility() == View.VISIBLE;
- }
-
- void animateToMode(boolean toActionMode) {
- if (toActionMode) {
- show(false);
- }
- if (mCurrentModeAnim != null) {
- mCurrentModeAnim.end();
- }
-
- mActionView.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE);
- mContextView.animateToVisibility(toActionMode ? View.VISIBLE : View.GONE);
- if (mTabScrollView != null && !mActionView.hasEmbeddedTabs() && mActionView.isCollapsed()) {
- mTabScrollView.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE);
- }
- }
-
- public Context getThemedContext() {
- if (mThemedContext == null) {
- TypedValue outValue = new TypedValue();
- Resources.Theme currentTheme = mContext.getTheme();
- currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme,
- outValue, true);
- final int targetThemeRes = outValue.resourceId;
-
- if (targetThemeRes != 0) { //XXX && mContext.getThemeResId() != targetThemeRes) {
- mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes);
- } else {
- mThemedContext = mContext;
- }
- }
- return mThemedContext;
- }
-
- /**
- * @hide
- */
- public class ActionModeImpl extends ActionMode implements MenuBuilder.Callback {
- private ActionMode.Callback mCallback;
- private MenuBuilder mMenu;
- private WeakReference mCustomView;
-
- public ActionModeImpl(ActionMode.Callback callback) {
- mCallback = callback;
- mMenu = new MenuBuilder(getThemedContext())
- .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
- mMenu.setCallback(this);
- }
-
- @Override
- public MenuInflater getMenuInflater() {
- return new MenuInflater(getThemedContext());
- }
-
- @Override
- public Menu getMenu() {
- return mMenu;
- }
-
- @Override
- public void finish() {
- if (mActionMode != this) {
- // Not the active action mode - no-op
- return;
- }
-
- // If we were hidden before the mode was shown, defer the onDestroy
- // callback until the animation is finished and associated relayout
- // is about to happen. This lets apps better anticipate visibility
- // and layout behavior.
- if (mWasHiddenBeforeMode) {
- mDeferredDestroyActionMode = this;
- mDeferredModeDestroyCallback = mCallback;
- } else {
- mCallback.onDestroyActionMode(this);
- }
- mCallback = null;
- animateToMode(false);
-
- // Clear out the context mode views after the animation finishes
- mContextView.closeMode();
- mActionView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
-
- mActionMode = null;
-
- if (mWasHiddenBeforeMode) {
- hide();
- }
- }
-
- @Override
- public void invalidate() {
- mMenu.stopDispatchingItemsChanged();
- try {
- mCallback.onPrepareActionMode(this, mMenu);
- } finally {
- mMenu.startDispatchingItemsChanged();
- }
- }
-
- public boolean dispatchOnCreate() {
- mMenu.stopDispatchingItemsChanged();
- try {
- return mCallback.onCreateActionMode(this, mMenu);
- } finally {
- mMenu.startDispatchingItemsChanged();
- }
- }
-
- @Override
- public void setCustomView(View view) {
- mContextView.setCustomView(view);
- mCustomView = new WeakReference(view);
- }
-
- @Override
- public void setSubtitle(CharSequence subtitle) {
- mContextView.setSubtitle(subtitle);
- }
-
- @Override
- public void setTitle(CharSequence title) {
- mContextView.setTitle(title);
- }
-
- @Override
- public void setTitle(int resId) {
- setTitle(mContext.getResources().getString(resId));
- }
-
- @Override
- public void setSubtitle(int resId) {
- setSubtitle(mContext.getResources().getString(resId));
- }
-
- @Override
- public CharSequence getTitle() {
- return mContextView.getTitle();
- }
-
- @Override
- public CharSequence getSubtitle() {
- return mContextView.getSubtitle();
- }
-
- @Override
- public View getCustomView() {
- return mCustomView != null ? mCustomView.get() : null;
- }
-
- public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
- if (mCallback != null) {
- return mCallback.onActionItemClicked(this, item);
- } else {
- return false;
- }
- }
-
- public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
- }
-
- public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
- if (mCallback == null) {
- return false;
- }
-
- if (!subMenu.hasVisibleItems()) {
- return true;
- }
-
- new MenuPopupHelper(getThemedContext(), subMenu).show();
- return true;
- }
-
- public void onCloseSubMenu(SubMenuBuilder menu) {
- }
-
- public void onMenuModeChange(MenuBuilder menu) {
- if (mCallback == null) {
- return;
- }
- invalidate();
- mContextView.showOverflowMenu();
- }
- }
-
- /**
- * @hide
- */
- public class TabImpl extends ActionBar.Tab {
- private ActionBar.TabListener mCallback;
- private Object mTag;
- private Drawable mIcon;
- private CharSequence mText;
- private CharSequence mContentDesc;
- private int mPosition = -1;
- private View mCustomView;
-
- @Override
- public Object getTag() {
- return mTag;
- }
-
- @Override
- public Tab setTag(Object tag) {
- mTag = tag;
- return this;
- }
-
- public ActionBar.TabListener getCallback() {
- return mCallback;
- }
-
- @Override
- public Tab setTabListener(ActionBar.TabListener callback) {
- mCallback = callback;
- return this;
- }
-
- @Override
- public View getCustomView() {
- return mCustomView;
- }
-
- @Override
- public Tab setCustomView(View view) {
- mCustomView = view;
- if (mPosition >= 0) {
- mTabScrollView.updateTab(mPosition);
- }
- return this;
- }
-
- @Override
- public Tab setCustomView(int layoutResId) {
- return setCustomView(LayoutInflater.from(getThemedContext())
- .inflate(layoutResId, null));
- }
-
- @Override
- public Drawable getIcon() {
- return mIcon;
- }
-
- @Override
- public int getPosition() {
- return mPosition;
- }
-
- public void setPosition(int position) {
- mPosition = position;
- }
-
- @Override
- public CharSequence getText() {
- return mText;
- }
-
- @Override
- public Tab setIcon(Drawable icon) {
- mIcon = icon;
- if (mPosition >= 0) {
- mTabScrollView.updateTab(mPosition);
- }
- return this;
- }
-
- @Override
- public Tab setIcon(int resId) {
- return setIcon(mContext.getResources().getDrawable(resId));
- }
-
- @Override
- public Tab setText(CharSequence text) {
- mText = text;
- if (mPosition >= 0) {
- mTabScrollView.updateTab(mPosition);
- }
- return this;
- }
-
- @Override
- public Tab setText(int resId) {
- return setText(mContext.getResources().getText(resId));
- }
-
- @Override
- public void select() {
- selectTab(this);
- }
-
- @Override
- public Tab setContentDescription(int resId) {
- return setContentDescription(mContext.getResources().getText(resId));
- }
-
- @Override
- public Tab setContentDescription(CharSequence contentDesc) {
- mContentDesc = contentDesc;
- if (mPosition >= 0) {
- mTabScrollView.updateTab(mPosition);
- }
- return this;
- }
-
- @Override
- public CharSequence getContentDescription() {
- return mContentDesc;
- }
- }
-
- @Override
- public void setCustomView(View view) {
- mActionView.setCustomNavigationView(view);
- }
-
- @Override
- public void setCustomView(View view, LayoutParams layoutParams) {
- view.setLayoutParams(layoutParams);
- mActionView.setCustomNavigationView(view);
- }
-
- @Override
- public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) {
- mActionView.setDropdownAdapter(adapter);
- mActionView.setCallback(callback);
- }
-
- @Override
- public int getSelectedNavigationIndex() {
- switch (mActionView.getNavigationMode()) {
- case NAVIGATION_MODE_TABS:
- return mSelectedTab != null ? mSelectedTab.getPosition() : -1;
- case NAVIGATION_MODE_LIST:
- return mActionView.getDropdownSelectedPosition();
- default:
- return -1;
- }
- }
-
- @Override
- public int getNavigationItemCount() {
- switch (mActionView.getNavigationMode()) {
- case NAVIGATION_MODE_TABS:
- return mTabs.size();
- case NAVIGATION_MODE_LIST:
- SpinnerAdapter adapter = mActionView.getDropdownAdapter();
- return adapter != null ? adapter.getCount() : 0;
- default:
- return 0;
- }
- }
-
- @Override
- public int getTabCount() {
- return mTabs.size();
- }
-
- @Override
- public void setNavigationMode(int mode) {
- final int oldMode = mActionView.getNavigationMode();
- switch (oldMode) {
- case NAVIGATION_MODE_TABS:
- mSavedTabPosition = getSelectedNavigationIndex();
- selectTab(null);
- mTabScrollView.setVisibility(View.GONE);
- break;
- }
- mActionView.setNavigationMode(mode);
- switch (mode) {
- case NAVIGATION_MODE_TABS:
- ensureTabsExist();
- mTabScrollView.setVisibility(View.VISIBLE);
- if (mSavedTabPosition != INVALID_POSITION) {
- setSelectedNavigationItem(mSavedTabPosition);
- mSavedTabPosition = INVALID_POSITION;
- }
- break;
- }
- mActionView.setCollapsable(mode == NAVIGATION_MODE_TABS && !mHasEmbeddedTabs);
- }
-
- @Override
- public Tab getTabAt(int index) {
- return mTabs.get(index);
- }
-
-
- @Override
- public void setIcon(int resId) {
- mActionView.setIcon(resId);
- }
-
- @Override
- public void setIcon(Drawable icon) {
- mActionView.setIcon(icon);
- }
-
- @Override
- public void setLogo(int resId) {
- mActionView.setLogo(resId);
- }
-
- @Override
- public void setLogo(Drawable logo) {
- mActionView.setLogo(logo);
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java
deleted file mode 100644
index e390ea4284..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java
+++ /dev/null
@@ -1,468 +0,0 @@
-package com.actionbarsherlock.internal.app;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import android.app.Activity;
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.support.v4.app.FragmentTransaction;
-import android.view.View;
-import android.widget.SpinnerAdapter;
-
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-
-public class ActionBarWrapper extends ActionBar implements android.app.ActionBar.OnNavigationListener, android.app.ActionBar.OnMenuVisibilityListener {
- private final Activity mActivity;
- private final android.app.ActionBar mActionBar;
- private ActionBar.OnNavigationListener mNavigationListener;
- private Set mMenuVisibilityListeners = new HashSet(1);
- private FragmentTransaction mFragmentTransaction;
-
-
- public ActionBarWrapper(Activity activity) {
- mActivity = activity;
- mActionBar = activity.getActionBar();
- if (mActionBar != null) {
- mActionBar.addOnMenuVisibilityListener(this);
- }
- }
-
-
- @Override
- public void setHomeButtonEnabled(boolean enabled) {
- mActionBar.setHomeButtonEnabled(enabled);
- }
-
- @Override
- public Context getThemedContext() {
- return mActionBar.getThemedContext();
- }
-
- @Override
- public void setCustomView(View view) {
- mActionBar.setCustomView(view);
- }
-
- @Override
- public void setCustomView(View view, LayoutParams layoutParams) {
- android.app.ActionBar.LayoutParams lp = new android.app.ActionBar.LayoutParams(layoutParams);
- lp.gravity = layoutParams.gravity;
- lp.bottomMargin = layoutParams.bottomMargin;
- lp.topMargin = layoutParams.topMargin;
- lp.leftMargin = layoutParams.leftMargin;
- lp.rightMargin = layoutParams.rightMargin;
- mActionBar.setCustomView(view, lp);
- }
-
- @Override
- public void setCustomView(int resId) {
- mActionBar.setCustomView(resId);
- }
-
- @Override
- public void setIcon(int resId) {
- mActionBar.setIcon(resId);
- }
-
- @Override
- public void setIcon(Drawable icon) {
- mActionBar.setIcon(icon);
- }
-
- @Override
- public void setLogo(int resId) {
- mActionBar.setLogo(resId);
- }
-
- @Override
- public void setLogo(Drawable logo) {
- mActionBar.setLogo(logo);
- }
-
- @Override
- public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) {
- mNavigationListener = callback;
- mActionBar.setListNavigationCallbacks(adapter, (callback != null) ? this : null);
- }
-
- @Override
- public boolean onNavigationItemSelected(int itemPosition, long itemId) {
- //This should never be a NullPointerException since we only set
- //ourselves as the listener when the callback is not null.
- return mNavigationListener.onNavigationItemSelected(itemPosition, itemId);
- }
-
- @Override
- public void setSelectedNavigationItem(int position) {
- mActionBar.setSelectedNavigationItem(position);
- }
-
- @Override
- public int getSelectedNavigationIndex() {
- return mActionBar.getSelectedNavigationIndex();
- }
-
- @Override
- public int getNavigationItemCount() {
- return mActionBar.getNavigationItemCount();
- }
-
- @Override
- public void setTitle(CharSequence title) {
- mActionBar.setTitle(title);
- }
-
- @Override
- public void setTitle(int resId) {
- mActionBar.setTitle(resId);
- }
-
- @Override
- public void setSubtitle(CharSequence subtitle) {
- mActionBar.setSubtitle(subtitle);
- }
-
- @Override
- public void setSubtitle(int resId) {
- mActionBar.setSubtitle(resId);
- }
-
- @Override
- public void setDisplayOptions(int options) {
- mActionBar.setDisplayOptions(options);
- }
-
- @Override
- public void setDisplayOptions(int options, int mask) {
- mActionBar.setDisplayOptions(options, mask);
- }
-
- @Override
- public void setDisplayUseLogoEnabled(boolean useLogo) {
- mActionBar.setDisplayUseLogoEnabled(useLogo);
- }
-
- @Override
- public void setDisplayShowHomeEnabled(boolean showHome) {
- mActionBar.setDisplayShowHomeEnabled(showHome);
- }
-
- @Override
- public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) {
- mActionBar.setDisplayHomeAsUpEnabled(showHomeAsUp);
- }
-
- @Override
- public void setDisplayShowTitleEnabled(boolean showTitle) {
- mActionBar.setDisplayShowTitleEnabled(showTitle);
- }
-
- @Override
- public void setDisplayShowCustomEnabled(boolean showCustom) {
- mActionBar.setDisplayShowCustomEnabled(showCustom);
- }
-
- @Override
- public void setBackgroundDrawable(Drawable d) {
- mActionBar.setBackgroundDrawable(d);
- }
-
- @Override
- public void setStackedBackgroundDrawable(Drawable d) {
- mActionBar.setStackedBackgroundDrawable(d);
- }
-
- @Override
- public void setSplitBackgroundDrawable(Drawable d) {
- mActionBar.setSplitBackgroundDrawable(d);
- }
-
- @Override
- public View getCustomView() {
- return mActionBar.getCustomView();
- }
-
- @Override
- public CharSequence getTitle() {
- return mActionBar.getTitle();
- }
-
- @Override
- public CharSequence getSubtitle() {
- return mActionBar.getSubtitle();
- }
-
- @Override
- public int getNavigationMode() {
- return mActionBar.getNavigationMode();
- }
-
- @Override
- public void setNavigationMode(int mode) {
- mActionBar.setNavigationMode(mode);
- }
-
- @Override
- public int getDisplayOptions() {
- return mActionBar.getDisplayOptions();
- }
-
- public class TabWrapper extends ActionBar.Tab implements android.app.ActionBar.TabListener {
- final android.app.ActionBar.Tab mNativeTab;
- private Object mTag;
- private TabListener mListener;
-
- public TabWrapper(android.app.ActionBar.Tab nativeTab) {
- mNativeTab = nativeTab;
- mNativeTab.setTag(this);
- }
-
- @Override
- public int getPosition() {
- return mNativeTab.getPosition();
- }
-
- @Override
- public Drawable getIcon() {
- return mNativeTab.getIcon();
- }
-
- @Override
- public CharSequence getText() {
- return mNativeTab.getText();
- }
-
- @Override
- public Tab setIcon(Drawable icon) {
- mNativeTab.setIcon(icon);
- return this;
- }
-
- @Override
- public Tab setIcon(int resId) {
- mNativeTab.setIcon(resId);
- return this;
- }
-
- @Override
- public Tab setText(CharSequence text) {
- mNativeTab.setText(text);
- return this;
- }
-
- @Override
- public Tab setText(int resId) {
- mNativeTab.setText(resId);
- return this;
- }
-
- @Override
- public Tab setCustomView(View view) {
- mNativeTab.setCustomView(view);
- return this;
- }
-
- @Override
- public Tab setCustomView(int layoutResId) {
- mNativeTab.setCustomView(layoutResId);
- return this;
- }
-
- @Override
- public View getCustomView() {
- return mNativeTab.getCustomView();
- }
-
- @Override
- public Tab setTag(Object obj) {
- mTag = obj;
- return this;
- }
-
- @Override
- public Object getTag() {
- return mTag;
- }
-
- @Override
- public Tab setTabListener(TabListener listener) {
- mNativeTab.setTabListener(listener != null ? this : null);
- mListener = listener;
- return this;
- }
-
- @Override
- public void select() {
- mNativeTab.select();
- }
-
- @Override
- public Tab setContentDescription(int resId) {
- mNativeTab.setContentDescription(resId);
- return this;
- }
-
- @Override
- public Tab setContentDescription(CharSequence contentDesc) {
- mNativeTab.setContentDescription(contentDesc);
- return this;
- }
-
- @Override
- public CharSequence getContentDescription() {
- return mNativeTab.getContentDescription();
- }
-
- @Override
- public void onTabReselected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) {
- if (mListener != null) {
- FragmentTransaction trans = null;
- if (mActivity instanceof SherlockFragmentActivity) {
- trans = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction()
- .disallowAddToBackStack();
- }
-
- mListener.onTabReselected(this, trans);
-
- if (trans != null && !trans.isEmpty()) {
- trans.commit();
- }
- }
- }
-
- @Override
- public void onTabSelected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) {
- if (mListener != null) {
-
- if (mFragmentTransaction == null && mActivity instanceof SherlockFragmentActivity) {
- mFragmentTransaction = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction()
- .disallowAddToBackStack();
- }
-
- mListener.onTabSelected(this, mFragmentTransaction);
-
- if (mFragmentTransaction != null) {
- if (!mFragmentTransaction.isEmpty()) {
- mFragmentTransaction.commit();
- }
- mFragmentTransaction = null;
- }
- }
- }
-
- @Override
- public void onTabUnselected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) {
- if (mListener != null) {
- FragmentTransaction trans = null;
- if (mActivity instanceof SherlockFragmentActivity) {
- trans = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction()
- .disallowAddToBackStack();
- mFragmentTransaction = trans;
- }
-
- mListener.onTabUnselected(this, trans);
- }
- }
- }
-
- @Override
- public Tab newTab() {
- return new TabWrapper(mActionBar.newTab());
- }
-
- @Override
- public void addTab(Tab tab) {
- mActionBar.addTab(((TabWrapper)tab).mNativeTab);
- }
-
- @Override
- public void addTab(Tab tab, boolean setSelected) {
- mActionBar.addTab(((TabWrapper)tab).mNativeTab, setSelected);
- }
-
- @Override
- public void addTab(Tab tab, int position) {
- mActionBar.addTab(((TabWrapper)tab).mNativeTab, position);
- }
-
- @Override
- public void addTab(Tab tab, int position, boolean setSelected) {
- mActionBar.addTab(((TabWrapper)tab).mNativeTab, position, setSelected);
- }
-
- @Override
- public void removeTab(Tab tab) {
- mActionBar.removeTab(((TabWrapper)tab).mNativeTab);
- }
-
- @Override
- public void removeTabAt(int position) {
- mActionBar.removeTabAt(position);
- }
-
- @Override
- public void removeAllTabs() {
- mActionBar.removeAllTabs();
- }
-
- @Override
- public void selectTab(Tab tab) {
- mActionBar.selectTab(((TabWrapper)tab).mNativeTab);
- }
-
- @Override
- public Tab getSelectedTab() {
- android.app.ActionBar.Tab selected = mActionBar.getSelectedTab();
- return (selected != null) ? (Tab)selected.getTag() : null;
- }
-
- @Override
- public Tab getTabAt(int index) {
- android.app.ActionBar.Tab selected = mActionBar.getTabAt(index);
- return (selected != null) ? (Tab)selected.getTag() : null;
- }
-
- @Override
- public int getTabCount() {
- return mActionBar.getTabCount();
- }
-
- @Override
- public int getHeight() {
- return mActionBar.getHeight();
- }
-
- @Override
- public void show() {
- mActionBar.show();
- }
-
- @Override
- public void hide() {
- mActionBar.hide();
- }
-
- @Override
- public boolean isShowing() {
- return mActionBar.isShowing();
- }
-
- @Override
- public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
- mMenuVisibilityListeners.add(listener);
- }
-
- @Override
- public void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
- mMenuVisibilityListeners.remove(listener);
- }
-
- @Override
- public void onMenuVisibilityChanged(boolean isVisible) {
- for (OnMenuVisibilityListener listener : mMenuVisibilityListeners) {
- listener.onMenuVisibilityChanged(isVisible);
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java
deleted file mode 100644
index 2caf5b4a96..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation;
-
-import java.util.ArrayList;
-
-import android.view.animation.Interpolator;
-
-/**
- * This is the superclass for classes which provide basic support for animations which can be
- * started, ended, and have AnimatorListeners added to them.
- */
-public abstract class Animator implements Cloneable {
-
-
- /**
- * The set of listeners to be sent events through the life of an animation.
- */
- ArrayList mListeners = null;
-
- /**
- * Starts this animation. If the animation has a nonzero startDelay, the animation will start
- * running after that delay elapses. A non-delayed animation will have its initial
- * value(s) set immediately, followed by calls to
- * {@link AnimatorListener#onAnimationStart(Animator)} for any listeners of this animator.
- *
- *
The animation started by calling this method will be run on the thread that called
- * this method. This thread should have a Looper on it (a runtime exception will be thrown if
- * this is not the case). Also, if the animation will animate
- * properties of objects in the view hierarchy, then the calling thread should be the UI
- * thread for that view hierarchy.
- *
- */
- public void start() {
- }
-
- /**
- * Cancels the animation. Unlike {@link #end()}, cancel() causes the animation to
- * stop in its tracks, sending an
- * {@link android.animation.Animator.AnimatorListener#onAnimationCancel(Animator)} to
- * its listeners, followed by an
- * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} message.
- *
- *
This method must be called on the thread that is running the animation.
- */
- public void cancel() {
- }
-
- /**
- * Ends the animation. This causes the animation to assign the end value of the property being
- * animated, then calling the
- * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} method on
- * its listeners.
- *
- *
This method must be called on the thread that is running the animation.
- */
- public void end() {
- }
-
- /**
- * The amount of time, in milliseconds, to delay starting the animation after
- * {@link #start()} is called.
- *
- * @return the number of milliseconds to delay running the animation
- */
- public abstract long getStartDelay();
-
- /**
- * The amount of time, in milliseconds, to delay starting the animation after
- * {@link #start()} is called.
-
- * @param startDelay The amount of the delay, in milliseconds
- */
- public abstract void setStartDelay(long startDelay);
-
-
- /**
- * Sets the length of the animation.
- *
- * @param duration The length of the animation, in milliseconds.
- */
- public abstract Animator setDuration(long duration);
-
- /**
- * Gets the length of the animation.
- *
- * @return The length of the animation, in milliseconds.
- */
- public abstract long getDuration();
-
- /**
- * The time interpolator used in calculating the elapsed fraction of this animation. The
- * interpolator determines whether the animation runs with linear or non-linear motion,
- * such as acceleration and deceleration. The default value is
- * {@link android.view.animation.AccelerateDecelerateInterpolator}
- *
- * @param value the interpolator to be used by this animation
- */
- public abstract void setInterpolator(/*Time*/Interpolator value);
-
- /**
- * Returns whether this Animator is currently running (having been started and gone past any
- * initial startDelay period and not yet ended).
- *
- * @return Whether the Animator is running.
- */
- public abstract boolean isRunning();
-
- /**
- * Returns whether this Animator has been started and not yet ended. This state is a superset
- * of the state of {@link #isRunning()}, because an Animator with a nonzero
- * {@link #getStartDelay() startDelay} will return true for {@link #isStarted()} during the
- * delay phase, whereas {@link #isRunning()} will return true only after the delay phase
- * is complete.
- *
- * @return Whether the Animator has been started and not yet ended.
- */
- public boolean isStarted() {
- // Default method returns value for isRunning(). Subclasses should override to return a
- // real value.
- return isRunning();
- }
-
- /**
- * Adds a listener to the set of listeners that are sent events through the life of an
- * animation, such as start, repeat, and end.
- *
- * @param listener the listener to be added to the current set of listeners for this animation.
- */
- public void addListener(AnimatorListener listener) {
- if (mListeners == null) {
- mListeners = new ArrayList();
- }
- mListeners.add(listener);
- }
-
- /**
- * Removes a listener from the set listening to this animation.
- *
- * @param listener the listener to be removed from the current set of listeners for this
- * animation.
- */
- public void removeListener(AnimatorListener listener) {
- if (mListeners == null) {
- return;
- }
- mListeners.remove(listener);
- if (mListeners.size() == 0) {
- mListeners = null;
- }
- }
-
- /**
- * Gets the set of {@link android.animation.Animator.AnimatorListener} objects that are currently
- * listening for events on this Animator object.
- *
- * @return ArrayList The set of listeners.
- */
- public ArrayList getListeners() {
- return mListeners;
- }
-
- /**
- * Removes all listeners from this object. This is equivalent to calling
- * getListeners() followed by calling clear() on the
- * returned list of listeners.
- */
- public void removeAllListeners() {
- if (mListeners != null) {
- mListeners.clear();
- mListeners = null;
- }
- }
-
- @Override
- public Animator clone() {
- try {
- final Animator anim = (Animator) super.clone();
- if (mListeners != null) {
- ArrayList oldListeners = mListeners;
- anim.mListeners = new ArrayList();
- int numListeners = oldListeners.size();
- for (int i = 0; i < numListeners; ++i) {
- anim.mListeners.add(oldListeners.get(i));
- }
- }
- return anim;
- } catch (CloneNotSupportedException e) {
- throw new AssertionError();
- }
- }
-
- /**
- * This method tells the object to use appropriate information to extract
- * starting values for the animation. For example, a AnimatorSet object will pass
- * this call to its child objects to tell them to set up the values. A
- * ObjectAnimator object will use the information it has about its target object
- * and PropertyValuesHolder objects to get the start values for its properties.
- * An ValueAnimator object will ignore the request since it does not have enough
- * information (such as a target object) to gather these values.
- */
- public void setupStartValues() {
- }
-
- /**
- * This method tells the object to use appropriate information to extract
- * ending values for the animation. For example, a AnimatorSet object will pass
- * this call to its child objects to tell them to set up the values. A
- * ObjectAnimator object will use the information it has about its target object
- * and PropertyValuesHolder objects to get the start values for its properties.
- * An ValueAnimator object will ignore the request since it does not have enough
- * information (such as a target object) to gather these values.
- */
- public void setupEndValues() {
- }
-
- /**
- * Sets the target object whose property will be animated by this animation. Not all subclasses
- * operate on target objects (for example, {@link ValueAnimator}, but this method
- * is on the superclass for the convenience of dealing generically with those subclasses
- * that do handle targets.
- *
- * @param target The object being animated
- */
- public void setTarget(Object target) {
- }
-
- /**
- *
An animation listener receives notifications from an animation.
- * Notifications indicate animation related events, such as the end or the
- * repetition of the animation.
- *
- * @param animation The started animation.
- */
- void onAnimationStart(Animator animation);
-
- /**
- *
Notifies the end of the animation. This callback is not invoked
- * for animations with repeat count set to INFINITE.
- *
- * @param animation The animation which reached its end.
- */
- void onAnimationEnd(Animator animation);
-
- /**
- *
Notifies the cancellation of the animation. This callback is not invoked
- * for animations with repeat count set to INFINITE.
- *
- * @param animation The animation which was canceled.
- */
- void onAnimationCancel(Animator animation);
-
- /**
- *
Notifies the repetition of the animation.
- *
- * @param animation The animation which was repeated.
- */
- void onAnimationRepeat(Animator animation);
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorListenerAdapter.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorListenerAdapter.java
deleted file mode 100644
index 02ddff48d2..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorListenerAdapter.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation;
-
-/**
- * This adapter class provides empty implementations of the methods from {@link android.animation.Animator.AnimatorListener}.
- * Any custom listener that cares only about a subset of the methods of this listener can
- * simply subclass this adapter class instead of implementing the interface directly.
- */
-public abstract class AnimatorListenerAdapter implements Animator.AnimatorListener {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onAnimationCancel(Animator animation) {
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onAnimationEnd(Animator animation) {
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onAnimationRepeat(Animator animation) {
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onAnimationStart(Animator animation) {
- }
-
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java
deleted file mode 100644
index 3231080c44..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java
+++ /dev/null
@@ -1,1111 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-
-import android.view.animation.Interpolator;
-
-/**
- * This class plays a set of {@link Animator} objects in the specified order. Animations
- * can be set up to play together, in sequence, or after a specified delay.
- *
- *
There are two different approaches to adding animations to a AnimatorSet:
- * either the {@link AnimatorSet#playTogether(Animator[]) playTogether()} or
- * {@link AnimatorSet#playSequentially(Animator[]) playSequentially()} methods can be called to add
- * a set of animations all at once, or the {@link AnimatorSet#play(Animator)} can be
- * used in conjunction with methods in the {@link AnimatorSet.Builder Builder}
- * class to add animations
- * one by one.
- *
- *
It is possible to set up a AnimatorSet with circular dependencies between
- * its animations. For example, an animation a1 could be set up to start before animation a2, a2
- * before a3, and a3 before a1. The results of this configuration are undefined, but will typically
- * result in none of the affected animations being played. Because of this (and because
- * circular dependencies do not make logical sense anyway), circular dependencies
- * should be avoided, and the dependency flow of animations should only be in one direction.
- */
-@SuppressWarnings("unchecked")
-public final class AnimatorSet extends Animator {
-
- /**
- * Internal variables
- * NOTE: This object implements the clone() method, making a deep copy of any referenced
- * objects. As other non-trivial fields are added to this class, make sure to add logic
- * to clone() to make deep copies of them.
- */
-
- /**
- * Tracks animations currently being played, so that we know what to
- * cancel or end when cancel() or end() is called on this AnimatorSet
- */
- private ArrayList mPlayingSet = new ArrayList();
-
- /**
- * Contains all nodes, mapped to their respective Animators. When new
- * dependency information is added for an Animator, we want to add it
- * to a single node representing that Animator, not create a new Node
- * if one already exists.
- */
- private HashMap mNodeMap = new HashMap();
-
- /**
- * Set of all nodes created for this AnimatorSet. This list is used upon
- * starting the set, and the nodes are placed in sorted order into the
- * sortedNodes collection.
- */
- private ArrayList mNodes = new ArrayList();
-
- /**
- * The sorted list of nodes. This is the order in which the animations will
- * be played. The details about when exactly they will be played depend
- * on the dependency relationships of the nodes.
- */
- private ArrayList mSortedNodes = new ArrayList();
-
- /**
- * Flag indicating whether the nodes should be sorted prior to playing. This
- * flag allows us to cache the previous sorted nodes so that if the sequence
- * is replayed with no changes, it does not have to re-sort the nodes again.
- */
- private boolean mNeedsSort = true;
-
- private AnimatorSetListener mSetListener = null;
-
- /**
- * Flag indicating that the AnimatorSet has been manually
- * terminated (by calling cancel() or end()).
- * This flag is used to avoid starting other animations when currently-playing
- * child animations of this AnimatorSet end. It also determines whether cancel/end
- * notifications are sent out via the normal AnimatorSetListener mechanism.
- */
- boolean mTerminated = false;
-
- /**
- * Indicates whether an AnimatorSet has been start()'d, whether or
- * not there is a nonzero startDelay.
- */
- private boolean mStarted = false;
-
- // The amount of time in ms to delay starting the animation after start() is called
- private long mStartDelay = 0;
-
- // Animator used for a nonzero startDelay
- private ValueAnimator mDelayAnim = null;
-
-
- // How long the child animations should last in ms. The default value is negative, which
- // simply means that there is no duration set on the AnimatorSet. When a real duration is
- // set, it is passed along to the child animations.
- private long mDuration = -1;
-
-
- /**
- * Sets up this AnimatorSet to play all of the supplied animations at the same time.
- *
- * @param items The animations that will be started simultaneously.
- */
- public void playTogether(Animator... items) {
- if (items != null) {
- mNeedsSort = true;
- Builder builder = play(items[0]);
- for (int i = 1; i < items.length; ++i) {
- builder.with(items[i]);
- }
- }
- }
-
- /**
- * Sets up this AnimatorSet to play all of the supplied animations at the same time.
- *
- * @param items The animations that will be started simultaneously.
- */
- public void playTogether(Collection items) {
- if (items != null && items.size() > 0) {
- mNeedsSort = true;
- Builder builder = null;
- for (Animator anim : items) {
- if (builder == null) {
- builder = play(anim);
- } else {
- builder.with(anim);
- }
- }
- }
- }
-
- /**
- * Sets up this AnimatorSet to play each of the supplied animations when the
- * previous animation ends.
- *
- * @param items The animations that will be started one after another.
- */
- public void playSequentially(Animator... items) {
- if (items != null) {
- mNeedsSort = true;
- if (items.length == 1) {
- play(items[0]);
- } else {
- for (int i = 0; i < items.length - 1; ++i) {
- play(items[i]).before(items[i+1]);
- }
- }
- }
- }
-
- /**
- * Sets up this AnimatorSet to play each of the supplied animations when the
- * previous animation ends.
- *
- * @param items The animations that will be started one after another.
- */
- public void playSequentially(List items) {
- if (items != null && items.size() > 0) {
- mNeedsSort = true;
- if (items.size() == 1) {
- play(items.get(0));
- } else {
- for (int i = 0; i < items.size() - 1; ++i) {
- play(items.get(i)).before(items.get(i+1));
- }
- }
- }
- }
-
- /**
- * Returns the current list of child Animator objects controlled by this
- * AnimatorSet. This is a copy of the internal list; modifications to the returned list
- * will not affect the AnimatorSet, although changes to the underlying Animator objects
- * will affect those objects being managed by the AnimatorSet.
- *
- * @return ArrayList The list of child animations of this AnimatorSet.
- */
- public ArrayList getChildAnimations() {
- ArrayList childList = new ArrayList();
- for (Node node : mNodes) {
- childList.add(node.animation);
- }
- return childList;
- }
-
- /**
- * Sets the target object for all current {@link #getChildAnimations() child animations}
- * of this AnimatorSet that take targets ({@link ObjectAnimator} and
- * AnimatorSet).
- *
- * @param target The object being animated
- */
- @Override
- public void setTarget(Object target) {
- for (Node node : mNodes) {
- Animator animation = node.animation;
- if (animation instanceof AnimatorSet) {
- ((AnimatorSet)animation).setTarget(target);
- } else if (animation instanceof ObjectAnimator) {
- ((ObjectAnimator)animation).setTarget(target);
- }
- }
- }
-
- /**
- * Sets the TimeInterpolator for all current {@link #getChildAnimations() child animations}
- * of this AnimatorSet.
- *
- * @param interpolator the interpolator to be used by each child animation of this AnimatorSet
- */
- @Override
- public void setInterpolator(/*Time*/Interpolator interpolator) {
- for (Node node : mNodes) {
- node.animation.setInterpolator(interpolator);
- }
- }
-
- /**
- * This method creates a Builder object, which is used to
- * set up playing constraints. This initial play() method
- * tells the Builder the animation that is the dependency for
- * the succeeding commands to the Builder. For example,
- * calling play(a1).with(a2) sets up the AnimatorSet to play
- * a1 and a2 at the same time,
- * play(a1).before(a2) sets up the AnimatorSet to play
- * a1 first, followed by a2, and
- * play(a1).after(a2) sets up the AnimatorSet to play
- * a2 first, followed by a1.
- *
- *
Note that play() is the only way to tell the
- * Builder the animation upon which the dependency is created,
- * so successive calls to the various functions in Builder
- * will all refer to the initial parameter supplied in play()
- * as the dependency of the other animations. For example, calling
- * play(a1).before(a2).before(a3) will play both a2
- * and a3 when a1 ends; it does not set up a dependency between
- * a2 and a3.
- *
- * @param anim The animation that is the dependency used in later calls to the
- * methods in the returned Builder object. A null parameter will result
- * in a null Builder return value.
- * @return Builder The object that constructs the AnimatorSet based on the dependencies
- * outlined in the calls to play and the other methods in the
- * BuilderNote that canceling a AnimatorSet also cancels all of the animations that it
- * is responsible for.
- */
- @Override
- public void cancel() {
- mTerminated = true;
- if (isStarted()) {
- ArrayList tmpListeners = null;
- if (mListeners != null) {
- tmpListeners = (ArrayList) mListeners.clone();
- for (AnimatorListener listener : tmpListeners) {
- listener.onAnimationCancel(this);
- }
- }
- if (mDelayAnim != null && mDelayAnim.isRunning()) {
- // If we're currently in the startDelay period, just cancel that animator and
- // send out the end event to all listeners
- mDelayAnim.cancel();
- } else if (mSortedNodes.size() > 0) {
- for (Node node : mSortedNodes) {
- node.animation.cancel();
- }
- }
- if (tmpListeners != null) {
- for (AnimatorListener listener : tmpListeners) {
- listener.onAnimationEnd(this);
- }
- }
- mStarted = false;
- }
- }
-
- /**
- * {@inheritDoc}
- *
- *
Note that ending a AnimatorSet also ends all of the animations that it is
- * responsible for.
- */
- @Override
- public void end() {
- mTerminated = true;
- if (isStarted()) {
- if (mSortedNodes.size() != mNodes.size()) {
- // hasn't been started yet - sort the nodes now, then end them
- sortNodes();
- for (Node node : mSortedNodes) {
- if (mSetListener == null) {
- mSetListener = new AnimatorSetListener(this);
- }
- node.animation.addListener(mSetListener);
- }
- }
- if (mDelayAnim != null) {
- mDelayAnim.cancel();
- }
- if (mSortedNodes.size() > 0) {
- for (Node node : mSortedNodes) {
- node.animation.end();
- }
- }
- if (mListeners != null) {
- ArrayList tmpListeners =
- (ArrayList) mListeners.clone();
- for (AnimatorListener listener : tmpListeners) {
- listener.onAnimationEnd(this);
- }
- }
- mStarted = false;
- }
- }
-
- /**
- * Returns true if any of the child animations of this AnimatorSet have been started and have
- * not yet ended.
- * @return Whether this AnimatorSet has been started and has not yet ended.
- */
- @Override
- public boolean isRunning() {
- for (Node node : mNodes) {
- if (node.animation.isRunning()) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public boolean isStarted() {
- return mStarted;
- }
-
- /**
- * The amount of time, in milliseconds, to delay starting the animation after
- * {@link #start()} is called.
- *
- * @return the number of milliseconds to delay running the animation
- */
- @Override
- public long getStartDelay() {
- return mStartDelay;
- }
-
- /**
- * The amount of time, in milliseconds, to delay starting the animation after
- * {@link #start()} is called.
-
- * @param startDelay The amount of the delay, in milliseconds
- */
- @Override
- public void setStartDelay(long startDelay) {
- mStartDelay = startDelay;
- }
-
- /**
- * Gets the length of each of the child animations of this AnimatorSet. This value may
- * be less than 0, which indicates that no duration has been set on this AnimatorSet
- * and each of the child animations will use their own duration.
- *
- * @return The length of the animation, in milliseconds, of each of the child
- * animations of this AnimatorSet.
- */
- @Override
- public long getDuration() {
- return mDuration;
- }
-
- /**
- * Sets the length of each of the current child animations of this AnimatorSet. By default,
- * each child animation will use its own duration. If the duration is set on the AnimatorSet,
- * then each child animation inherits this duration.
- *
- * @param duration The length of the animation, in milliseconds, of each of the child
- * animations of this AnimatorSet.
- */
- @Override
- public AnimatorSet setDuration(long duration) {
- if (duration < 0) {
- throw new IllegalArgumentException("duration must be a value of zero or greater");
- }
- for (Node node : mNodes) {
- // TODO: don't set the duration of the timing-only nodes created by AnimatorSet to
- // insert "play-after" delays
- node.animation.setDuration(duration);
- }
- mDuration = duration;
- return this;
- }
-
- @Override
- public void setupStartValues() {
- for (Node node : mNodes) {
- node.animation.setupStartValues();
- }
- }
-
- @Override
- public void setupEndValues() {
- for (Node node : mNodes) {
- node.animation.setupEndValues();
- }
- }
-
- /**
- * {@inheritDoc}
- *
- *
Starting this AnimatorSet will, in turn, start the animations for which
- * it is responsible. The details of when exactly those animations are started depends on
- * the dependency relationships that have been set up between the animations.
- */
- @Override
- public void start() {
- mTerminated = false;
- mStarted = true;
-
- // First, sort the nodes (if necessary). This will ensure that sortedNodes
- // contains the animation nodes in the correct order.
- sortNodes();
-
- int numSortedNodes = mSortedNodes.size();
- for (int i = 0; i < numSortedNodes; ++i) {
- Node node = mSortedNodes.get(i);
- // First, clear out the old listeners
- ArrayList oldListeners = node.animation.getListeners();
- if (oldListeners != null && oldListeners.size() > 0) {
- final ArrayList clonedListeners = new
- ArrayList(oldListeners);
-
- for (AnimatorListener listener : clonedListeners) {
- if (listener instanceof DependencyListener ||
- listener instanceof AnimatorSetListener) {
- node.animation.removeListener(listener);
- }
- }
- }
- }
-
- // nodesToStart holds the list of nodes to be started immediately. We don't want to
- // start the animations in the loop directly because we first need to set up
- // dependencies on all of the nodes. For example, we don't want to start an animation
- // when some other animation also wants to start when the first animation begins.
- final ArrayList nodesToStart = new ArrayList();
- for (int i = 0; i < numSortedNodes; ++i) {
- Node node = mSortedNodes.get(i);
- if (mSetListener == null) {
- mSetListener = new AnimatorSetListener(this);
- }
- if (node.dependencies == null || node.dependencies.size() == 0) {
- nodesToStart.add(node);
- } else {
- int numDependencies = node.dependencies.size();
- for (int j = 0; j < numDependencies; ++j) {
- Dependency dependency = node.dependencies.get(j);
- dependency.node.animation.addListener(
- new DependencyListener(this, node, dependency.rule));
- }
- node.tmpDependencies = (ArrayList) node.dependencies.clone();
- }
- node.animation.addListener(mSetListener);
- }
- // Now that all dependencies are set up, start the animations that should be started.
- if (mStartDelay <= 0) {
- for (Node node : nodesToStart) {
- node.animation.start();
- mPlayingSet.add(node.animation);
- }
- } else {
- mDelayAnim = ValueAnimator.ofFloat(0f, 1f);
- mDelayAnim.setDuration(mStartDelay);
- mDelayAnim.addListener(new AnimatorListenerAdapter() {
- boolean canceled = false;
- public void onAnimationCancel(Animator anim) {
- canceled = true;
- }
- public void onAnimationEnd(Animator anim) {
- if (!canceled) {
- int numNodes = nodesToStart.size();
- for (int i = 0; i < numNodes; ++i) {
- Node node = nodesToStart.get(i);
- node.animation.start();
- mPlayingSet.add(node.animation);
- }
- }
- }
- });
- mDelayAnim.start();
- }
- if (mListeners != null) {
- ArrayList tmpListeners =
- (ArrayList) mListeners.clone();
- int numListeners = tmpListeners.size();
- for (int i = 0; i < numListeners; ++i) {
- tmpListeners.get(i).onAnimationStart(this);
- }
- }
- if (mNodes.size() == 0 && mStartDelay == 0) {
- // Handle unusual case where empty AnimatorSet is started - should send out
- // end event immediately since the event will not be sent out at all otherwise
- mStarted = false;
- if (mListeners != null) {
- ArrayList tmpListeners =
- (ArrayList) mListeners.clone();
- int numListeners = tmpListeners.size();
- for (int i = 0; i < numListeners; ++i) {
- tmpListeners.get(i).onAnimationEnd(this);
- }
- }
- }
- }
-
- @Override
- public AnimatorSet clone() {
- final AnimatorSet anim = (AnimatorSet) super.clone();
- /*
- * The basic clone() operation copies all items. This doesn't work very well for
- * AnimatorSet, because it will copy references that need to be recreated and state
- * that may not apply. What we need to do now is put the clone in an uninitialized
- * state, with fresh, empty data structures. Then we will build up the nodes list
- * manually, as we clone each Node (and its animation). The clone will then be sorted,
- * and will populate any appropriate lists, when it is started.
- */
- anim.mNeedsSort = true;
- anim.mTerminated = false;
- anim.mStarted = false;
- anim.mPlayingSet = new ArrayList();
- anim.mNodeMap = new HashMap();
- anim.mNodes = new ArrayList();
- anim.mSortedNodes = new ArrayList();
-
- // Walk through the old nodes list, cloning each node and adding it to the new nodemap.
- // One problem is that the old node dependencies point to nodes in the old AnimatorSet.
- // We need to track the old/new nodes in order to reconstruct the dependencies in the clone.
- HashMap nodeCloneMap = new HashMap(); //
- for (Node node : mNodes) {
- Node nodeClone = node.clone();
- nodeCloneMap.put(node, nodeClone);
- anim.mNodes.add(nodeClone);
- anim.mNodeMap.put(nodeClone.animation, nodeClone);
- // Clear out the dependencies in the clone; we'll set these up manually later
- nodeClone.dependencies = null;
- nodeClone.tmpDependencies = null;
- nodeClone.nodeDependents = null;
- nodeClone.nodeDependencies = null;
- // clear out any listeners that were set up by the AnimatorSet; these will
- // be set up when the clone's nodes are sorted
- ArrayList cloneListeners = nodeClone.animation.getListeners();
- if (cloneListeners != null) {
- ArrayList listenersToRemove = null;
- for (AnimatorListener listener : cloneListeners) {
- if (listener instanceof AnimatorSetListener) {
- if (listenersToRemove == null) {
- listenersToRemove = new ArrayList();
- }
- listenersToRemove.add(listener);
- }
- }
- if (listenersToRemove != null) {
- for (AnimatorListener listener : listenersToRemove) {
- cloneListeners.remove(listener);
- }
- }
- }
- }
- // Now that we've cloned all of the nodes, we're ready to walk through their
- // dependencies, mapping the old dependencies to the new nodes
- for (Node node : mNodes) {
- Node nodeClone = nodeCloneMap.get(node);
- if (node.dependencies != null) {
- for (Dependency dependency : node.dependencies) {
- Node clonedDependencyNode = nodeCloneMap.get(dependency.node);
- Dependency cloneDependency = new Dependency(clonedDependencyNode,
- dependency.rule);
- nodeClone.addDependency(cloneDependency);
- }
- }
- }
-
- return anim;
- }
-
- /**
- * This class is the mechanism by which animations are started based on events in other
- * animations. If an animation has multiple dependencies on other animations, then
- * all dependencies must be satisfied before the animation is started.
- */
- private static class DependencyListener implements AnimatorListener {
-
- private AnimatorSet mAnimatorSet;
-
- // The node upon which the dependency is based.
- private Node mNode;
-
- // The Dependency rule (WITH or AFTER) that the listener should wait for on
- // the node
- private int mRule;
-
- public DependencyListener(AnimatorSet animatorSet, Node node, int rule) {
- this.mAnimatorSet = animatorSet;
- this.mNode = node;
- this.mRule = rule;
- }
-
- /**
- * Ignore cancel events for now. We may want to handle this eventually,
- * to prevent follow-on animations from running when some dependency
- * animation is canceled.
- */
- public void onAnimationCancel(Animator animation) {
- }
-
- /**
- * An end event is received - see if this is an event we are listening for
- */
- public void onAnimationEnd(Animator animation) {
- if (mRule == Dependency.AFTER) {
- startIfReady(animation);
- }
- }
-
- /**
- * Ignore repeat events for now
- */
- public void onAnimationRepeat(Animator animation) {
- }
-
- /**
- * A start event is received - see if this is an event we are listening for
- */
- public void onAnimationStart(Animator animation) {
- if (mRule == Dependency.WITH) {
- startIfReady(animation);
- }
- }
-
- /**
- * Check whether the event received is one that the node was waiting for.
- * If so, mark it as complete and see whether it's time to start
- * the animation.
- * @param dependencyAnimation the animation that sent the event.
- */
- private void startIfReady(Animator dependencyAnimation) {
- if (mAnimatorSet.mTerminated) {
- // if the parent AnimatorSet was canceled, then don't start any dependent anims
- return;
- }
- Dependency dependencyToRemove = null;
- int numDependencies = mNode.tmpDependencies.size();
- for (int i = 0; i < numDependencies; ++i) {
- Dependency dependency = mNode.tmpDependencies.get(i);
- if (dependency.rule == mRule &&
- dependency.node.animation == dependencyAnimation) {
- // rule fired - remove the dependency and listener and check to
- // see whether it's time to start the animation
- dependencyToRemove = dependency;
- dependencyAnimation.removeListener(this);
- break;
- }
- }
- mNode.tmpDependencies.remove(dependencyToRemove);
- if (mNode.tmpDependencies.size() == 0) {
- // all dependencies satisfied: start the animation
- mNode.animation.start();
- mAnimatorSet.mPlayingSet.add(mNode.animation);
- }
- }
-
- }
-
- private class AnimatorSetListener implements AnimatorListener {
-
- private AnimatorSet mAnimatorSet;
-
- AnimatorSetListener(AnimatorSet animatorSet) {
- mAnimatorSet = animatorSet;
- }
-
- public void onAnimationCancel(Animator animation) {
- if (!mTerminated) {
- // Listeners are already notified of the AnimatorSet canceling in cancel().
- // The logic below only kicks in when animations end normally
- if (mPlayingSet.size() == 0) {
- if (mListeners != null) {
- int numListeners = mListeners.size();
- for (int i = 0; i < numListeners; ++i) {
- mListeners.get(i).onAnimationCancel(mAnimatorSet);
- }
- }
- }
- }
- }
-
- public void onAnimationEnd(Animator animation) {
- animation.removeListener(this);
- mPlayingSet.remove(animation);
- Node animNode = mAnimatorSet.mNodeMap.get(animation);
- animNode.done = true;
- if (!mTerminated) {
- // Listeners are already notified of the AnimatorSet ending in cancel() or
- // end(); the logic below only kicks in when animations end normally
- ArrayList sortedNodes = mAnimatorSet.mSortedNodes;
- boolean allDone = true;
- int numSortedNodes = sortedNodes.size();
- for (int i = 0; i < numSortedNodes; ++i) {
- if (!sortedNodes.get(i).done) {
- allDone = false;
- break;
- }
- }
- if (allDone) {
- // If this was the last child animation to end, then notify listeners that this
- // AnimatorSet has ended
- if (mListeners != null) {
- ArrayList tmpListeners =
- (ArrayList) mListeners.clone();
- int numListeners = tmpListeners.size();
- for (int i = 0; i < numListeners; ++i) {
- tmpListeners.get(i).onAnimationEnd(mAnimatorSet);
- }
- }
- mAnimatorSet.mStarted = false;
- }
- }
- }
-
- // Nothing to do
- public void onAnimationRepeat(Animator animation) {
- }
-
- // Nothing to do
- public void onAnimationStart(Animator animation) {
- }
-
- }
-
- /**
- * This method sorts the current set of nodes, if needed. The sort is a simple
- * DependencyGraph sort, which goes like this:
- * - All nodes without dependencies become 'roots'
- * - while roots list is not null
- * - for each root r
- * - add r to sorted list
- * - remove r as a dependency from any other node
- * - any nodes with no dependencies are added to the roots list
- */
- private void sortNodes() {
- if (mNeedsSort) {
- mSortedNodes.clear();
- ArrayList roots = new ArrayList();
- int numNodes = mNodes.size();
- for (int i = 0; i < numNodes; ++i) {
- Node node = mNodes.get(i);
- if (node.dependencies == null || node.dependencies.size() == 0) {
- roots.add(node);
- }
- }
- ArrayList tmpRoots = new ArrayList();
- while (roots.size() > 0) {
- int numRoots = roots.size();
- for (int i = 0; i < numRoots; ++i) {
- Node root = roots.get(i);
- mSortedNodes.add(root);
- if (root.nodeDependents != null) {
- int numDependents = root.nodeDependents.size();
- for (int j = 0; j < numDependents; ++j) {
- Node node = root.nodeDependents.get(j);
- node.nodeDependencies.remove(root);
- if (node.nodeDependencies.size() == 0) {
- tmpRoots.add(node);
- }
- }
- }
- }
- roots.clear();
- roots.addAll(tmpRoots);
- tmpRoots.clear();
- }
- mNeedsSort = false;
- if (mSortedNodes.size() != mNodes.size()) {
- throw new IllegalStateException("Circular dependencies cannot exist"
- + " in AnimatorSet");
- }
- } else {
- // Doesn't need sorting, but still need to add in the nodeDependencies list
- // because these get removed as the event listeners fire and the dependencies
- // are satisfied
- int numNodes = mNodes.size();
- for (int i = 0; i < numNodes; ++i) {
- Node node = mNodes.get(i);
- if (node.dependencies != null && node.dependencies.size() > 0) {
- int numDependencies = node.dependencies.size();
- for (int j = 0; j < numDependencies; ++j) {
- Dependency dependency = node.dependencies.get(j);
- if (node.nodeDependencies == null) {
- node.nodeDependencies = new ArrayList();
- }
- if (!node.nodeDependencies.contains(dependency.node)) {
- node.nodeDependencies.add(dependency.node);
- }
- }
- }
- // nodes are 'done' by default; they become un-done when started, and done
- // again when ended
- node.done = false;
- }
- }
- }
-
- /**
- * Dependency holds information about the node that some other node is
- * dependent upon and the nature of that dependency.
- *
- */
- private static class Dependency {
- static final int WITH = 0; // dependent node must start with this dependency node
- static final int AFTER = 1; // dependent node must start when this dependency node finishes
-
- // The node that the other node with this Dependency is dependent upon
- public Node node;
-
- // The nature of the dependency (WITH or AFTER)
- public int rule;
-
- public Dependency(Node node, int rule) {
- this.node = node;
- this.rule = rule;
- }
- }
-
- /**
- * A Node is an embodiment of both the Animator that it wraps as well as
- * any dependencies that are associated with that Animation. This includes
- * both dependencies upon other nodes (in the dependencies list) as
- * well as dependencies of other nodes upon this (in the nodeDependents list).
- */
- private static class Node implements Cloneable {
- public Animator animation;
-
- /**
- * These are the dependencies that this node's animation has on other
- * nodes. For example, if this node's animation should begin with some
- * other animation ends, then there will be an item in this node's
- * dependencies list for that other animation's node.
- */
- public ArrayList dependencies = null;
-
- /**
- * tmpDependencies is a runtime detail. We use the dependencies list for sorting.
- * But we also use the list to keep track of when multiple dependencies are satisfied,
- * but removing each dependency as it is satisfied. We do not want to remove
- * the dependency itself from the list, because we need to retain that information
- * if the AnimatorSet is launched in the future. So we create a copy of the dependency
- * list when the AnimatorSet starts and use this tmpDependencies list to track the
- * list of satisfied dependencies.
- */
- public ArrayList tmpDependencies = null;
-
- /**
- * nodeDependencies is just a list of the nodes that this Node is dependent upon.
- * This information is used in sortNodes(), to determine when a node is a root.
- */
- public ArrayList nodeDependencies = null;
-
- /**
- * nodeDepdendents is the list of nodes that have this node as a dependency. This
- * is a utility field used in sortNodes to facilitate removing this node as a
- * dependency when it is a root node.
- */
- public ArrayList nodeDependents = null;
-
- /**
- * Flag indicating whether the animation in this node is finished. This flag
- * is used by AnimatorSet to check, as each animation ends, whether all child animations
- * are done and it's time to send out an end event for the entire AnimatorSet.
- */
- public boolean done = false;
-
- /**
- * Constructs the Node with the animation that it encapsulates. A Node has no
- * dependencies by default; dependencies are added via the addDependency()
- * method.
- *
- * @param animation The animation that the Node encapsulates.
- */
- public Node(Animator animation) {
- this.animation = animation;
- }
-
- /**
- * Add a dependency to this Node. The dependency includes information about the
- * node that this node is dependency upon and the nature of the dependency.
- * @param dependency
- */
- public void addDependency(Dependency dependency) {
- if (dependencies == null) {
- dependencies = new ArrayList();
- nodeDependencies = new ArrayList();
- }
- dependencies.add(dependency);
- if (!nodeDependencies.contains(dependency.node)) {
- nodeDependencies.add(dependency.node);
- }
- Node dependencyNode = dependency.node;
- if (dependencyNode.nodeDependents == null) {
- dependencyNode.nodeDependents = new ArrayList();
- }
- dependencyNode.nodeDependents.add(this);
- }
-
- @Override
- public Node clone() {
- try {
- Node node = (Node) super.clone();
- node.animation = animation.clone();
- return node;
- } catch (CloneNotSupportedException e) {
- throw new AssertionError();
- }
- }
- }
-
- /**
- * The Builder object is a utility class to facilitate adding animations to a
- * AnimatorSet along with the relationships between the various animations. The
- * intention of the Builder methods, along with the {@link
- * AnimatorSet#play(Animator) play()} method of AnimatorSet is to make it possible
- * to express the dependency relationships of animations in a natural way. Developers can also
- * use the {@link AnimatorSet#playTogether(Animator[]) playTogether()} and {@link
- * AnimatorSet#playSequentially(Animator[]) playSequentially()} methods if these suit the need,
- * but it might be easier in some situations to express the AnimatorSet of animations in pairs.
- *
- *
The Builder object cannot be constructed directly, but is rather constructed
- * internally via a call to {@link AnimatorSet#play(Animator)}.
- *
- *
For example, this sets up a AnimatorSet to play anim1 and anim2 at the same time, anim3 to
- * play when anim2 finishes, and anim4 to play when anim3 finishes:
- *
- * AnimatorSet s = new AnimatorSet();
- * s.play(anim1).with(anim2);
- * s.play(anim2).before(anim3);
- * s.play(anim4).after(anim3);
- *
- *
- *
Note in the example that both {@link Builder#before(Animator)} and {@link
- * Builder#after(Animator)} are used. These are just different ways of expressing the same
- * relationship and are provided to make it easier to say things in a way that is more natural,
- * depending on the situation.
- *
- *
It is possible to make several calls into the same Builder object to express
- * multiple relationships. However, note that it is only the animation passed into the initial
- * {@link AnimatorSet#play(Animator)} method that is the dependency in any of the successive
- * calls to the Builder object. For example, the following code starts both anim2
- * and anim3 when anim1 ends; there is no direct dependency relationship between anim2 and
- * anim3:
- *
- * AnimatorSet s = new AnimatorSet();
- * s.play(anim1).before(anim2).before(anim3);
- *
- * If the desired result is to play anim1 then anim2 then anim3, this code expresses the
- * relationship correctly:
- *
- * AnimatorSet s = new AnimatorSet();
- * s.play(anim1).before(anim2);
- * s.play(anim2).before(anim3);
- *
- *
- *
Note that it is possible to express relationships that cannot be resolved and will not
- * result in sensible results. For example, play(anim1).after(anim1) makes no
- * sense. In general, circular dependencies like this one (or more indirect ones where a depends
- * on b, which depends on c, which depends on a) should be avoided. Only create AnimatorSets
- * that can boil down to a simple, one-way relationship of animations starting with, before, and
- * after other, different, animations.
- */
- public class Builder {
-
- /**
- * This tracks the current node being processed. It is supplied to the play() method
- * of AnimatorSet and passed into the constructor of Builder.
- */
- private Node mCurrentNode;
-
- /**
- * package-private constructor. Builders are only constructed by AnimatorSet, when the
- * play() method is called.
- *
- * @param anim The animation that is the dependency for the other animations passed into
- * the other methods of this Builder object.
- */
- Builder(Animator anim) {
- mCurrentNode = mNodeMap.get(anim);
- if (mCurrentNode == null) {
- mCurrentNode = new Node(anim);
- mNodeMap.put(anim, mCurrentNode);
- mNodes.add(mCurrentNode);
- }
- }
-
- /**
- * Sets up the given animation to play at the same time as the animation supplied in the
- * {@link AnimatorSet#play(Animator)} call that created this Builder object.
- *
- * @param anim The animation that will play when the animation supplied to the
- * {@link AnimatorSet#play(Animator)} method starts.
- */
- public Builder with(Animator anim) {
- Node node = mNodeMap.get(anim);
- if (node == null) {
- node = new Node(anim);
- mNodeMap.put(anim, node);
- mNodes.add(node);
- }
- Dependency dependency = new Dependency(mCurrentNode, Dependency.WITH);
- node.addDependency(dependency);
- return this;
- }
-
- /**
- * Sets up the given animation to play when the animation supplied in the
- * {@link AnimatorSet#play(Animator)} call that created this Builder object
- * ends.
- *
- * @param anim The animation that will play when the animation supplied to the
- * {@link AnimatorSet#play(Animator)} method ends.
- */
- public Builder before(Animator anim) {
- Node node = mNodeMap.get(anim);
- if (node == null) {
- node = new Node(anim);
- mNodeMap.put(anim, node);
- mNodes.add(node);
- }
- Dependency dependency = new Dependency(mCurrentNode, Dependency.AFTER);
- node.addDependency(dependency);
- return this;
- }
-
- /**
- * Sets up the given animation to play when the animation supplied in the
- * {@link AnimatorSet#play(Animator)} call that created this Builder object
- * to start when the animation supplied in this method call ends.
- *
- * @param anim The animation whose end will cause the animation supplied to the
- * {@link AnimatorSet#play(Animator)} method to play.
- */
- public Builder after(Animator anim) {
- Node node = mNodeMap.get(anim);
- if (node == null) {
- node = new Node(anim);
- mNodeMap.put(anim, node);
- mNodes.add(node);
- }
- Dependency dependency = new Dependency(node, Dependency.AFTER);
- mCurrentNode.addDependency(dependency);
- return this;
- }
-
- /**
- * Sets up the animation supplied in the
- * {@link AnimatorSet#play(Animator)} call that created this Builder object
- * to play when the given amount of time elapses.
- *
- * @param delay The number of milliseconds that should elapse before the
- * animation starts.
- */
- public Builder after(long delay) {
- // setup dummy ValueAnimator just to run the clock
- ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
- anim.setDuration(delay);
- after(anim);
- return this;
- }
-
- }
-
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java
deleted file mode 100644
index e41019364d..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation;
-
-/**
- * This evaluator can be used to perform type interpolation between float values.
- */
-public class FloatEvaluator implements TypeEvaluator {
-
- /**
- * This function returns the result of linearly interpolating the start and end values, with
- * fraction representing the proportion between the start and end values. The
- * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0),
- * where x0 is startValue, x1 is endValue,
- * and t is fraction.
- *
- * @param fraction The fraction from the starting to the ending values
- * @param startValue The start value; should be of type float or
- * Float
- * @param endValue The end value; should be of type float or Float
- * @return A linear interpolation between the start and end values, given the
- * fraction parameter.
- */
- public Float evaluate(float fraction, Number startValue, Number endValue) {
- float startFloat = startValue.floatValue();
- return startFloat + fraction * (endValue.floatValue() - startFloat);
- }
-}
\ No newline at end of file
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java
deleted file mode 100644
index 6d9dafa7a4..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation;
-
-import java.util.ArrayList;
-import android.view.animation.Interpolator;
-
-import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.FloatKeyframe;
-
-/**
- * This class holds a collection of FloatKeyframe objects and is called by ValueAnimator to calculate
- * values between those keyframes for a given animation. The class internal to the animation
- * package because it is an implementation detail of how Keyframes are stored and used.
- *
- *
This type-specific subclass of KeyframeSet, along with the other type-specific subclass for
- * int, exists to speed up the getValue() method when there is no custom
- * TypeEvaluator set for the animation, so that values can be calculated without autoboxing to the
- * Object equivalents of these primitive types.
- */
-@SuppressWarnings("unchecked")
-class FloatKeyframeSet extends KeyframeSet {
- private float firstValue;
- private float lastValue;
- private float deltaValue;
- private boolean firstTime = true;
-
- public FloatKeyframeSet(FloatKeyframe... keyframes) {
- super(keyframes);
- }
-
- @Override
- public Object getValue(float fraction) {
- return getFloatValue(fraction);
- }
-
- @Override
- public FloatKeyframeSet clone() {
- ArrayList keyframes = mKeyframes;
- int numKeyframes = mKeyframes.size();
- FloatKeyframe[] newKeyframes = new FloatKeyframe[numKeyframes];
- for (int i = 0; i < numKeyframes; ++i) {
- newKeyframes[i] = (FloatKeyframe) keyframes.get(i).clone();
- }
- FloatKeyframeSet newSet = new FloatKeyframeSet(newKeyframes);
- return newSet;
- }
-
- public float getFloatValue(float fraction) {
- if (mNumKeyframes == 2) {
- if (firstTime) {
- firstTime = false;
- firstValue = ((FloatKeyframe) mKeyframes.get(0)).getFloatValue();
- lastValue = ((FloatKeyframe) mKeyframes.get(1)).getFloatValue();
- deltaValue = lastValue - firstValue;
- }
- if (mInterpolator != null) {
- fraction = mInterpolator.getInterpolation(fraction);
- }
- if (mEvaluator == null) {
- return firstValue + fraction * deltaValue;
- } else {
- return ((Number)mEvaluator.evaluate(fraction, firstValue, lastValue)).floatValue();
- }
- }
- if (fraction <= 0f) {
- final FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(0);
- final FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(1);
- float prevValue = prevKeyframe.getFloatValue();
- float nextValue = nextKeyframe.getFloatValue();
- float prevFraction = prevKeyframe.getFraction();
- float nextFraction = nextKeyframe.getFraction();
- final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator();
- if (interpolator != null) {
- fraction = interpolator.getInterpolation(fraction);
- }
- float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction);
- return mEvaluator == null ?
- prevValue + intervalFraction * (nextValue - prevValue) :
- ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).
- floatValue();
- } else if (fraction >= 1f) {
- final FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(mNumKeyframes - 2);
- final FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(mNumKeyframes - 1);
- float prevValue = prevKeyframe.getFloatValue();
- float nextValue = nextKeyframe.getFloatValue();
- float prevFraction = prevKeyframe.getFraction();
- float nextFraction = nextKeyframe.getFraction();
- final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator();
- if (interpolator != null) {
- fraction = interpolator.getInterpolation(fraction);
- }
- float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction);
- return mEvaluator == null ?
- prevValue + intervalFraction * (nextValue - prevValue) :
- ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).
- floatValue();
- }
- FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(0);
- for (int i = 1; i < mNumKeyframes; ++i) {
- FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(i);
- if (fraction < nextKeyframe.getFraction()) {
- final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator();
- if (interpolator != null) {
- fraction = interpolator.getInterpolation(fraction);
- }
- float intervalFraction = (fraction - prevKeyframe.getFraction()) /
- (nextKeyframe.getFraction() - prevKeyframe.getFraction());
- float prevValue = prevKeyframe.getFloatValue();
- float nextValue = nextKeyframe.getFloatValue();
- return mEvaluator == null ?
- prevValue + intervalFraction * (nextValue - prevValue) :
- ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).
- floatValue();
- }
- prevKeyframe = nextKeyframe;
- }
- // shouldn't get here
- return ((Number)mKeyframes.get(mNumKeyframes - 1).getValue()).floatValue();
- }
-
-}
-
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntEvaluator.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntEvaluator.java
deleted file mode 100644
index ed5e79ec64..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntEvaluator.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation;
-
-/**
- * This evaluator can be used to perform type interpolation between int values.
- */
-public class IntEvaluator implements TypeEvaluator {
-
- /**
- * This function returns the result of linearly interpolating the start and end values, with
- * fraction representing the proportion between the start and end values. The
- * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0),
- * where x0 is startValue, x1 is endValue,
- * and t is fraction.
- *
- * @param fraction The fraction from the starting to the ending values
- * @param startValue The start value; should be of type int or
- * Integer
- * @param endValue The end value; should be of type int or Integer
- * @return A linear interpolation between the start and end values, given the
- * fraction parameter.
- */
- public Integer evaluate(float fraction, Integer startValue, Integer endValue) {
- int startInt = startValue;
- return (int)(startInt + fraction * (endValue - startInt));
- }
-}
\ No newline at end of file
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java
deleted file mode 100644
index e9215e7f8c..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation;
-
-import java.util.ArrayList;
-import android.view.animation.Interpolator;
-
-import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.IntKeyframe;
-
-/**
- * This class holds a collection of IntKeyframe objects and is called by ValueAnimator to calculate
- * values between those keyframes for a given animation. The class internal to the animation
- * package because it is an implementation detail of how Keyframes are stored and used.
- *
- *
This type-specific subclass of KeyframeSet, along with the other type-specific subclass for
- * float, exists to speed up the getValue() method when there is no custom
- * TypeEvaluator set for the animation, so that values can be calculated without autoboxing to the
- * Object equivalents of these primitive types.
- */
-@SuppressWarnings("unchecked")
-class IntKeyframeSet extends KeyframeSet {
- private int firstValue;
- private int lastValue;
- private int deltaValue;
- private boolean firstTime = true;
-
- public IntKeyframeSet(IntKeyframe... keyframes) {
- super(keyframes);
- }
-
- @Override
- public Object getValue(float fraction) {
- return getIntValue(fraction);
- }
-
- @Override
- public IntKeyframeSet clone() {
- ArrayList keyframes = mKeyframes;
- int numKeyframes = mKeyframes.size();
- IntKeyframe[] newKeyframes = new IntKeyframe[numKeyframes];
- for (int i = 0; i < numKeyframes; ++i) {
- newKeyframes[i] = (IntKeyframe) keyframes.get(i).clone();
- }
- IntKeyframeSet newSet = new IntKeyframeSet(newKeyframes);
- return newSet;
- }
-
- public int getIntValue(float fraction) {
- if (mNumKeyframes == 2) {
- if (firstTime) {
- firstTime = false;
- firstValue = ((IntKeyframe) mKeyframes.get(0)).getIntValue();
- lastValue = ((IntKeyframe) mKeyframes.get(1)).getIntValue();
- deltaValue = lastValue - firstValue;
- }
- if (mInterpolator != null) {
- fraction = mInterpolator.getInterpolation(fraction);
- }
- if (mEvaluator == null) {
- return firstValue + (int)(fraction * deltaValue);
- } else {
- return ((Number)mEvaluator.evaluate(fraction, firstValue, lastValue)).intValue();
- }
- }
- if (fraction <= 0f) {
- final IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(0);
- final IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(1);
- int prevValue = prevKeyframe.getIntValue();
- int nextValue = nextKeyframe.getIntValue();
- float prevFraction = prevKeyframe.getFraction();
- float nextFraction = nextKeyframe.getFraction();
- final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator();
- if (interpolator != null) {
- fraction = interpolator.getInterpolation(fraction);
- }
- float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction);
- return mEvaluator == null ?
- prevValue + (int)(intervalFraction * (nextValue - prevValue)) :
- ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).
- intValue();
- } else if (fraction >= 1f) {
- final IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(mNumKeyframes - 2);
- final IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(mNumKeyframes - 1);
- int prevValue = prevKeyframe.getIntValue();
- int nextValue = nextKeyframe.getIntValue();
- float prevFraction = prevKeyframe.getFraction();
- float nextFraction = nextKeyframe.getFraction();
- final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator();
- if (interpolator != null) {
- fraction = interpolator.getInterpolation(fraction);
- }
- float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction);
- return mEvaluator == null ?
- prevValue + (int)(intervalFraction * (nextValue - prevValue)) :
- ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).intValue();
- }
- IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(0);
- for (int i = 1; i < mNumKeyframes; ++i) {
- IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(i);
- if (fraction < nextKeyframe.getFraction()) {
- final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator();
- if (interpolator != null) {
- fraction = interpolator.getInterpolation(fraction);
- }
- float intervalFraction = (fraction - prevKeyframe.getFraction()) /
- (nextKeyframe.getFraction() - prevKeyframe.getFraction());
- int prevValue = prevKeyframe.getIntValue();
- int nextValue = nextKeyframe.getIntValue();
- return mEvaluator == null ?
- prevValue + (int)(intervalFraction * (nextValue - prevValue)) :
- ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).
- intValue();
- }
- prevKeyframe = nextKeyframe;
- }
- // shouldn't get here
- return ((Number)mKeyframes.get(mNumKeyframes - 1).getValue()).intValue();
- }
-
-}
-
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Keyframe.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Keyframe.java
deleted file mode 100644
index ab76fa7f68..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Keyframe.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation;
-
-import android.view.animation.Interpolator;
-
-/**
- * This class holds a time/value pair for an animation. The Keyframe class is used
- * by {@link ValueAnimator} to define the values that the animation target will have over the course
- * of the animation. As the time proceeds from one keyframe to the other, the value of the
- * target object will animate between the value at the previous keyframe and the value at the
- * next keyframe. Each keyframe also holds an optional {@link TimeInterpolator}
- * object, which defines the time interpolation over the intervalue preceding the keyframe.
- *
- *
The Keyframe class itself is abstract. The type-specific factory methods will return
- * a subclass of Keyframe specific to the type of value being stored. This is done to improve
- * performance when dealing with the most common cases (e.g., float and
- * int values). Other types will fall into a more general Keyframe class that
- * treats its values as Objects. Unless your animation requires dealing with a custom type
- * or a data structure that needs to be animated directly (and evaluated using an implementation
- * of {@link TypeEvaluator}), you should stick to using float and int as animations using those
- * types have lower runtime overhead than other types.
- */
-@SuppressWarnings("rawtypes")
-public abstract class Keyframe implements Cloneable {
- /**
- * The time at which mValue will hold true.
- */
- float mFraction;
-
- /**
- * The type of the value in this Keyframe. This type is determined at construction time,
- * based on the type of the value object passed into the constructor.
- */
- Class mValueType;
-
- /**
- * The optional time interpolator for the interval preceding this keyframe. A null interpolator
- * (the default) results in linear interpolation over the interval.
- */
- private /*Time*/Interpolator mInterpolator = null;
-
- /**
- * Flag to indicate whether this keyframe has a valid value. This flag is used when an
- * animation first starts, to populate placeholder keyframes with real values derived
- * from the target object.
- */
- boolean mHasValue = false;
-
- /**
- * Constructs a Keyframe object with the given time and value. The time defines the
- * time, as a proportion of an overall animation's duration, at which the value will hold true
- * for the animation. The value for the animation between keyframes will be calculated as
- * an interpolation between the values at those keyframes.
- *
- * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
- * of time elapsed of the overall animation duration.
- * @param value The value that the object will animate to as the animation time approaches
- * the time in this keyframe, and the the value animated from as the time passes the time in
- * this keyframe.
- */
- public static Keyframe ofInt(float fraction, int value) {
- return new IntKeyframe(fraction, value);
- }
-
- /**
- * Constructs a Keyframe object with the given time. The value at this time will be derived
- * from the target object when the animation first starts (note that this implies that keyframes
- * with no initial value must be used as part of an {@link ObjectAnimator}).
- * The time defines the
- * time, as a proportion of an overall animation's duration, at which the value will hold true
- * for the animation. The value for the animation between keyframes will be calculated as
- * an interpolation between the values at those keyframes.
- *
- * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
- * of time elapsed of the overall animation duration.
- */
- public static Keyframe ofInt(float fraction) {
- return new IntKeyframe(fraction);
- }
-
- /**
- * Constructs a Keyframe object with the given time and value. The time defines the
- * time, as a proportion of an overall animation's duration, at which the value will hold true
- * for the animation. The value for the animation between keyframes will be calculated as
- * an interpolation between the values at those keyframes.
- *
- * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
- * of time elapsed of the overall animation duration.
- * @param value The value that the object will animate to as the animation time approaches
- * the time in this keyframe, and the the value animated from as the time passes the time in
- * this keyframe.
- */
- public static Keyframe ofFloat(float fraction, float value) {
- return new FloatKeyframe(fraction, value);
- }
-
- /**
- * Constructs a Keyframe object with the given time. The value at this time will be derived
- * from the target object when the animation first starts (note that this implies that keyframes
- * with no initial value must be used as part of an {@link ObjectAnimator}).
- * The time defines the
- * time, as a proportion of an overall animation's duration, at which the value will hold true
- * for the animation. The value for the animation between keyframes will be calculated as
- * an interpolation between the values at those keyframes.
- *
- * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
- * of time elapsed of the overall animation duration.
- */
- public static Keyframe ofFloat(float fraction) {
- return new FloatKeyframe(fraction);
- }
-
- /**
- * Constructs a Keyframe object with the given time and value. The time defines the
- * time, as a proportion of an overall animation's duration, at which the value will hold true
- * for the animation. The value for the animation between keyframes will be calculated as
- * an interpolation between the values at those keyframes.
- *
- * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
- * of time elapsed of the overall animation duration.
- * @param value The value that the object will animate to as the animation time approaches
- * the time in this keyframe, and the the value animated from as the time passes the time in
- * this keyframe.
- */
- public static Keyframe ofObject(float fraction, Object value) {
- return new ObjectKeyframe(fraction, value);
- }
-
- /**
- * Constructs a Keyframe object with the given time. The value at this time will be derived
- * from the target object when the animation first starts (note that this implies that keyframes
- * with no initial value must be used as part of an {@link ObjectAnimator}).
- * The time defines the
- * time, as a proportion of an overall animation's duration, at which the value will hold true
- * for the animation. The value for the animation between keyframes will be calculated as
- * an interpolation between the values at those keyframes.
- *
- * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
- * of time elapsed of the overall animation duration.
- */
- public static Keyframe ofObject(float fraction) {
- return new ObjectKeyframe(fraction, null);
- }
-
- /**
- * Indicates whether this keyframe has a valid value. This method is called internally when
- * an {@link ObjectAnimator} first starts; keyframes without values are assigned values at
- * that time by deriving the value for the property from the target object.
- *
- * @return boolean Whether this object has a value assigned.
- */
- public boolean hasValue() {
- return mHasValue;
- }
-
- /**
- * Gets the value for this Keyframe.
- *
- * @return The value for this Keyframe.
- */
- public abstract Object getValue();
-
- /**
- * Sets the value for this Keyframe.
- *
- * @param value value for this Keyframe.
- */
- public abstract void setValue(Object value);
-
- /**
- * Gets the time for this keyframe, as a fraction of the overall animation duration.
- *
- * @return The time associated with this keyframe, as a fraction of the overall animation
- * duration. This should be a value between 0 and 1.
- */
- public float getFraction() {
- return mFraction;
- }
-
- /**
- * Sets the time for this keyframe, as a fraction of the overall animation duration.
- *
- * @param fraction time associated with this keyframe, as a fraction of the overall animation
- * duration. This should be a value between 0 and 1.
- */
- public void setFraction(float fraction) {
- mFraction = fraction;
- }
-
- /**
- * Gets the optional interpolator for this Keyframe. A value of null indicates
- * that there is no interpolation, which is the same as linear interpolation.
- *
- * @return The optional interpolator for this Keyframe.
- */
- public /*Time*/Interpolator getInterpolator() {
- return mInterpolator;
- }
-
- /**
- * Sets the optional interpolator for this Keyframe. A value of null indicates
- * that there is no interpolation, which is the same as linear interpolation.
- *
- * @return The optional interpolator for this Keyframe.
- */
- public void setInterpolator(/*Time*/Interpolator interpolator) {
- mInterpolator = interpolator;
- }
-
- /**
- * Gets the type of keyframe. This information is used by ValueAnimator to determine the type of
- * {@link TypeEvaluator} to use when calculating values between keyframes. The type is based
- * on the type of Keyframe created.
- *
- * @return The type of the value stored in the Keyframe.
- */
- public Class getType() {
- return mValueType;
- }
-
- @Override
- public abstract Keyframe clone();
-
- /**
- * This internal subclass is used for all types which are not int or float.
- */
- static class ObjectKeyframe extends Keyframe {
-
- /**
- * The value of the animation at the time mFraction.
- */
- Object mValue;
-
- ObjectKeyframe(float fraction, Object value) {
- mFraction = fraction;
- mValue = value;
- mHasValue = (value != null);
- mValueType = mHasValue ? value.getClass() : Object.class;
- }
-
- public Object getValue() {
- return mValue;
- }
-
- public void setValue(Object value) {
- mValue = value;
- mHasValue = (value != null);
- }
-
- @Override
- public ObjectKeyframe clone() {
- ObjectKeyframe kfClone = new ObjectKeyframe(getFraction(), mValue);
- kfClone.setInterpolator(getInterpolator());
- return kfClone;
- }
- }
-
- /**
- * Internal subclass used when the keyframe value is of type int.
- */
- static class IntKeyframe extends Keyframe {
-
- /**
- * The value of the animation at the time mFraction.
- */
- int mValue;
-
- IntKeyframe(float fraction, int value) {
- mFraction = fraction;
- mValue = value;
- mValueType = int.class;
- mHasValue = true;
- }
-
- IntKeyframe(float fraction) {
- mFraction = fraction;
- mValueType = int.class;
- }
-
- public int getIntValue() {
- return mValue;
- }
-
- public Object getValue() {
- return mValue;
- }
-
- public void setValue(Object value) {
- if (value != null && value.getClass() == Integer.class) {
- mValue = ((Integer)value).intValue();
- mHasValue = true;
- }
- }
-
- @Override
- public IntKeyframe clone() {
- IntKeyframe kfClone = new IntKeyframe(getFraction(), mValue);
- kfClone.setInterpolator(getInterpolator());
- return kfClone;
- }
- }
-
- /**
- * Internal subclass used when the keyframe value is of type float.
- */
- static class FloatKeyframe extends Keyframe {
- /**
- * The value of the animation at the time mFraction.
- */
- float mValue;
-
- FloatKeyframe(float fraction, float value) {
- mFraction = fraction;
- mValue = value;
- mValueType = float.class;
- mHasValue = true;
- }
-
- FloatKeyframe(float fraction) {
- mFraction = fraction;
- mValueType = float.class;
- }
-
- public float getFloatValue() {
- return mValue;
- }
-
- public Object getValue() {
- return mValue;
- }
-
- public void setValue(Object value) {
- if (value != null && value.getClass() == Float.class) {
- mValue = ((Float)value).floatValue();
- mHasValue = true;
- }
- }
-
- @Override
- public FloatKeyframe clone() {
- FloatKeyframe kfClone = new FloatKeyframe(getFraction(), mValue);
- kfClone.setInterpolator(getInterpolator());
- return kfClone;
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java
deleted file mode 100644
index a71e1ad3cf..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import android.view.animation.Interpolator;
-
-import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.FloatKeyframe;
-import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.IntKeyframe;
-import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.ObjectKeyframe;
-
-/**
- * This class holds a collection of Keyframe objects and is called by ValueAnimator to calculate
- * values between those keyframes for a given animation. The class internal to the animation
- * package because it is an implementation detail of how Keyframes are stored and used.
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-class KeyframeSet {
-
- int mNumKeyframes;
-
- Keyframe mFirstKeyframe;
- Keyframe mLastKeyframe;
- /*Time*/Interpolator mInterpolator; // only used in the 2-keyframe case
- ArrayList mKeyframes; // only used when there are not 2 keyframes
- TypeEvaluator mEvaluator;
-
-
- public KeyframeSet(Keyframe... keyframes) {
- mNumKeyframes = keyframes.length;
- mKeyframes = new ArrayList();
- mKeyframes.addAll(Arrays.asList(keyframes));
- mFirstKeyframe = mKeyframes.get(0);
- mLastKeyframe = mKeyframes.get(mNumKeyframes - 1);
- mInterpolator = mLastKeyframe.getInterpolator();
- }
-
- public static KeyframeSet ofInt(int... values) {
- int numKeyframes = values.length;
- IntKeyframe keyframes[] = new IntKeyframe[Math.max(numKeyframes,2)];
- if (numKeyframes == 1) {
- keyframes[0] = (IntKeyframe) Keyframe.ofInt(0f);
- keyframes[1] = (IntKeyframe) Keyframe.ofInt(1f, values[0]);
- } else {
- keyframes[0] = (IntKeyframe) Keyframe.ofInt(0f, values[0]);
- for (int i = 1; i < numKeyframes; ++i) {
- keyframes[i] = (IntKeyframe) Keyframe.ofInt((float) i / (numKeyframes - 1), values[i]);
- }
- }
- return new IntKeyframeSet(keyframes);
- }
-
- public static KeyframeSet ofFloat(float... values) {
- int numKeyframes = values.length;
- FloatKeyframe keyframes[] = new FloatKeyframe[Math.max(numKeyframes,2)];
- if (numKeyframes == 1) {
- keyframes[0] = (FloatKeyframe) Keyframe.ofFloat(0f);
- keyframes[1] = (FloatKeyframe) Keyframe.ofFloat(1f, values[0]);
- } else {
- keyframes[0] = (FloatKeyframe) Keyframe.ofFloat(0f, values[0]);
- for (int i = 1; i < numKeyframes; ++i) {
- keyframes[i] = (FloatKeyframe) Keyframe.ofFloat((float) i / (numKeyframes - 1), values[i]);
- }
- }
- return new FloatKeyframeSet(keyframes);
- }
-
- public static KeyframeSet ofKeyframe(Keyframe... keyframes) {
- // if all keyframes of same primitive type, create the appropriate KeyframeSet
- int numKeyframes = keyframes.length;
- boolean hasFloat = false;
- boolean hasInt = false;
- boolean hasOther = false;
- for (int i = 0; i < numKeyframes; ++i) {
- if (keyframes[i] instanceof FloatKeyframe) {
- hasFloat = true;
- } else if (keyframes[i] instanceof IntKeyframe) {
- hasInt = true;
- } else {
- hasOther = true;
- }
- }
- if (hasFloat && !hasInt && !hasOther) {
- FloatKeyframe floatKeyframes[] = new FloatKeyframe[numKeyframes];
- for (int i = 0; i < numKeyframes; ++i) {
- floatKeyframes[i] = (FloatKeyframe) keyframes[i];
- }
- return new FloatKeyframeSet(floatKeyframes);
- } else if (hasInt && !hasFloat && !hasOther) {
- IntKeyframe intKeyframes[] = new IntKeyframe[numKeyframes];
- for (int i = 0; i < numKeyframes; ++i) {
- intKeyframes[i] = (IntKeyframe) keyframes[i];
- }
- return new IntKeyframeSet(intKeyframes);
- } else {
- return new KeyframeSet(keyframes);
- }
- }
-
- public static KeyframeSet ofObject(Object... values) {
- int numKeyframes = values.length;
- ObjectKeyframe keyframes[] = new ObjectKeyframe[Math.max(numKeyframes,2)];
- if (numKeyframes == 1) {
- keyframes[0] = (ObjectKeyframe) Keyframe.ofObject(0f);
- keyframes[1] = (ObjectKeyframe) Keyframe.ofObject(1f, values[0]);
- } else {
- keyframes[0] = (ObjectKeyframe) Keyframe.ofObject(0f, values[0]);
- for (int i = 1; i < numKeyframes; ++i) {
- keyframes[i] = (ObjectKeyframe) Keyframe.ofObject((float) i / (numKeyframes - 1), values[i]);
- }
- }
- return new KeyframeSet(keyframes);
- }
-
- /**
- * Sets the TypeEvaluator to be used when calculating animated values. This object
- * is required only for KeyframeSets that are not either IntKeyframeSet or FloatKeyframeSet,
- * both of which assume their own evaluator to speed up calculations with those primitive
- * types.
- *
- * @param evaluator The TypeEvaluator to be used to calculate animated values.
- */
- public void setEvaluator(TypeEvaluator evaluator) {
- mEvaluator = evaluator;
- }
-
- @Override
- public KeyframeSet clone() {
- ArrayList keyframes = mKeyframes;
- int numKeyframes = mKeyframes.size();
- Keyframe[] newKeyframes = new Keyframe[numKeyframes];
- for (int i = 0; i < numKeyframes; ++i) {
- newKeyframes[i] = keyframes.get(i).clone();
- }
- KeyframeSet newSet = new KeyframeSet(newKeyframes);
- return newSet;
- }
-
- /**
- * Gets the animated value, given the elapsed fraction of the animation (interpolated by the
- * animation's interpolator) and the evaluator used to calculate in-between values. This
- * function maps the input fraction to the appropriate keyframe interval and a fraction
- * between them and returns the interpolated value. Note that the input fraction may fall
- * outside the [0-1] bounds, if the animation's interpolator made that happen (e.g., a
- * spring interpolation that might send the fraction past 1.0). We handle this situation by
- * just using the two keyframes at the appropriate end when the value is outside those bounds.
- *
- * @param fraction The elapsed fraction of the animation
- * @return The animated value.
- */
- public Object getValue(float fraction) {
-
- // Special-case optimization for the common case of only two keyframes
- if (mNumKeyframes == 2) {
- if (mInterpolator != null) {
- fraction = mInterpolator.getInterpolation(fraction);
- }
- return mEvaluator.evaluate(fraction, mFirstKeyframe.getValue(),
- mLastKeyframe.getValue());
- }
- if (fraction <= 0f) {
- final Keyframe nextKeyframe = mKeyframes.get(1);
- final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator();
- if (interpolator != null) {
- fraction = interpolator.getInterpolation(fraction);
- }
- final float prevFraction = mFirstKeyframe.getFraction();
- float intervalFraction = (fraction - prevFraction) /
- (nextKeyframe.getFraction() - prevFraction);
- return mEvaluator.evaluate(intervalFraction, mFirstKeyframe.getValue(),
- nextKeyframe.getValue());
- } else if (fraction >= 1f) {
- final Keyframe prevKeyframe = mKeyframes.get(mNumKeyframes - 2);
- final /*Time*/Interpolator interpolator = mLastKeyframe.getInterpolator();
- if (interpolator != null) {
- fraction = interpolator.getInterpolation(fraction);
- }
- final float prevFraction = prevKeyframe.getFraction();
- float intervalFraction = (fraction - prevFraction) /
- (mLastKeyframe.getFraction() - prevFraction);
- return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(),
- mLastKeyframe.getValue());
- }
- Keyframe prevKeyframe = mFirstKeyframe;
- for (int i = 1; i < mNumKeyframes; ++i) {
- Keyframe nextKeyframe = mKeyframes.get(i);
- if (fraction < nextKeyframe.getFraction()) {
- final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator();
- if (interpolator != null) {
- fraction = interpolator.getInterpolation(fraction);
- }
- final float prevFraction = prevKeyframe.getFraction();
- float intervalFraction = (fraction - prevFraction) /
- (nextKeyframe.getFraction() - prevFraction);
- return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(),
- nextKeyframe.getValue());
- }
- prevKeyframe = nextKeyframe;
- }
- // shouldn't reach here
- return mLastKeyframe.getValue();
- }
-
- @Override
- public String toString() {
- String returnVal = " ";
- for (int i = 0; i < mNumKeyframes; ++i) {
- returnVal += mKeyframes.get(i).getValue() + " ";
- }
- return returnVal;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ObjectAnimator.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ObjectAnimator.java
deleted file mode 100644
index 21d15c02ac..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ObjectAnimator.java
+++ /dev/null
@@ -1,491 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation;
-
-import android.util.Log;
-//import android.util.Property;
-
-//import java.lang.reflect.Method;
-import java.util.ArrayList;
-
-/**
- * This subclass of {@link ValueAnimator} provides support for animating properties on target objects.
- * The constructors of this class take parameters to define the target object that will be animated
- * as well as the name of the property that will be animated. Appropriate set/get functions
- * are then determined internally and the animation will call these functions as necessary to
- * animate the property.
- *
- * @see #setPropertyName(String)
- *
- */
-@SuppressWarnings("rawtypes")
-public final class ObjectAnimator extends ValueAnimator {
- private static final boolean DBG = false;
-
- // The target object on which the property exists, set in the constructor
- private Object mTarget;
-
- private String mPropertyName;
-
- //private Property mProperty;
-
- /**
- * Sets the name of the property that will be animated. This name is used to derive
- * a setter function that will be called to set animated values.
- * For example, a property name of foo will result
- * in a call to the function setFoo() on the target object. If either
- * valueFrom or valueTo is null, then a getter function will
- * also be derived and called.
- *
- *
For best performance of the mechanism that calls the setter function determined by the
- * name of the property being animated, use float or int typed values,
- * and make the setter function for those properties have a void return value. This
- * will cause the code to take an optimized path for these constrained circumstances. Other
- * property types and return types will work, but will have more overhead in processing
- * the requests due to normal reflection mechanisms.
- *
- *
Note that the setter function derived from this property name
- * must take the same parameter type as the
- * valueFrom and valueTo properties, otherwise the call to
- * the setter function will fail.
- *
- *
If this ObjectAnimator has been set up to animate several properties together,
- * using more than one PropertyValuesHolder objects, then setting the propertyName simply
- * sets the propertyName in the first of those PropertyValuesHolder objects.
- *
- * @param propertyName The name of the property being animated. Should not be null.
- */
- public void setPropertyName(String propertyName) {
- // mValues could be null if this is being constructed piecemeal. Just record the
- // propertyName to be used later when setValues() is called if so.
- if (mValues != null) {
- PropertyValuesHolder valuesHolder = mValues[0];
- String oldName = valuesHolder.getPropertyName();
- valuesHolder.setPropertyName(propertyName);
- mValuesMap.remove(oldName);
- mValuesMap.put(propertyName, valuesHolder);
- }
- mPropertyName = propertyName;
- // New property/values/target should cause re-initialization prior to starting
- mInitialized = false;
- }
-
- /**
- * Sets the property that will be animated. Property objects will take precedence over
- * properties specified by the {@link #setPropertyName(String)} method. Animations should
- * be set up to use one or the other, not both.
- *
- * @param property The property being animated. Should not be null.
- */
- //public void setProperty(Property property) {
- // // mValues could be null if this is being constructed piecemeal. Just record the
- // // propertyName to be used later when setValues() is called if so.
- // if (mValues != null) {
- // PropertyValuesHolder valuesHolder = mValues[0];
- // String oldName = valuesHolder.getPropertyName();
- // valuesHolder.setProperty(property);
- // mValuesMap.remove(oldName);
- // mValuesMap.put(mPropertyName, valuesHolder);
- // }
- // if (mProperty != null) {
- // mPropertyName = property.getName();
- // }
- // mProperty = property;
- // // New property/values/target should cause re-initialization prior to starting
- // mInitialized = false;
- //}
-
- /**
- * Gets the name of the property that will be animated. This name will be used to derive
- * a setter function that will be called to set animated values.
- * For example, a property name of foo will result
- * in a call to the function setFoo() on the target object. If either
- * valueFrom or valueTo is null, then a getter function will
- * also be derived and called.
- */
- public String getPropertyName() {
- return mPropertyName;
- }
-
- /**
- * Creates a new ObjectAnimator object. This default constructor is primarily for
- * use internally; the other constructors which take parameters are more generally
- * useful.
- */
- public ObjectAnimator() {
- }
-
- /**
- * Private utility constructor that initializes the target object and name of the
- * property being animated.
- *
- * @param target The object whose property is to be animated. This object should
- * have a public method on it called setName(), where name is
- * the value of the propertyName parameter.
- * @param propertyName The name of the property being animated.
- */
- private ObjectAnimator(Object target, String propertyName) {
- mTarget = target;
- setPropertyName(propertyName);
- }
-
- /**
- * Private utility constructor that initializes the target object and property being animated.
- *
- * @param target The object whose property is to be animated.
- * @param property The property being animated.
- */
- //private ObjectAnimator(T target, Property property) {
- // mTarget = target;
- // setProperty(property);
- //}
-
- /**
- * Constructs and returns an ObjectAnimator that animates between int values. A single
- * value implies that that value is the one being animated to. Two values imply a starting
- * and ending values. More than two values imply a starting value, values to animate through
- * along the way, and an ending value (these values will be distributed evenly across
- * the duration of the animation).
- *
- * @param target The object whose property is to be animated. This object should
- * have a public method on it called setName(), where name is
- * the value of the propertyName parameter.
- * @param propertyName The name of the property being animated.
- * @param values A set of values that the animation will animate between over time.
- * @return An ObjectAnimator object that is set up to animate between the given values.
- */
- public static ObjectAnimator ofInt(Object target, String propertyName, int... values) {
- ObjectAnimator anim = new ObjectAnimator(target, propertyName);
- anim.setIntValues(values);
- return anim;
- }
-
- /**
- * Constructs and returns an ObjectAnimator that animates between int values. A single
- * value implies that that value is the one being animated to. Two values imply a starting
- * and ending values. More than two values imply a starting value, values to animate through
- * along the way, and an ending value (these values will be distributed evenly across
- * the duration of the animation).
- *
- * @param target The object whose property is to be animated.
- * @param property The property being animated.
- * @param values A set of values that the animation will animate between over time.
- * @return An ObjectAnimator object that is set up to animate between the given values.
- */
- //public static ObjectAnimator ofInt(T target, Property property, int... values) {
- // ObjectAnimator anim = new ObjectAnimator(target, property);
- // anim.setIntValues(values);
- // return anim;
- //}
-
- /**
- * Constructs and returns an ObjectAnimator that animates between float values. A single
- * value implies that that value is the one being animated to. Two values imply a starting
- * and ending values. More than two values imply a starting value, values to animate through
- * along the way, and an ending value (these values will be distributed evenly across
- * the duration of the animation).
- *
- * @param target The object whose property is to be animated. This object should
- * have a public method on it called setName(), where name is
- * the value of the propertyName parameter.
- * @param propertyName The name of the property being animated.
- * @param values A set of values that the animation will animate between over time.
- * @return An ObjectAnimator object that is set up to animate between the given values.
- */
- public static ObjectAnimator ofFloat(Object target, String propertyName, float... values) {
- ObjectAnimator anim = new ObjectAnimator(target, propertyName);
- anim.setFloatValues(values);
- return anim;
- }
-
- /**
- * Constructs and returns an ObjectAnimator that animates between float values. A single
- * value implies that that value is the one being animated to. Two values imply a starting
- * and ending values. More than two values imply a starting value, values to animate through
- * along the way, and an ending value (these values will be distributed evenly across
- * the duration of the animation).
- *
- * @param target The object whose property is to be animated.
- * @param property The property being animated.
- * @param values A set of values that the animation will animate between over time.
- * @return An ObjectAnimator object that is set up to animate between the given values.
- */
- //public static ObjectAnimator ofFloat(T target, Property property,
- // float... values) {
- // ObjectAnimator anim = new ObjectAnimator(target, property);
- // anim.setFloatValues(values);
- // return anim;
- //}
-
- /**
- * Constructs and returns an ObjectAnimator that animates between Object values. A single
- * value implies that that value is the one being animated to. Two values imply a starting
- * and ending values. More than two values imply a starting value, values to animate through
- * along the way, and an ending value (these values will be distributed evenly across
- * the duration of the animation).
- *
- * @param target The object whose property is to be animated. This object should
- * have a public method on it called setName(), where name is
- * the value of the propertyName parameter.
- * @param propertyName The name of the property being animated.
- * @param evaluator A TypeEvaluator that will be called on each animation frame to
- * provide the necessary interpolation between the Object values to derive the animated
- * value.
- * @param values A set of values that the animation will animate between over time.
- * @return An ObjectAnimator object that is set up to animate between the given values.
- */
- public static ObjectAnimator ofObject(Object target, String propertyName,
- TypeEvaluator evaluator, Object... values) {
- ObjectAnimator anim = new ObjectAnimator(target, propertyName);
- anim.setObjectValues(values);
- anim.setEvaluator(evaluator);
- return anim;
- }
-
- /**
- * Constructs and returns an ObjectAnimator that animates between Object values. A single
- * value implies that that value is the one being animated to. Two values imply a starting
- * and ending values. More than two values imply a starting value, values to animate through
- * along the way, and an ending value (these values will be distributed evenly across
- * the duration of the animation).
- *
- * @param target The object whose property is to be animated.
- * @param property The property being animated.
- * @param evaluator A TypeEvaluator that will be called on each animation frame to
- * provide the necessary interpolation between the Object values to derive the animated
- * value.
- * @param values A set of values that the animation will animate between over time.
- * @return An ObjectAnimator object that is set up to animate between the given values.
- */
- //public static ObjectAnimator ofObject(T target, Property property,
- // TypeEvaluator evaluator, V... values) {
- // ObjectAnimator anim = new ObjectAnimator(target, property);
- // anim.setObjectValues(values);
- // anim.setEvaluator(evaluator);
- // return anim;
- //}
-
- /**
- * Constructs and returns an ObjectAnimator that animates between the sets of values specified
- * in PropertyValueHolder objects. This variant should be used when animating
- * several properties at once with the same ObjectAnimator, since PropertyValuesHolder allows
- * you to associate a set of animation values with a property name.
- *
- * @param target The object whose property is to be animated. Depending on how the
- * PropertyValuesObjects were constructed, the target object should either have the {@link
- * android.util.Property} objects used to construct the PropertyValuesHolder objects or (if the
- * PropertyValuesHOlder objects were created with property names) the target object should have
- * public methods on it called setName(), where name is the name of
- * the property passed in as the propertyName parameter for each of the
- * PropertyValuesHolder objects.
- * @param values A set of PropertyValuesHolder objects whose values will be animated between
- * over time.
- * @return An ObjectAnimator object that is set up to animate between the given values.
- */
- public static ObjectAnimator ofPropertyValuesHolder(Object target,
- PropertyValuesHolder... values) {
- ObjectAnimator anim = new ObjectAnimator();
- anim.mTarget = target;
- anim.setValues(values);
- return anim;
- }
-
- @Override
- public void setIntValues(int... values) {
- if (mValues == null || mValues.length == 0) {
- // No values yet - this animator is being constructed piecemeal. Init the values with
- // whatever the current propertyName is
- //if (mProperty != null) {
- // setValues(PropertyValuesHolder.ofInt(mProperty, values));
- //} else {
- setValues(PropertyValuesHolder.ofInt(mPropertyName, values));
- //}
- } else {
- super.setIntValues(values);
- }
- }
-
- @Override
- public void setFloatValues(float... values) {
- if (mValues == null || mValues.length == 0) {
- // No values yet - this animator is being constructed piecemeal. Init the values with
- // whatever the current propertyName is
- //if (mProperty != null) {
- // setValues(PropertyValuesHolder.ofFloat(mProperty, values));
- //} else {
- setValues(PropertyValuesHolder.ofFloat(mPropertyName, values));
- //}
- } else {
- super.setFloatValues(values);
- }
- }
-
- @Override
- public void setObjectValues(Object... values) {
- if (mValues == null || mValues.length == 0) {
- // No values yet - this animator is being constructed piecemeal. Init the values with
- // whatever the current propertyName is
- //if (mProperty != null) {
- // setValues(PropertyValuesHolder.ofObject(mProperty, (TypeEvaluator)null, values));
- //} else {
- setValues(PropertyValuesHolder.ofObject(mPropertyName, (TypeEvaluator)null, values));
- //}
- } else {
- super.setObjectValues(values);
- }
- }
-
- @Override
- public void start() {
- if (DBG) {
- Log.d("ObjectAnimator", "Anim target, duration: " + mTarget + ", " + getDuration());
- for (int i = 0; i < mValues.length; ++i) {
- PropertyValuesHolder pvh = mValues[i];
- ArrayList keyframes = pvh.mKeyframeSet.mKeyframes;
- Log.d("ObjectAnimator", " Values[" + i + "]: " +
- pvh.getPropertyName() + ", " + keyframes.get(0).getValue() + ", " +
- keyframes.get(pvh.mKeyframeSet.mNumKeyframes - 1).getValue());
- }
- }
- super.start();
- }
-
- /**
- * This function is called immediately before processing the first animation
- * frame of an animation. If there is a nonzero startDelay, the
- * function is called after that delay ends.
- * It takes care of the final initialization steps for the
- * animation. This includes setting mEvaluator, if the user has not yet
- * set it up, and the setter/getter methods, if the user did not supply
- * them.
- *
- *
Overriders of this method should call the superclass method to cause
- * internal mechanisms to be set up correctly.
- */
- @Override
- void initAnimation() {
- if (!mInitialized) {
- // mValueType may change due to setter/getter setup; do this before calling super.init(),
- // which uses mValueType to set up the default type evaluator.
- int numValues = mValues.length;
- for (int i = 0; i < numValues; ++i) {
- mValues[i].setupSetterAndGetter(mTarget);
- }
- super.initAnimation();
- }
- }
-
- /**
- * Sets the length of the animation. The default duration is 300 milliseconds.
- *
- * @param duration The length of the animation, in milliseconds.
- * @return ObjectAnimator The object called with setDuration(). This return
- * value makes it easier to compose statements together that construct and then set the
- * duration, as in
- * ObjectAnimator.ofInt(target, propertyName, 0, 10).setDuration(500).start().
- */
- @Override
- public ObjectAnimator setDuration(long duration) {
- super.setDuration(duration);
- return this;
- }
-
-
- /**
- * The target object whose property will be animated by this animation
- *
- * @return The object being animated
- */
- public Object getTarget() {
- return mTarget;
- }
-
- /**
- * Sets the target object whose property will be animated by this animation
- *
- * @param target The object being animated
- */
- @Override
- public void setTarget(Object target) {
- if (mTarget != target) {
- final Object oldTarget = mTarget;
- mTarget = target;
- if (oldTarget != null && target != null && oldTarget.getClass() == target.getClass()) {
- return;
- }
- // New target type should cause re-initialization prior to starting
- mInitialized = false;
- }
- }
-
- @Override
- public void setupStartValues() {
- initAnimation();
- int numValues = mValues.length;
- for (int i = 0; i < numValues; ++i) {
- mValues[i].setupStartValue(mTarget);
- }
- }
-
- @Override
- public void setupEndValues() {
- initAnimation();
- int numValues = mValues.length;
- for (int i = 0; i < numValues; ++i) {
- mValues[i].setupEndValue(mTarget);
- }
- }
-
- /**
- * This method is called with the elapsed fraction of the animation during every
- * animation frame. This function turns the elapsed fraction into an interpolated fraction
- * and then into an animated value (from the evaluator. The function is called mostly during
- * animation updates, but it is also called when the end()
- * function is called, to set the final value on the property.
- *
- *
Overrides of this method must call the superclass to perform the calculation
- * of the animated value.
- *
- * @param fraction The elapsed fraction of the animation.
- */
- @Override
- void animateValue(float fraction) {
- super.animateValue(fraction);
- int numValues = mValues.length;
- for (int i = 0; i < numValues; ++i) {
- mValues[i].setAnimatedValue(mTarget);
- }
- }
-
- @Override
- public ObjectAnimator clone() {
- final ObjectAnimator anim = (ObjectAnimator) super.clone();
- return anim;
- }
-
- @Override
- public String toString() {
- String returnVal = "ObjectAnimator@" + Integer.toHexString(hashCode()) + ", target " +
- mTarget;
- if (mValues != null) {
- for (int i = 0; i < mValues.length; ++i) {
- returnVal += "\n " + mValues[i].toString();
- }
- }
- return returnVal;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java
deleted file mode 100644
index 84f7504abc..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java
+++ /dev/null
@@ -1,1012 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation;
-
-//import android.util.FloatProperty;
-//import android.util.IntProperty;
-import android.util.Log;
-//import android.util.Property;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-/**
- * This class holds information about a property and the values that that property
- * should take on during an animation. PropertyValuesHolder objects can be used to create
- * animations with ValueAnimator or ObjectAnimator that operate on several different properties
- * in parallel.
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-public class PropertyValuesHolder implements Cloneable {
-
- /**
- * The name of the property associated with the values. This need not be a real property,
- * unless this object is being used with ObjectAnimator. But this is the name by which
- * aniamted values are looked up with getAnimatedValue(String) in ValueAnimator.
- */
- String mPropertyName;
-
- /**
- * @hide
- */
- //protected Property mProperty;
-
- /**
- * The setter function, if needed. ObjectAnimator hands off this functionality to
- * PropertyValuesHolder, since it holds all of the per-property information. This
- * property is automatically
- * derived when the animation starts in setupSetterAndGetter() if using ObjectAnimator.
- */
- Method mSetter = null;
-
- /**
- * The getter function, if needed. ObjectAnimator hands off this functionality to
- * PropertyValuesHolder, since it holds all of the per-property information. This
- * property is automatically
- * derived when the animation starts in setupSetterAndGetter() if using ObjectAnimator.
- * The getter is only derived and used if one of the values is null.
- */
- private Method mGetter = null;
-
- /**
- * The type of values supplied. This information is used both in deriving the setter/getter
- * functions and in deriving the type of TypeEvaluator.
- */
- Class mValueType;
-
- /**
- * The set of keyframes (time/value pairs) that define this animation.
- */
- KeyframeSet mKeyframeSet = null;
-
-
- // type evaluators for the primitive types handled by this implementation
- private static final TypeEvaluator sIntEvaluator = new IntEvaluator();
- private static final TypeEvaluator sFloatEvaluator = new FloatEvaluator();
-
- // We try several different types when searching for appropriate setter/getter functions.
- // The caller may have supplied values in a type that does not match the setter/getter
- // functions (such as the integers 0 and 1 to represent floating point values for alpha).
- // Also, the use of generics in constructors means that we end up with the Object versions
- // of primitive types (Float vs. float). But most likely, the setter/getter functions
- // will take primitive types instead.
- // So we supply an ordered array of other types to try before giving up.
- private static Class[] FLOAT_VARIANTS = {float.class, Float.class, double.class, int.class,
- Double.class, Integer.class};
- private static Class[] INTEGER_VARIANTS = {int.class, Integer.class, float.class, double.class,
- Float.class, Double.class};
- private static Class[] DOUBLE_VARIANTS = {double.class, Double.class, float.class, int.class,
- Float.class, Integer.class};
-
- // These maps hold all property entries for a particular class. This map
- // is used to speed up property/setter/getter lookups for a given class/property
- // combination. No need to use reflection on the combination more than once.
- private static final HashMap> sSetterPropertyMap =
- new HashMap>();
- private static final HashMap> sGetterPropertyMap =
- new HashMap>();
-
- // This lock is used to ensure that only one thread is accessing the property maps
- // at a time.
- final ReentrantReadWriteLock mPropertyMapLock = new ReentrantReadWriteLock();
-
- // Used to pass single value to varargs parameter in setter invocation
- final Object[] mTmpValueArray = new Object[1];
-
- /**
- * The type evaluator used to calculate the animated values. This evaluator is determined
- * automatically based on the type of the start/end objects passed into the constructor,
- * but the system only knows about the primitive types int and float. Any other
- * type will need to set the evaluator to a custom evaluator for that type.
- */
- private TypeEvaluator mEvaluator;
-
- /**
- * The value most recently calculated by calculateValue(). This is set during
- * that function and might be retrieved later either by ValueAnimator.animatedValue() or
- * by the property-setting logic in ObjectAnimator.animatedValue().
- */
- private Object mAnimatedValue;
-
- /**
- * Internal utility constructor, used by the factory methods to set the property name.
- * @param propertyName The name of the property for this holder.
- */
- private PropertyValuesHolder(String propertyName) {
- mPropertyName = propertyName;
- }
-
- /**
- * Internal utility constructor, used by the factory methods to set the property.
- * @param property The property for this holder.
- */
- //private PropertyValuesHolder(Property property) {
- // mProperty = property;
- // if (property != null) {
- // mPropertyName = property.getName();
- // }
- //}
-
- /**
- * Constructs and returns a PropertyValuesHolder with a given property name and
- * set of int values.
- * @param propertyName The name of the property being animated.
- * @param values The values that the named property will animate between.
- * @return PropertyValuesHolder The constructed PropertyValuesHolder object.
- */
- public static PropertyValuesHolder ofInt(String propertyName, int... values) {
- return new IntPropertyValuesHolder(propertyName, values);
- }
-
- /**
- * Constructs and returns a PropertyValuesHolder with a given property and
- * set of int values.
- * @param property The property being animated. Should not be null.
- * @param values The values that the property will animate between.
- * @return PropertyValuesHolder The constructed PropertyValuesHolder object.
- */
- //public static PropertyValuesHolder ofInt(Property, Integer> property, int... values) {
- // return new IntPropertyValuesHolder(property, values);
- //}
-
- /**
- * Constructs and returns a PropertyValuesHolder with a given property name and
- * set of float values.
- * @param propertyName The name of the property being animated.
- * @param values The values that the named property will animate between.
- * @return PropertyValuesHolder The constructed PropertyValuesHolder object.
- */
- public static PropertyValuesHolder ofFloat(String propertyName, float... values) {
- return new FloatPropertyValuesHolder(propertyName, values);
- }
-
- /**
- * Constructs and returns a PropertyValuesHolder with a given property and
- * set of float values.
- * @param property The property being animated. Should not be null.
- * @param values The values that the property will animate between.
- * @return PropertyValuesHolder The constructed PropertyValuesHolder object.
- */
- //public static PropertyValuesHolder ofFloat(Property, Float> property, float... values) {
- // return new FloatPropertyValuesHolder(property, values);
- //}
-
- /**
- * Constructs and returns a PropertyValuesHolder with a given property name and
- * set of Object values. This variant also takes a TypeEvaluator because the system
- * cannot automatically interpolate between objects of unknown type.
- *
- * @param propertyName The name of the property being animated.
- * @param evaluator A TypeEvaluator that will be called on each animation frame to
- * provide the necessary interpolation between the Object values to derive the animated
- * value.
- * @param values The values that the named property will animate between.
- * @return PropertyValuesHolder The constructed PropertyValuesHolder object.
- */
- public static PropertyValuesHolder ofObject(String propertyName, TypeEvaluator evaluator,
- Object... values) {
- PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName);
- pvh.setObjectValues(values);
- pvh.setEvaluator(evaluator);
- return pvh;
- }
-
- /**
- * Constructs and returns a PropertyValuesHolder with a given property and
- * set of Object values. This variant also takes a TypeEvaluator because the system
- * cannot automatically interpolate between objects of unknown type.
- *
- * @param property The property being animated. Should not be null.
- * @param evaluator A TypeEvaluator that will be called on each animation frame to
- * provide the necessary interpolation between the Object values to derive the animated
- * value.
- * @param values The values that the property will animate between.
- * @return PropertyValuesHolder The constructed PropertyValuesHolder object.
- */
- //public static PropertyValuesHolder ofObject(Property property,
- // TypeEvaluator evaluator, V... values) {
- // PropertyValuesHolder pvh = new PropertyValuesHolder(property);
- // pvh.setObjectValues(values);
- // pvh.setEvaluator(evaluator);
- // return pvh;
- //}
-
- /**
- * Constructs and returns a PropertyValuesHolder object with the specified property name and set
- * of values. These values can be of any type, but the type should be consistent so that
- * an appropriate {@link android.animation.TypeEvaluator} can be found that matches
- * the common type.
- *
If there is only one value, it is assumed to be the end value of an animation,
- * and an initial value will be derived, if possible, by calling a getter function
- * on the object. Also, if any value is null, the value will be filled in when the animation
- * starts in the same way. This mechanism of automatically getting null values only works
- * if the PropertyValuesHolder object is used in conjunction
- * {@link ObjectAnimator}, and with a getter function
- * derived automatically from propertyName, since otherwise PropertyValuesHolder has
- * no way of determining what the value should be.
- * @param propertyName The name of the property associated with this set of values. This
- * can be the actual property name to be used when using a ObjectAnimator object, or
- * just a name used to get animated values, such as if this object is used with an
- * ValueAnimator object.
- * @param values The set of values to animate between.
- */
- public static PropertyValuesHolder ofKeyframe(String propertyName, Keyframe... values) {
- KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values);
- if (keyframeSet instanceof IntKeyframeSet) {
- return new IntPropertyValuesHolder(propertyName, (IntKeyframeSet) keyframeSet);
- } else if (keyframeSet instanceof FloatKeyframeSet) {
- return new FloatPropertyValuesHolder(propertyName, (FloatKeyframeSet) keyframeSet);
- }
- else {
- PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName);
- pvh.mKeyframeSet = keyframeSet;
- pvh.mValueType = values[0].getType();
- return pvh;
- }
- }
-
- /**
- * Constructs and returns a PropertyValuesHolder object with the specified property and set
- * of values. These values can be of any type, but the type should be consistent so that
- * an appropriate {@link android.animation.TypeEvaluator} can be found that matches
- * the common type.
- *
If there is only one value, it is assumed to be the end value of an animation,
- * and an initial value will be derived, if possible, by calling the property's
- * {@link android.util.Property#get(Object)} function.
- * Also, if any value is null, the value will be filled in when the animation
- * starts in the same way. This mechanism of automatically getting null values only works
- * if the PropertyValuesHolder object is used in conjunction with
- * {@link ObjectAnimator}, since otherwise PropertyValuesHolder has
- * no way of determining what the value should be.
- * @param property The property associated with this set of values. Should not be null.
- * @param values The set of values to animate between.
- */
- //public static PropertyValuesHolder ofKeyframe(Property property, Keyframe... values) {
- // KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values);
- // if (keyframeSet instanceof IntKeyframeSet) {
- // return new IntPropertyValuesHolder(property, (IntKeyframeSet) keyframeSet);
- // } else if (keyframeSet instanceof FloatKeyframeSet) {
- // return new FloatPropertyValuesHolder(property, (FloatKeyframeSet) keyframeSet);
- // }
- // else {
- // PropertyValuesHolder pvh = new PropertyValuesHolder(property);
- // pvh.mKeyframeSet = keyframeSet;
- // pvh.mValueType = ((Keyframe)values[0]).getType();
- // return pvh;
- // }
- //}
-
- /**
- * Set the animated values for this object to this set of ints.
- * If there is only one value, it is assumed to be the end value of an animation,
- * and an initial value will be derived, if possible, by calling a getter function
- * on the object. Also, if any value is null, the value will be filled in when the animation
- * starts in the same way. This mechanism of automatically getting null values only works
- * if the PropertyValuesHolder object is used in conjunction
- * {@link ObjectAnimator}, and with a getter function
- * derived automatically from propertyName, since otherwise PropertyValuesHolder has
- * no way of determining what the value should be.
- *
- * @param values One or more values that the animation will animate between.
- */
- public void setIntValues(int... values) {
- mValueType = int.class;
- mKeyframeSet = KeyframeSet.ofInt(values);
- }
-
- /**
- * Set the animated values for this object to this set of floats.
- * If there is only one value, it is assumed to be the end value of an animation,
- * and an initial value will be derived, if possible, by calling a getter function
- * on the object. Also, if any value is null, the value will be filled in when the animation
- * starts in the same way. This mechanism of automatically getting null values only works
- * if the PropertyValuesHolder object is used in conjunction
- * {@link ObjectAnimator}, and with a getter function
- * derived automatically from propertyName, since otherwise PropertyValuesHolder has
- * no way of determining what the value should be.
- *
- * @param values One or more values that the animation will animate between.
- */
- public void setFloatValues(float... values) {
- mValueType = float.class;
- mKeyframeSet = KeyframeSet.ofFloat(values);
- }
-
- /**
- * Set the animated values for this object to this set of Keyframes.
- *
- * @param values One or more values that the animation will animate between.
- */
- public void setKeyframes(Keyframe... values) {
- int numKeyframes = values.length;
- Keyframe keyframes[] = new Keyframe[Math.max(numKeyframes,2)];
- mValueType = values[0].getType();
- for (int i = 0; i < numKeyframes; ++i) {
- keyframes[i] = values[i];
- }
- mKeyframeSet = new KeyframeSet(keyframes);
- }
-
- /**
- * Set the animated values for this object to this set of Objects.
- * If there is only one value, it is assumed to be the end value of an animation,
- * and an initial value will be derived, if possible, by calling a getter function
- * on the object. Also, if any value is null, the value will be filled in when the animation
- * starts in the same way. This mechanism of automatically getting null values only works
- * if the PropertyValuesHolder object is used in conjunction
- * {@link ObjectAnimator}, and with a getter function
- * derived automatically from propertyName, since otherwise PropertyValuesHolder has
- * no way of determining what the value should be.
- *
- * @param values One or more values that the animation will animate between.
- */
- public void setObjectValues(Object... values) {
- mValueType = values[0].getClass();
- mKeyframeSet = KeyframeSet.ofObject(values);
- }
-
- /**
- * Determine the setter or getter function using the JavaBeans convention of setFoo or
- * getFoo for a property named 'foo'. This function figures out what the name of the
- * function should be and uses reflection to find the Method with that name on the
- * target object.
- *
- * @param targetClass The class to search for the method
- * @param prefix "set" or "get", depending on whether we need a setter or getter.
- * @param valueType The type of the parameter (in the case of a setter). This type
- * is derived from the values set on this PropertyValuesHolder. This type is used as
- * a first guess at the parameter type, but we check for methods with several different
- * types to avoid problems with slight mis-matches between supplied values and actual
- * value types used on the setter.
- * @return Method the method associated with mPropertyName.
- */
- private Method getPropertyFunction(Class targetClass, String prefix, Class valueType) {
- // TODO: faster implementation...
- Method returnVal = null;
- String methodName = getMethodName(prefix, mPropertyName);
- Class args[] = null;
- if (valueType == null) {
- try {
- returnVal = targetClass.getMethod(methodName, args);
- } catch (NoSuchMethodException e) {
- Log.e("PropertyValuesHolder", targetClass.getSimpleName() + " - " +
- "Couldn't find no-arg method for property " + mPropertyName + ": " + e);
- }
- } else {
- args = new Class[1];
- Class typeVariants[];
- if (mValueType.equals(Float.class)) {
- typeVariants = FLOAT_VARIANTS;
- } else if (mValueType.equals(Integer.class)) {
- typeVariants = INTEGER_VARIANTS;
- } else if (mValueType.equals(Double.class)) {
- typeVariants = DOUBLE_VARIANTS;
- } else {
- typeVariants = new Class[1];
- typeVariants[0] = mValueType;
- }
- for (Class typeVariant : typeVariants) {
- args[0] = typeVariant;
- try {
- returnVal = targetClass.getMethod(methodName, args);
- // change the value type to suit
- mValueType = typeVariant;
- return returnVal;
- } catch (NoSuchMethodException e) {
- // Swallow the error and keep trying other variants
- }
- }
- // If we got here, then no appropriate function was found
- Log.e("PropertyValuesHolder",
- "Couldn't find " + prefix + "ter property " + mPropertyName +
- " for " + targetClass.getSimpleName() +
- " with value type "+ mValueType);
- }
-
- return returnVal;
- }
-
-
- /**
- * Returns the setter or getter requested. This utility function checks whether the
- * requested method exists in the propertyMapMap cache. If not, it calls another
- * utility function to request the Method from the targetClass directly.
- * @param targetClass The Class on which the requested method should exist.
- * @param propertyMapMap The cache of setters/getters derived so far.
- * @param prefix "set" or "get", for the setter or getter.
- * @param valueType The type of parameter passed into the method (null for getter).
- * @return Method the method associated with mPropertyName.
- */
- private Method setupSetterOrGetter(Class targetClass,
- HashMap> propertyMapMap,
- String prefix, Class valueType) {
- Method setterOrGetter = null;
- try {
- // Have to lock property map prior to reading it, to guard against
- // another thread putting something in there after we've checked it
- // but before we've added an entry to it
- mPropertyMapLock.writeLock().lock();
- HashMap propertyMap = propertyMapMap.get(targetClass);
- if (propertyMap != null) {
- setterOrGetter = propertyMap.get(mPropertyName);
- }
- if (setterOrGetter == null) {
- setterOrGetter = getPropertyFunction(targetClass, prefix, valueType);
- if (propertyMap == null) {
- propertyMap = new HashMap();
- propertyMapMap.put(targetClass, propertyMap);
- }
- propertyMap.put(mPropertyName, setterOrGetter);
- }
- } finally {
- mPropertyMapLock.writeLock().unlock();
- }
- return setterOrGetter;
- }
-
- /**
- * Utility function to get the setter from targetClass
- * @param targetClass The Class on which the requested method should exist.
- */
- void setupSetter(Class targetClass) {
- mSetter = setupSetterOrGetter(targetClass, sSetterPropertyMap, "set", mValueType);
- }
-
- /**
- * Utility function to get the getter from targetClass
- */
- private void setupGetter(Class targetClass) {
- mGetter = setupSetterOrGetter(targetClass, sGetterPropertyMap, "get", null);
- }
-
- /**
- * Internal function (called from ObjectAnimator) to set up the setter and getter
- * prior to running the animation. If the setter has not been manually set for this
- * object, it will be derived automatically given the property name, target object, and
- * types of values supplied. If no getter has been set, it will be supplied iff any of the
- * supplied values was null. If there is a null value, then the getter (supplied or derived)
- * will be called to set those null values to the current value of the property
- * on the target object.
- * @param target The object on which the setter (and possibly getter) exist.
- */
- void setupSetterAndGetter(Object target) {
- //if (mProperty != null) {
- // // check to make sure that mProperty is on the class of target
- // try {
- // Object testValue = mProperty.get(target);
- // for (Keyframe kf : mKeyframeSet.mKeyframes) {
- // if (!kf.hasValue()) {
- // kf.setValue(mProperty.get(target));
- // }
- // }
- // return;
- // } catch (ClassCastException e) {
- // Log.e("PropertyValuesHolder","No such property (" + mProperty.getName() +
- // ") on target object " + target + ". Trying reflection instead");
- // mProperty = null;
- // }
- //}
- Class targetClass = target.getClass();
- if (mSetter == null) {
- setupSetter(targetClass);
- }
- for (Keyframe kf : mKeyframeSet.mKeyframes) {
- if (!kf.hasValue()) {
- if (mGetter == null) {
- setupGetter(targetClass);
- }
- try {
- kf.setValue(mGetter.invoke(target));
- } catch (InvocationTargetException e) {
- Log.e("PropertyValuesHolder", e.toString());
- } catch (IllegalAccessException e) {
- Log.e("PropertyValuesHolder", e.toString());
- }
- }
- }
- }
-
- /**
- * Utility function to set the value stored in a particular Keyframe. The value used is
- * whatever the value is for the property name specified in the keyframe on the target object.
- *
- * @param target The target object from which the current value should be extracted.
- * @param kf The keyframe which holds the property name and value.
- */
- private void setupValue(Object target, Keyframe kf) {
- //if (mProperty != null) {
- // kf.setValue(mProperty.get(target));
- //}
- try {
- if (mGetter == null) {
- Class targetClass = target.getClass();
- setupGetter(targetClass);
- }
- kf.setValue(mGetter.invoke(target));
- } catch (InvocationTargetException e) {
- Log.e("PropertyValuesHolder", e.toString());
- } catch (IllegalAccessException e) {
- Log.e("PropertyValuesHolder", e.toString());
- }
- }
-
- /**
- * This function is called by ObjectAnimator when setting the start values for an animation.
- * The start values are set according to the current values in the target object. The
- * property whose value is extracted is whatever is specified by the propertyName of this
- * PropertyValuesHolder object.
- *
- * @param target The object which holds the start values that should be set.
- */
- void setupStartValue(Object target) {
- setupValue(target, mKeyframeSet.mKeyframes.get(0));
- }
-
- /**
- * This function is called by ObjectAnimator when setting the end values for an animation.
- * The end values are set according to the current values in the target object. The
- * property whose value is extracted is whatever is specified by the propertyName of this
- * PropertyValuesHolder object.
- *
- * @param target The object which holds the start values that should be set.
- */
- void setupEndValue(Object target) {
- setupValue(target, mKeyframeSet.mKeyframes.get(mKeyframeSet.mKeyframes.size() - 1));
- }
-
- @Override
- public PropertyValuesHolder clone() {
- try {
- PropertyValuesHolder newPVH = (PropertyValuesHolder) super.clone();
- newPVH.mPropertyName = mPropertyName;
- //newPVH.mProperty = mProperty;
- newPVH.mKeyframeSet = mKeyframeSet.clone();
- newPVH.mEvaluator = mEvaluator;
- return newPVH;
- } catch (CloneNotSupportedException e) {
- // won't reach here
- return null;
- }
- }
-
- /**
- * Internal function to set the value on the target object, using the setter set up
- * earlier on this PropertyValuesHolder object. This function is called by ObjectAnimator
- * to handle turning the value calculated by ValueAnimator into a value set on the object
- * according to the name of the property.
- * @param target The target object on which the value is set
- */
- void setAnimatedValue(Object target) {
- //if (mProperty != null) {
- // mProperty.set(target, getAnimatedValue());
- //}
- if (mSetter != null) {
- try {
- mTmpValueArray[0] = getAnimatedValue();
- mSetter.invoke(target, mTmpValueArray);
- } catch (InvocationTargetException e) {
- Log.e("PropertyValuesHolder", e.toString());
- } catch (IllegalAccessException e) {
- Log.e("PropertyValuesHolder", e.toString());
- }
- }
- }
-
- /**
- * Internal function, called by ValueAnimator, to set up the TypeEvaluator that will be used
- * to calculate animated values.
- */
- void init() {
- if (mEvaluator == null) {
- // We already handle int and float automatically, but not their Object
- // equivalents
- mEvaluator = (mValueType == Integer.class) ? sIntEvaluator :
- (mValueType == Float.class) ? sFloatEvaluator :
- null;
- }
- if (mEvaluator != null) {
- // KeyframeSet knows how to evaluate the common types - only give it a custom
- // evaluator if one has been set on this class
- mKeyframeSet.setEvaluator(mEvaluator);
- }
- }
-
- /**
- * The TypeEvaluator will the automatically determined based on the type of values
- * supplied to PropertyValuesHolder. The evaluator can be manually set, however, if so
- * desired. This may be important in cases where either the type of the values supplied
- * do not match the way that they should be interpolated between, or if the values
- * are of a custom type or one not currently understood by the animation system. Currently,
- * only values of type float and int (and their Object equivalents: Float
- * and Integer) are correctly interpolated; all other types require setting a TypeEvaluator.
- * @param evaluator
- */
- public void setEvaluator(TypeEvaluator evaluator) {
- mEvaluator = evaluator;
- mKeyframeSet.setEvaluator(evaluator);
- }
-
- /**
- * Function used to calculate the value according to the evaluator set up for
- * this PropertyValuesHolder object. This function is called by ValueAnimator.animateValue().
- *
- * @param fraction The elapsed, interpolated fraction of the animation.
- */
- void calculateValue(float fraction) {
- mAnimatedValue = mKeyframeSet.getValue(fraction);
- }
-
- /**
- * Sets the name of the property that will be animated. This name is used to derive
- * a setter function that will be called to set animated values.
- * For example, a property name of foo will result
- * in a call to the function setFoo() on the target object. If either
- * valueFrom or valueTo is null, then a getter function will
- * also be derived and called.
- *
- *
Note that the setter function derived from this property name
- * must take the same parameter type as the
- * valueFrom and valueTo properties, otherwise the call to
- * the setter function will fail.
- *
- * @param propertyName The name of the property being animated.
- */
- public void setPropertyName(String propertyName) {
- mPropertyName = propertyName;
- }
-
- /**
- * Sets the property that will be animated.
- *
- *
Note that if this PropertyValuesHolder object is used with ObjectAnimator, the property
- * must exist on the target object specified in that ObjectAnimator.
- *
- * @param property The property being animated.
- */
- //public void setProperty(Property property) {
- // mProperty = property;
- //}
-
- /**
- * Gets the name of the property that will be animated. This name will be used to derive
- * a setter function that will be called to set animated values.
- * For example, a property name of foo will result
- * in a call to the function setFoo() on the target object. If either
- * valueFrom or valueTo is null, then a getter function will
- * also be derived and called.
- */
- public String getPropertyName() {
- return mPropertyName;
- }
-
- /**
- * Internal function, called by ValueAnimator and ObjectAnimator, to retrieve the value
- * most recently calculated in calculateValue().
- * @return
- */
- Object getAnimatedValue() {
- return mAnimatedValue;
- }
-
- @Override
- public String toString() {
- return mPropertyName + ": " + mKeyframeSet.toString();
- }
-
- /**
- * Utility method to derive a setter/getter method name from a property name, where the
- * prefix is typically "set" or "get" and the first letter of the property name is
- * capitalized.
- *
- * @param prefix The precursor to the method name, before the property name begins, typically
- * "set" or "get".
- * @param propertyName The name of the property that represents the bulk of the method name
- * after the prefix. The first letter of this word will be capitalized in the resulting
- * method name.
- * @return String the property name converted to a method name according to the conventions
- * specified above.
- */
- static String getMethodName(String prefix, String propertyName) {
- if (propertyName == null || propertyName.length() == 0) {
- // shouldn't get here
- return prefix;
- }
- char firstLetter = Character.toUpperCase(propertyName.charAt(0));
- String theRest = propertyName.substring(1);
- return prefix + firstLetter + theRest;
- }
-
- static class IntPropertyValuesHolder extends PropertyValuesHolder {
-
- // Cache JNI functions to avoid looking them up twice
- //private static final HashMap> sJNISetterPropertyMap =
- // new HashMap>();
- //int mJniSetter;
- //private IntProperty mIntProperty;
-
- IntKeyframeSet mIntKeyframeSet;
- int mIntAnimatedValue;
-
- public IntPropertyValuesHolder(String propertyName, IntKeyframeSet keyframeSet) {
- super(propertyName);
- mValueType = int.class;
- mKeyframeSet = keyframeSet;
- mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet;
- }
-
- //public IntPropertyValuesHolder(Property property, IntKeyframeSet keyframeSet) {
- // super(property);
- // mValueType = int.class;
- // mKeyframeSet = keyframeSet;
- // mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet;
- // if (property instanceof IntProperty) {
- // mIntProperty = (IntProperty) mProperty;
- // }
- //}
-
- public IntPropertyValuesHolder(String propertyName, int... values) {
- super(propertyName);
- setIntValues(values);
- }
-
- //public IntPropertyValuesHolder(Property property, int... values) {
- // super(property);
- // setIntValues(values);
- // if (property instanceof IntProperty) {
- // mIntProperty = (IntProperty) mProperty;
- // }
- //}
-
- @Override
- public void setIntValues(int... values) {
- super.setIntValues(values);
- mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet;
- }
-
- @Override
- void calculateValue(float fraction) {
- mIntAnimatedValue = mIntKeyframeSet.getIntValue(fraction);
- }
-
- @Override
- Object getAnimatedValue() {
- return mIntAnimatedValue;
- }
-
- @Override
- public IntPropertyValuesHolder clone() {
- IntPropertyValuesHolder newPVH = (IntPropertyValuesHolder) super.clone();
- newPVH.mIntKeyframeSet = (IntKeyframeSet) newPVH.mKeyframeSet;
- return newPVH;
- }
-
- /**
- * Internal function to set the value on the target object, using the setter set up
- * earlier on this PropertyValuesHolder object. This function is called by ObjectAnimator
- * to handle turning the value calculated by ValueAnimator into a value set on the object
- * according to the name of the property.
- * @param target The target object on which the value is set
- */
- @Override
- void setAnimatedValue(Object target) {
- //if (mIntProperty != null) {
- // mIntProperty.setValue(target, mIntAnimatedValue);
- // return;
- //}
- //if (mProperty != null) {
- // mProperty.set(target, mIntAnimatedValue);
- // return;
- //}
- //if (mJniSetter != 0) {
- // nCallIntMethod(target, mJniSetter, mIntAnimatedValue);
- // return;
- //}
- if (mSetter != null) {
- try {
- mTmpValueArray[0] = mIntAnimatedValue;
- mSetter.invoke(target, mTmpValueArray);
- } catch (InvocationTargetException e) {
- Log.e("PropertyValuesHolder", e.toString());
- } catch (IllegalAccessException e) {
- Log.e("PropertyValuesHolder", e.toString());
- }
- }
- }
-
- @Override
- void setupSetter(Class targetClass) {
- //if (mProperty != null) {
- // return;
- //}
- // Check new static hashmap for setter method
- //try {
- // mPropertyMapLock.writeLock().lock();
- // HashMap propertyMap = sJNISetterPropertyMap.get(targetClass);
- // if (propertyMap != null) {
- // Integer mJniSetterInteger = propertyMap.get(mPropertyName);
- // if (mJniSetterInteger != null) {
- // mJniSetter = mJniSetterInteger;
- // }
- // }
- // if (mJniSetter == 0) {
- // String methodName = getMethodName("set", mPropertyName);
- // mJniSetter = nGetIntMethod(targetClass, methodName);
- // if (mJniSetter != 0) {
- // if (propertyMap == null) {
- // propertyMap = new HashMap();
- // sJNISetterPropertyMap.put(targetClass, propertyMap);
- // }
- // propertyMap.put(mPropertyName, mJniSetter);
- // }
- // }
- //} catch (NoSuchMethodError e) {
- // Log.d("PropertyValuesHolder",
- // "Can't find native method using JNI, use reflection" + e);
- //} finally {
- // mPropertyMapLock.writeLock().unlock();
- //}
- //if (mJniSetter == 0) {
- // Couldn't find method through fast JNI approach - just use reflection
- super.setupSetter(targetClass);
- //}
- }
- }
-
- static class FloatPropertyValuesHolder extends PropertyValuesHolder {
-
- // Cache JNI functions to avoid looking them up twice
- //private static final HashMap> sJNISetterPropertyMap =
- // new HashMap>();
- //int mJniSetter;
- //private FloatProperty mFloatProperty;
-
- FloatKeyframeSet mFloatKeyframeSet;
- float mFloatAnimatedValue;
-
- public FloatPropertyValuesHolder(String propertyName, FloatKeyframeSet keyframeSet) {
- super(propertyName);
- mValueType = float.class;
- mKeyframeSet = keyframeSet;
- mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet;
- }
-
- //public FloatPropertyValuesHolder(Property property, FloatKeyframeSet keyframeSet) {
- // super(property);
- // mValueType = float.class;
- // mKeyframeSet = keyframeSet;
- // mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet;
- // if (property instanceof FloatProperty) {
- // mFloatProperty = (FloatProperty) mProperty;
- // }
- //}
-
- public FloatPropertyValuesHolder(String propertyName, float... values) {
- super(propertyName);
- setFloatValues(values);
- }
-
- //public FloatPropertyValuesHolder(Property property, float... values) {
- // super(property);
- // setFloatValues(values);
- // if (property instanceof FloatProperty) {
- // mFloatProperty = (FloatProperty) mProperty;
- // }
- //}
-
- @Override
- public void setFloatValues(float... values) {
- super.setFloatValues(values);
- mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet;
- }
-
- @Override
- void calculateValue(float fraction) {
- mFloatAnimatedValue = mFloatKeyframeSet.getFloatValue(fraction);
- }
-
- @Override
- Object getAnimatedValue() {
- return mFloatAnimatedValue;
- }
-
- @Override
- public FloatPropertyValuesHolder clone() {
- FloatPropertyValuesHolder newPVH = (FloatPropertyValuesHolder) super.clone();
- newPVH.mFloatKeyframeSet = (FloatKeyframeSet) newPVH.mKeyframeSet;
- return newPVH;
- }
-
- /**
- * Internal function to set the value on the target object, using the setter set up
- * earlier on this PropertyValuesHolder object. This function is called by ObjectAnimator
- * to handle turning the value calculated by ValueAnimator into a value set on the object
- * according to the name of the property.
- * @param target The target object on which the value is set
- */
- @Override
- void setAnimatedValue(Object target) {
- //if (mFloatProperty != null) {
- // mFloatProperty.setValue(target, mFloatAnimatedValue);
- // return;
- //}
- //if (mProperty != null) {
- // mProperty.set(target, mFloatAnimatedValue);
- // return;
- //}
- //if (mJniSetter != 0) {
- // nCallFloatMethod(target, mJniSetter, mFloatAnimatedValue);
- // return;
- //}
- if (mSetter != null) {
- try {
- mTmpValueArray[0] = mFloatAnimatedValue;
- mSetter.invoke(target, mTmpValueArray);
- } catch (InvocationTargetException e) {
- Log.e("PropertyValuesHolder", e.toString());
- } catch (IllegalAccessException e) {
- Log.e("PropertyValuesHolder", e.toString());
- }
- }
- }
-
- @Override
- void setupSetter(Class targetClass) {
- //if (mProperty != null) {
- // return;
- //}
- // Check new static hashmap for setter method
- //try {
- // mPropertyMapLock.writeLock().lock();
- // HashMap propertyMap = sJNISetterPropertyMap.get(targetClass);
- // if (propertyMap != null) {
- // Integer mJniSetterInteger = propertyMap.get(mPropertyName);
- // if (mJniSetterInteger != null) {
- // mJniSetter = mJniSetterInteger;
- // }
- // }
- // if (mJniSetter == 0) {
- // String methodName = getMethodName("set", mPropertyName);
- // mJniSetter = nGetFloatMethod(targetClass, methodName);
- // if (mJniSetter != 0) {
- // if (propertyMap == null) {
- // propertyMap = new HashMap();
- // sJNISetterPropertyMap.put(targetClass, propertyMap);
- // }
- // propertyMap.put(mPropertyName, mJniSetter);
- // }
- // }
- //} catch (NoSuchMethodError e) {
- // Log.d("PropertyValuesHolder",
- // "Can't find native method using JNI, use reflection" + e);
- //} finally {
- // mPropertyMapLock.writeLock().unlock();
- //}
- //if (mJniSetter == 0) {
- // Couldn't find method through fast JNI approach - just use reflection
- super.setupSetter(targetClass);
- //}
- }
-
- }
-
- //native static private int nGetIntMethod(Class targetClass, String methodName);
- //native static private int nGetFloatMethod(Class targetClass, String methodName);
- //native static private void nCallIntMethod(Object target, int methodID, int arg);
- //native static private void nCallFloatMethod(Object target, int methodID, float arg);
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java
deleted file mode 100644
index 0ea3192446..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation;
-
-/**
- * Interface for use with the {@link ValueAnimator#setEvaluator(TypeEvaluator)} function. Evaluators
- * allow developers to create animations on arbitrary property types, by allowing them to supply
- * custom evaulators for types that are not automatically understood and used by the animation
- * system.
- *
- * @see ValueAnimator#setEvaluator(TypeEvaluator)
- */
-public interface TypeEvaluator {
-
- /**
- * This function returns the result of linearly interpolating the start and end values, with
- * fraction representing the proportion between the start and end values. The
- * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0),
- * where x0 is startValue, x1 is endValue,
- * and t is fraction.
- *
- * @param fraction The fraction from the starting to the ending values
- * @param startValue The start value.
- * @param endValue The end value.
- * @return A linear interpolation between the start and end values, given the
- * fraction parameter.
- */
- public T evaluate(float fraction, T startValue, T endValue);
-
-}
\ No newline at end of file
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java
deleted file mode 100644
index d8a12c6882..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java
+++ /dev/null
@@ -1,1265 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation;
-
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.util.AndroidRuntimeException;
-import android.view.animation.AccelerateDecelerateInterpolator;
-import android.view.animation.AnimationUtils;
-import android.view.animation.Interpolator;
-import android.view.animation.LinearInterpolator;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-/**
- * This class provides a simple timing engine for running animations
- * which calculate animated values and set them on target objects.
- *
- *
There is a single timing pulse that all animations use. It runs in a
- * custom handler to ensure that property changes happen on the UI thread.
- *
- *
By default, ValueAnimator uses non-linear time interpolation, via the
- * {@link AccelerateDecelerateInterpolator} class, which accelerates into and decelerates
- * out of an animation. This behavior can be changed by calling
- * {@link ValueAnimator#setInterpolator(TimeInterpolator)}.
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-public class ValueAnimator extends Animator {
-
- /**
- * Internal constants
- */
-
- /*
- * The default amount of time in ms between animation frames
- */
- private static final long DEFAULT_FRAME_DELAY = 10;
-
- /**
- * Messages sent to timing handler: START is sent when an animation first begins, FRAME is sent
- * by the handler to itself to process the next animation frame
- */
- static final int ANIMATION_START = 0;
- static final int ANIMATION_FRAME = 1;
-
- /**
- * Values used with internal variable mPlayingState to indicate the current state of an
- * animation.
- */
- static final int STOPPED = 0; // Not yet playing
- static final int RUNNING = 1; // Playing normally
- static final int SEEKED = 2; // Seeked to some time value
-
- /**
- * Internal variables
- * NOTE: This object implements the clone() method, making a deep copy of any referenced
- * objects. As other non-trivial fields are added to this class, make sure to add logic
- * to clone() to make deep copies of them.
- */
-
- // The first time that the animation's animateFrame() method is called. This time is used to
- // determine elapsed time (and therefore the elapsed fraction) in subsequent calls
- // to animateFrame()
- long mStartTime;
-
- /**
- * Set when setCurrentPlayTime() is called. If negative, animation is not currently seeked
- * to a value.
- */
- long mSeekTime = -1;
-
- // TODO: We access the following ThreadLocal variables often, some of them on every update.
- // If ThreadLocal access is significantly expensive, we may want to put all of these
- // fields into a structure sot hat we just access ThreadLocal once to get the reference
- // to that structure, then access the structure directly for each field.
-
- // The static sAnimationHandler processes the internal timing loop on which all animations
- // are based
- private static ThreadLocal sAnimationHandler =
- new ThreadLocal();
-
- // The per-thread list of all active animations
- private static final ThreadLocal> sAnimations =
- new ThreadLocal>() {
- @Override
- protected ArrayList initialValue() {
- return new ArrayList();
- }
- };
-
- // The per-thread set of animations to be started on the next animation frame
- private static final ThreadLocal> sPendingAnimations =
- new ThreadLocal>() {
- @Override
- protected ArrayList initialValue() {
- return new ArrayList();
- }
- };
-
- /**
- * Internal per-thread collections used to avoid set collisions as animations start and end
- * while being processed.
- */
- private static final ThreadLocal> sDelayedAnims =
- new ThreadLocal>() {
- @Override
- protected ArrayList initialValue() {
- return new ArrayList();
- }
- };
-
- private static final ThreadLocal> sEndingAnims =
- new ThreadLocal>() {
- @Override
- protected ArrayList initialValue() {
- return new ArrayList();
- }
- };
-
- private static final ThreadLocal> sReadyAnims =
- new ThreadLocal>() {
- @Override
- protected ArrayList initialValue() {
- return new ArrayList();
- }
- };
-
- // The time interpolator to be used if none is set on the animation
- private static final /*Time*/Interpolator sDefaultInterpolator =
- new AccelerateDecelerateInterpolator();
-
- // type evaluators for the primitive types handled by this implementation
- //private static final TypeEvaluator sIntEvaluator = new IntEvaluator();
- //private static final TypeEvaluator sFloatEvaluator = new FloatEvaluator();
-
- /**
- * Used to indicate whether the animation is currently playing in reverse. This causes the
- * elapsed fraction to be inverted to calculate the appropriate values.
- */
- private boolean mPlayingBackwards = false;
-
- /**
- * This variable tracks the current iteration that is playing. When mCurrentIteration exceeds the
- * repeatCount (if repeatCount!=INFINITE), the animation ends
- */
- private int mCurrentIteration = 0;
-
- /**
- * Tracks current elapsed/eased fraction, for querying in getAnimatedFraction().
- */
- private float mCurrentFraction = 0f;
-
- /**
- * Tracks whether a startDelay'd animation has begun playing through the startDelay.
- */
- private boolean mStartedDelay = false;
-
- /**
- * Tracks the time at which the animation began playing through its startDelay. This is
- * different from the mStartTime variable, which is used to track when the animation became
- * active (which is when the startDelay expired and the animation was added to the active
- * animations list).
- */
- private long mDelayStartTime;
-
- /**
- * Flag that represents the current state of the animation. Used to figure out when to start
- * an animation (if state == STOPPED). Also used to end an animation that
- * has been cancel()'d or end()'d since the last animation frame. Possible values are
- * STOPPED, RUNNING, SEEKED.
- */
- int mPlayingState = STOPPED;
-
- /**
- * Additional playing state to indicate whether an animator has been start()'d. There is
- * some lag between a call to start() and the first animation frame. We should still note
- * that the animation has been started, even if it's first animation frame has not yet
- * happened, and reflect that state in isRunning().
- * Note that delayed animations are different: they are not started until their first
- * animation frame, which occurs after their delay elapses.
- */
- private boolean mRunning = false;
-
- /**
- * Additional playing state to indicate whether an animator has been start()'d, whether or
- * not there is a nonzero startDelay.
- */
- private boolean mStarted = false;
-
- /**
- * Flag that denotes whether the animation is set up and ready to go. Used to
- * set up animation that has not yet been started.
- */
- boolean mInitialized = false;
-
- //
- // Backing variables
- //
-
- // How long the animation should last in ms
- private long mDuration = 300;
-
- // The amount of time in ms to delay starting the animation after start() is called
- private long mStartDelay = 0;
-
- // The number of milliseconds between animation frames
- private static long sFrameDelay = DEFAULT_FRAME_DELAY;
-
- // The number of times the animation will repeat. The default is 0, which means the animation
- // will play only once
- private int mRepeatCount = 0;
-
- /**
- * The type of repetition that will occur when repeatMode is nonzero. RESTART means the
- * animation will start from the beginning on every new cycle. REVERSE means the animation
- * will reverse directions on each iteration.
- */
- private int mRepeatMode = RESTART;
-
- /**
- * The time interpolator to be used. The elapsed fraction of the animation will be passed
- * through this interpolator to calculate the interpolated fraction, which is then used to
- * calculate the animated values.
- */
- private /*Time*/Interpolator mInterpolator = sDefaultInterpolator;
-
- /**
- * The set of listeners to be sent events through the life of an animation.
- */
- private ArrayList mUpdateListeners = null;
-
- /**
- * The property/value sets being animated.
- */
- PropertyValuesHolder[] mValues;
-
- /**
- * A hashmap of the PropertyValuesHolder objects. This map is used to lookup animated values
- * by property name during calls to getAnimatedValue(String).
- */
- HashMap mValuesMap;
-
- /**
- * Public constants
- */
-
- /**
- * When the animation reaches the end and repeatCount is INFINITE
- * or a positive value, the animation restarts from the beginning.
- */
- public static final int RESTART = 1;
- /**
- * When the animation reaches the end and repeatCount is INFINITE
- * or a positive value, the animation reverses direction on every iteration.
- */
- public static final int REVERSE = 2;
- /**
- * This value used used with the {@link #setRepeatCount(int)} property to repeat
- * the animation indefinitely.
- */
- public static final int INFINITE = -1;
-
- /**
- * Creates a new ValueAnimator object. This default constructor is primarily for
- * use internally; the factory methods which take parameters are more generally
- * useful.
- */
- public ValueAnimator() {
- }
-
- /**
- * Constructs and returns a ValueAnimator that animates between int values. A single
- * value implies that that value is the one being animated to. However, this is not typically
- * useful in a ValueAnimator object because there is no way for the object to determine the
- * starting value for the animation (unlike ObjectAnimator, which can derive that value
- * from the target object and property being animated). Therefore, there should typically
- * be two or more values.
- *
- * @param values A set of values that the animation will animate between over time.
- * @return A ValueAnimator object that is set up to animate between the given values.
- */
- public static ValueAnimator ofInt(int... values) {
- ValueAnimator anim = new ValueAnimator();
- anim.setIntValues(values);
- return anim;
- }
-
- /**
- * Constructs and returns a ValueAnimator that animates between float values. A single
- * value implies that that value is the one being animated to. However, this is not typically
- * useful in a ValueAnimator object because there is no way for the object to determine the
- * starting value for the animation (unlike ObjectAnimator, which can derive that value
- * from the target object and property being animated). Therefore, there should typically
- * be two or more values.
- *
- * @param values A set of values that the animation will animate between over time.
- * @return A ValueAnimator object that is set up to animate between the given values.
- */
- public static ValueAnimator ofFloat(float... values) {
- ValueAnimator anim = new ValueAnimator();
- anim.setFloatValues(values);
- return anim;
- }
-
- /**
- * Constructs and returns a ValueAnimator that animates between the values
- * specified in the PropertyValuesHolder objects.
- *
- * @param values A set of PropertyValuesHolder objects whose values will be animated
- * between over time.
- * @return A ValueAnimator object that is set up to animate between the given values.
- */
- public static ValueAnimator ofPropertyValuesHolder(PropertyValuesHolder... values) {
- ValueAnimator anim = new ValueAnimator();
- anim.setValues(values);
- return anim;
- }
- /**
- * Constructs and returns a ValueAnimator that animates between Object values. A single
- * value implies that that value is the one being animated to. However, this is not typically
- * useful in a ValueAnimator object because there is no way for the object to determine the
- * starting value for the animation (unlike ObjectAnimator, which can derive that value
- * from the target object and property being animated). Therefore, there should typically
- * be two or more values.
- *
- *
Since ValueAnimator does not know how to animate between arbitrary Objects, this
- * factory method also takes a TypeEvaluator object that the ValueAnimator will use
- * to perform that interpolation.
- *
- * @param evaluator A TypeEvaluator that will be called on each animation frame to
- * provide the ncessry interpolation between the Object values to derive the animated
- * value.
- * @param values A set of values that the animation will animate between over time.
- * @return A ValueAnimator object that is set up to animate between the given values.
- */
- public static ValueAnimator ofObject(TypeEvaluator evaluator, Object... values) {
- ValueAnimator anim = new ValueAnimator();
- anim.setObjectValues(values);
- anim.setEvaluator(evaluator);
- return anim;
- }
-
- /**
- * Sets int values that will be animated between. A single
- * value implies that that value is the one being animated to. However, this is not typically
- * useful in a ValueAnimator object because there is no way for the object to determine the
- * starting value for the animation (unlike ObjectAnimator, which can derive that value
- * from the target object and property being animated). Therefore, there should typically
- * be two or more values.
- *
- *
If there are already multiple sets of values defined for this ValueAnimator via more
- * than one PropertyValuesHolder object, this method will set the values for the first
- * of those objects.
- *
- * @param values A set of values that the animation will animate between over time.
- */
- public void setIntValues(int... values) {
- if (values == null || values.length == 0) {
- return;
- }
- if (mValues == null || mValues.length == 0) {
- setValues(new PropertyValuesHolder[]{PropertyValuesHolder.ofInt("", values)});
- } else {
- PropertyValuesHolder valuesHolder = mValues[0];
- valuesHolder.setIntValues(values);
- }
- // New property/values/target should cause re-initialization prior to starting
- mInitialized = false;
- }
-
- /**
- * Sets float values that will be animated between. A single
- * value implies that that value is the one being animated to. However, this is not typically
- * useful in a ValueAnimator object because there is no way for the object to determine the
- * starting value for the animation (unlike ObjectAnimator, which can derive that value
- * from the target object and property being animated). Therefore, there should typically
- * be two or more values.
- *
- *
If there are already multiple sets of values defined for this ValueAnimator via more
- * than one PropertyValuesHolder object, this method will set the values for the first
- * of those objects.
- *
- * @param values A set of values that the animation will animate between over time.
- */
- public void setFloatValues(float... values) {
- if (values == null || values.length == 0) {
- return;
- }
- if (mValues == null || mValues.length == 0) {
- setValues(new PropertyValuesHolder[]{PropertyValuesHolder.ofFloat("", values)});
- } else {
- PropertyValuesHolder valuesHolder = mValues[0];
- valuesHolder.setFloatValues(values);
- }
- // New property/values/target should cause re-initialization prior to starting
- mInitialized = false;
- }
-
- /**
- * Sets the values to animate between for this animation. A single
- * value implies that that value is the one being animated to. However, this is not typically
- * useful in a ValueAnimator object because there is no way for the object to determine the
- * starting value for the animation (unlike ObjectAnimator, which can derive that value
- * from the target object and property being animated). Therefore, there should typically
- * be two or more values.
- *
- *
If there are already multiple sets of values defined for this ValueAnimator via more
- * than one PropertyValuesHolder object, this method will set the values for the first
- * of those objects.
- *
- *
There should be a TypeEvaluator set on the ValueAnimator that knows how to interpolate
- * between these value objects. ValueAnimator only knows how to interpolate between the
- * primitive types specified in the other setValues() methods.
- *
- * @param values The set of values to animate between.
- */
- public void setObjectValues(Object... values) {
- if (values == null || values.length == 0) {
- return;
- }
- if (mValues == null || mValues.length == 0) {
- setValues(new PropertyValuesHolder[]{PropertyValuesHolder.ofObject("",
- (TypeEvaluator)null, values)});
- } else {
- PropertyValuesHolder valuesHolder = mValues[0];
- valuesHolder.setObjectValues(values);
- }
- // New property/values/target should cause re-initialization prior to starting
- mInitialized = false;
- }
-
- /**
- * Sets the values, per property, being animated between. This function is called internally
- * by the constructors of ValueAnimator that take a list of values. But an ValueAnimator can
- * be constructed without values and this method can be called to set the values manually
- * instead.
- *
- * @param values The set of values, per property, being animated between.
- */
- public void setValues(PropertyValuesHolder... values) {
- int numValues = values.length;
- mValues = values;
- mValuesMap = new HashMap(numValues);
- for (int i = 0; i < numValues; ++i) {
- PropertyValuesHolder valuesHolder = values[i];
- mValuesMap.put(valuesHolder.getPropertyName(), valuesHolder);
- }
- // New property/values/target should cause re-initialization prior to starting
- mInitialized = false;
- }
-
- /**
- * Returns the values that this ValueAnimator animates between. These values are stored in
- * PropertyValuesHolder objects, even if the ValueAnimator was created with a simple list
- * of value objects instead.
- *
- * @return PropertyValuesHolder[] An array of PropertyValuesHolder objects which hold the
- * values, per property, that define the animation.
- */
- public PropertyValuesHolder[] getValues() {
- return mValues;
- }
-
- /**
- * This function is called immediately before processing the first animation
- * frame of an animation. If there is a nonzero startDelay, the
- * function is called after that delay ends.
- * It takes care of the final initialization steps for the
- * animation.
- *
- *
Overrides of this method should call the superclass method to ensure
- * that internal mechanisms for the animation are set up correctly.
- */
- void initAnimation() {
- if (!mInitialized) {
- int numValues = mValues.length;
- for (int i = 0; i < numValues; ++i) {
- mValues[i].init();
- }
- mInitialized = true;
- }
- }
-
-
- /**
- * Sets the length of the animation. The default duration is 300 milliseconds.
- *
- * @param duration The length of the animation, in milliseconds. This value cannot
- * be negative.
- * @return ValueAnimator The object called with setDuration(). This return
- * value makes it easier to compose statements together that construct and then set the
- * duration, as in ValueAnimator.ofInt(0, 10).setDuration(500).start().
- */
- public ValueAnimator setDuration(long duration) {
- if (duration < 0) {
- throw new IllegalArgumentException("Animators cannot have negative duration: " +
- duration);
- }
- mDuration = duration;
- return this;
- }
-
- /**
- * Gets the length of the animation. The default duration is 300 milliseconds.
- *
- * @return The length of the animation, in milliseconds.
- */
- public long getDuration() {
- return mDuration;
- }
-
- /**
- * Sets the position of the animation to the specified point in time. This time should
- * be between 0 and the total duration of the animation, including any repetition. If
- * the animation has not yet been started, then it will not advance forward after it is
- * set to this time; it will simply set the time to this value and perform any appropriate
- * actions based on that time. If the animation is already running, then setCurrentPlayTime()
- * will set the current playing time to this value and continue playing from that point.
- *
- * @param playTime The time, in milliseconds, to which the animation is advanced or rewound.
- */
- public void setCurrentPlayTime(long playTime) {
- initAnimation();
- long currentTime = AnimationUtils.currentAnimationTimeMillis();
- if (mPlayingState != RUNNING) {
- mSeekTime = playTime;
- mPlayingState = SEEKED;
- }
- mStartTime = currentTime - playTime;
- animationFrame(currentTime);
- }
-
- /**
- * Gets the current position of the animation in time, which is equal to the current
- * time minus the time that the animation started. An animation that is not yet started will
- * return a value of zero.
- *
- * @return The current position in time of the animation.
- */
- public long getCurrentPlayTime() {
- if (!mInitialized || mPlayingState == STOPPED) {
- return 0;
- }
- return AnimationUtils.currentAnimationTimeMillis() - mStartTime;
- }
-
- /**
- * This custom, static handler handles the timing pulse that is shared by
- * all active animations. This approach ensures that the setting of animation
- * values will happen on the UI thread and that all animations will share
- * the same times for calculating their values, which makes synchronizing
- * animations possible.
- *
- */
- private static class AnimationHandler extends Handler {
- /**
- * There are only two messages that we care about: ANIMATION_START and
- * ANIMATION_FRAME. The START message is sent when an animation's start()
- * method is called. It cannot start synchronously when start() is called
- * because the call may be on the wrong thread, and it would also not be
- * synchronized with other animations because it would not start on a common
- * timing pulse. So each animation sends a START message to the handler, which
- * causes the handler to place the animation on the active animations queue and
- * start processing frames for that animation.
- * The FRAME message is the one that is sent over and over while there are any
- * active animations to process.
- */
- @Override
- public void handleMessage(Message msg) {
- boolean callAgain = true;
- ArrayList animations = sAnimations.get();
- ArrayList delayedAnims = sDelayedAnims.get();
- switch (msg.what) {
- // TODO: should we avoid sending frame message when starting if we
- // were already running?
- case ANIMATION_START:
- ArrayList pendingAnimations = sPendingAnimations.get();
- if (animations.size() > 0 || delayedAnims.size() > 0) {
- callAgain = false;
- }
- // pendingAnims holds any animations that have requested to be started
- // We're going to clear sPendingAnimations, but starting animation may
- // cause more to be added to the pending list (for example, if one animation
- // starting triggers another starting). So we loop until sPendingAnimations
- // is empty.
- while (pendingAnimations.size() > 0) {
- ArrayList pendingCopy =
- (ArrayList) pendingAnimations.clone();
- pendingAnimations.clear();
- int count = pendingCopy.size();
- for (int i = 0; i < count; ++i) {
- ValueAnimator anim = pendingCopy.get(i);
- // If the animation has a startDelay, place it on the delayed list
- if (anim.mStartDelay == 0) {
- anim.startAnimation();
- } else {
- delayedAnims.add(anim);
- }
- }
- }
- // fall through to process first frame of new animations
- case ANIMATION_FRAME:
- // currentTime holds the common time for all animations processed
- // during this frame
- long currentTime = AnimationUtils.currentAnimationTimeMillis();
- ArrayList readyAnims = sReadyAnims.get();
- ArrayList endingAnims = sEndingAnims.get();
-
- // First, process animations currently sitting on the delayed queue, adding
- // them to the active animations if they are ready
- int numDelayedAnims = delayedAnims.size();
- for (int i = 0; i < numDelayedAnims; ++i) {
- ValueAnimator anim = delayedAnims.get(i);
- if (anim.delayedAnimationFrame(currentTime)) {
- readyAnims.add(anim);
- }
- }
- int numReadyAnims = readyAnims.size();
- if (numReadyAnims > 0) {
- for (int i = 0; i < numReadyAnims; ++i) {
- ValueAnimator anim = readyAnims.get(i);
- anim.startAnimation();
- anim.mRunning = true;
- delayedAnims.remove(anim);
- }
- readyAnims.clear();
- }
-
- // Now process all active animations. The return value from animationFrame()
- // tells the handler whether it should now be ended
- int numAnims = animations.size();
- int i = 0;
- while (i < numAnims) {
- ValueAnimator anim = animations.get(i);
- if (anim.animationFrame(currentTime)) {
- endingAnims.add(anim);
- }
- if (animations.size() == numAnims) {
- ++i;
- } else {
- // An animation might be canceled or ended by client code
- // during the animation frame. Check to see if this happened by
- // seeing whether the current index is the same as it was before
- // calling animationFrame(). Another approach would be to copy
- // animations to a temporary list and process that list instead,
- // but that entails garbage and processing overhead that would
- // be nice to avoid.
- --numAnims;
- endingAnims.remove(anim);
- }
- }
- if (endingAnims.size() > 0) {
- for (i = 0; i < endingAnims.size(); ++i) {
- endingAnims.get(i).endAnimation();
- }
- endingAnims.clear();
- }
-
- // If there are still active or delayed animations, call the handler again
- // after the frameDelay
- if (callAgain && (!animations.isEmpty() || !delayedAnims.isEmpty())) {
- sendEmptyMessageDelayed(ANIMATION_FRAME, Math.max(0, sFrameDelay -
- (AnimationUtils.currentAnimationTimeMillis() - currentTime)));
- }
- break;
- }
- }
- }
-
- /**
- * The amount of time, in milliseconds, to delay starting the animation after
- * {@link #start()} is called.
- *
- * @return the number of milliseconds to delay running the animation
- */
- public long getStartDelay() {
- return mStartDelay;
- }
-
- /**
- * The amount of time, in milliseconds, to delay starting the animation after
- * {@link #start()} is called.
-
- * @param startDelay The amount of the delay, in milliseconds
- */
- public void setStartDelay(long startDelay) {
- this.mStartDelay = startDelay;
- }
-
- /**
- * The amount of time, in milliseconds, between each frame of the animation. This is a
- * requested time that the animation will attempt to honor, but the actual delay between
- * frames may be different, depending on system load and capabilities. This is a static
- * function because the same delay will be applied to all animations, since they are all
- * run off of a single timing loop.
- *
- * @return the requested time between frames, in milliseconds
- */
- public static long getFrameDelay() {
- return sFrameDelay;
- }
-
- /**
- * The amount of time, in milliseconds, between each frame of the animation. This is a
- * requested time that the animation will attempt to honor, but the actual delay between
- * frames may be different, depending on system load and capabilities. This is a static
- * function because the same delay will be applied to all animations, since they are all
- * run off of a single timing loop.
- *
- * @param frameDelay the requested time between frames, in milliseconds
- */
- public static void setFrameDelay(long frameDelay) {
- sFrameDelay = frameDelay;
- }
-
- /**
- * The most recent value calculated by this ValueAnimator when there is just one
- * property being animated. This value is only sensible while the animation is running. The main
- * purpose for this read-only property is to retrieve the value from the ValueAnimator
- * during a call to {@link AnimatorUpdateListener#onAnimationUpdate(ValueAnimator)}, which
- * is called during each animation frame, immediately after the value is calculated.
- *
- * @return animatedValue The value most recently calculated by this ValueAnimator for
- * the single property being animated. If there are several properties being animated
- * (specified by several PropertyValuesHolder objects in the constructor), this function
- * returns the animated value for the first of those objects.
- */
- public Object getAnimatedValue() {
- if (mValues != null && mValues.length > 0) {
- return mValues[0].getAnimatedValue();
- }
- // Shouldn't get here; should always have values unless ValueAnimator was set up wrong
- return null;
- }
-
- /**
- * The most recent value calculated by this ValueAnimator for propertyName.
- * The main purpose for this read-only property is to retrieve the value from the
- * ValueAnimator during a call to
- * {@link AnimatorUpdateListener#onAnimationUpdate(ValueAnimator)}, which
- * is called during each animation frame, immediately after the value is calculated.
- *
- * @return animatedValue The value most recently calculated for the named property
- * by this ValueAnimator.
- */
- public Object getAnimatedValue(String propertyName) {
- PropertyValuesHolder valuesHolder = mValuesMap.get(propertyName);
- if (valuesHolder != null) {
- return valuesHolder.getAnimatedValue();
- } else {
- // At least avoid crashing if called with bogus propertyName
- return null;
- }
- }
-
- /**
- * Sets how many times the animation should be repeated. If the repeat
- * count is 0, the animation is never repeated. If the repeat count is
- * greater than 0 or {@link #INFINITE}, the repeat mode will be taken
- * into account. The repeat count is 0 by default.
- *
- * @param value the number of times the animation should be repeated
- */
- public void setRepeatCount(int value) {
- mRepeatCount = value;
- }
- /**
- * Defines how many times the animation should repeat. The default value
- * is 0.
- *
- * @return the number of times the animation should repeat, or {@link #INFINITE}
- */
- public int getRepeatCount() {
- return mRepeatCount;
- }
-
- /**
- * Defines what this animation should do when it reaches the end. This
- * setting is applied only when the repeat count is either greater than
- * 0 or {@link #INFINITE}. Defaults to {@link #RESTART}.
- *
- * @param value {@link #RESTART} or {@link #REVERSE}
- */
- public void setRepeatMode(int value) {
- mRepeatMode = value;
- }
-
- /**
- * Defines what this animation should do when it reaches the end.
- *
- * @return either one of {@link #REVERSE} or {@link #RESTART}
- */
- public int getRepeatMode() {
- return mRepeatMode;
- }
-
- /**
- * Adds a listener to the set of listeners that are sent update events through the life of
- * an animation. This method is called on all listeners for every frame of the animation,
- * after the values for the animation have been calculated.
- *
- * @param listener the listener to be added to the current set of listeners for this animation.
- */
- public void addUpdateListener(AnimatorUpdateListener listener) {
- if (mUpdateListeners == null) {
- mUpdateListeners = new ArrayList();
- }
- mUpdateListeners.add(listener);
- }
-
- /**
- * Removes all listeners from the set listening to frame updates for this animation.
- */
- public void removeAllUpdateListeners() {
- if (mUpdateListeners == null) {
- return;
- }
- mUpdateListeners.clear();
- mUpdateListeners = null;
- }
-
- /**
- * Removes a listener from the set listening to frame updates for this animation.
- *
- * @param listener the listener to be removed from the current set of update listeners
- * for this animation.
- */
- public void removeUpdateListener(AnimatorUpdateListener listener) {
- if (mUpdateListeners == null) {
- return;
- }
- mUpdateListeners.remove(listener);
- if (mUpdateListeners.size() == 0) {
- mUpdateListeners = null;
- }
- }
-
-
- /**
- * The time interpolator used in calculating the elapsed fraction of this animation. The
- * interpolator determines whether the animation runs with linear or non-linear motion,
- * such as acceleration and deceleration. The default value is
- * {@link android.view.animation.AccelerateDecelerateInterpolator}
- *
- * @param value the interpolator to be used by this animation. A value of null
- * will result in linear interpolation.
- */
- @Override
- public void setInterpolator(/*Time*/Interpolator value) {
- if (value != null) {
- mInterpolator = value;
- } else {
- mInterpolator = new LinearInterpolator();
- }
- }
-
- /**
- * Returns the timing interpolator that this ValueAnimator uses.
- *
- * @return The timing interpolator for this ValueAnimator.
- */
- public /*Time*/Interpolator getInterpolator() {
- return mInterpolator;
- }
-
- /**
- * The type evaluator to be used when calculating the animated values of this animation.
- * The system will automatically assign a float or int evaluator based on the type
- * of startValue and endValue in the constructor. But if these values
- * are not one of these primitive types, or if different evaluation is desired (such as is
- * necessary with int values that represent colors), a custom evaluator needs to be assigned.
- * For example, when running an animation on color values, the {@link ArgbEvaluator}
- * should be used to get correct RGB color interpolation.
- *
- *
If this ValueAnimator has only one set of values being animated between, this evaluator
- * will be used for that set. If there are several sets of values being animated, which is
- * the case if PropertyValuesHOlder objects were set on the ValueAnimator, then the evaluator
- * is assigned just to the first PropertyValuesHolder object.
- *
- * @param value the evaluator to be used this animation
- */
- public void setEvaluator(TypeEvaluator value) {
- if (value != null && mValues != null && mValues.length > 0) {
- mValues[0].setEvaluator(value);
- }
- }
-
- /**
- * Start the animation playing. This version of start() takes a boolean flag that indicates
- * whether the animation should play in reverse. The flag is usually false, but may be set
- * to true if called from the reverse() method.
- *
- *
The animation started by calling this method will be run on the thread that called
- * this method. This thread should have a Looper on it (a runtime exception will be thrown if
- * this is not the case). Also, if the animation will animate
- * properties of objects in the view hierarchy, then the calling thread should be the UI
- * thread for that view hierarchy.
- *
- * @param playBackwards Whether the ValueAnimator should start playing in reverse.
- */
- private void start(boolean playBackwards) {
- if (Looper.myLooper() == null) {
- throw new AndroidRuntimeException("Animators may only be run on Looper threads");
- }
- mPlayingBackwards = playBackwards;
- mCurrentIteration = 0;
- mPlayingState = STOPPED;
- mStarted = true;
- mStartedDelay = false;
- sPendingAnimations.get().add(this);
- if (mStartDelay == 0) {
- // This sets the initial value of the animation, prior to actually starting it running
- setCurrentPlayTime(getCurrentPlayTime());
- mPlayingState = STOPPED;
- mRunning = true;
-
- if (mListeners != null) {
- ArrayList tmpListeners =
- (ArrayList) mListeners.clone();
- int numListeners = tmpListeners.size();
- for (int i = 0; i < numListeners; ++i) {
- tmpListeners.get(i).onAnimationStart(this);
- }
- }
- }
- AnimationHandler animationHandler = sAnimationHandler.get();
- if (animationHandler == null) {
- animationHandler = new AnimationHandler();
- sAnimationHandler.set(animationHandler);
- }
- animationHandler.sendEmptyMessage(ANIMATION_START);
- }
-
- @Override
- public void start() {
- start(false);
- }
-
- @Override
- public void cancel() {
- // Only cancel if the animation is actually running or has been started and is about
- // to run
- if (mPlayingState != STOPPED || sPendingAnimations.get().contains(this) ||
- sDelayedAnims.get().contains(this)) {
- // Only notify listeners if the animator has actually started
- if (mRunning && mListeners != null) {
- ArrayList tmpListeners =
- (ArrayList) mListeners.clone();
- for (AnimatorListener listener : tmpListeners) {
- listener.onAnimationCancel(this);
- }
- }
- endAnimation();
- }
- }
-
- @Override
- public void end() {
- if (!sAnimations.get().contains(this) && !sPendingAnimations.get().contains(this)) {
- // Special case if the animation has not yet started; get it ready for ending
- mStartedDelay = false;
- startAnimation();
- } else if (!mInitialized) {
- initAnimation();
- }
- // The final value set on the target varies, depending on whether the animation
- // was supposed to repeat an odd number of times
- if (mRepeatCount > 0 && (mRepeatCount & 0x01) == 1) {
- animateValue(0f);
- } else {
- animateValue(1f);
- }
- endAnimation();
- }
-
- @Override
- public boolean isRunning() {
- return (mPlayingState == RUNNING || mRunning);
- }
-
- @Override
- public boolean isStarted() {
- return mStarted;
- }
-
- /**
- * Plays the ValueAnimator in reverse. If the animation is already running,
- * it will stop itself and play backwards from the point reached when reverse was called.
- * If the animation is not currently running, then it will start from the end and
- * play backwards. This behavior is only set for the current animation; future playing
- * of the animation will use the default behavior of playing forward.
- */
- public void reverse() {
- mPlayingBackwards = !mPlayingBackwards;
- if (mPlayingState == RUNNING) {
- long currentTime = AnimationUtils.currentAnimationTimeMillis();
- long currentPlayTime = currentTime - mStartTime;
- long timeLeft = mDuration - currentPlayTime;
- mStartTime = currentTime - timeLeft;
- } else {
- start(true);
- }
- }
-
- /**
- * Called internally to end an animation by removing it from the animations list. Must be
- * called on the UI thread.
- */
- private void endAnimation() {
- sAnimations.get().remove(this);
- sPendingAnimations.get().remove(this);
- sDelayedAnims.get().remove(this);
- mPlayingState = STOPPED;
- if (mRunning && mListeners != null) {
- ArrayList tmpListeners =
- (ArrayList) mListeners.clone();
- int numListeners = tmpListeners.size();
- for (int i = 0; i < numListeners; ++i) {
- tmpListeners.get(i).onAnimationEnd(this);
- }
- }
- mRunning = false;
- mStarted = false;
- }
-
- /**
- * Called internally to start an animation by adding it to the active animations list. Must be
- * called on the UI thread.
- */
- private void startAnimation() {
- initAnimation();
- sAnimations.get().add(this);
- if (mStartDelay > 0 && mListeners != null) {
- // Listeners were already notified in start() if startDelay is 0; this is
- // just for delayed animations
- ArrayList tmpListeners =
- (ArrayList) mListeners.clone();
- int numListeners = tmpListeners.size();
- for (int i = 0; i < numListeners; ++i) {
- tmpListeners.get(i).onAnimationStart(this);
- }
- }
- }
-
- /**
- * Internal function called to process an animation frame on an animation that is currently
- * sleeping through its startDelay phase. The return value indicates whether it
- * should be woken up and put on the active animations queue.
- *
- * @param currentTime The current animation time, used to calculate whether the animation
- * has exceeded its startDelay and should be started.
- * @return True if the animation's startDelay has been exceeded and the animation
- * should be added to the set of active animations.
- */
- private boolean delayedAnimationFrame(long currentTime) {
- if (!mStartedDelay) {
- mStartedDelay = true;
- mDelayStartTime = currentTime;
- } else {
- long deltaTime = currentTime - mDelayStartTime;
- if (deltaTime > mStartDelay) {
- // startDelay ended - start the anim and record the
- // mStartTime appropriately
- mStartTime = currentTime - (deltaTime - mStartDelay);
- mPlayingState = RUNNING;
- return true;
- }
- }
- return false;
- }
-
- /**
- * This internal function processes a single animation frame for a given animation. The
- * currentTime parameter is the timing pulse sent by the handler, used to calculate the
- * elapsed duration, and therefore
- * the elapsed fraction, of the animation. The return value indicates whether the animation
- * should be ended (which happens when the elapsed time of the animation exceeds the
- * animation's duration, including the repeatCount).
- *
- * @param currentTime The current time, as tracked by the static timing handler
- * @return true if the animation's duration, including any repetitions due to
- * repeatCount has been exceeded and the animation should be ended.
- */
- boolean animationFrame(long currentTime) {
- boolean done = false;
-
- if (mPlayingState == STOPPED) {
- mPlayingState = RUNNING;
- if (mSeekTime < 0) {
- mStartTime = currentTime;
- } else {
- mStartTime = currentTime - mSeekTime;
- // Now that we're playing, reset the seek time
- mSeekTime = -1;
- }
- }
- switch (mPlayingState) {
- case RUNNING:
- case SEEKED:
- float fraction = mDuration > 0 ? (float)(currentTime - mStartTime) / mDuration : 1f;
- if (fraction >= 1f) {
- if (mCurrentIteration < mRepeatCount || mRepeatCount == INFINITE) {
- // Time to repeat
- if (mListeners != null) {
- int numListeners = mListeners.size();
- for (int i = 0; i < numListeners; ++i) {
- mListeners.get(i).onAnimationRepeat(this);
- }
- }
- if (mRepeatMode == REVERSE) {
- mPlayingBackwards = mPlayingBackwards ? false : true;
- }
- mCurrentIteration += (int)fraction;
- fraction = fraction % 1f;
- mStartTime += mDuration;
- } else {
- done = true;
- fraction = Math.min(fraction, 1.0f);
- }
- }
- if (mPlayingBackwards) {
- fraction = 1f - fraction;
- }
- animateValue(fraction);
- break;
- }
-
- return done;
- }
-
- /**
- * Returns the current animation fraction, which is the elapsed/interpolated fraction used in
- * the most recent frame update on the animation.
- *
- * @return Elapsed/interpolated fraction of the animation.
- */
- public float getAnimatedFraction() {
- return mCurrentFraction;
- }
-
- /**
- * This method is called with the elapsed fraction of the animation during every
- * animation frame. This function turns the elapsed fraction into an interpolated fraction
- * and then into an animated value (from the evaluator. The function is called mostly during
- * animation updates, but it is also called when the end()
- * function is called, to set the final value on the property.
- *
- *
Overrides of this method must call the superclass to perform the calculation
- * of the animated value.
- *
- * @param fraction The elapsed fraction of the animation.
- */
- void animateValue(float fraction) {
- fraction = mInterpolator.getInterpolation(fraction);
- mCurrentFraction = fraction;
- int numValues = mValues.length;
- for (int i = 0; i < numValues; ++i) {
- mValues[i].calculateValue(fraction);
- }
- if (mUpdateListeners != null) {
- int numListeners = mUpdateListeners.size();
- for (int i = 0; i < numListeners; ++i) {
- mUpdateListeners.get(i).onAnimationUpdate(this);
- }
- }
- }
-
- @Override
- public ValueAnimator clone() {
- final ValueAnimator anim = (ValueAnimator) super.clone();
- if (mUpdateListeners != null) {
- ArrayList oldListeners = mUpdateListeners;
- anim.mUpdateListeners = new ArrayList();
- int numListeners = oldListeners.size();
- for (int i = 0; i < numListeners; ++i) {
- anim.mUpdateListeners.add(oldListeners.get(i));
- }
- }
- anim.mSeekTime = -1;
- anim.mPlayingBackwards = false;
- anim.mCurrentIteration = 0;
- anim.mInitialized = false;
- anim.mPlayingState = STOPPED;
- anim.mStartedDelay = false;
- PropertyValuesHolder[] oldValues = mValues;
- if (oldValues != null) {
- int numValues = oldValues.length;
- anim.mValues = new PropertyValuesHolder[numValues];
- anim.mValuesMap = new HashMap(numValues);
- for (int i = 0; i < numValues; ++i) {
- PropertyValuesHolder newValuesHolder = oldValues[i].clone();
- anim.mValues[i] = newValuesHolder;
- anim.mValuesMap.put(newValuesHolder.getPropertyName(), newValuesHolder);
- }
- }
- return anim;
- }
-
- /**
- * Implementors of this interface can add themselves as update listeners
- * to an ValueAnimator instance to receive callbacks on every animation
- * frame, after the current frame's values have been calculated for that
- * ValueAnimator.
- */
- public static interface AnimatorUpdateListener {
- /**
- *
Notifies the occurrence of another frame of the animation.
- *
- * @param animation The animation which was repeated.
- */
- void onAnimationUpdate(ValueAnimator animation);
-
- }
-
- /**
- * Return the number of animations currently running.
- *
- * Used by StrictMode internally to annotate violations. Only
- * called on the main thread.
- *
- * @hide
- */
- public static int getCurrentAnimationsCount() {
- return sAnimations.get().size();
- }
-
- /**
- * Clear all animations on this thread, without canceling or ending them.
- * This should be used with caution.
- *
- * @hide
- */
- public static void clearAllAnimations() {
- sAnimations.get().clear();
- sPendingAnimations.get().clear();
- sDelayedAnims.get().clear();
- }
-
- @Override
- public String toString() {
- String returnVal = "ValueAnimator@" + Integer.toHexString(hashCode());
- if (mValues != null) {
- for (int i = 0; i < mValues.length; ++i) {
- returnVal += "\n " + mValues[i].toString();
- }
- }
- return returnVal;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.java
deleted file mode 100644
index 7b830b9c05..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package com.actionbarsherlock.internal.nineoldandroids.view;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.ViewGroup;
-
-import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy;
-
-public abstract class NineViewGroup extends ViewGroup {
- private final AnimatorProxy mProxy;
-
- public NineViewGroup(Context context) {
- super(context);
- mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null;
- }
- public NineViewGroup(Context context, AttributeSet attrs) {
- super(context, attrs);
- mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null;
- }
- public NineViewGroup(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null;
- }
-
- @Override
- public void setVisibility(int visibility) {
- if (mProxy != null) {
- if (visibility == GONE) {
- clearAnimation();
- } else if (visibility == VISIBLE) {
- setAnimation(mProxy);
- }
- }
- super.setVisibility(visibility);
- }
-
- public float getAlpha() {
- if (AnimatorProxy.NEEDS_PROXY) {
- return mProxy.getAlpha();
- } else {
- return super.getAlpha();
- }
- }
- public void setAlpha(float alpha) {
- if (AnimatorProxy.NEEDS_PROXY) {
- mProxy.setAlpha(alpha);
- } else {
- super.setAlpha(alpha);
- }
- }
- public float getTranslationX() {
- if (AnimatorProxy.NEEDS_PROXY) {
- return mProxy.getTranslationX();
- } else {
- return super.getTranslationX();
- }
- }
- public void setTranslationX(float translationX) {
- if (AnimatorProxy.NEEDS_PROXY) {
- mProxy.setTranslationX(translationX);
- } else {
- super.setTranslationX(translationX);
- }
- }
- public float getTranslationY() {
- if (AnimatorProxy.NEEDS_PROXY) {
- return mProxy.getTranslationY();
- } else {
- return super.getTranslationY();
- }
- }
- public void setTranslationY(float translationY) {
- if (AnimatorProxy.NEEDS_PROXY) {
- mProxy.setTranslationY(translationY);
- } else {
- super.setTranslationY(translationY);
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.java
deleted file mode 100644
index 067d0494ee..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.java
+++ /dev/null
@@ -1,212 +0,0 @@
-package com.actionbarsherlock.internal.nineoldandroids.view.animation;
-
-import java.lang.ref.WeakReference;
-import java.util.WeakHashMap;
-import android.graphics.Matrix;
-import android.graphics.RectF;
-import android.os.Build;
-import android.util.FloatMath;
-import android.view.View;
-import android.view.animation.Animation;
-import android.view.animation.Transformation;
-
-public final class AnimatorProxy extends Animation {
- public static final boolean NEEDS_PROXY = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB;
-
- private static final WeakHashMap PROXIES =
- new WeakHashMap();
-
- public static AnimatorProxy wrap(View view) {
- AnimatorProxy proxy = PROXIES.get(view);
- if (proxy == null) {
- proxy = new AnimatorProxy(view);
- PROXIES.put(view, proxy);
- }
- return proxy;
- }
-
- private final WeakReference mView;
-
- private float mAlpha = 1;
- private float mScaleX = 1;
- private float mScaleY = 1;
- private float mTranslationX;
- private float mTranslationY;
-
- private final RectF mBefore = new RectF();
- private final RectF mAfter = new RectF();
- private final Matrix mTempMatrix = new Matrix();
-
- private AnimatorProxy(View view) {
- setDuration(0); //perform transformation immediately
- setFillAfter(true); //persist transformation beyond duration
- view.setAnimation(this);
- mView = new WeakReference(view);
- }
-
- public float getAlpha() {
- return mAlpha;
- }
- public void setAlpha(float alpha) {
- if (mAlpha != alpha) {
- mAlpha = alpha;
- View view = mView.get();
- if (view != null) {
- view.invalidate();
- }
- }
- }
- public float getScaleX() {
- return mScaleX;
- }
- public void setScaleX(float scaleX) {
- if (mScaleX != scaleX) {
- prepareForUpdate();
- mScaleX = scaleX;
- invalidateAfterUpdate();
- }
- }
- public float getScaleY() {
- return mScaleY;
- }
- public void setScaleY(float scaleY) {
- if (mScaleY != scaleY) {
- prepareForUpdate();
- mScaleY = scaleY;
- invalidateAfterUpdate();
- }
- }
- public int getScrollX() {
- View view = mView.get();
- if (view == null) {
- return 0;
- }
- return view.getScrollX();
- }
- public void setScrollX(int value) {
- View view = mView.get();
- if (view != null) {
- view.scrollTo(value, view.getScrollY());
- }
- }
- public int getScrollY() {
- View view = mView.get();
- if (view == null) {
- return 0;
- }
- return view.getScrollY();
- }
- public void setScrollY(int value) {
- View view = mView.get();
- if (view != null) {
- view.scrollTo(view.getScrollY(), value);
- }
- }
-
- public float getTranslationX() {
- return mTranslationX;
- }
- public void setTranslationX(float translationX) {
- if (mTranslationX != translationX) {
- prepareForUpdate();
- mTranslationX = translationX;
- invalidateAfterUpdate();
- }
- }
- public float getTranslationY() {
- return mTranslationY;
- }
- public void setTranslationY(float translationY) {
- if (mTranslationY != translationY) {
- prepareForUpdate();
- mTranslationY = translationY;
- invalidateAfterUpdate();
- }
- }
-
- private void prepareForUpdate() {
- View view = mView.get();
- if (view != null) {
- computeRect(mBefore, view);
- }
- }
- private void invalidateAfterUpdate() {
- View view = mView.get();
- if (view == null) {
- return;
- }
- View parent = (View)view.getParent();
- if (parent == null) {
- return;
- }
-
- view.setAnimation(this);
-
- final RectF after = mAfter;
- computeRect(after, view);
- after.union(mBefore);
-
- parent.invalidate(
- (int) FloatMath.floor(after.left),
- (int) FloatMath.floor(after.top),
- (int) FloatMath.ceil(after.right),
- (int) FloatMath.ceil(after.bottom));
- }
-
- private void computeRect(final RectF r, View view) {
- // compute current rectangle according to matrix transformation
- final float w = view.getWidth();
- final float h = view.getHeight();
-
- // use a rectangle at 0,0 to make sure we don't run into issues with scaling
- r.set(0, 0, w, h);
-
- final Matrix m = mTempMatrix;
- m.reset();
- transformMatrix(m, view);
- mTempMatrix.mapRect(r);
-
- r.offset(view.getLeft(), view.getTop());
-
- // Straighten coords if rotations flipped them
- if (r.right < r.left) {
- final float f = r.right;
- r.right = r.left;
- r.left = f;
- }
- if (r.bottom < r.top) {
- final float f = r.top;
- r.top = r.bottom;
- r.bottom = f;
- }
- }
-
- private void transformMatrix(Matrix m, View view) {
- final float w = view.getWidth();
- final float h = view.getHeight();
-
- final float sX = mScaleX;
- final float sY = mScaleY;
- if ((sX != 1.0f) || (sY != 1.0f)) {
- final float deltaSX = ((sX * w) - w) / 2f;
- final float deltaSY = ((sY * h) - h) / 2f;
- m.postScale(sX, sY);
- m.postTranslate(-deltaSX, -deltaSY);
- }
- m.postTranslate(mTranslationX, mTranslationY);
- }
-
- @Override
- protected void applyTransformation(float interpolatedTime, Transformation t) {
- View view = mView.get();
- if (view != null) {
- t.setAlpha(mAlpha);
- transformMatrix(t.getMatrix(), view);
- }
- }
-
- @Override
- public void reset() {
- /* Do nothing. */
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.java
deleted file mode 100644
index 2c428e9071..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package com.actionbarsherlock.internal.nineoldandroids.widget;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.FrameLayout;
-
-import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy;
-
-public class NineFrameLayout extends FrameLayout {
- private final AnimatorProxy mProxy;
-
- public NineFrameLayout(Context context) {
- super(context);
- mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null;
- }
- public NineFrameLayout(Context context, AttributeSet attrs) {
- super(context, attrs);
- mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null;
- }
- public NineFrameLayout(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null;
- }
-
- @Override
- public void setVisibility(int visibility) {
- if (mProxy != null) {
- if (visibility == GONE) {
- clearAnimation();
- } else if (visibility == VISIBLE) {
- setAnimation(mProxy);
- }
- }
- super.setVisibility(visibility);
- }
-
- public float getAlpha() {
- if (AnimatorProxy.NEEDS_PROXY) {
- return mProxy.getAlpha();
- } else {
- return super.getAlpha();
- }
- }
- public void setAlpha(float alpha) {
- if (AnimatorProxy.NEEDS_PROXY) {
- mProxy.setAlpha(alpha);
- } else {
- super.setAlpha(alpha);
- }
- }
- public float getTranslationY() {
- if (AnimatorProxy.NEEDS_PROXY) {
- return mProxy.getTranslationY();
- } else {
- return super.getTranslationY();
- }
- }
- public void setTranslationY(float translationY) {
- if (AnimatorProxy.NEEDS_PROXY) {
- mProxy.setTranslationY(translationY);
- } else {
- super.setTranslationY(translationY);
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java
deleted file mode 100644
index 129b5aaaa6..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.actionbarsherlock.internal.nineoldandroids.widget;
-
-import android.content.Context;
-import android.widget.HorizontalScrollView;
-import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy;
-
-public class NineHorizontalScrollView extends HorizontalScrollView {
- private final AnimatorProxy mProxy;
-
- public NineHorizontalScrollView(Context context) {
- super(context);
- mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null;
- }
-
- @Override
- public void setVisibility(int visibility) {
- if (mProxy != null) {
- if (visibility == GONE) {
- clearAnimation();
- } else if (visibility == VISIBLE) {
- setAnimation(mProxy);
- }
- }
- super.setVisibility(visibility);
- }
-
- public float getAlpha() {
- if (AnimatorProxy.NEEDS_PROXY) {
- return mProxy.getAlpha();
- } else {
- return super.getAlpha();
- }
- }
- public void setAlpha(float alpha) {
- if (AnimatorProxy.NEEDS_PROXY) {
- mProxy.setAlpha(alpha);
- } else {
- super.setAlpha(alpha);
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.java
deleted file mode 100644
index a670b1f64d..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package com.actionbarsherlock.internal.nineoldandroids.widget;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.LinearLayout;
-
-import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy;
-
-public class NineLinearLayout extends LinearLayout {
- private final AnimatorProxy mProxy;
-
- public NineLinearLayout(Context context) {
- super(context);
- mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null;
- }
- public NineLinearLayout(Context context, AttributeSet attrs) {
- super(context, attrs);
- mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null;
- }
- public NineLinearLayout(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null;
- }
-
- @Override
- public void setVisibility(int visibility) {
- if (mProxy != null) {
- if (visibility == GONE) {
- clearAnimation();
- } else if (visibility == VISIBLE) {
- setAnimation(mProxy);
- }
- }
- super.setVisibility(visibility);
- }
-
- public float getAlpha() {
- if (AnimatorProxy.NEEDS_PROXY) {
- return mProxy.getAlpha();
- } else {
- return super.getAlpha();
- }
- }
- public void setAlpha(float alpha) {
- if (AnimatorProxy.NEEDS_PROXY) {
- mProxy.setAlpha(alpha);
- } else {
- super.setAlpha(alpha);
- }
- }
- public float getTranslationX() {
- if (AnimatorProxy.NEEDS_PROXY) {
- return mProxy.getTranslationX();
- } else {
- return super.getTranslationX();
- }
- }
- public void setTranslationX(float translationX) {
- if (AnimatorProxy.NEEDS_PROXY) {
- mProxy.setTranslationX(translationX);
- } else {
- super.setTranslationX(translationX);
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/ActionProviderWrapper.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/ActionProviderWrapper.java
deleted file mode 100644
index b136d50f07..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/ActionProviderWrapper.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.actionbarsherlock.internal.view;
-
-import com.actionbarsherlock.internal.view.menu.SubMenuWrapper;
-import com.actionbarsherlock.view.ActionProvider;
-import android.view.View;
-
-public class ActionProviderWrapper extends android.view.ActionProvider {
- private final ActionProvider mProvider;
-
-
- public ActionProviderWrapper(ActionProvider provider) {
- super(null/*TODO*/); //XXX this *should* be unused
- mProvider = provider;
- }
-
-
- public ActionProvider unwrap() {
- return mProvider;
- }
-
- @Override
- public View onCreateActionView() {
- return mProvider.onCreateActionView();
- }
-
- @Override
- public boolean hasSubMenu() {
- return mProvider.hasSubMenu();
- }
-
- @Override
- public boolean onPerformDefaultAction() {
- return mProvider.onPerformDefaultAction();
- }
-
- @Override
- public void onPrepareSubMenu(android.view.SubMenu subMenu) {
- mProvider.onPrepareSubMenu(new SubMenuWrapper(subMenu));
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/StandaloneActionMode.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/StandaloneActionMode.java
deleted file mode 100644
index 0a87bd3f79..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/StandaloneActionMode.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.view;
-
-import android.content.Context;
-import android.view.View;
-import android.view.accessibility.AccessibilityEvent;
-
-import java.lang.ref.WeakReference;
-
-import com.actionbarsherlock.internal.view.menu.MenuBuilder;
-import com.actionbarsherlock.internal.view.menu.MenuPopupHelper;
-import com.actionbarsherlock.internal.view.menu.SubMenuBuilder;
-import com.actionbarsherlock.internal.widget.ActionBarContextView;
-import com.actionbarsherlock.view.ActionMode;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-public class StandaloneActionMode extends ActionMode implements MenuBuilder.Callback {
- private Context mContext;
- private ActionBarContextView mContextView;
- private ActionMode.Callback mCallback;
- private WeakReference mCustomView;
- private boolean mFinished;
- private boolean mFocusable;
-
- private MenuBuilder mMenu;
-
- public StandaloneActionMode(Context context, ActionBarContextView view,
- ActionMode.Callback callback, boolean isFocusable) {
- mContext = context;
- mContextView = view;
- mCallback = callback;
-
- mMenu = new MenuBuilder(context).setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
- mMenu.setCallback(this);
- mFocusable = isFocusable;
- }
-
- @Override
- public void setTitle(CharSequence title) {
- mContextView.setTitle(title);
- }
-
- @Override
- public void setSubtitle(CharSequence subtitle) {
- mContextView.setSubtitle(subtitle);
- }
-
- @Override
- public void setTitle(int resId) {
- setTitle(mContext.getString(resId));
- }
-
- @Override
- public void setSubtitle(int resId) {
- setSubtitle(mContext.getString(resId));
- }
-
- @Override
- public void setCustomView(View view) {
- mContextView.setCustomView(view);
- mCustomView = view != null ? new WeakReference(view) : null;
- }
-
- @Override
- public void invalidate() {
- mCallback.onPrepareActionMode(this, mMenu);
- }
-
- @Override
- public void finish() {
- if (mFinished) {
- return;
- }
- mFinished = true;
-
- mContextView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
- mCallback.onDestroyActionMode(this);
- }
-
- @Override
- public Menu getMenu() {
- return mMenu;
- }
-
- @Override
- public CharSequence getTitle() {
- return mContextView.getTitle();
- }
-
- @Override
- public CharSequence getSubtitle() {
- return mContextView.getSubtitle();
- }
-
- @Override
- public View getCustomView() {
- return mCustomView != null ? mCustomView.get() : null;
- }
-
- @Override
- public MenuInflater getMenuInflater() {
- return new MenuInflater(mContext);
- }
-
- public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
- return mCallback.onActionItemClicked(this, item);
- }
-
- public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
- }
-
- public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
- if (!subMenu.hasVisibleItems()) {
- return true;
- }
-
- new MenuPopupHelper(mContext, subMenu).show();
- return true;
- }
-
- public void onCloseSubMenu(SubMenuBuilder menu) {
- }
-
- public void onMenuModeChange(MenuBuilder menu) {
- invalidate();
- mContextView.showOverflowMenu();
- }
-
- public boolean isUiFocusable() {
- return mFocusable;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/View_HasStateListenerSupport.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/View_HasStateListenerSupport.java
deleted file mode 100644
index 7d45e81be7..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/View_HasStateListenerSupport.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package com.actionbarsherlock.internal.view;
-
-public interface View_HasStateListenerSupport {
- void addOnAttachStateChangeListener(View_OnAttachStateChangeListener listener);
- void removeOnAttachStateChangeListener(View_OnAttachStateChangeListener listener);
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/View_OnAttachStateChangeListener.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/View_OnAttachStateChangeListener.java
deleted file mode 100644
index 3869d32907..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/View_OnAttachStateChangeListener.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.actionbarsherlock.internal.view;
-
-import android.view.View;
-
-public interface View_OnAttachStateChangeListener {
- void onViewAttachedToWindow(View v);
- void onViewDetachedFromWindow(View v);
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenu.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenu.java
deleted file mode 100644
index 0354ad1ad1..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenu.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.view.KeyEvent;
-
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuItem;
-import com.actionbarsherlock.view.SubMenu;
-
-/**
- * @hide
- */
-public class ActionMenu implements Menu {
- private Context mContext;
-
- private boolean mIsQwerty;
-
- private ArrayList mItems;
-
- public ActionMenu(Context context) {
- mContext = context;
- mItems = new ArrayList();
- }
-
- public Context getContext() {
- return mContext;
- }
-
- public MenuItem add(CharSequence title) {
- return add(0, 0, 0, title);
- }
-
- public MenuItem add(int titleRes) {
- return add(0, 0, 0, titleRes);
- }
-
- public MenuItem add(int groupId, int itemId, int order, int titleRes) {
- return add(groupId, itemId, order, mContext.getResources().getString(titleRes));
- }
-
- public MenuItem add(int groupId, int itemId, int order, CharSequence title) {
- ActionMenuItem item = new ActionMenuItem(getContext(),
- groupId, itemId, 0, order, title);
- mItems.add(order, item);
- return item;
- }
-
- public int addIntentOptions(int groupId, int itemId, int order,
- ComponentName caller, Intent[] specifics, Intent intent, int flags,
- MenuItem[] outSpecificItems) {
- PackageManager pm = mContext.getPackageManager();
- final List lri =
- pm.queryIntentActivityOptions(caller, specifics, intent, 0);
- final int N = lri != null ? lri.size() : 0;
-
- if ((flags & FLAG_APPEND_TO_GROUP) == 0) {
- removeGroup(groupId);
- }
-
- for (int i=0; i= 0) {
- outSpecificItems[ri.specificIndex] = item;
- }
- }
-
- return N;
- }
-
- public SubMenu addSubMenu(CharSequence title) {
- // TODO Implement submenus
- return null;
- }
-
- public SubMenu addSubMenu(int titleRes) {
- // TODO Implement submenus
- return null;
- }
-
- public SubMenu addSubMenu(int groupId, int itemId, int order,
- CharSequence title) {
- // TODO Implement submenus
- return null;
- }
-
- public SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes) {
- // TODO Implement submenus
- return null;
- }
-
- public void clear() {
- mItems.clear();
- }
-
- public void close() {
- }
-
- private int findItemIndex(int id) {
- final ArrayList items = mItems;
- final int itemCount = items.size();
- for (int i = 0; i < itemCount; i++) {
- if (items.get(i).getItemId() == id) {
- return i;
- }
- }
-
- return -1;
- }
-
- public MenuItem findItem(int id) {
- return mItems.get(findItemIndex(id));
- }
-
- public MenuItem getItem(int index) {
- return mItems.get(index);
- }
-
- public boolean hasVisibleItems() {
- final ArrayList items = mItems;
- final int itemCount = items.size();
-
- for (int i = 0; i < itemCount; i++) {
- if (items.get(i).isVisible()) {
- return true;
- }
- }
-
- return false;
- }
-
- private ActionMenuItem findItemWithShortcut(int keyCode, KeyEvent event) {
- // TODO Make this smarter.
- final boolean qwerty = mIsQwerty;
- final ArrayList items = mItems;
- final int itemCount = items.size();
-
- for (int i = 0; i < itemCount; i++) {
- ActionMenuItem item = items.get(i);
- final char shortcut = qwerty ? item.getAlphabeticShortcut() :
- item.getNumericShortcut();
- if (keyCode == shortcut) {
- return item;
- }
- }
- return null;
- }
-
- public boolean isShortcutKey(int keyCode, KeyEvent event) {
- return findItemWithShortcut(keyCode, event) != null;
- }
-
- public boolean performIdentifierAction(int id, int flags) {
- final int index = findItemIndex(id);
- if (index < 0) {
- return false;
- }
-
- return mItems.get(index).invoke();
- }
-
- public boolean performShortcut(int keyCode, KeyEvent event, int flags) {
- ActionMenuItem item = findItemWithShortcut(keyCode, event);
- if (item == null) {
- return false;
- }
-
- return item.invoke();
- }
-
- public void removeGroup(int groupId) {
- final ArrayList items = mItems;
- int itemCount = items.size();
- int i = 0;
- while (i < itemCount) {
- if (items.get(i).getGroupId() == groupId) {
- items.remove(i);
- itemCount--;
- } else {
- i++;
- }
- }
- }
-
- public void removeItem(int id) {
- mItems.remove(findItemIndex(id));
- }
-
- public void setGroupCheckable(int group, boolean checkable,
- boolean exclusive) {
- final ArrayList items = mItems;
- final int itemCount = items.size();
-
- for (int i = 0; i < itemCount; i++) {
- ActionMenuItem item = items.get(i);
- if (item.getGroupId() == group) {
- item.setCheckable(checkable);
- item.setExclusiveCheckable(exclusive);
- }
- }
- }
-
- public void setGroupEnabled(int group, boolean enabled) {
- final ArrayList items = mItems;
- final int itemCount = items.size();
-
- for (int i = 0; i < itemCount; i++) {
- ActionMenuItem item = items.get(i);
- if (item.getGroupId() == group) {
- item.setEnabled(enabled);
- }
- }
- }
-
- public void setGroupVisible(int group, boolean visible) {
- final ArrayList items = mItems;
- final int itemCount = items.size();
-
- for (int i = 0; i < itemCount; i++) {
- ActionMenuItem item = items.get(i);
- if (item.getGroupId() == group) {
- item.setVisible(visible);
- }
- }
- }
-
- public void setQwertyMode(boolean isQwerty) {
- mIsQwerty = isQwerty;
- }
-
- public int size() {
- return mItems.size();
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItem.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItem.java
deleted file mode 100644
index 510b974886..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItem.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu;
-
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.drawable.Drawable;
-import android.view.ContextMenu.ContextMenuInfo;
-import android.view.View;
-
-import com.actionbarsherlock.view.ActionProvider;
-import com.actionbarsherlock.view.MenuItem;
-import com.actionbarsherlock.view.SubMenu;
-
-/**
- * @hide
- */
-public class ActionMenuItem implements MenuItem {
- private final int mId;
- private final int mGroup;
- //UNUSED private final int mCategoryOrder;
- private final int mOrdering;
-
- private CharSequence mTitle;
- private CharSequence mTitleCondensed;
- private Intent mIntent;
- private char mShortcutNumericChar;
- private char mShortcutAlphabeticChar;
-
- private Drawable mIconDrawable;
- //UNUSED private int mIconResId = NO_ICON;
-
- private Context mContext;
-
- private MenuItem.OnMenuItemClickListener mClickListener;
-
- //UNUSED private static final int NO_ICON = 0;
-
- private int mFlags = ENABLED;
- private static final int CHECKABLE = 0x00000001;
- private static final int CHECKED = 0x00000002;
- private static final int EXCLUSIVE = 0x00000004;
- private static final int HIDDEN = 0x00000008;
- private static final int ENABLED = 0x00000010;
-
- public ActionMenuItem(Context context, int group, int id, int categoryOrder, int ordering,
- CharSequence title) {
- mContext = context;
- mId = id;
- mGroup = group;
- //UNUSED mCategoryOrder = categoryOrder;
- mOrdering = ordering;
- mTitle = title;
- }
-
- public char getAlphabeticShortcut() {
- return mShortcutAlphabeticChar;
- }
-
- public int getGroupId() {
- return mGroup;
- }
-
- public Drawable getIcon() {
- return mIconDrawable;
- }
-
- public Intent getIntent() {
- return mIntent;
- }
-
- public int getItemId() {
- return mId;
- }
-
- public ContextMenuInfo getMenuInfo() {
- return null;
- }
-
- public char getNumericShortcut() {
- return mShortcutNumericChar;
- }
-
- public int getOrder() {
- return mOrdering;
- }
-
- public SubMenu getSubMenu() {
- return null;
- }
-
- public CharSequence getTitle() {
- return mTitle;
- }
-
- public CharSequence getTitleCondensed() {
- return mTitleCondensed;
- }
-
- public boolean hasSubMenu() {
- return false;
- }
-
- public boolean isCheckable() {
- return (mFlags & CHECKABLE) != 0;
- }
-
- public boolean isChecked() {
- return (mFlags & CHECKED) != 0;
- }
-
- public boolean isEnabled() {
- return (mFlags & ENABLED) != 0;
- }
-
- public boolean isVisible() {
- return (mFlags & HIDDEN) == 0;
- }
-
- public MenuItem setAlphabeticShortcut(char alphaChar) {
- mShortcutAlphabeticChar = alphaChar;
- return this;
- }
-
- public MenuItem setCheckable(boolean checkable) {
- mFlags = (mFlags & ~CHECKABLE) | (checkable ? CHECKABLE : 0);
- return this;
- }
-
- public ActionMenuItem setExclusiveCheckable(boolean exclusive) {
- mFlags = (mFlags & ~EXCLUSIVE) | (exclusive ? EXCLUSIVE : 0);
- return this;
- }
-
- public MenuItem setChecked(boolean checked) {
- mFlags = (mFlags & ~CHECKED) | (checked ? CHECKED : 0);
- return this;
- }
-
- public MenuItem setEnabled(boolean enabled) {
- mFlags = (mFlags & ~ENABLED) | (enabled ? ENABLED : 0);
- return this;
- }
-
- public MenuItem setIcon(Drawable icon) {
- mIconDrawable = icon;
- //UNUSED mIconResId = NO_ICON;
- return this;
- }
-
- public MenuItem setIcon(int iconRes) {
- //UNUSED mIconResId = iconRes;
- mIconDrawable = mContext.getResources().getDrawable(iconRes);
- return this;
- }
-
- public MenuItem setIntent(Intent intent) {
- mIntent = intent;
- return this;
- }
-
- public MenuItem setNumericShortcut(char numericChar) {
- mShortcutNumericChar = numericChar;
- return this;
- }
-
- public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener menuItemClickListener) {
- mClickListener = menuItemClickListener;
- return this;
- }
-
- public MenuItem setShortcut(char numericChar, char alphaChar) {
- mShortcutNumericChar = numericChar;
- mShortcutAlphabeticChar = alphaChar;
- return this;
- }
-
- public MenuItem setTitle(CharSequence title) {
- mTitle = title;
- return this;
- }
-
- public MenuItem setTitle(int title) {
- mTitle = mContext.getResources().getString(title);
- return this;
- }
-
- public MenuItem setTitleCondensed(CharSequence title) {
- mTitleCondensed = title;
- return this;
- }
-
- public MenuItem setVisible(boolean visible) {
- mFlags = (mFlags & HIDDEN) | (visible ? 0 : HIDDEN);
- return this;
- }
-
- public boolean invoke() {
- if (mClickListener != null && mClickListener.onMenuItemClick(this)) {
- return true;
- }
-
- if (mIntent != null) {
- mContext.startActivity(mIntent);
- return true;
- }
-
- return false;
- }
-
- public void setShowAsAction(int show) {
- // Do nothing. ActionMenuItems always show as action buttons.
- }
-
- public MenuItem setActionView(View actionView) {
- throw new UnsupportedOperationException();
- }
-
- public View getActionView() {
- return null;
- }
-
- @Override
- public MenuItem setActionView(int resId) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ActionProvider getActionProvider() {
- return null;
- }
-
- @Override
- public MenuItem setActionProvider(ActionProvider actionProvider) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public MenuItem setShowAsActionFlags(int actionEnum) {
- setShowAsAction(actionEnum);
- return this;
- }
-
- @Override
- public boolean expandActionView() {
- return false;
- }
-
- @Override
- public boolean collapseActionView() {
- return false;
- }
-
- @Override
- public boolean isActionViewExpanded() {
- return false;
- }
-
- @Override
- public MenuItem setOnActionExpandListener(OnActionExpandListener listener) {
- // No need to save the listener; ActionMenuItem does not support collapsing items.
- return this;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java
deleted file mode 100644
index dcb50f3621..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu;
-
-import java.util.HashSet;
-import java.util.Set;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.accessibility.AccessibilityEvent;
-import android.widget.ImageButton;
-import android.widget.LinearLayout;
-import android.widget.Toast;
-
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.internal.view.View_HasStateListenerSupport;
-import com.actionbarsherlock.internal.view.View_OnAttachStateChangeListener;
-import com.actionbarsherlock.internal.widget.CapitalizingButton;
-
-import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean;
-
-/**
- * @hide
- */
-public class ActionMenuItemView extends LinearLayout
- implements MenuView.ItemView, View.OnClickListener, View.OnLongClickListener,
- ActionMenuView.ActionMenuChildView, View_HasStateListenerSupport {
- //UNUSED private static final String TAG = "ActionMenuItemView";
-
- private MenuItemImpl mItemData;
- private CharSequence mTitle;
- private MenuBuilder.ItemInvoker mItemInvoker;
-
- private ImageButton mImageButton;
- private CapitalizingButton mTextButton;
- private boolean mAllowTextWithIcon;
- private boolean mExpandedFormat;
- private int mMinWidth;
-
- private final Set mListeners = new HashSet();
-
- public ActionMenuItemView(Context context) {
- this(context, null);
- }
-
- public ActionMenuItemView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public ActionMenuItemView(Context context, AttributeSet attrs, int defStyle) {
- //TODO super(context, attrs, defStyle);
- super(context, attrs);
- mAllowTextWithIcon = getResources_getBoolean(context,
- R.bool.abs__config_allowActionMenuItemTextWithIcon);
- TypedArray a = context.obtainStyledAttributes(attrs,
- R.styleable.SherlockActionMenuItemView, 0, 0);
- mMinWidth = a.getDimensionPixelSize(
- R.styleable.SherlockActionMenuItemView_android_minWidth, 0);
- a.recycle();
- }
-
- @Override
- public void addOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) {
- mListeners.add(listener);
- }
-
- @Override
- public void removeOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) {
- mListeners.remove(listener);
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- for (View_OnAttachStateChangeListener listener : mListeners) {
- listener.onViewAttachedToWindow(this);
- }
- }
-
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- for (View_OnAttachStateChangeListener listener : mListeners) {
- listener.onViewDetachedFromWindow(this);
- }
- }
-
- @Override
- public void onFinishInflate() {
-
- mImageButton = (ImageButton) findViewById(R.id.abs__imageButton);
- mTextButton = (CapitalizingButton) findViewById(R.id.abs__textButton);
- mImageButton.setOnClickListener(this);
- mTextButton.setOnClickListener(this);
- mImageButton.setOnLongClickListener(this);
- setOnClickListener(this);
- setOnLongClickListener(this);
- }
-
- public MenuItemImpl getItemData() {
- return mItemData;
- }
-
- public void initialize(MenuItemImpl itemData, int menuType) {
- mItemData = itemData;
-
- setIcon(itemData.getIcon());
- setTitle(itemData.getTitleForItemView(this)); // Title only takes effect if there is no icon
- setId(itemData.getItemId());
-
- setVisibility(itemData.isVisible() ? View.VISIBLE : View.GONE);
- setEnabled(itemData.isEnabled());
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- super.setEnabled(enabled);
- mImageButton.setEnabled(enabled);
- mTextButton.setEnabled(enabled);
- }
-
- public void onClick(View v) {
- if (mItemInvoker != null) {
- mItemInvoker.invokeItem(mItemData);
- }
- }
-
- public void setItemInvoker(MenuBuilder.ItemInvoker invoker) {
- mItemInvoker = invoker;
- }
-
- public boolean prefersCondensedTitle() {
- return true;
- }
-
- public void setCheckable(boolean checkable) {
- // TODO Support checkable action items
- }
-
- public void setChecked(boolean checked) {
- // TODO Support checkable action items
- }
-
- public void setExpandedFormat(boolean expandedFormat) {
- if (mExpandedFormat != expandedFormat) {
- mExpandedFormat = expandedFormat;
- if (mItemData != null) {
- mItemData.actionFormatChanged();
- }
- }
- }
-
- private void updateTextButtonVisibility() {
- boolean visible = !TextUtils.isEmpty(mTextButton.getText());
- visible &= mImageButton.getDrawable() == null ||
- (mItemData.showsTextAsAction() && (mAllowTextWithIcon || mExpandedFormat));
-
- mTextButton.setVisibility(visible ? VISIBLE : GONE);
- }
-
- public void setIcon(Drawable icon) {
- mImageButton.setImageDrawable(icon);
- if (icon != null) {
- mImageButton.setVisibility(VISIBLE);
- } else {
- mImageButton.setVisibility(GONE);
- }
-
- updateTextButtonVisibility();
- }
-
- public boolean hasText() {
- return mTextButton.getVisibility() != GONE;
- }
-
- public void setShortcut(boolean showShortcut, char shortcutKey) {
- // Action buttons don't show text for shortcut keys.
- }
-
- public void setTitle(CharSequence title) {
- mTitle = title;
-
- mTextButton.setTextCompat(mTitle);
-
- setContentDescription(mTitle);
- updateTextButtonVisibility();
- }
-
- @Override
- public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
- onPopulateAccessibilityEvent(event);
- return true;
- }
-
- @Override
- public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- super.onPopulateAccessibilityEvent(event);
- }
- final CharSequence cdesc = getContentDescription();
- if (!TextUtils.isEmpty(cdesc)) {
- event.getText().add(cdesc);
- }
- }
-
- @Override
- public boolean dispatchHoverEvent(MotionEvent event) {
- // Don't allow children to hover; we want this to be treated as a single component.
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- return onHoverEvent(event);
- }
- return false;
- }
-
- public boolean showsIcon() {
- return true;
- }
-
- public boolean needsDividerBefore() {
- return hasText() && mItemData.getIcon() == null;
- }
-
- public boolean needsDividerAfter() {
- return hasText();
- }
-
- @Override
- public boolean onLongClick(View v) {
- if (hasText()) {
- // Don't show the cheat sheet for items that already show text.
- return false;
- }
-
- final int[] screenPos = new int[2];
- final Rect displayFrame = new Rect();
- getLocationOnScreen(screenPos);
- getWindowVisibleDisplayFrame(displayFrame);
-
- final Context context = getContext();
- final int width = getWidth();
- final int height = getHeight();
- final int midy = screenPos[1] + height / 2;
- final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
-
- Toast cheatSheet = Toast.makeText(context, mItemData.getTitle(), Toast.LENGTH_SHORT);
- if (midy < displayFrame.height()) {
- // Show along the top; follow action buttons
- cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT,
- screenWidth - screenPos[0] - width / 2, height);
- } else {
- // Show along the bottom center
- cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
- }
- cheatSheet.show();
- return true;
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-
- final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
- final int specSize = MeasureSpec.getSize(widthMeasureSpec);
- final int oldMeasuredWidth = getMeasuredWidth();
- final int targetWidth = widthMode == MeasureSpec.AT_MOST ? Math.min(specSize, mMinWidth)
- : mMinWidth;
-
- if (widthMode != MeasureSpec.EXACTLY && mMinWidth > 0 && oldMeasuredWidth < targetWidth) {
- // Remeasure at exactly the minimum width.
- super.onMeasure(MeasureSpec.makeMeasureSpec(targetWidth, MeasureSpec.EXACTLY),
- heightMeasureSpec);
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java
deleted file mode 100644
index 6f568c6981..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java
+++ /dev/null
@@ -1,721 +0,0 @@
-/*
- * Copyright (C) 2011 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.actionbarsherlock.internal.view.menu;
-
-import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getInteger;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
-import android.content.Context;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.os.Build;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.util.SparseBooleanArray;
-import android.view.SoundEffectConstants;
-import android.view.View;
-import android.view.View.MeasureSpec;
-import android.view.ViewConfiguration;
-import android.view.ViewGroup;
-import android.widget.ImageButton;
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.internal.view.View_HasStateListenerSupport;
-import com.actionbarsherlock.internal.view.View_OnAttachStateChangeListener;
-import com.actionbarsherlock.internal.view.menu.ActionMenuView.ActionMenuChildView;
-import com.actionbarsherlock.view.ActionProvider;
-import com.actionbarsherlock.view.MenuItem;
-
-/**
- * MenuPresenter for building action menus as seen in the action bar and action modes.
- */
-public class ActionMenuPresenter extends BaseMenuPresenter
- implements ActionProvider.SubUiVisibilityListener {
- //UNUSED private static final String TAG = "ActionMenuPresenter";
-
- private View mOverflowButton;
- private boolean mReserveOverflow;
- private boolean mReserveOverflowSet;
- private int mWidthLimit;
- private int mActionItemWidthLimit;
- private int mMaxItems;
- private boolean mMaxItemsSet;
- private boolean mStrictWidthLimit;
- private boolean mWidthLimitSet;
- private boolean mExpandedActionViewsExclusive;
-
- private int mMinCellSize;
-
- // Group IDs that have been added as actions - used temporarily, allocated here for reuse.
- private final SparseBooleanArray mActionButtonGroups = new SparseBooleanArray();
-
- private View mScrapActionButtonView;
-
- private OverflowPopup mOverflowPopup;
- private ActionButtonSubmenu mActionButtonPopup;
-
- private OpenOverflowRunnable mPostedOpenRunnable;
-
- final PopupPresenterCallback mPopupPresenterCallback = new PopupPresenterCallback();
- int mOpenSubMenuId;
-
- public ActionMenuPresenter(Context context) {
- super(context, R.layout.abs__action_menu_layout,
- R.layout.abs__action_menu_item_layout);
- }
-
- @Override
- public void initForMenu(Context context, MenuBuilder menu) {
- super.initForMenu(context, menu);
-
- final Resources res = context.getResources();
-
- if (!mReserveOverflowSet) {
- mReserveOverflow = reserveOverflow(mContext);
- }
-
- if (!mWidthLimitSet) {
- mWidthLimit = res.getDisplayMetrics().widthPixels / 2;
- }
-
- // Measure for initial configuration
- if (!mMaxItemsSet) {
- mMaxItems = getResources_getInteger(context, R.integer.abs__max_action_buttons);
- }
-
- int width = mWidthLimit;
- if (mReserveOverflow) {
- if (mOverflowButton == null) {
- mOverflowButton = new OverflowMenuButton(mSystemContext);
- final int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
- mOverflowButton.measure(spec, spec);
- }
- width -= mOverflowButton.getMeasuredWidth();
- } else {
- mOverflowButton = null;
- }
-
- mActionItemWidthLimit = width;
-
- mMinCellSize = (int) (ActionMenuView.MIN_CELL_SIZE * res.getDisplayMetrics().density);
-
- // Drop a scrap view as it may no longer reflect the proper context/config.
- mScrapActionButtonView = null;
- }
-
- public static boolean reserveOverflow(Context context) {
- //Check for theme-forced overflow action item
- TypedArray a = context.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme);
- boolean result = a.getBoolean(R.styleable.SherlockTheme_absForceOverflow, false);
- a.recycle();
- if (result) {
- return true;
- }
-
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB);
- } else {
- return !HasPermanentMenuKey.get(context);
- }
- }
-
- private static class HasPermanentMenuKey {
- public static boolean get(Context context) {
- return ViewConfiguration.get(context).hasPermanentMenuKey();
- }
- }
-
- public void onConfigurationChanged(Configuration newConfig) {
- if (!mMaxItemsSet) {
- mMaxItems = getResources_getInteger(mContext,
- R.integer.abs__max_action_buttons);
- if (mMenu != null) {
- mMenu.onItemsChanged(true);
- }
- }
- }
-
- public void setWidthLimit(int width, boolean strict) {
- mWidthLimit = width;
- mStrictWidthLimit = strict;
- mWidthLimitSet = true;
- }
-
- public void setReserveOverflow(boolean reserveOverflow) {
- mReserveOverflow = reserveOverflow;
- mReserveOverflowSet = true;
- }
-
- public void setItemLimit(int itemCount) {
- mMaxItems = itemCount;
- mMaxItemsSet = true;
- }
-
- public void setExpandedActionViewsExclusive(boolean isExclusive) {
- mExpandedActionViewsExclusive = isExclusive;
- }
-
- @Override
- public MenuView getMenuView(ViewGroup root) {
- MenuView result = super.getMenuView(root);
- ((ActionMenuView) result).setPresenter(this);
- return result;
- }
-
- @Override
- public View getItemView(MenuItemImpl item, View convertView, ViewGroup parent) {
- View actionView = item.getActionView();
- if (actionView == null || item.hasCollapsibleActionView()) {
- if (!(convertView instanceof ActionMenuItemView)) {
- convertView = null;
- }
- actionView = super.getItemView(item, convertView, parent);
- }
- actionView.setVisibility(item.isActionViewExpanded() ? View.GONE : View.VISIBLE);
-
- final ActionMenuView menuParent = (ActionMenuView) parent;
- final ViewGroup.LayoutParams lp = actionView.getLayoutParams();
- if (!menuParent.checkLayoutParams(lp)) {
- actionView.setLayoutParams(menuParent.generateLayoutParams(lp));
- }
- return actionView;
- }
-
- @Override
- public void bindItemView(MenuItemImpl item, MenuView.ItemView itemView) {
- itemView.initialize(item, 0);
-
- final ActionMenuView menuView = (ActionMenuView) mMenuView;
- ActionMenuItemView actionItemView = (ActionMenuItemView) itemView;
- actionItemView.setItemInvoker(menuView);
- }
-
- @Override
- public boolean shouldIncludeItem(int childIndex, MenuItemImpl item) {
- return item.isActionButton();
- }
-
- @Override
- public void updateMenuView(boolean cleared) {
- super.updateMenuView(cleared);
-
- if (mMenu != null) {
- final ArrayList actionItems = mMenu.getActionItems();
- final int count = actionItems.size();
- for (int i = 0; i < count; i++) {
- final ActionProvider provider = actionItems.get(i).getActionProvider();
- if (provider != null) {
- provider.setSubUiVisibilityListener(this);
- }
- }
- }
-
- final ArrayList nonActionItems = mMenu != null ?
- mMenu.getNonActionItems() : null;
-
- boolean hasOverflow = false;
- if (mReserveOverflow && nonActionItems != null) {
- final int count = nonActionItems.size();
- if (count == 1) {
- hasOverflow = !nonActionItems.get(0).isActionViewExpanded();
- } else {
- hasOverflow = count > 0;
- }
- }
-
- if (hasOverflow) {
- if (mOverflowButton == null) {
- mOverflowButton = new OverflowMenuButton(mSystemContext);
- }
- ViewGroup parent = (ViewGroup) mOverflowButton.getParent();
- if (parent != mMenuView) {
- if (parent != null) {
- parent.removeView(mOverflowButton);
- }
- ActionMenuView menuView = (ActionMenuView) mMenuView;
- menuView.addView(mOverflowButton, menuView.generateOverflowButtonLayoutParams());
- }
- } else if (mOverflowButton != null && mOverflowButton.getParent() == mMenuView) {
- ((ViewGroup) mMenuView).removeView(mOverflowButton);
- }
-
- ((ActionMenuView) mMenuView).setOverflowReserved(mReserveOverflow);
- }
-
- @Override
- public boolean filterLeftoverView(ViewGroup parent, int childIndex) {
- if (parent.getChildAt(childIndex) == mOverflowButton) return false;
- return super.filterLeftoverView(parent, childIndex);
- }
-
- public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
- if (!subMenu.hasVisibleItems()) return false;
-
- SubMenuBuilder topSubMenu = subMenu;
- while (topSubMenu.getParentMenu() != mMenu) {
- topSubMenu = (SubMenuBuilder) topSubMenu.getParentMenu();
- }
- View anchor = findViewForItem(topSubMenu.getItem());
- if (anchor == null) {
- if (mOverflowButton == null) return false;
- anchor = mOverflowButton;
- }
-
- mOpenSubMenuId = subMenu.getItem().getItemId();
- mActionButtonPopup = new ActionButtonSubmenu(mContext, subMenu);
- mActionButtonPopup.setAnchorView(anchor);
- mActionButtonPopup.show();
- super.onSubMenuSelected(subMenu);
- return true;
- }
-
- private View findViewForItem(MenuItem item) {
- final ViewGroup parent = (ViewGroup) mMenuView;
- if (parent == null) return null;
-
- final int count = parent.getChildCount();
- for (int i = 0; i < count; i++) {
- final View child = parent.getChildAt(i);
- if (child instanceof MenuView.ItemView &&
- ((MenuView.ItemView) child).getItemData() == item) {
- return child;
- }
- }
- return null;
- }
-
- /**
- * Display the overflow menu if one is present.
- * @return true if the overflow menu was shown, false otherwise.
- */
- public boolean showOverflowMenu() {
- if (mReserveOverflow && !isOverflowMenuShowing() && mMenu != null && mMenuView != null &&
- mPostedOpenRunnable == null && !mMenu.getNonActionItems().isEmpty()) {
- OverflowPopup popup = new OverflowPopup(mContext, mMenu, mOverflowButton, true);
- mPostedOpenRunnable = new OpenOverflowRunnable(popup);
- // Post this for later; we might still need a layout for the anchor to be right.
- ((View) mMenuView).post(mPostedOpenRunnable);
-
- // ActionMenuPresenter uses null as a callback argument here
- // to indicate overflow is opening.
- super.onSubMenuSelected(null);
-
- return true;
- }
- return false;
- }
-
- /**
- * Hide the overflow menu if it is currently showing.
- *
- * @return true if the overflow menu was hidden, false otherwise.
- */
- public boolean hideOverflowMenu() {
- if (mPostedOpenRunnable != null && mMenuView != null) {
- ((View) mMenuView).removeCallbacks(mPostedOpenRunnable);
- mPostedOpenRunnable = null;
- return true;
- }
-
- MenuPopupHelper popup = mOverflowPopup;
- if (popup != null) {
- popup.dismiss();
- return true;
- }
- return false;
- }
-
- /**
- * Dismiss all popup menus - overflow and submenus.
- * @return true if popups were dismissed, false otherwise. (This can be because none were open.)
- */
- public boolean dismissPopupMenus() {
- boolean result = hideOverflowMenu();
- result |= hideSubMenus();
- return result;
- }
-
- /**
- * Dismiss all submenu popups.
- *
- * @return true if popups were dismissed, false otherwise. (This can be because none were open.)
- */
- public boolean hideSubMenus() {
- if (mActionButtonPopup != null) {
- mActionButtonPopup.dismiss();
- return true;
- }
- return false;
- }
-
- /**
- * @return true if the overflow menu is currently showing
- */
- public boolean isOverflowMenuShowing() {
- return mOverflowPopup != null && mOverflowPopup.isShowing();
- }
-
- /**
- * @return true if space has been reserved in the action menu for an overflow item.
- */
- public boolean isOverflowReserved() {
- return mReserveOverflow;
- }
-
- public boolean flagActionItems() {
- final ArrayList visibleItems = mMenu.getVisibleItems();
- final int itemsSize = visibleItems.size();
- int maxActions = mMaxItems;
- int widthLimit = mActionItemWidthLimit;
- final int querySpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
- final ViewGroup parent = (ViewGroup) mMenuView;
-
- int requiredItems = 0;
- int requestedItems = 0;
- int firstActionWidth = 0;
- boolean hasOverflow = false;
- for (int i = 0; i < itemsSize; i++) {
- MenuItemImpl item = visibleItems.get(i);
- if (item.requiresActionButton()) {
- requiredItems++;
- } else if (item.requestsActionButton()) {
- requestedItems++;
- } else {
- hasOverflow = true;
- }
- if (mExpandedActionViewsExclusive && item.isActionViewExpanded()) {
- // Overflow everything if we have an expanded action view and we're
- // space constrained.
- maxActions = 0;
- }
- }
-
- // Reserve a spot for the overflow item if needed.
- if (mReserveOverflow &&
- (hasOverflow || requiredItems + requestedItems > maxActions)) {
- maxActions--;
- }
- maxActions -= requiredItems;
-
- final SparseBooleanArray seenGroups = mActionButtonGroups;
- seenGroups.clear();
-
- int cellSize = 0;
- int cellsRemaining = 0;
- if (mStrictWidthLimit) {
- cellsRemaining = widthLimit / mMinCellSize;
- final int cellSizeRemaining = widthLimit % mMinCellSize;
- cellSize = mMinCellSize + cellSizeRemaining / cellsRemaining;
- }
-
- // Flag as many more requested items as will fit.
- for (int i = 0; i < itemsSize; i++) {
- MenuItemImpl item = visibleItems.get(i);
-
- if (item.requiresActionButton()) {
- View v = getItemView(item, mScrapActionButtonView, parent);
- if (mScrapActionButtonView == null) {
- mScrapActionButtonView = v;
- }
- if (mStrictWidthLimit) {
- cellsRemaining -= ActionMenuView.measureChildForCells(v,
- cellSize, cellsRemaining, querySpec, 0);
- } else {
- v.measure(querySpec, querySpec);
- }
- final int measuredWidth = v.getMeasuredWidth();
- widthLimit -= measuredWidth;
- if (firstActionWidth == 0) {
- firstActionWidth = measuredWidth;
- }
- final int groupId = item.getGroupId();
- if (groupId != 0) {
- seenGroups.put(groupId, true);
- }
- item.setIsActionButton(true);
- } else if (item.requestsActionButton()) {
- // Items in a group with other items that already have an action slot
- // can break the max actions rule, but not the width limit.
- final int groupId = item.getGroupId();
- final boolean inGroup = seenGroups.get(groupId);
- boolean isAction = (maxActions > 0 || inGroup) && widthLimit > 0 &&
- (!mStrictWidthLimit || cellsRemaining > 0);
-
- if (isAction) {
- View v = getItemView(item, mScrapActionButtonView, parent);
- if (mScrapActionButtonView == null) {
- mScrapActionButtonView = v;
- }
- if (mStrictWidthLimit) {
- final int cells = ActionMenuView.measureChildForCells(v,
- cellSize, cellsRemaining, querySpec, 0);
- cellsRemaining -= cells;
- if (cells == 0) {
- isAction = false;
- }
- } else {
- v.measure(querySpec, querySpec);
- }
- final int measuredWidth = v.getMeasuredWidth();
- widthLimit -= measuredWidth;
- if (firstActionWidth == 0) {
- firstActionWidth = measuredWidth;
- }
-
- if (mStrictWidthLimit) {
- isAction &= widthLimit >= 0;
- } else {
- // Did this push the entire first item past the limit?
- isAction &= widthLimit + firstActionWidth > 0;
- }
- }
-
- if (isAction && groupId != 0) {
- seenGroups.put(groupId, true);
- } else if (inGroup) {
- // We broke the width limit. Demote the whole group, they all overflow now.
- seenGroups.put(groupId, false);
- for (int j = 0; j < i; j++) {
- MenuItemImpl areYouMyGroupie = visibleItems.get(j);
- if (areYouMyGroupie.getGroupId() == groupId) {
- // Give back the action slot
- if (areYouMyGroupie.isActionButton()) maxActions++;
- areYouMyGroupie.setIsActionButton(false);
- }
- }
- }
-
- if (isAction) maxActions--;
-
- item.setIsActionButton(isAction);
- }
- }
- return true;
- }
-
- @Override
- public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
- dismissPopupMenus();
- super.onCloseMenu(menu, allMenusAreClosing);
- }
-
- @Override
- public Parcelable onSaveInstanceState() {
- SavedState state = new SavedState();
- state.openSubMenuId = mOpenSubMenuId;
- return state;
- }
-
- @Override
- public void onRestoreInstanceState(Parcelable state) {
- SavedState saved = (SavedState) state;
- if (saved.openSubMenuId > 0) {
- MenuItem item = mMenu.findItem(saved.openSubMenuId);
- if (item != null) {
- SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
- onSubMenuSelected(subMenu);
- }
- }
- }
-
- @Override
- public void onSubUiVisibilityChanged(boolean isVisible) {
- if (isVisible) {
- // Not a submenu, but treat it like one.
- super.onSubMenuSelected(null);
- } else {
- mMenu.close(false);
- }
- }
-
- private static class SavedState implements Parcelable {
- public int openSubMenuId;
-
- SavedState() {
- }
-
- SavedState(Parcel in) {
- openSubMenuId = in.readInt();
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(openSubMenuId);
- }
-
- @SuppressWarnings("unused")
- public static final Parcelable.Creator CREATOR
- = new Parcelable.Creator() {
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
-
- private class OverflowMenuButton extends ImageButton implements ActionMenuChildView, View_HasStateListenerSupport {
- private final Set mListeners = new HashSet();
-
- public OverflowMenuButton(Context context) {
- super(context, null, R.attr.actionOverflowButtonStyle);
-
- setClickable(true);
- setFocusable(true);
- setVisibility(VISIBLE);
- setEnabled(true);
- }
-
- @Override
- public boolean performClick() {
- if (super.performClick()) {
- return true;
- }
-
- playSoundEffect(SoundEffectConstants.CLICK);
- showOverflowMenu();
- return true;
- }
-
- public boolean needsDividerBefore() {
- return false;
- }
-
- public boolean needsDividerAfter() {
- return false;
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- for (View_OnAttachStateChangeListener listener : mListeners) {
- listener.onViewAttachedToWindow(this);
- }
- }
-
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- for (View_OnAttachStateChangeListener listener : mListeners) {
- listener.onViewDetachedFromWindow(this);
- }
- }
-
- @Override
- public void addOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) {
- mListeners.add(listener);
- }
-
- @Override
- public void removeOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) {
- mListeners.remove(listener);
- }
- }
-
- private class OverflowPopup extends MenuPopupHelper {
- public OverflowPopup(Context context, MenuBuilder menu, View anchorView,
- boolean overflowOnly) {
- super(context, menu, anchorView, overflowOnly);
- setCallback(mPopupPresenterCallback);
- }
-
- @Override
- public void onDismiss() {
- super.onDismiss();
- mMenu.close();
- mOverflowPopup = null;
- }
- }
-
- private class ActionButtonSubmenu extends MenuPopupHelper {
- //UNUSED private SubMenuBuilder mSubMenu;
-
- public ActionButtonSubmenu(Context context, SubMenuBuilder subMenu) {
- super(context, subMenu);
- //UNUSED mSubMenu = subMenu;
-
- MenuItemImpl item = (MenuItemImpl) subMenu.getItem();
- if (!item.isActionButton()) {
- // Give a reasonable anchor to nested submenus.
- setAnchorView(mOverflowButton == null ? (View) mMenuView : mOverflowButton);
- }
-
- setCallback(mPopupPresenterCallback);
-
- boolean preserveIconSpacing = false;
- final int count = subMenu.size();
- for (int i = 0; i < count; i++) {
- MenuItem childItem = subMenu.getItem(i);
- if (childItem.isVisible() && childItem.getIcon() != null) {
- preserveIconSpacing = true;
- break;
- }
- }
- setForceShowIcon(preserveIconSpacing);
- }
-
- @Override
- public void onDismiss() {
- super.onDismiss();
- mActionButtonPopup = null;
- mOpenSubMenuId = 0;
- }
- }
-
- private class PopupPresenterCallback implements MenuPresenter.Callback {
-
- @Override
- public boolean onOpenSubMenu(MenuBuilder subMenu) {
- if (subMenu == null) return false;
-
- mOpenSubMenuId = ((SubMenuBuilder) subMenu).getItem().getItemId();
- return false;
- }
-
- @Override
- public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
- if (menu instanceof SubMenuBuilder) {
- ((SubMenuBuilder) menu).getRootMenu().close(false);
- }
- }
- }
-
- private class OpenOverflowRunnable implements Runnable {
- private OverflowPopup mPopup;
-
- public OpenOverflowRunnable(OverflowPopup popup) {
- mPopup = popup;
- }
-
- public void run() {
- mMenu.changeMenuMode();
- final View menuView = (View) mMenuView;
- if (menuView != null && menuView.getWindowToken() != null && mPopup.tryShow()) {
- mOverflowPopup = mPopup;
- }
- mPostedOpenRunnable = null;
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java
deleted file mode 100644
index e090677a12..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java
+++ /dev/null
@@ -1,572 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu;
-
-import android.content.Context;
-import android.content.res.Configuration;
-import android.graphics.Canvas;
-import android.os.Build;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.accessibility.AccessibilityEvent;
-import android.widget.LinearLayout;
-import com.actionbarsherlock.internal.widget.IcsLinearLayout;
-
-/**
- * @hide
- */
-public class ActionMenuView extends IcsLinearLayout implements MenuBuilder.ItemInvoker, MenuView {
- //UNUSED private static final String TAG = "ActionMenuView";
- private static final boolean IS_FROYO = Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO;
-
- static final int MIN_CELL_SIZE = 56; // dips
- static final int GENERATED_ITEM_PADDING = 4; // dips
-
- private MenuBuilder mMenu;
-
- private boolean mReserveOverflow;
- private ActionMenuPresenter mPresenter;
- private boolean mFormatItems;
- private int mFormatItemsWidth;
- private int mMinCellSize;
- private int mGeneratedItemPadding;
- //UNUSED private int mMeasuredExtraWidth;
-
- private boolean mFirst = true;
-
- public ActionMenuView(Context context) {
- this(context, null);
- }
-
- public ActionMenuView(Context context, AttributeSet attrs) {
- super(context, attrs);
- setBaselineAligned(false);
- final float density = context.getResources().getDisplayMetrics().density;
- mMinCellSize = (int) (MIN_CELL_SIZE * density);
- mGeneratedItemPadding = (int) (GENERATED_ITEM_PADDING * density);
- }
-
- public void setPresenter(ActionMenuPresenter presenter) {
- mPresenter = presenter;
- }
-
- public boolean isExpandedFormat() {
- return mFormatItems;
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- if (IS_FROYO) {
- super.onConfigurationChanged(newConfig);
- }
- mPresenter.updateMenuView(false);
-
- if (mPresenter != null && mPresenter.isOverflowMenuShowing()) {
- mPresenter.hideOverflowMenu();
- mPresenter.showOverflowMenu();
- }
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- //Need to trigger a relayout since we may have been added extremely
- //late in the initial rendering (e.g., when contained in a ViewPager).
- //See: https://github.com/JakeWharton/ActionBarSherlock/issues/272
- if (!IS_FROYO && mFirst) {
- mFirst = false;
- requestLayout();
- return;
- }
- super.onDraw(canvas);
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- // If we've been given an exact size to match, apply special formatting during layout.
- final boolean wasFormatted = mFormatItems;
- mFormatItems = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY;
-
- if (wasFormatted != mFormatItems) {
- mFormatItemsWidth = 0; // Reset this when switching modes
- }
-
- // Special formatting can change whether items can fit as action buttons.
- // Kick the menu and update presenters when this changes.
- final int widthSize = MeasureSpec.getMode(widthMeasureSpec);
- if (mFormatItems && mMenu != null && widthSize != mFormatItemsWidth) {
- mFormatItemsWidth = widthSize;
- mMenu.onItemsChanged(true);
- }
-
- if (mFormatItems) {
- onMeasureExactFormat(widthMeasureSpec, heightMeasureSpec);
- } else {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- }
- }
-
- private void onMeasureExactFormat(int widthMeasureSpec, int heightMeasureSpec) {
- // We already know the width mode is EXACTLY if we're here.
- final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
- int widthSize = MeasureSpec.getSize(widthMeasureSpec);
- int heightSize = MeasureSpec.getSize(heightMeasureSpec);
-
- final int widthPadding = getPaddingLeft() + getPaddingRight();
- final int heightPadding = getPaddingTop() + getPaddingBottom();
-
- widthSize -= widthPadding;
-
- // Divide the view into cells.
- final int cellCount = widthSize / mMinCellSize;
- final int cellSizeRemaining = widthSize % mMinCellSize;
-
- if (cellCount == 0) {
- // Give up, nothing fits.
- setMeasuredDimension(widthSize, 0);
- return;
- }
-
- final int cellSize = mMinCellSize + cellSizeRemaining / cellCount;
-
- int cellsRemaining = cellCount;
- int maxChildHeight = 0;
- int maxCellsUsed = 0;
- int expandableItemCount = 0;
- int visibleItemCount = 0;
- boolean hasOverflow = false;
-
- // This is used as a bitfield to locate the smallest items present. Assumes childCount < 64.
- long smallestItemsAt = 0;
-
- final int childCount = getChildCount();
- for (int i = 0; i < childCount; i++) {
- final View child = getChildAt(i);
- if (child.getVisibility() == GONE) continue;
-
- final boolean isGeneratedItem = child instanceof ActionMenuItemView;
- visibleItemCount++;
-
- if (isGeneratedItem) {
- // Reset padding for generated menu item views; it may change below
- // and views are recycled.
- child.setPadding(mGeneratedItemPadding, 0, mGeneratedItemPadding, 0);
- }
-
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- lp.expanded = false;
- lp.extraPixels = 0;
- lp.cellsUsed = 0;
- lp.expandable = false;
- lp.leftMargin = 0;
- lp.rightMargin = 0;
- lp.preventEdgeOffset = isGeneratedItem && ((ActionMenuItemView) child).hasText();
-
- // Overflow always gets 1 cell. No more, no less.
- final int cellsAvailable = lp.isOverflowButton ? 1 : cellsRemaining;
-
- final int cellsUsed = measureChildForCells(child, cellSize, cellsAvailable,
- heightMeasureSpec, heightPadding);
-
- maxCellsUsed = Math.max(maxCellsUsed, cellsUsed);
- if (lp.expandable) expandableItemCount++;
- if (lp.isOverflowButton) hasOverflow = true;
-
- cellsRemaining -= cellsUsed;
- maxChildHeight = Math.max(maxChildHeight, child.getMeasuredHeight());
- if (cellsUsed == 1) smallestItemsAt |= (1 << i);
- }
-
- // When we have overflow and a single expanded (text) item, we want to try centering it
- // visually in the available space even though overflow consumes some of it.
- final boolean centerSingleExpandedItem = hasOverflow && visibleItemCount == 2;
-
- // Divide space for remaining cells if we have items that can expand.
- // Try distributing whole leftover cells to smaller items first.
-
- boolean needsExpansion = false;
- while (expandableItemCount > 0 && cellsRemaining > 0) {
- int minCells = Integer.MAX_VALUE;
- long minCellsAt = 0; // Bit locations are indices of relevant child views
- int minCellsItemCount = 0;
- for (int i = 0; i < childCount; i++) {
- final View child = getChildAt(i);
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
-
- // Don't try to expand items that shouldn't.
- if (!lp.expandable) continue;
-
- // Mark indices of children that can receive an extra cell.
- if (lp.cellsUsed < minCells) {
- minCells = lp.cellsUsed;
- minCellsAt = 1 << i;
- minCellsItemCount = 1;
- } else if (lp.cellsUsed == minCells) {
- minCellsAt |= 1 << i;
- minCellsItemCount++;
- }
- }
-
- // Items that get expanded will always be in the set of smallest items when we're done.
- smallestItemsAt |= minCellsAt;
-
- if (minCellsItemCount > cellsRemaining) break; // Couldn't expand anything evenly. Stop.
-
- // We have enough cells, all minimum size items will be incremented.
- minCells++;
-
- for (int i = 0; i < childCount; i++) {
- final View child = getChildAt(i);
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- if ((minCellsAt & (1 << i)) == 0) {
- // If this item is already at our small item count, mark it for later.
- if (lp.cellsUsed == minCells) smallestItemsAt |= 1 << i;
- continue;
- }
-
- if (centerSingleExpandedItem && lp.preventEdgeOffset && cellsRemaining == 1) {
- // Add padding to this item such that it centers.
- child.setPadding(mGeneratedItemPadding + cellSize, 0, mGeneratedItemPadding, 0);
- }
- lp.cellsUsed++;
- lp.expanded = true;
- cellsRemaining--;
- }
-
- needsExpansion = true;
- }
-
- // Divide any space left that wouldn't divide along cell boundaries
- // evenly among the smallest items
-
- final boolean singleItem = !hasOverflow && visibleItemCount == 1;
- if (cellsRemaining > 0 && smallestItemsAt != 0 &&
- (cellsRemaining < visibleItemCount - 1 || singleItem || maxCellsUsed > 1)) {
- float expandCount = Long.bitCount(smallestItemsAt);
-
- if (!singleItem) {
- // The items at the far edges may only expand by half in order to pin to either side.
- if ((smallestItemsAt & 1) != 0) {
- LayoutParams lp = (LayoutParams) getChildAt(0).getLayoutParams();
- if (!lp.preventEdgeOffset) expandCount -= 0.5f;
- }
- if ((smallestItemsAt & (1 << (childCount - 1))) != 0) {
- LayoutParams lp = ((LayoutParams) getChildAt(childCount - 1).getLayoutParams());
- if (!lp.preventEdgeOffset) expandCount -= 0.5f;
- }
- }
-
- final int extraPixels = expandCount > 0 ?
- (int) (cellsRemaining * cellSize / expandCount) : 0;
-
- for (int i = 0; i < childCount; i++) {
- if ((smallestItemsAt & (1 << i)) == 0) continue;
-
- final View child = getChildAt(i);
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- if (child instanceof ActionMenuItemView) {
- // If this is one of our views, expand and measure at the larger size.
- lp.extraPixels = extraPixels;
- lp.expanded = true;
- if (i == 0 && !lp.preventEdgeOffset) {
- // First item gets part of its new padding pushed out of sight.
- // The last item will get this implicitly from layout.
- lp.leftMargin = -extraPixels / 2;
- }
- needsExpansion = true;
- } else if (lp.isOverflowButton) {
- lp.extraPixels = extraPixels;
- lp.expanded = true;
- lp.rightMargin = -extraPixels / 2;
- needsExpansion = true;
- } else {
- // If we don't know what it is, give it some margins instead
- // and let it center within its space. We still want to pin
- // against the edges.
- if (i != 0) {
- lp.leftMargin = extraPixels / 2;
- }
- if (i != childCount - 1) {
- lp.rightMargin = extraPixels / 2;
- }
- }
- }
-
- cellsRemaining = 0;
- }
-
- // Remeasure any items that have had extra space allocated to them.
- if (needsExpansion) {
- int heightSpec = MeasureSpec.makeMeasureSpec(heightSize - heightPadding, heightMode);
- for (int i = 0; i < childCount; i++) {
- final View child = getChildAt(i);
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
-
- if (!lp.expanded) continue;
-
- final int width = lp.cellsUsed * cellSize + lp.extraPixels;
- child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), heightSpec);
- }
- }
-
- if (heightMode != MeasureSpec.EXACTLY) {
- heightSize = maxChildHeight;
- }
-
- setMeasuredDimension(widthSize, heightSize);
- //UNUSED mMeasuredExtraWidth = cellsRemaining * cellSize;
- }
-
- /**
- * Measure a child view to fit within cell-based formatting. The child's width
- * will be measured to a whole multiple of cellSize.
- *
- *
Sets the expandable and cellsUsed fields of LayoutParams.
- *
- * @param child Child to measure
- * @param cellSize Size of one cell
- * @param cellsRemaining Number of cells remaining that this view can expand to fill
- * @param parentHeightMeasureSpec MeasureSpec used by the parent view
- * @param parentHeightPadding Padding present in the parent view
- * @return Number of cells this child was measured to occupy
- */
- static int measureChildForCells(View child, int cellSize, int cellsRemaining,
- int parentHeightMeasureSpec, int parentHeightPadding) {
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
-
- final int childHeightSize = MeasureSpec.getSize(parentHeightMeasureSpec) -
- parentHeightPadding;
- final int childHeightMode = MeasureSpec.getMode(parentHeightMeasureSpec);
- final int childHeightSpec = MeasureSpec.makeMeasureSpec(childHeightSize, childHeightMode);
-
- int cellsUsed = 0;
- if (cellsRemaining > 0) {
- final int childWidthSpec = MeasureSpec.makeMeasureSpec(
- cellSize * cellsRemaining, MeasureSpec.AT_MOST);
- child.measure(childWidthSpec, childHeightSpec);
-
- final int measuredWidth = child.getMeasuredWidth();
- cellsUsed = measuredWidth / cellSize;
- if (measuredWidth % cellSize != 0) cellsUsed++;
- }
-
- final ActionMenuItemView itemView = child instanceof ActionMenuItemView ?
- (ActionMenuItemView) child : null;
- final boolean expandable = !lp.isOverflowButton && itemView != null && itemView.hasText();
- lp.expandable = expandable;
-
- lp.cellsUsed = cellsUsed;
- final int targetWidth = cellsUsed * cellSize;
- child.measure(MeasureSpec.makeMeasureSpec(targetWidth, MeasureSpec.EXACTLY),
- childHeightSpec);
- return cellsUsed;
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- if (!mFormatItems) {
- super.onLayout(changed, left, top, right, bottom);
- return;
- }
-
- final int childCount = getChildCount();
- final int midVertical = (top + bottom) / 2;
- final int dividerWidth = 0;//getDividerWidth();
- int overflowWidth = 0;
- //UNUSED int nonOverflowWidth = 0;
- int nonOverflowCount = 0;
- int widthRemaining = right - left - getPaddingRight() - getPaddingLeft();
- boolean hasOverflow = false;
- for (int i = 0; i < childCount; i++) {
- final View v = getChildAt(i);
- if (v.getVisibility() == GONE) {
- continue;
- }
-
- LayoutParams p = (LayoutParams) v.getLayoutParams();
- if (p.isOverflowButton) {
- overflowWidth = v.getMeasuredWidth();
- if (hasDividerBeforeChildAt(i)) {
- overflowWidth += dividerWidth;
- }
-
- int height = v.getMeasuredHeight();
- int r = getWidth() - getPaddingRight() - p.rightMargin;
- int l = r - overflowWidth;
- int t = midVertical - (height / 2);
- int b = t + height;
- v.layout(l, t, r, b);
-
- widthRemaining -= overflowWidth;
- hasOverflow = true;
- } else {
- final int size = v.getMeasuredWidth() + p.leftMargin + p.rightMargin;
- //UNUSED nonOverflowWidth += size;
- widthRemaining -= size;
- //if (hasDividerBeforeChildAt(i)) {
- //UNUSED nonOverflowWidth += dividerWidth;
- //}
- nonOverflowCount++;
- }
- }
-
- if (childCount == 1 && !hasOverflow) {
- // Center a single child
- final View v = getChildAt(0);
- final int width = v.getMeasuredWidth();
- final int height = v.getMeasuredHeight();
- final int midHorizontal = (right - left) / 2;
- final int l = midHorizontal - width / 2;
- final int t = midVertical - height / 2;
- v.layout(l, t, l + width, t + height);
- return;
- }
-
- final int spacerCount = nonOverflowCount - (hasOverflow ? 0 : 1);
- final int spacerSize = Math.max(0, spacerCount > 0 ? widthRemaining / spacerCount : 0);
-
- int startLeft = getPaddingLeft();
- for (int i = 0; i < childCount; i++) {
- final View v = getChildAt(i);
- final LayoutParams lp = (LayoutParams) v.getLayoutParams();
- if (v.getVisibility() == GONE || lp.isOverflowButton) {
- continue;
- }
-
- startLeft += lp.leftMargin;
- int width = v.getMeasuredWidth();
- int height = v.getMeasuredHeight();
- int t = midVertical - height / 2;
- v.layout(startLeft, t, startLeft + width, t + height);
- startLeft += width + lp.rightMargin + spacerSize;
- }
- }
-
- @Override
- public void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- mPresenter.dismissPopupMenus();
- }
-
- public boolean isOverflowReserved() {
- return mReserveOverflow;
- }
-
- public void setOverflowReserved(boolean reserveOverflow) {
- mReserveOverflow = reserveOverflow;
- }
-
- @Override
- protected LayoutParams generateDefaultLayoutParams() {
- LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
- LayoutParams.WRAP_CONTENT);
- params.gravity = Gravity.CENTER_VERTICAL;
- return params;
- }
-
- @Override
- public LayoutParams generateLayoutParams(AttributeSet attrs) {
- return new LayoutParams(getContext(), attrs);
- }
-
- @Override
- protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
- if (p instanceof LayoutParams) {
- LayoutParams result = new LayoutParams((LayoutParams) p);
- if (result.gravity <= Gravity.NO_GRAVITY) {
- result.gravity = Gravity.CENTER_VERTICAL;
- }
- return result;
- }
- return generateDefaultLayoutParams();
- }
-
- @Override
- protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
- return p != null && p instanceof LayoutParams;
- }
-
- public LayoutParams generateOverflowButtonLayoutParams() {
- LayoutParams result = generateDefaultLayoutParams();
- result.isOverflowButton = true;
- return result;
- }
-
- public boolean invokeItem(MenuItemImpl item) {
- return mMenu.performItemAction(item, 0);
- }
-
- public int getWindowAnimations() {
- return 0;
- }
-
- public void initialize(MenuBuilder menu) {
- mMenu = menu;
- }
-
- //@Override
- protected boolean hasDividerBeforeChildAt(int childIndex) {
- final View childBefore = getChildAt(childIndex - 1);
- final View child = getChildAt(childIndex);
- boolean result = false;
- if (childIndex < getChildCount() && childBefore instanceof ActionMenuChildView) {
- result |= ((ActionMenuChildView) childBefore).needsDividerAfter();
- }
- if (childIndex > 0 && child instanceof ActionMenuChildView) {
- result |= ((ActionMenuChildView) child).needsDividerBefore();
- }
- return result;
- }
-
- public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
- return false;
- }
-
- public interface ActionMenuChildView {
- public boolean needsDividerBefore();
- public boolean needsDividerAfter();
- }
-
- public static class LayoutParams extends LinearLayout.LayoutParams {
- public boolean isOverflowButton;
- public int cellsUsed;
- public int extraPixels;
- public boolean expandable;
- public boolean preventEdgeOffset;
-
- public boolean expanded;
-
- public LayoutParams(Context c, AttributeSet attrs) {
- super(c, attrs);
- }
-
- public LayoutParams(LayoutParams other) {
- super((LinearLayout.LayoutParams) other);
- isOverflowButton = other.isOverflowButton;
- }
-
- public LayoutParams(int width, int height) {
- super(width, height);
- isOverflowButton = false;
- }
-
- public LayoutParams(int width, int height, boolean isOverflowButton) {
- super(width, height);
- this.isOverflowButton = isOverflowButton;
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java
deleted file mode 100644
index 6da26f2ae7..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (C) 2011 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.actionbarsherlock.internal.view.menu;
-
-import java.util.ArrayList;
-import android.content.Context;
-import android.os.Build;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-/**
- * Base class for MenuPresenters that have a consistent container view and item
- * views. Behaves similarly to an AdapterView in that existing item views will
- * be reused if possible when items change.
- */
-public abstract class BaseMenuPresenter implements MenuPresenter {
- private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
-
- protected Context mSystemContext;
- protected Context mContext;
- protected MenuBuilder mMenu;
- protected LayoutInflater mSystemInflater;
- protected LayoutInflater mInflater;
- private Callback mCallback;
-
- private int mMenuLayoutRes;
- private int mItemLayoutRes;
-
- protected MenuView mMenuView;
-
- private int mId;
-
- /**
- * Construct a new BaseMenuPresenter.
- *
- * @param context Context for generating system-supplied views
- * @param menuLayoutRes Layout resource ID for the menu container view
- * @param itemLayoutRes Layout resource ID for a single item view
- */
- public BaseMenuPresenter(Context context, int menuLayoutRes, int itemLayoutRes) {
- mSystemContext = context;
- mSystemInflater = LayoutInflater.from(context);
- mMenuLayoutRes = menuLayoutRes;
- mItemLayoutRes = itemLayoutRes;
- }
-
- @Override
- public void initForMenu(Context context, MenuBuilder menu) {
- mContext = context;
- mInflater = LayoutInflater.from(mContext);
- mMenu = menu;
- }
-
- @Override
- public MenuView getMenuView(ViewGroup root) {
- if (mMenuView == null) {
- mMenuView = (MenuView) mSystemInflater.inflate(mMenuLayoutRes, root, false);
- mMenuView.initialize(mMenu);
- updateMenuView(true);
- }
-
- return mMenuView;
- }
-
- /**
- * Reuses item views when it can
- */
- public void updateMenuView(boolean cleared) {
- final ViewGroup parent = (ViewGroup) mMenuView;
- if (parent == null) return;
-
- int childIndex = 0;
- if (mMenu != null) {
- mMenu.flagActionItems();
- ArrayList visibleItems = mMenu.getVisibleItems();
- final int itemCount = visibleItems.size();
- for (int i = 0; i < itemCount; i++) {
- MenuItemImpl item = visibleItems.get(i);
- if (shouldIncludeItem(childIndex, item)) {
- final View convertView = parent.getChildAt(childIndex);
- final MenuItemImpl oldItem = convertView instanceof MenuView.ItemView ?
- ((MenuView.ItemView) convertView).getItemData() : null;
- final View itemView = getItemView(item, convertView, parent);
- if (item != oldItem) {
- // Don't let old states linger with new data.
- itemView.setPressed(false);
- if (IS_HONEYCOMB) itemView.jumpDrawablesToCurrentState();
- }
- if (itemView != convertView) {
- addItemView(itemView, childIndex);
- }
- childIndex++;
- }
- }
- }
-
- // Remove leftover views.
- while (childIndex < parent.getChildCount()) {
- if (!filterLeftoverView(parent, childIndex)) {
- childIndex++;
- }
- }
- }
-
- /**
- * Add an item view at the given index.
- *
- * @param itemView View to add
- * @param childIndex Index within the parent to insert at
- */
- protected void addItemView(View itemView, int childIndex) {
- final ViewGroup currentParent = (ViewGroup) itemView.getParent();
- if (currentParent != null) {
- currentParent.removeView(itemView);
- }
- ((ViewGroup) mMenuView).addView(itemView, childIndex);
- }
-
- /**
- * Filter the child view at index and remove it if appropriate.
- * @param parent Parent to filter from
- * @param childIndex Index to filter
- * @return true if the child view at index was removed
- */
- protected boolean filterLeftoverView(ViewGroup parent, int childIndex) {
- parent.removeViewAt(childIndex);
- return true;
- }
-
- public void setCallback(Callback cb) {
- mCallback = cb;
- }
-
- /**
- * Create a new item view that can be re-bound to other item data later.
- *
- * @return The new item view
- */
- public MenuView.ItemView createItemView(ViewGroup parent) {
- return (MenuView.ItemView) mSystemInflater.inflate(mItemLayoutRes, parent, false);
- }
-
- /**
- * Prepare an item view for use. See AdapterView for the basic idea at work here.
- * This may require creating a new item view, but well-behaved implementations will
- * re-use the view passed as convertView if present. The returned view will be populated
- * with data from the item parameter.
- *
- * @param item Item to present
- * @param convertView Existing view to reuse
- * @param parent Intended parent view - use for inflation.
- * @return View that presents the requested menu item
- */
- public View getItemView(MenuItemImpl item, View convertView, ViewGroup parent) {
- MenuView.ItemView itemView;
- if (convertView instanceof MenuView.ItemView) {
- itemView = (MenuView.ItemView) convertView;
- } else {
- itemView = createItemView(parent);
- }
- bindItemView(item, itemView);
- return (View) itemView;
- }
-
- /**
- * Bind item data to an existing item view.
- *
- * @param item Item to bind
- * @param itemView View to populate with item data
- */
- public abstract void bindItemView(MenuItemImpl item, MenuView.ItemView itemView);
-
- /**
- * Filter item by child index and item data.
- *
- * @param childIndex Indended presentation index of this item
- * @param item Item to present
- * @return true if this item should be included in this menu presentation; false otherwise
- */
- public boolean shouldIncludeItem(int childIndex, MenuItemImpl item) {
- return true;
- }
-
- public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
- if (mCallback != null) {
- mCallback.onCloseMenu(menu, allMenusAreClosing);
- }
- }
-
- public boolean onSubMenuSelected(SubMenuBuilder menu) {
- if (mCallback != null) {
- return mCallback.onOpenSubMenu(menu);
- }
- return false;
- }
-
- public boolean flagActionItems() {
- return false;
- }
-
- public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) {
- return false;
- }
-
- public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) {
- return false;
- }
-
- public int getId() {
- return mId;
- }
-
- public void setId(int id) {
- mId = id;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ListMenuItemView.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ListMenuItemView.java
deleted file mode 100644
index ac25c37369..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ListMenuItemView.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu;
-
-import com.actionbarsherlock.R;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.RadioButton;
-import android.widget.TextView;
-
-/**
- * The item view for each item in the ListView-based MenuViews.
- */
-public class ListMenuItemView extends LinearLayout implements MenuView.ItemView {
- private MenuItemImpl mItemData;
-
- private ImageView mIconView;
- private RadioButton mRadioButton;
- private TextView mTitleView;
- private CheckBox mCheckBox;
- private TextView mShortcutView;
-
- private Drawable mBackground;
- private int mTextAppearance;
- private Context mTextAppearanceContext;
- private boolean mPreserveIconSpacing;
-
- //UNUSED private int mMenuType;
-
- private LayoutInflater mInflater;
-
- private boolean mForceShowIcon;
-
- final Context mContext;
-
- public ListMenuItemView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs);
- mContext = context;
-
- TypedArray a =
- context.obtainStyledAttributes(
- attrs, R.styleable.SherlockMenuView, defStyle, 0);
-
- mBackground = a.getDrawable(R.styleable.SherlockMenuView_itemBackground);
- mTextAppearance = a.getResourceId(R.styleable.
- SherlockMenuView_itemTextAppearance, -1);
- mPreserveIconSpacing = a.getBoolean(
- R.styleable.SherlockMenuView_preserveIconSpacing, false);
- mTextAppearanceContext = context;
-
- a.recycle();
- }
-
- public ListMenuItemView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
-
- setBackgroundDrawable(mBackground);
-
- mTitleView = (TextView) findViewById(R.id.abs__title);
- if (mTextAppearance != -1) {
- mTitleView.setTextAppearance(mTextAppearanceContext,
- mTextAppearance);
- }
-
- mShortcutView = (TextView) findViewById(R.id.abs__shortcut);
- }
-
- public void initialize(MenuItemImpl itemData, int menuType) {
- mItemData = itemData;
- //UNUSED mMenuType = menuType;
-
- setVisibility(itemData.isVisible() ? View.VISIBLE : View.GONE);
-
- setTitle(itemData.getTitleForItemView(this));
- setCheckable(itemData.isCheckable());
- setShortcut(itemData.shouldShowShortcut(), itemData.getShortcut());
- setIcon(itemData.getIcon());
- setEnabled(itemData.isEnabled());
- }
-
- public void setForceShowIcon(boolean forceShow) {
- mPreserveIconSpacing = mForceShowIcon = forceShow;
- }
-
- public void setTitle(CharSequence title) {
- if (title != null) {
- mTitleView.setText(title);
-
- if (mTitleView.getVisibility() != VISIBLE) mTitleView.setVisibility(VISIBLE);
- } else {
- if (mTitleView.getVisibility() != GONE) mTitleView.setVisibility(GONE);
- }
- }
-
- public MenuItemImpl getItemData() {
- return mItemData;
- }
-
- public void setCheckable(boolean checkable) {
-
- if (!checkable && mRadioButton == null && mCheckBox == null) {
- return;
- }
-
- if (mRadioButton == null) {
- insertRadioButton();
- }
- if (mCheckBox == null) {
- insertCheckBox();
- }
-
- // Depending on whether its exclusive check or not, the checkbox or
- // radio button will be the one in use (and the other will be otherCompoundButton)
- final CompoundButton compoundButton;
- final CompoundButton otherCompoundButton;
-
- if (mItemData.isExclusiveCheckable()) {
- compoundButton = mRadioButton;
- otherCompoundButton = mCheckBox;
- } else {
- compoundButton = mCheckBox;
- otherCompoundButton = mRadioButton;
- }
-
- if (checkable) {
- compoundButton.setChecked(mItemData.isChecked());
-
- final int newVisibility = checkable ? VISIBLE : GONE;
- if (compoundButton.getVisibility() != newVisibility) {
- compoundButton.setVisibility(newVisibility);
- }
-
- // Make sure the other compound button isn't visible
- if (otherCompoundButton.getVisibility() != GONE) {
- otherCompoundButton.setVisibility(GONE);
- }
- } else {
- mCheckBox.setVisibility(GONE);
- mRadioButton.setVisibility(GONE);
- }
- }
-
- public void setChecked(boolean checked) {
- CompoundButton compoundButton;
-
- if (mItemData.isExclusiveCheckable()) {
- if (mRadioButton == null) {
- insertRadioButton();
- }
- compoundButton = mRadioButton;
- } else {
- if (mCheckBox == null) {
- insertCheckBox();
- }
- compoundButton = mCheckBox;
- }
-
- compoundButton.setChecked(checked);
- }
-
- public void setShortcut(boolean showShortcut, char shortcutKey) {
- final int newVisibility = (showShortcut && mItemData.shouldShowShortcut())
- ? VISIBLE : GONE;
-
- if (newVisibility == VISIBLE) {
- mShortcutView.setText(mItemData.getShortcutLabel());
- }
-
- if (mShortcutView.getVisibility() != newVisibility) {
- mShortcutView.setVisibility(newVisibility);
- }
- }
-
- public void setIcon(Drawable icon) {
- final boolean showIcon = mItemData.shouldShowIcon() || mForceShowIcon;
- if (!showIcon && !mPreserveIconSpacing) {
- return;
- }
-
- if (mIconView == null && icon == null && !mPreserveIconSpacing) {
- return;
- }
-
- if (mIconView == null) {
- insertIconView();
- }
-
- if (icon != null || mPreserveIconSpacing) {
- mIconView.setImageDrawable(showIcon ? icon : null);
-
- if (mIconView.getVisibility() != VISIBLE) {
- mIconView.setVisibility(VISIBLE);
- }
- } else {
- mIconView.setVisibility(GONE);
- }
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- if (mIconView != null && mPreserveIconSpacing) {
- // Enforce minimum icon spacing
- ViewGroup.LayoutParams lp = getLayoutParams();
- LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams();
- if (lp.height > 0 && iconLp.width <= 0) {
- iconLp.width = lp.height;
- }
- }
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- }
-
- private void insertIconView() {
- LayoutInflater inflater = getInflater();
- mIconView = (ImageView) inflater.inflate(R.layout.abs__list_menu_item_icon,
- this, false);
- addView(mIconView, 0);
- }
-
- private void insertRadioButton() {
- LayoutInflater inflater = getInflater();
- mRadioButton =
- (RadioButton) inflater.inflate(R.layout.abs__list_menu_item_radio,
- this, false);
- addView(mRadioButton);
- }
-
- private void insertCheckBox() {
- LayoutInflater inflater = getInflater();
- mCheckBox =
- (CheckBox) inflater.inflate(R.layout.abs__list_menu_item_checkbox,
- this, false);
- addView(mCheckBox);
- }
-
- public boolean prefersCondensedTitle() {
- return false;
- }
-
- public boolean showsIcon() {
- return mForceShowIcon;
- }
-
- private LayoutInflater getInflater() {
- if (mInflater == null) {
- mInflater = LayoutInflater.from(mContext);
- }
- return mInflater;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java
deleted file mode 100644
index 179b8f0379..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java
+++ /dev/null
@@ -1,1335 +0,0 @@
-/*
- * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu;
-
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.util.SparseArray;
-import android.view.ContextMenu.ContextMenuInfo;
-import android.view.KeyCharacterMap;
-import android.view.KeyEvent;
-import android.view.View;
-
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.view.ActionProvider;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuItem;
-import com.actionbarsherlock.view.SubMenu;
-
-/**
- * Implementation of the {@link android.view.Menu} interface for creating a
- * standard menu UI.
- */
-public class MenuBuilder implements Menu {
- //UNUSED private static final String TAG = "MenuBuilder";
-
- private static final String PRESENTER_KEY = "android:menu:presenters";
- private static final String ACTION_VIEW_STATES_KEY = "android:menu:actionviewstates";
- private static final String EXPANDED_ACTION_VIEW_ID = "android:menu:expandedactionview";
-
- private static final int[] sCategoryToOrder = new int[] {
- 1, /* No category */
- 4, /* CONTAINER */
- 5, /* SYSTEM */
- 3, /* SECONDARY */
- 2, /* ALTERNATIVE */
- 0, /* SELECTED_ALTERNATIVE */
- };
-
- private final Context mContext;
- private final Resources mResources;
-
- /**
- * Whether the shortcuts should be qwerty-accessible. Use isQwertyMode()
- * instead of accessing this directly.
- */
- private boolean mQwertyMode;
-
- /**
- * Whether the shortcuts should be visible on menus. Use isShortcutsVisible()
- * instead of accessing this directly.
- */
- private boolean mShortcutsVisible;
-
- /**
- * Callback that will receive the various menu-related events generated by
- * this class. Use getCallback to get a reference to the callback.
- */
- private Callback mCallback;
-
- /** Contains all of the items for this menu */
- private ArrayList mItems;
-
- /** Contains only the items that are currently visible. This will be created/refreshed from
- * {@link #getVisibleItems()} */
- private ArrayList mVisibleItems;
- /**
- * Whether or not the items (or any one item's shown state) has changed since it was last
- * fetched from {@link #getVisibleItems()}
- */
- private boolean mIsVisibleItemsStale;
-
- /**
- * Contains only the items that should appear in the Action Bar, if present.
- */
- private ArrayList mActionItems;
- /**
- * Contains items that should NOT appear in the Action Bar, if present.
- */
- private ArrayList mNonActionItems;
-
- /**
- * Whether or not the items (or any one item's action state) has changed since it was
- * last fetched.
- */
- private boolean mIsActionItemsStale;
-
- /**
- * Default value for how added items should show in the action list.
- */
- private int mDefaultShowAsAction = MenuItem.SHOW_AS_ACTION_NEVER;
-
- /**
- * Current use case is Context Menus: As Views populate the context menu, each one has
- * extra information that should be passed along. This is the current menu info that
- * should be set on all items added to this menu.
- */
- private ContextMenuInfo mCurrentMenuInfo;
-
- /** Header title for menu types that have a header (context and submenus) */
- CharSequence mHeaderTitle;
- /** Header icon for menu types that have a header and support icons (context) */
- Drawable mHeaderIcon;
- /** Header custom view for menu types that have a header and support custom views (context) */
- View mHeaderView;
-
- /**
- * Contains the state of the View hierarchy for all menu views when the menu
- * was frozen.
- */
- //UNUSED private SparseArray mFrozenViewStates;
-
- /**
- * Prevents onItemsChanged from doing its junk, useful for batching commands
- * that may individually call onItemsChanged.
- */
- private boolean mPreventDispatchingItemsChanged = false;
- private boolean mItemsChangedWhileDispatchPrevented = false;
-
- private boolean mOptionalIconsVisible = false;
-
- private boolean mIsClosing = false;
-
- private ArrayList mTempShortcutItemList = new ArrayList();
-
- private CopyOnWriteArrayList> mPresenters =
- new CopyOnWriteArrayList>();
-
- /**
- * Currently expanded menu item; must be collapsed when we clear.
- */
- private MenuItemImpl mExpandedItem;
-
- /**
- * Called by menu to notify of close and selection changes.
- */
- public interface Callback {
- /**
- * Called when a menu item is selected.
- * @param menu The menu that is the parent of the item
- * @param item The menu item that is selected
- * @return whether the menu item selection was handled
- */
- public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item);
-
- /**
- * Called when the mode of the menu changes (for example, from icon to expanded).
- *
- * @param menu the menu that has changed modes
- */
- public void onMenuModeChange(MenuBuilder menu);
- }
-
- /**
- * Called by menu items to execute their associated action
- */
- public interface ItemInvoker {
- public boolean invokeItem(MenuItemImpl item);
- }
-
- public MenuBuilder(Context context) {
- mContext = context;
- mResources = context.getResources();
-
- mItems = new ArrayList();
-
- mVisibleItems = new ArrayList();
- mIsVisibleItemsStale = true;
-
- mActionItems = new ArrayList();
- mNonActionItems = new ArrayList();
- mIsActionItemsStale = true;
-
- setShortcutsVisibleInner(true);
- }
-
- public MenuBuilder setDefaultShowAsAction(int defaultShowAsAction) {
- mDefaultShowAsAction = defaultShowAsAction;
- return this;
- }
-
- /**
- * Add a presenter to this menu. This will only hold a WeakReference;
- * you do not need to explicitly remove a presenter, but you can using
- * {@link #removeMenuPresenter(MenuPresenter)}.
- *
- * @param presenter The presenter to add
- */
- public void addMenuPresenter(MenuPresenter presenter) {
- mPresenters.add(new WeakReference(presenter));
- presenter.initForMenu(mContext, this);
- mIsActionItemsStale = true;
- }
-
- /**
- * Remove a presenter from this menu. That presenter will no longer
- * receive notifications of updates to this menu's data.
- *
- * @param presenter The presenter to remove
- */
- public void removeMenuPresenter(MenuPresenter presenter) {
- for (WeakReference ref : mPresenters) {
- final MenuPresenter item = ref.get();
- if (item == null || item == presenter) {
- mPresenters.remove(ref);
- }
- }
- }
-
- private void dispatchPresenterUpdate(boolean cleared) {
- if (mPresenters.isEmpty()) return;
-
- stopDispatchingItemsChanged();
- for (WeakReference ref : mPresenters) {
- final MenuPresenter presenter = ref.get();
- if (presenter == null) {
- mPresenters.remove(ref);
- } else {
- presenter.updateMenuView(cleared);
- }
- }
- startDispatchingItemsChanged();
- }
-
- private boolean dispatchSubMenuSelected(SubMenuBuilder subMenu) {
- if (mPresenters.isEmpty()) return false;
-
- boolean result = false;
-
- for (WeakReference ref : mPresenters) {
- final MenuPresenter presenter = ref.get();
- if (presenter == null) {
- mPresenters.remove(ref);
- } else if (!result) {
- result = presenter.onSubMenuSelected(subMenu);
- }
- }
- return result;
- }
-
- private void dispatchSaveInstanceState(Bundle outState) {
- if (mPresenters.isEmpty()) return;
-
- SparseArray presenterStates = new SparseArray();
-
- for (WeakReference ref : mPresenters) {
- final MenuPresenter presenter = ref.get();
- if (presenter == null) {
- mPresenters.remove(ref);
- } else {
- final int id = presenter.getId();
- if (id > 0) {
- final Parcelable state = presenter.onSaveInstanceState();
- if (state != null) {
- presenterStates.put(id, state);
- }
- }
- }
- }
-
- outState.putSparseParcelableArray(PRESENTER_KEY, presenterStates);
- }
-
- private void dispatchRestoreInstanceState(Bundle state) {
- SparseArray presenterStates = state.getSparseParcelableArray(PRESENTER_KEY);
-
- if (presenterStates == null || mPresenters.isEmpty()) return;
-
- for (WeakReference ref : mPresenters) {
- final MenuPresenter presenter = ref.get();
- if (presenter == null) {
- mPresenters.remove(ref);
- } else {
- final int id = presenter.getId();
- if (id > 0) {
- Parcelable parcel = presenterStates.get(id);
- if (parcel != null) {
- presenter.onRestoreInstanceState(parcel);
- }
- }
- }
- }
- }
-
- public void savePresenterStates(Bundle outState) {
- dispatchSaveInstanceState(outState);
- }
-
- public void restorePresenterStates(Bundle state) {
- dispatchRestoreInstanceState(state);
- }
-
- public void saveActionViewStates(Bundle outStates) {
- SparseArray viewStates = null;
-
- final int itemCount = size();
- for (int i = 0; i < itemCount; i++) {
- final MenuItem item = getItem(i);
- final View v = item.getActionView();
- if (v != null && v.getId() != View.NO_ID) {
- if (viewStates == null) {
- viewStates = new SparseArray();
- }
- v.saveHierarchyState(viewStates);
- if (item.isActionViewExpanded()) {
- outStates.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId());
- }
- }
- if (item.hasSubMenu()) {
- final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
- subMenu.saveActionViewStates(outStates);
- }
- }
-
- if (viewStates != null) {
- outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates);
- }
- }
-
- public void restoreActionViewStates(Bundle states) {
- if (states == null) {
- return;
- }
-
- SparseArray viewStates = states.getSparseParcelableArray(
- getActionViewStatesKey());
-
- final int itemCount = size();
- for (int i = 0; i < itemCount; i++) {
- final MenuItem item = getItem(i);
- final View v = item.getActionView();
- if (v != null && v.getId() != View.NO_ID) {
- v.restoreHierarchyState(viewStates);
- }
- if (item.hasSubMenu()) {
- final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
- subMenu.restoreActionViewStates(states);
- }
- }
-
- final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
- if (expandedId > 0) {
- MenuItem itemToExpand = findItem(expandedId);
- if (itemToExpand != null) {
- itemToExpand.expandActionView();
- }
- }
- }
-
- protected String getActionViewStatesKey() {
- return ACTION_VIEW_STATES_KEY;
- }
-
- public void setCallback(Callback cb) {
- mCallback = cb;
- }
-
- /**
- * Adds an item to the menu. The other add methods funnel to this.
- */
- private MenuItem addInternal(int group, int id, int categoryOrder, CharSequence title) {
- final int ordering = getOrdering(categoryOrder);
-
- final MenuItemImpl item = new MenuItemImpl(this, group, id, categoryOrder,
- ordering, title, mDefaultShowAsAction);
-
- if (mCurrentMenuInfo != null) {
- // Pass along the current menu info
- item.setMenuInfo(mCurrentMenuInfo);
- }
-
- mItems.add(findInsertIndex(mItems, ordering), item);
- onItemsChanged(true);
-
- return item;
- }
-
- public MenuItem add(CharSequence title) {
- return addInternal(0, 0, 0, title);
- }
-
- public MenuItem add(int titleRes) {
- return addInternal(0, 0, 0, mResources.getString(titleRes));
- }
-
- public MenuItem add(int group, int id, int categoryOrder, CharSequence title) {
- return addInternal(group, id, categoryOrder, title);
- }
-
- public MenuItem add(int group, int id, int categoryOrder, int title) {
- return addInternal(group, id, categoryOrder, mResources.getString(title));
- }
-
- public SubMenu addSubMenu(CharSequence title) {
- return addSubMenu(0, 0, 0, title);
- }
-
- public SubMenu addSubMenu(int titleRes) {
- return addSubMenu(0, 0, 0, mResources.getString(titleRes));
- }
-
- public SubMenu addSubMenu(int group, int id, int categoryOrder, CharSequence title) {
- final MenuItemImpl item = (MenuItemImpl) addInternal(group, id, categoryOrder, title);
- final SubMenuBuilder subMenu = new SubMenuBuilder(mContext, this, item);
- item.setSubMenu(subMenu);
-
- return subMenu;
- }
-
- public SubMenu addSubMenu(int group, int id, int categoryOrder, int title) {
- return addSubMenu(group, id, categoryOrder, mResources.getString(title));
- }
-
- public int addIntentOptions(int group, int id, int categoryOrder, ComponentName caller,
- Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) {
- PackageManager pm = mContext.getPackageManager();
- final List lri =
- pm.queryIntentActivityOptions(caller, specifics, intent, 0);
- final int N = lri != null ? lri.size() : 0;
-
- if ((flags & FLAG_APPEND_TO_GROUP) == 0) {
- removeGroup(group);
- }
-
- for (int i=0; i= 0) {
- outSpecificItems[ri.specificIndex] = item;
- }
- }
-
- return N;
- }
-
- public void removeItem(int id) {
- removeItemAtInt(findItemIndex(id), true);
- }
-
- public void removeGroup(int group) {
- final int i = findGroupIndex(group);
-
- if (i >= 0) {
- final int maxRemovable = mItems.size() - i;
- int numRemoved = 0;
- while ((numRemoved++ < maxRemovable) && (mItems.get(i).getGroupId() == group)) {
- // Don't force update for each one, this method will do it at the end
- removeItemAtInt(i, false);
- }
-
- // Notify menu views
- onItemsChanged(true);
- }
- }
-
- /**
- * Remove the item at the given index and optionally forces menu views to
- * update.
- *
- * @param index The index of the item to be removed. If this index is
- * invalid an exception is thrown.
- * @param updateChildrenOnMenuViews Whether to force update on menu views.
- * Please make sure you eventually call this after your batch of
- * removals.
- */
- private void removeItemAtInt(int index, boolean updateChildrenOnMenuViews) {
- if ((index < 0) || (index >= mItems.size())) return;
-
- mItems.remove(index);
-
- if (updateChildrenOnMenuViews) onItemsChanged(true);
- }
-
- public void removeItemAt(int index) {
- removeItemAtInt(index, true);
- }
-
- public void clearAll() {
- mPreventDispatchingItemsChanged = true;
- clear();
- clearHeader();
- mPreventDispatchingItemsChanged = false;
- mItemsChangedWhileDispatchPrevented = false;
- onItemsChanged(true);
- }
-
- public void clear() {
- if (mExpandedItem != null) {
- collapseItemActionView(mExpandedItem);
- }
- mItems.clear();
-
- onItemsChanged(true);
- }
-
- void setExclusiveItemChecked(MenuItem item) {
- final int group = item.getGroupId();
-
- final int N = mItems.size();
- for (int i = 0; i < N; i++) {
- MenuItemImpl curItem = mItems.get(i);
- if (curItem.getGroupId() == group) {
- if (!curItem.isExclusiveCheckable()) continue;
- if (!curItem.isCheckable()) continue;
-
- // Check the item meant to be checked, uncheck the others (that are in the group)
- curItem.setCheckedInt(curItem == item);
- }
- }
- }
-
- public void setGroupCheckable(int group, boolean checkable, boolean exclusive) {
- final int N = mItems.size();
-
- for (int i = 0; i < N; i++) {
- MenuItemImpl item = mItems.get(i);
- if (item.getGroupId() == group) {
- item.setExclusiveCheckable(exclusive);
- item.setCheckable(checkable);
- }
- }
- }
-
- public void setGroupVisible(int group, boolean visible) {
- final int N = mItems.size();
-
- // We handle the notification of items being changed ourselves, so we use setVisibleInt rather
- // than setVisible and at the end notify of items being changed
-
- boolean changedAtLeastOneItem = false;
- for (int i = 0; i < N; i++) {
- MenuItemImpl item = mItems.get(i);
- if (item.getGroupId() == group) {
- if (item.setVisibleInt(visible)) changedAtLeastOneItem = true;
- }
- }
-
- if (changedAtLeastOneItem) onItemsChanged(true);
- }
-
- public void setGroupEnabled(int group, boolean enabled) {
- final int N = mItems.size();
-
- for (int i = 0; i < N; i++) {
- MenuItemImpl item = mItems.get(i);
- if (item.getGroupId() == group) {
- item.setEnabled(enabled);
- }
- }
- }
-
- public boolean hasVisibleItems() {
- final int size = size();
-
- for (int i = 0; i < size; i++) {
- MenuItemImpl item = mItems.get(i);
- if (item.isVisible()) {
- return true;
- }
- }
-
- return false;
- }
-
- public MenuItem findItem(int id) {
- final int size = size();
- for (int i = 0; i < size; i++) {
- MenuItemImpl item = mItems.get(i);
- if (item.getItemId() == id) {
- return item;
- } else if (item.hasSubMenu()) {
- MenuItem possibleItem = item.getSubMenu().findItem(id);
-
- if (possibleItem != null) {
- return possibleItem;
- }
- }
- }
-
- return null;
- }
-
- public int findItemIndex(int id) {
- final int size = size();
-
- for (int i = 0; i < size; i++) {
- MenuItemImpl item = mItems.get(i);
- if (item.getItemId() == id) {
- return i;
- }
- }
-
- return -1;
- }
-
- public int findGroupIndex(int group) {
- return findGroupIndex(group, 0);
- }
-
- public int findGroupIndex(int group, int start) {
- final int size = size();
-
- if (start < 0) {
- start = 0;
- }
-
- for (int i = start; i < size; i++) {
- final MenuItemImpl item = mItems.get(i);
-
- if (item.getGroupId() == group) {
- return i;
- }
- }
-
- return -1;
- }
-
- public int size() {
- return mItems.size();
- }
-
- /** {@inheritDoc} */
- public MenuItem getItem(int index) {
- return mItems.get(index);
- }
-
- public boolean isShortcutKey(int keyCode, KeyEvent event) {
- return findItemWithShortcutForKey(keyCode, event) != null;
- }
-
- public void setQwertyMode(boolean isQwerty) {
- mQwertyMode = isQwerty;
-
- onItemsChanged(false);
- }
-
- /**
- * Returns the ordering across all items. This will grab the category from
- * the upper bits, find out how to order the category with respect to other
- * categories, and combine it with the lower bits.
- *
- * @param categoryOrder The category order for a particular item (if it has
- * not been or/add with a category, the default category is
- * assumed).
- * @return An ordering integer that can be used to order this item across
- * all the items (even from other categories).
- */
- private static int getOrdering(int categoryOrder) {
- final int index = (categoryOrder & CATEGORY_MASK) >> CATEGORY_SHIFT;
-
- if (index < 0 || index >= sCategoryToOrder.length) {
- throw new IllegalArgumentException("order does not contain a valid category.");
- }
-
- return (sCategoryToOrder[index] << CATEGORY_SHIFT) | (categoryOrder & USER_MASK);
- }
-
- /**
- * @return whether the menu shortcuts are in qwerty mode or not
- */
- boolean isQwertyMode() {
- return mQwertyMode;
- }
-
- /**
- * Sets whether the shortcuts should be visible on menus. Devices without hardware
- * key input will never make shortcuts visible even if this method is passed 'true'.
- *
- * @param shortcutsVisible Whether shortcuts should be visible (if true and a
- * menu item does not have a shortcut defined, that item will
- * still NOT show a shortcut)
- */
- public void setShortcutsVisible(boolean shortcutsVisible) {
- if (mShortcutsVisible == shortcutsVisible) return;
-
- setShortcutsVisibleInner(shortcutsVisible);
- onItemsChanged(false);
- }
-
- private void setShortcutsVisibleInner(boolean shortcutsVisible) {
- mShortcutsVisible = shortcutsVisible
- && mResources.getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS
- && mResources.getBoolean(
- R.bool.abs__config_showMenuShortcutsWhenKeyboardPresent);
- }
-
- /**
- * @return Whether shortcuts should be visible on menus.
- */
- public boolean isShortcutsVisible() {
- return mShortcutsVisible;
- }
-
- Resources getResources() {
- return mResources;
- }
-
- public Context getContext() {
- return mContext;
- }
-
- boolean dispatchMenuItemSelected(MenuBuilder menu, MenuItem item) {
- return mCallback != null && mCallback.onMenuItemSelected(menu, item);
- }
-
- /**
- * Dispatch a mode change event to this menu's callback.
- */
- public void changeMenuMode() {
- if (mCallback != null) {
- mCallback.onMenuModeChange(this);
- }
- }
-
- private static int findInsertIndex(ArrayList items, int ordering) {
- for (int i = items.size() - 1; i >= 0; i--) {
- MenuItemImpl item = items.get(i);
- if (item.getOrdering() <= ordering) {
- return i + 1;
- }
- }
-
- return 0;
- }
-
- public boolean performShortcut(int keyCode, KeyEvent event, int flags) {
- final MenuItemImpl item = findItemWithShortcutForKey(keyCode, event);
-
- boolean handled = false;
-
- if (item != null) {
- handled = performItemAction(item, flags);
- }
-
- if ((flags & FLAG_ALWAYS_PERFORM_CLOSE) != 0) {
- close(true);
- }
-
- return handled;
- }
-
- /*
- * This function will return all the menu and sub-menu items that can
- * be directly (the shortcut directly corresponds) and indirectly
- * (the ALT-enabled char corresponds to the shortcut) associated
- * with the keyCode.
- */
- @SuppressWarnings("deprecation")
- void findItemsWithShortcutForKey(List items, int keyCode, KeyEvent event) {
- final boolean qwerty = isQwertyMode();
- final int metaState = event.getMetaState();
- final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
- // Get the chars associated with the keyCode (i.e using any chording combo)
- final boolean isKeyCodeMapped = event.getKeyData(possibleChars);
- // The delete key is not mapped to '\b' so we treat it specially
- if (!isKeyCodeMapped && (keyCode != KeyEvent.KEYCODE_DEL)) {
- return;
- }
-
- // Look for an item whose shortcut is this key.
- final int N = mItems.size();
- for (int i = 0; i < N; i++) {
- MenuItemImpl item = mItems.get(i);
- if (item.hasSubMenu()) {
- ((MenuBuilder)item.getSubMenu()).findItemsWithShortcutForKey(items, keyCode, event);
- }
- final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut();
- if (((metaState & (KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0) &&
- (shortcutChar != 0) &&
- (shortcutChar == possibleChars.meta[0]
- || shortcutChar == possibleChars.meta[2]
- || (qwerty && shortcutChar == '\b' &&
- keyCode == KeyEvent.KEYCODE_DEL)) &&
- item.isEnabled()) {
- items.add(item);
- }
- }
- }
-
- /*
- * We want to return the menu item associated with the key, but if there is no
- * ambiguity (i.e. there is only one menu item corresponding to the key) we want
- * to return it even if it's not an exact match; this allow the user to
- * _not_ use the ALT key for example, making the use of shortcuts slightly more
- * user-friendly. An example is on the G1, '!' and '1' are on the same key, and
- * in Gmail, Menu+1 will trigger Menu+! (the actual shortcut).
- *
- * On the other hand, if two (or more) shortcuts corresponds to the same key,
- * we have to only return the exact match.
- */
- @SuppressWarnings("deprecation")
- MenuItemImpl findItemWithShortcutForKey(int keyCode, KeyEvent event) {
- // Get all items that can be associated directly or indirectly with the keyCode
- ArrayList items = mTempShortcutItemList;
- items.clear();
- findItemsWithShortcutForKey(items, keyCode, event);
-
- if (items.isEmpty()) {
- return null;
- }
-
- final int metaState = event.getMetaState();
- final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
- // Get the chars associated with the keyCode (i.e using any chording combo)
- event.getKeyData(possibleChars);
-
- // If we have only one element, we can safely returns it
- final int size = items.size();
- if (size == 1) {
- return items.get(0);
- }
-
- final boolean qwerty = isQwertyMode();
- // If we found more than one item associated with the key,
- // we have to return the exact match
- for (int i = 0; i < size; i++) {
- final MenuItemImpl item = items.get(i);
- final char shortcutChar = qwerty ? item.getAlphabeticShortcut() :
- item.getNumericShortcut();
- if ((shortcutChar == possibleChars.meta[0] &&
- (metaState & KeyEvent.META_ALT_ON) == 0)
- || (shortcutChar == possibleChars.meta[2] &&
- (metaState & KeyEvent.META_ALT_ON) != 0)
- || (qwerty && shortcutChar == '\b' &&
- keyCode == KeyEvent.KEYCODE_DEL)) {
- return item;
- }
- }
- return null;
- }
-
- public boolean performIdentifierAction(int id, int flags) {
- // Look for an item whose identifier is the id.
- return performItemAction(findItem(id), flags);
- }
-
- public boolean performItemAction(MenuItem item, int flags) {
- MenuItemImpl itemImpl = (MenuItemImpl) item;
-
- if (itemImpl == null || !itemImpl.isEnabled()) {
- return false;
- }
-
- boolean invoked = itemImpl.invoke();
-
- if (itemImpl.hasCollapsibleActionView()) {
- invoked |= itemImpl.expandActionView();
- if (invoked) close(true);
- } else if (item.hasSubMenu()) {
- close(false);
-
- final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
- final ActionProvider provider = item.getActionProvider();
- if (provider != null && provider.hasSubMenu()) {
- provider.onPrepareSubMenu(subMenu);
- }
- invoked |= dispatchSubMenuSelected(subMenu);
- if (!invoked) close(true);
- } else {
- if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
- close(true);
- }
- }
-
- return invoked;
- }
-
- /**
- * Closes the visible menu.
- *
- * @param allMenusAreClosing Whether the menus are completely closing (true),
- * or whether there is another menu coming in this menu's place
- * (false). For example, if the menu is closing because a
- * sub menu is about to be shown, allMenusAreClosing
- * is false.
- */
- final void close(boolean allMenusAreClosing) {
- if (mIsClosing) return;
-
- mIsClosing = true;
- for (WeakReference ref : mPresenters) {
- final MenuPresenter presenter = ref.get();
- if (presenter == null) {
- mPresenters.remove(ref);
- } else {
- presenter.onCloseMenu(this, allMenusAreClosing);
- }
- }
- mIsClosing = false;
- }
-
- /** {@inheritDoc} */
- public void close() {
- close(true);
- }
-
- /**
- * Called when an item is added or removed.
- *
- * @param structureChanged true if the menu structure changed,
- * false if only item properties changed.
- * (Visibility is a structural property since it affects layout.)
- */
- void onItemsChanged(boolean structureChanged) {
- if (!mPreventDispatchingItemsChanged) {
- if (structureChanged) {
- mIsVisibleItemsStale = true;
- mIsActionItemsStale = true;
- }
-
- dispatchPresenterUpdate(structureChanged);
- } else {
- mItemsChangedWhileDispatchPrevented = true;
- }
- }
-
- /**
- * Stop dispatching item changed events to presenters until
- * {@link #startDispatchingItemsChanged()} is called. Useful when
- * many menu operations are going to be performed as a batch.
- */
- public void stopDispatchingItemsChanged() {
- if (!mPreventDispatchingItemsChanged) {
- mPreventDispatchingItemsChanged = true;
- mItemsChangedWhileDispatchPrevented = false;
- }
- }
-
- public void startDispatchingItemsChanged() {
- mPreventDispatchingItemsChanged = false;
-
- if (mItemsChangedWhileDispatchPrevented) {
- mItemsChangedWhileDispatchPrevented = false;
- onItemsChanged(true);
- }
- }
-
- /**
- * Called by {@link MenuItemImpl} when its visible flag is changed.
- * @param item The item that has gone through a visibility change.
- */
- void onItemVisibleChanged(MenuItemImpl item) {
- // Notify of items being changed
- mIsVisibleItemsStale = true;
- onItemsChanged(true);
- }
-
- /**
- * Called by {@link MenuItemImpl} when its action request status is changed.
- * @param item The item that has gone through a change in action request status.
- */
- void onItemActionRequestChanged(MenuItemImpl item) {
- // Notify of items being changed
- mIsActionItemsStale = true;
- onItemsChanged(true);
- }
-
- ArrayList getVisibleItems() {
- if (!mIsVisibleItemsStale) return mVisibleItems;
-
- // Refresh the visible items
- mVisibleItems.clear();
-
- final int itemsSize = mItems.size();
- MenuItemImpl item;
- for (int i = 0; i < itemsSize; i++) {
- item = mItems.get(i);
- if (item.isVisible()) mVisibleItems.add(item);
- }
-
- mIsVisibleItemsStale = false;
- mIsActionItemsStale = true;
-
- return mVisibleItems;
- }
-
- /**
- * This method determines which menu items get to be 'action items' that will appear
- * in an action bar and which items should be 'overflow items' in a secondary menu.
- * The rules are as follows:
- *
- *
Items are considered for inclusion in the order specified within the menu.
- * There is a limit of mMaxActionItems as a total count, optionally including the overflow
- * menu button itself. This is a soft limit; if an item shares a group ID with an item
- * previously included as an action item, the new item will stay with its group and become
- * an action item itself even if it breaks the max item count limit. This is done to
- * limit the conceptual complexity of the items presented within an action bar. Only a few
- * unrelated concepts should be presented to the user in this space, and groups are treated
- * as a single concept.
- *
- *
There is also a hard limit of consumed measurable space: mActionWidthLimit. This
- * limit may be broken by a single item that exceeds the remaining space, but no further
- * items may be added. If an item that is part of a group cannot fit within the remaining
- * measured width, the entire group will be demoted to overflow. This is done to ensure room
- * for navigation and other affordances in the action bar as well as reduce general UI clutter.
- *
- *
The space freed by demoting a full group cannot be consumed by future menu items.
- * Once items begin to overflow, all future items become overflow items as well. This is
- * to avoid inadvertent reordering that may break the app's intended design.
- */
- public void flagActionItems() {
- if (!mIsActionItemsStale) {
- return;
- }
-
- // Presenters flag action items as needed.
- boolean flagged = false;
- for (WeakReference ref : mPresenters) {
- final MenuPresenter presenter = ref.get();
- if (presenter == null) {
- mPresenters.remove(ref);
- } else {
- flagged |= presenter.flagActionItems();
- }
- }
-
- if (flagged) {
- mActionItems.clear();
- mNonActionItems.clear();
- ArrayList visibleItems = getVisibleItems();
- final int itemsSize = visibleItems.size();
- for (int i = 0; i < itemsSize; i++) {
- MenuItemImpl item = visibleItems.get(i);
- if (item.isActionButton()) {
- mActionItems.add(item);
- } else {
- mNonActionItems.add(item);
- }
- }
- } else {
- // Nobody flagged anything, everything is a non-action item.
- // (This happens during a first pass with no action-item presenters.)
- mActionItems.clear();
- mNonActionItems.clear();
- mNonActionItems.addAll(getVisibleItems());
- }
- mIsActionItemsStale = false;
- }
-
- ArrayList getActionItems() {
- flagActionItems();
- return mActionItems;
- }
-
- ArrayList getNonActionItems() {
- flagActionItems();
- return mNonActionItems;
- }
-
- public void clearHeader() {
- mHeaderIcon = null;
- mHeaderTitle = null;
- mHeaderView = null;
-
- onItemsChanged(false);
- }
-
- private void setHeaderInternal(final int titleRes, final CharSequence title, final int iconRes,
- final Drawable icon, final View view) {
- final Resources r = getResources();
-
- if (view != null) {
- mHeaderView = view;
-
- // If using a custom view, then the title and icon aren't used
- mHeaderTitle = null;
- mHeaderIcon = null;
- } else {
- if (titleRes > 0) {
- mHeaderTitle = r.getText(titleRes);
- } else if (title != null) {
- mHeaderTitle = title;
- }
-
- if (iconRes > 0) {
- mHeaderIcon = r.getDrawable(iconRes);
- } else if (icon != null) {
- mHeaderIcon = icon;
- }
-
- // If using the title or icon, then a custom view isn't used
- mHeaderView = null;
- }
-
- // Notify of change
- onItemsChanged(false);
- }
-
- /**
- * Sets the header's title. This replaces the header view. Called by the
- * builder-style methods of subclasses.
- *
- * @param title The new title.
- * @return This MenuBuilder so additional setters can be called.
- */
- protected MenuBuilder setHeaderTitleInt(CharSequence title) {
- setHeaderInternal(0, title, 0, null, null);
- return this;
- }
-
- /**
- * Sets the header's title. This replaces the header view. Called by the
- * builder-style methods of subclasses.
- *
- * @param titleRes The new title (as a resource ID).
- * @return This MenuBuilder so additional setters can be called.
- */
- protected MenuBuilder setHeaderTitleInt(int titleRes) {
- setHeaderInternal(titleRes, null, 0, null, null);
- return this;
- }
-
- /**
- * Sets the header's icon. This replaces the header view. Called by the
- * builder-style methods of subclasses.
- *
- * @param icon The new icon.
- * @return This MenuBuilder so additional setters can be called.
- */
- protected MenuBuilder setHeaderIconInt(Drawable icon) {
- setHeaderInternal(0, null, 0, icon, null);
- return this;
- }
-
- /**
- * Sets the header's icon. This replaces the header view. Called by the
- * builder-style methods of subclasses.
- *
- * @param iconRes The new icon (as a resource ID).
- * @return This MenuBuilder so additional setters can be called.
- */
- protected MenuBuilder setHeaderIconInt(int iconRes) {
- setHeaderInternal(0, null, iconRes, null, null);
- return this;
- }
-
- /**
- * Sets the header's view. This replaces the title and icon. Called by the
- * builder-style methods of subclasses.
- *
- * @param view The new view.
- * @return This MenuBuilder so additional setters can be called.
- */
- protected MenuBuilder setHeaderViewInt(View view) {
- setHeaderInternal(0, null, 0, null, view);
- return this;
- }
-
- public CharSequence getHeaderTitle() {
- return mHeaderTitle;
- }
-
- public Drawable getHeaderIcon() {
- return mHeaderIcon;
- }
-
- public View getHeaderView() {
- return mHeaderView;
- }
-
- /**
- * Gets the root menu (if this is a submenu, find its root menu).
- * @return The root menu.
- */
- public MenuBuilder getRootMenu() {
- return this;
- }
-
- /**
- * Sets the current menu info that is set on all items added to this menu
- * (until this is called again with different menu info, in which case that
- * one will be added to all subsequent item additions).
- *
- * @param menuInfo The extra menu information to add.
- */
- public void setCurrentMenuInfo(ContextMenuInfo menuInfo) {
- mCurrentMenuInfo = menuInfo;
- }
-
- void setOptionalIconsVisible(boolean visible) {
- mOptionalIconsVisible = visible;
- }
-
- boolean getOptionalIconsVisible() {
- return mOptionalIconsVisible;
- }
-
- public boolean expandItemActionView(MenuItemImpl item) {
- if (mPresenters.isEmpty()) return false;
-
- boolean expanded = false;
-
- stopDispatchingItemsChanged();
- for (WeakReference ref : mPresenters) {
- final MenuPresenter presenter = ref.get();
- if (presenter == null) {
- mPresenters.remove(ref);
- } else if ((expanded = presenter.expandItemActionView(this, item))) {
- break;
- }
- }
- startDispatchingItemsChanged();
-
- if (expanded) {
- mExpandedItem = item;
- }
- return expanded;
- }
-
- public boolean collapseItemActionView(MenuItemImpl item) {
- if (mPresenters.isEmpty() || mExpandedItem != item) return false;
-
- boolean collapsed = false;
-
- stopDispatchingItemsChanged();
- for (WeakReference ref : mPresenters) {
- final MenuPresenter presenter = ref.get();
- if (presenter == null) {
- mPresenters.remove(ref);
- } else if ((collapsed = presenter.collapseItemActionView(this, item))) {
- break;
- }
- }
- startDispatchingItemsChanged();
-
- if (collapsed) {
- mExpandedItem = null;
- }
- return collapsed;
- }
-
- public MenuItemImpl getExpandedItem() {
- return mExpandedItem;
- }
-
- public boolean bindNativeOverflow(android.view.Menu menu, android.view.MenuItem.OnMenuItemClickListener listener, HashMap map) {
- final List nonActionItems = getNonActionItems();
- if (nonActionItems == null || nonActionItems.size() == 0) {
- return false;
- }
-
- boolean visible = false;
- menu.clear();
- for (MenuItemImpl nonActionItem : nonActionItems) {
- if (!nonActionItem.isVisible()) {
- continue;
- }
- visible = true;
-
- android.view.MenuItem nativeItem;
- if (nonActionItem.hasSubMenu()) {
- android.view.SubMenu nativeSub = menu.addSubMenu(nonActionItem.getGroupId(), nonActionItem.getItemId(),
- nonActionItem.getOrder(), nonActionItem.getTitle());
-
- SubMenuBuilder subMenu = (SubMenuBuilder)nonActionItem.getSubMenu();
- for (MenuItemImpl subItem : subMenu.getVisibleItems()) {
- android.view.MenuItem nativeSubItem = nativeSub.add(subItem.getGroupId(), subItem.getItemId(),
- subItem.getOrder(), subItem.getTitle());
-
- nativeSubItem.setIcon(subItem.getIcon());
- nativeSubItem.setOnMenuItemClickListener(listener);
- nativeSubItem.setEnabled(subItem.isEnabled());
- nativeSubItem.setIntent(subItem.getIntent());
- nativeSubItem.setNumericShortcut(subItem.getNumericShortcut());
- nativeSubItem.setAlphabeticShortcut(subItem.getAlphabeticShortcut());
- nativeSubItem.setTitleCondensed(subItem.getTitleCondensed());
- nativeSubItem.setCheckable(subItem.isCheckable());
- nativeSubItem.setChecked(subItem.isChecked());
-
- if (subItem.isExclusiveCheckable()) {
- nativeSub.setGroupCheckable(subItem.getGroupId(), true, true);
- }
-
- map.put(nativeSubItem, subItem);
- }
-
- nativeItem = nativeSub.getItem();
- } else {
- nativeItem = menu.add(nonActionItem.getGroupId(), nonActionItem.getItemId(),
- nonActionItem.getOrder(), nonActionItem.getTitle());
- }
- nativeItem.setIcon(nonActionItem.getIcon());
- nativeItem.setOnMenuItemClickListener(listener);
- nativeItem.setEnabled(nonActionItem.isEnabled());
- nativeItem.setIntent(nonActionItem.getIntent());
- nativeItem.setNumericShortcut(nonActionItem.getNumericShortcut());
- nativeItem.setAlphabeticShortcut(nonActionItem.getAlphabeticShortcut());
- nativeItem.setTitleCondensed(nonActionItem.getTitleCondensed());
- nativeItem.setCheckable(nonActionItem.isCheckable());
- nativeItem.setChecked(nonActionItem.isChecked());
-
- if (nonActionItem.isExclusiveCheckable()) {
- menu.setGroupCheckable(nonActionItem.getGroupId(), true, true);
- }
-
- map.put(nativeItem, nonActionItem);
- }
- return visible;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemImpl.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemImpl.java
deleted file mode 100644
index f5359fb407..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemImpl.java
+++ /dev/null
@@ -1,647 +0,0 @@
-/*
- * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu;
-
-import android.content.ActivityNotFoundException;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.drawable.Drawable;
-import android.util.Log;
-import android.view.ContextMenu.ContextMenuInfo;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewDebug;
-import android.widget.LinearLayout;
-
-import com.actionbarsherlock.view.ActionProvider;
-import com.actionbarsherlock.view.MenuItem;
-import com.actionbarsherlock.view.SubMenu;
-
-/**
- * @hide
- */
-public final class MenuItemImpl implements MenuItem {
- private static final String TAG = "MenuItemImpl";
-
- private static final int SHOW_AS_ACTION_MASK = SHOW_AS_ACTION_NEVER |
- SHOW_AS_ACTION_IF_ROOM |
- SHOW_AS_ACTION_ALWAYS;
-
- private final int mId;
- private final int mGroup;
- private final int mCategoryOrder;
- private final int mOrdering;
- private CharSequence mTitle;
- private CharSequence mTitleCondensed;
- private Intent mIntent;
- private char mShortcutNumericChar;
- private char mShortcutAlphabeticChar;
-
- /** The icon's drawable which is only created as needed */
- private Drawable mIconDrawable;
- /**
- * The icon's resource ID which is used to get the Drawable when it is
- * needed (if the Drawable isn't already obtained--only one of the two is
- * needed).
- */
- private int mIconResId = NO_ICON;
-
- /** The menu to which this item belongs */
- private MenuBuilder mMenu;
- /** If this item should launch a sub menu, this is the sub menu to launch */
- private SubMenuBuilder mSubMenu;
-
- private Runnable mItemCallback;
- private MenuItem.OnMenuItemClickListener mClickListener;
-
- private int mFlags = ENABLED;
- private static final int CHECKABLE = 0x00000001;
- private static final int CHECKED = 0x00000002;
- private static final int EXCLUSIVE = 0x00000004;
- private static final int HIDDEN = 0x00000008;
- private static final int ENABLED = 0x00000010;
- private static final int IS_ACTION = 0x00000020;
-
- private int mShowAsAction = SHOW_AS_ACTION_NEVER;
-
- private View mActionView;
- private ActionProvider mActionProvider;
- private OnActionExpandListener mOnActionExpandListener;
- private boolean mIsActionViewExpanded = false;
-
- /** Used for the icon resource ID if this item does not have an icon */
- static final int NO_ICON = 0;
-
- /**
- * Current use case is for context menu: Extra information linked to the
- * View that added this item to the context menu.
- */
- private ContextMenuInfo mMenuInfo;
-
- private static String sPrependShortcutLabel;
- private static String sEnterShortcutLabel;
- private static String sDeleteShortcutLabel;
- private static String sSpaceShortcutLabel;
-
-
- /**
- * Instantiates this menu item.
- *
- * @param menu
- * @param group Item ordering grouping control. The item will be added after
- * all other items whose order is <= this number, and before any
- * that are larger than it. This can also be used to define
- * groups of items for batch state changes. Normally use 0.
- * @param id Unique item ID. Use 0 if you do not need a unique ID.
- * @param categoryOrder The ordering for this item.
- * @param title The text to display for the item.
- */
- MenuItemImpl(MenuBuilder menu, int group, int id, int categoryOrder, int ordering,
- CharSequence title, int showAsAction) {
-
- /* TODO if (sPrependShortcutLabel == null) {
- // This is instantiated from the UI thread, so no chance of sync issues
- sPrependShortcutLabel = menu.getContext().getResources().getString(
- com.android.internal.R.string.prepend_shortcut_label);
- sEnterShortcutLabel = menu.getContext().getResources().getString(
- com.android.internal.R.string.menu_enter_shortcut_label);
- sDeleteShortcutLabel = menu.getContext().getResources().getString(
- com.android.internal.R.string.menu_delete_shortcut_label);
- sSpaceShortcutLabel = menu.getContext().getResources().getString(
- com.android.internal.R.string.menu_space_shortcut_label);
- }*/
-
- mMenu = menu;
- mId = id;
- mGroup = group;
- mCategoryOrder = categoryOrder;
- mOrdering = ordering;
- mTitle = title;
- mShowAsAction = showAsAction;
- }
-
- /**
- * Invokes the item by calling various listeners or callbacks.
- *
- * @return true if the invocation was handled, false otherwise
- */
- public boolean invoke() {
- if (mClickListener != null &&
- mClickListener.onMenuItemClick(this)) {
- return true;
- }
-
- if (mMenu.dispatchMenuItemSelected(mMenu.getRootMenu(), this)) {
- return true;
- }
-
- if (mItemCallback != null) {
- mItemCallback.run();
- return true;
- }
-
- if (mIntent != null) {
- try {
- mMenu.getContext().startActivity(mIntent);
- return true;
- } catch (ActivityNotFoundException e) {
- Log.e(TAG, "Can't find activity to handle intent; ignoring", e);
- }
- }
-
- if (mActionProvider != null && mActionProvider.onPerformDefaultAction()) {
- return true;
- }
-
- return false;
- }
-
- public boolean isEnabled() {
- return (mFlags & ENABLED) != 0;
- }
-
- public MenuItem setEnabled(boolean enabled) {
- if (enabled) {
- mFlags |= ENABLED;
- } else {
- mFlags &= ~ENABLED;
- }
-
- mMenu.onItemsChanged(false);
-
- return this;
- }
-
- public int getGroupId() {
- return mGroup;
- }
-
- @ViewDebug.CapturedViewProperty
- public int getItemId() {
- return mId;
- }
-
- public int getOrder() {
- return mCategoryOrder;
- }
-
- public int getOrdering() {
- return mOrdering;
- }
-
- public Intent getIntent() {
- return mIntent;
- }
-
- public MenuItem setIntent(Intent intent) {
- mIntent = intent;
- return this;
- }
-
- Runnable getCallback() {
- return mItemCallback;
- }
-
- public MenuItem setCallback(Runnable callback) {
- mItemCallback = callback;
- return this;
- }
-
- public char getAlphabeticShortcut() {
- return mShortcutAlphabeticChar;
- }
-
- public MenuItem setAlphabeticShortcut(char alphaChar) {
- if (mShortcutAlphabeticChar == alphaChar) return this;
-
- mShortcutAlphabeticChar = Character.toLowerCase(alphaChar);
-
- mMenu.onItemsChanged(false);
-
- return this;
- }
-
- public char getNumericShortcut() {
- return mShortcutNumericChar;
- }
-
- public MenuItem setNumericShortcut(char numericChar) {
- if (mShortcutNumericChar == numericChar) return this;
-
- mShortcutNumericChar = numericChar;
-
- mMenu.onItemsChanged(false);
-
- return this;
- }
-
- public MenuItem setShortcut(char numericChar, char alphaChar) {
- mShortcutNumericChar = numericChar;
- mShortcutAlphabeticChar = Character.toLowerCase(alphaChar);
-
- mMenu.onItemsChanged(false);
-
- return this;
- }
-
- /**
- * @return The active shortcut (based on QWERTY-mode of the menu).
- */
- char getShortcut() {
- return (mMenu.isQwertyMode() ? mShortcutAlphabeticChar : mShortcutNumericChar);
- }
-
- /**
- * @return The label to show for the shortcut. This includes the chording
- * key (for example 'Menu+a'). Also, any non-human readable
- * characters should be human readable (for example 'Menu+enter').
- */
- String getShortcutLabel() {
-
- char shortcut = getShortcut();
- if (shortcut == 0) {
- return "";
- }
-
- StringBuilder sb = new StringBuilder(sPrependShortcutLabel);
- switch (shortcut) {
-
- case '\n':
- sb.append(sEnterShortcutLabel);
- break;
-
- case '\b':
- sb.append(sDeleteShortcutLabel);
- break;
-
- case ' ':
- sb.append(sSpaceShortcutLabel);
- break;
-
- default:
- sb.append(shortcut);
- break;
- }
-
- return sb.toString();
- }
-
- /**
- * @return Whether this menu item should be showing shortcuts (depends on
- * whether the menu should show shortcuts and whether this item has
- * a shortcut defined)
- */
- boolean shouldShowShortcut() {
- // Show shortcuts if the menu is supposed to show shortcuts AND this item has a shortcut
- return mMenu.isShortcutsVisible() && (getShortcut() != 0);
- }
-
- public SubMenu getSubMenu() {
- return mSubMenu;
- }
-
- public boolean hasSubMenu() {
- return mSubMenu != null;
- }
-
- void setSubMenu(SubMenuBuilder subMenu) {
- mSubMenu = subMenu;
-
- subMenu.setHeaderTitle(getTitle());
- }
-
- @ViewDebug.CapturedViewProperty
- public CharSequence getTitle() {
- return mTitle;
- }
-
- /**
- * Gets the title for a particular {@link ItemView}
- *
- * @param itemView The ItemView that is receiving the title
- * @return Either the title or condensed title based on what the ItemView
- * prefers
- */
- CharSequence getTitleForItemView(MenuView.ItemView itemView) {
- return ((itemView != null) && itemView.prefersCondensedTitle())
- ? getTitleCondensed()
- : getTitle();
- }
-
- public MenuItem setTitle(CharSequence title) {
- mTitle = title;
-
- mMenu.onItemsChanged(false);
-
- if (mSubMenu != null) {
- mSubMenu.setHeaderTitle(title);
- }
-
- return this;
- }
-
- public MenuItem setTitle(int title) {
- return setTitle(mMenu.getContext().getString(title));
- }
-
- public CharSequence getTitleCondensed() {
- return mTitleCondensed != null ? mTitleCondensed : mTitle;
- }
-
- public MenuItem setTitleCondensed(CharSequence title) {
- mTitleCondensed = title;
-
- // Could use getTitle() in the loop below, but just cache what it would do here
- if (title == null) {
- title = mTitle;
- }
-
- mMenu.onItemsChanged(false);
-
- return this;
- }
-
- public Drawable getIcon() {
- if (mIconDrawable != null) {
- return mIconDrawable;
- }
-
- if (mIconResId != NO_ICON) {
- return mMenu.getResources().getDrawable(mIconResId);
- }
-
- return null;
- }
-
- public MenuItem setIcon(Drawable icon) {
- mIconResId = NO_ICON;
- mIconDrawable = icon;
- mMenu.onItemsChanged(false);
-
- return this;
- }
-
- public MenuItem setIcon(int iconResId) {
- mIconDrawable = null;
- mIconResId = iconResId;
-
- // If we have a view, we need to push the Drawable to them
- mMenu.onItemsChanged(false);
-
- return this;
- }
-
- public boolean isCheckable() {
- return (mFlags & CHECKABLE) == CHECKABLE;
- }
-
- public MenuItem setCheckable(boolean checkable) {
- final int oldFlags = mFlags;
- mFlags = (mFlags & ~CHECKABLE) | (checkable ? CHECKABLE : 0);
- if (oldFlags != mFlags) {
- mMenu.onItemsChanged(false);
- }
-
- return this;
- }
-
- public void setExclusiveCheckable(boolean exclusive) {
- mFlags = (mFlags & ~EXCLUSIVE) | (exclusive ? EXCLUSIVE : 0);
- }
-
- public boolean isExclusiveCheckable() {
- return (mFlags & EXCLUSIVE) != 0;
- }
-
- public boolean isChecked() {
- return (mFlags & CHECKED) == CHECKED;
- }
-
- public MenuItem setChecked(boolean checked) {
- if ((mFlags & EXCLUSIVE) != 0) {
- // Call the method on the Menu since it knows about the others in this
- // exclusive checkable group
- mMenu.setExclusiveItemChecked(this);
- } else {
- setCheckedInt(checked);
- }
-
- return this;
- }
-
- void setCheckedInt(boolean checked) {
- final int oldFlags = mFlags;
- mFlags = (mFlags & ~CHECKED) | (checked ? CHECKED : 0);
- if (oldFlags != mFlags) {
- mMenu.onItemsChanged(false);
- }
- }
-
- public boolean isVisible() {
- return (mFlags & HIDDEN) == 0;
- }
-
- /**
- * Changes the visibility of the item. This method DOES NOT notify the
- * parent menu of a change in this item, so this should only be called from
- * methods that will eventually trigger this change. If unsure, use {@link #setVisible(boolean)}
- * instead.
- *
- * @param shown Whether to show (true) or hide (false).
- * @return Whether the item's shown state was changed
- */
- boolean setVisibleInt(boolean shown) {
- final int oldFlags = mFlags;
- mFlags = (mFlags & ~HIDDEN) | (shown ? 0 : HIDDEN);
- return oldFlags != mFlags;
- }
-
- public MenuItem setVisible(boolean shown) {
- // Try to set the shown state to the given state. If the shown state was changed
- // (i.e. the previous state isn't the same as given state), notify the parent menu that
- // the shown state has changed for this item
- if (setVisibleInt(shown)) mMenu.onItemVisibleChanged(this);
-
- return this;
- }
-
- public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener clickListener) {
- mClickListener = clickListener;
- return this;
- }
-
- @Override
- public String toString() {
- return mTitle.toString();
- }
-
- void setMenuInfo(ContextMenuInfo menuInfo) {
- mMenuInfo = menuInfo;
- }
-
- public ContextMenuInfo getMenuInfo() {
- return mMenuInfo;
- }
-
- public void actionFormatChanged() {
- mMenu.onItemActionRequestChanged(this);
- }
-
- /**
- * @return Whether the menu should show icons for menu items.
- */
- public boolean shouldShowIcon() {
- return mMenu.getOptionalIconsVisible();
- }
-
- public boolean isActionButton() {
- return (mFlags & IS_ACTION) == IS_ACTION;
- }
-
- public boolean requestsActionButton() {
- return (mShowAsAction & SHOW_AS_ACTION_IF_ROOM) == SHOW_AS_ACTION_IF_ROOM;
- }
-
- public boolean requiresActionButton() {
- return (mShowAsAction & SHOW_AS_ACTION_ALWAYS) == SHOW_AS_ACTION_ALWAYS;
- }
-
- public void setIsActionButton(boolean isActionButton) {
- if (isActionButton) {
- mFlags |= IS_ACTION;
- } else {
- mFlags &= ~IS_ACTION;
- }
- }
-
- public boolean showsTextAsAction() {
- return (mShowAsAction & SHOW_AS_ACTION_WITH_TEXT) == SHOW_AS_ACTION_WITH_TEXT;
- }
-
- public void setShowAsAction(int actionEnum) {
- switch (actionEnum & SHOW_AS_ACTION_MASK) {
- case SHOW_AS_ACTION_ALWAYS:
- case SHOW_AS_ACTION_IF_ROOM:
- case SHOW_AS_ACTION_NEVER:
- // Looks good!
- break;
-
- default:
- // Mutually exclusive options selected!
- throw new IllegalArgumentException("SHOW_AS_ACTION_ALWAYS, SHOW_AS_ACTION_IF_ROOM,"
- + " and SHOW_AS_ACTION_NEVER are mutually exclusive.");
- }
- mShowAsAction = actionEnum;
- mMenu.onItemActionRequestChanged(this);
- }
-
- public MenuItem setActionView(View view) {
- mActionView = view;
- mActionProvider = null;
- if (view != null && view.getId() == View.NO_ID && mId > 0) {
- view.setId(mId);
- }
- mMenu.onItemActionRequestChanged(this);
- return this;
- }
-
- public MenuItem setActionView(int resId) {
- final Context context = mMenu.getContext();
- final LayoutInflater inflater = LayoutInflater.from(context);
- setActionView(inflater.inflate(resId, new LinearLayout(context), false));
- return this;
- }
-
- public View getActionView() {
- if (mActionView != null) {
- return mActionView;
- } else if (mActionProvider != null) {
- mActionView = mActionProvider.onCreateActionView();
- return mActionView;
- } else {
- return null;
- }
- }
-
- public ActionProvider getActionProvider() {
- return mActionProvider;
- }
-
- public MenuItem setActionProvider(ActionProvider actionProvider) {
- mActionView = null;
- mActionProvider = actionProvider;
- mMenu.onItemsChanged(true); // Measurement can be changed
- return this;
- }
-
- @Override
- public MenuItem setShowAsActionFlags(int actionEnum) {
- setShowAsAction(actionEnum);
- return this;
- }
-
- @Override
- public boolean expandActionView() {
- if ((mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) == 0 || mActionView == null) {
- return false;
- }
-
- if (mOnActionExpandListener == null ||
- mOnActionExpandListener.onMenuItemActionExpand(this)) {
- return mMenu.expandItemActionView(this);
- }
-
- return false;
- }
-
- @Override
- public boolean collapseActionView() {
- if ((mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) == 0) {
- return false;
- }
- if (mActionView == null) {
- // We're already collapsed if we have no action view.
- return true;
- }
-
- if (mOnActionExpandListener == null ||
- mOnActionExpandListener.onMenuItemActionCollapse(this)) {
- return mMenu.collapseItemActionView(this);
- }
-
- return false;
- }
-
- @Override
- public MenuItem setOnActionExpandListener(OnActionExpandListener listener) {
- mOnActionExpandListener = listener;
- return this;
- }
-
- public boolean hasCollapsibleActionView() {
- return (mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) != 0 && mActionView != null;
- }
-
- public void setActionViewExpanded(boolean isExpanded) {
- mIsActionViewExpanded = isExpanded;
- mMenu.onItemsChanged(false);
- }
-
- public boolean isActionViewExpanded() {
- return mIsActionViewExpanded;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java
deleted file mode 100644
index 907a7aa04a..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java
+++ /dev/null
@@ -1,292 +0,0 @@
-package com.actionbarsherlock.internal.view.menu;
-
-import android.content.Intent;
-import android.graphics.drawable.Drawable;
-import android.view.View;
-import android.view.ContextMenu.ContextMenuInfo;
-import com.actionbarsherlock.internal.view.ActionProviderWrapper;
-import com.actionbarsherlock.view.ActionProvider;
-import com.actionbarsherlock.view.MenuItem;
-import com.actionbarsherlock.view.SubMenu;
-
-public class MenuItemWrapper implements MenuItem, android.view.MenuItem.OnMenuItemClickListener {
- private final android.view.MenuItem mNativeItem;
- private SubMenu mSubMenu = null;
- private OnMenuItemClickListener mMenuItemClickListener = null;
- private OnActionExpandListener mActionExpandListener = null;
- private android.view.MenuItem.OnActionExpandListener mNativeActionExpandListener = null;
-
-
- public MenuItemWrapper(android.view.MenuItem nativeItem) {
- if (nativeItem == null) {
- throw new IllegalStateException("Wrapped menu item cannot be null.");
- }
- mNativeItem = nativeItem;
- }
-
-
- @Override
- public int getItemId() {
- return mNativeItem.getItemId();
- }
-
- @Override
- public int getGroupId() {
- return mNativeItem.getGroupId();
- }
-
- @Override
- public int getOrder() {
- return mNativeItem.getOrder();
- }
-
- @Override
- public MenuItem setTitle(CharSequence title) {
- mNativeItem.setTitle(title);
- return this;
- }
-
- @Override
- public MenuItem setTitle(int title) {
- mNativeItem.setTitle(title);
- return this;
- }
-
- @Override
- public CharSequence getTitle() {
- return mNativeItem.getTitle();
- }
-
- @Override
- public MenuItem setTitleCondensed(CharSequence title) {
- mNativeItem.setTitleCondensed(title);
- return this;
- }
-
- @Override
- public CharSequence getTitleCondensed() {
- return mNativeItem.getTitleCondensed();
- }
-
- @Override
- public MenuItem setIcon(Drawable icon) {
- mNativeItem.setIcon(icon);
- return this;
- }
-
- @Override
- public MenuItem setIcon(int iconRes) {
- mNativeItem.setIcon(iconRes);
- return this;
- }
-
- @Override
- public Drawable getIcon() {
- return mNativeItem.getIcon();
- }
-
- @Override
- public MenuItem setIntent(Intent intent) {
- mNativeItem.setIntent(intent);
- return this;
- }
-
- @Override
- public Intent getIntent() {
- return mNativeItem.getIntent();
- }
-
- @Override
- public MenuItem setShortcut(char numericChar, char alphaChar) {
- mNativeItem.setShortcut(numericChar, alphaChar);
- return this;
- }
-
- @Override
- public MenuItem setNumericShortcut(char numericChar) {
- mNativeItem.setNumericShortcut(numericChar);
- return this;
- }
-
- @Override
- public char getNumericShortcut() {
- return mNativeItem.getNumericShortcut();
- }
-
- @Override
- public MenuItem setAlphabeticShortcut(char alphaChar) {
- mNativeItem.setAlphabeticShortcut(alphaChar);
- return this;
- }
-
- @Override
- public char getAlphabeticShortcut() {
- return mNativeItem.getAlphabeticShortcut();
- }
-
- @Override
- public MenuItem setCheckable(boolean checkable) {
- mNativeItem.setCheckable(checkable);
- return this;
- }
-
- @Override
- public boolean isCheckable() {
- return mNativeItem.isCheckable();
- }
-
- @Override
- public MenuItem setChecked(boolean checked) {
- mNativeItem.setChecked(checked);
- return this;
- }
-
- @Override
- public boolean isChecked() {
- return mNativeItem.isChecked();
- }
-
- @Override
- public MenuItem setVisible(boolean visible) {
- mNativeItem.setVisible(visible);
- return this;
- }
-
- @Override
- public boolean isVisible() {
- return mNativeItem.isVisible();
- }
-
- @Override
- public MenuItem setEnabled(boolean enabled) {
- mNativeItem.setEnabled(enabled);
- return this;
- }
-
- @Override
- public boolean isEnabled() {
- return mNativeItem.isEnabled();
- }
-
- @Override
- public boolean hasSubMenu() {
- return mNativeItem.hasSubMenu();
- }
-
- @Override
- public SubMenu getSubMenu() {
- if (hasSubMenu() && (mSubMenu == null)) {
- mSubMenu = new SubMenuWrapper(mNativeItem.getSubMenu());
- }
- return mSubMenu;
- }
-
- @Override
- public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener menuItemClickListener) {
- mMenuItemClickListener = menuItemClickListener;
- //Register ourselves as the listener to proxy
- mNativeItem.setOnMenuItemClickListener(this);
- return this;
- }
-
- @Override
- public boolean onMenuItemClick(android.view.MenuItem item) {
- if (mMenuItemClickListener != null) {
- return mMenuItemClickListener.onMenuItemClick(this);
- }
- return false;
- }
-
- @Override
- public ContextMenuInfo getMenuInfo() {
- return mNativeItem.getMenuInfo();
- }
-
- @Override
- public void setShowAsAction(int actionEnum) {
- mNativeItem.setShowAsAction(actionEnum);
- }
-
- @Override
- public MenuItem setShowAsActionFlags(int actionEnum) {
- mNativeItem.setShowAsActionFlags(actionEnum);
- return this;
- }
-
- @Override
- public MenuItem setActionView(View view) {
- mNativeItem.setActionView(view);
- return this;
- }
-
- @Override
- public MenuItem setActionView(int resId) {
- mNativeItem.setActionView(resId);
- return this;
- }
-
- @Override
- public View getActionView() {
- return mNativeItem.getActionView();
- }
-
- @Override
- public MenuItem setActionProvider(ActionProvider actionProvider) {
- mNativeItem.setActionProvider(new ActionProviderWrapper(actionProvider));
- return this;
- }
-
- @Override
- public ActionProvider getActionProvider() {
- android.view.ActionProvider nativeProvider = mNativeItem.getActionProvider();
- if (nativeProvider != null && nativeProvider instanceof ActionProviderWrapper) {
- return ((ActionProviderWrapper)nativeProvider).unwrap();
- }
- return null;
- }
-
- @Override
- public boolean expandActionView() {
- return mNativeItem.expandActionView();
- }
-
- @Override
- public boolean collapseActionView() {
- return mNativeItem.collapseActionView();
- }
-
- @Override
- public boolean isActionViewExpanded() {
- return mNativeItem.isActionViewExpanded();
- }
-
- @Override
- public MenuItem setOnActionExpandListener(OnActionExpandListener listener) {
- mActionExpandListener = listener;
-
- if (mNativeActionExpandListener == null) {
- mNativeActionExpandListener = new android.view.MenuItem.OnActionExpandListener() {
- @Override
- public boolean onMenuItemActionExpand(android.view.MenuItem menuItem) {
- if (mActionExpandListener != null) {
- return mActionExpandListener.onMenuItemActionExpand(MenuItemWrapper.this);
- }
- return false;
- }
-
- @Override
- public boolean onMenuItemActionCollapse(android.view.MenuItem menuItem) {
- if (mActionExpandListener != null) {
- return mActionExpandListener.onMenuItemActionCollapse(MenuItemWrapper.this);
- }
- return false;
- }
- };
-
- //Register our inner-class as the listener to proxy method calls
- mNativeItem.setOnActionExpandListener(mNativeActionExpandListener);
- }
-
- return this;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuPopupHelper.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuPopupHelper.java
deleted file mode 100644
index f030de310a..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuPopupHelper.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu;
-
-import java.util.ArrayList;
-import android.content.Context;
-import android.content.res.Resources;
-import android.database.DataSetObserver;
-import android.os.Parcelable;
-import android.view.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.MeasureSpec;
-import android.view.ViewGroup;
-import android.view.ViewTreeObserver;
-import android.widget.AdapterView;
-import android.widget.BaseAdapter;
-import android.widget.FrameLayout;
-import android.widget.ListAdapter;
-import android.widget.PopupWindow;
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.internal.view.View_HasStateListenerSupport;
-import com.actionbarsherlock.internal.view.View_OnAttachStateChangeListener;
-import com.actionbarsherlock.internal.widget.IcsListPopupWindow;
-import com.actionbarsherlock.view.MenuItem;
-
-/**
- * Presents a menu as a small, simple popup anchored to another view.
- * @hide
- */
-public class MenuPopupHelper implements AdapterView.OnItemClickListener, View.OnKeyListener,
- ViewTreeObserver.OnGlobalLayoutListener, PopupWindow.OnDismissListener,
- View_OnAttachStateChangeListener, MenuPresenter {
- //UNUSED private static final String TAG = "MenuPopupHelper";
-
- static final int ITEM_LAYOUT = R.layout.abs__popup_menu_item_layout;
-
- private Context mContext;
- private LayoutInflater mInflater;
- private IcsListPopupWindow mPopup;
- private MenuBuilder mMenu;
- private int mPopupMaxWidth;
- private View mAnchorView;
- private boolean mOverflowOnly;
- private ViewTreeObserver mTreeObserver;
-
- private MenuAdapter mAdapter;
-
- private Callback mPresenterCallback;
-
- boolean mForceShowIcon;
-
- private ViewGroup mMeasureParent;
-
- public MenuPopupHelper(Context context, MenuBuilder menu) {
- this(context, menu, null, false);
- }
-
- public MenuPopupHelper(Context context, MenuBuilder menu, View anchorView) {
- this(context, menu, anchorView, false);
- }
-
- public MenuPopupHelper(Context context, MenuBuilder menu,
- View anchorView, boolean overflowOnly) {
- mContext = context;
- mInflater = LayoutInflater.from(context);
- mMenu = menu;
- mOverflowOnly = overflowOnly;
-
- final Resources res = context.getResources();
- mPopupMaxWidth = Math.max(res.getDisplayMetrics().widthPixels / 2,
- res.getDimensionPixelSize(R.dimen.abs__config_prefDialogWidth));
-
- mAnchorView = anchorView;
-
- menu.addMenuPresenter(this);
- }
-
- public void setAnchorView(View anchor) {
- mAnchorView = anchor;
- }
-
- public void setForceShowIcon(boolean forceShow) {
- mForceShowIcon = forceShow;
- }
-
- public void show() {
- if (!tryShow()) {
- throw new IllegalStateException("MenuPopupHelper cannot be used without an anchor");
- }
- }
-
- public boolean tryShow() {
- mPopup = new IcsListPopupWindow(mContext, null, R.attr.popupMenuStyle);
- mPopup.setOnDismissListener(this);
- mPopup.setOnItemClickListener(this);
-
- mAdapter = new MenuAdapter(mMenu);
- mPopup.setAdapter(mAdapter);
- mPopup.setModal(true);
-
- View anchor = mAnchorView;
- if (anchor != null) {
- final boolean addGlobalListener = mTreeObserver == null;
- mTreeObserver = anchor.getViewTreeObserver(); // Refresh to latest
- if (addGlobalListener) mTreeObserver.addOnGlobalLayoutListener(this);
- ((View_HasStateListenerSupport)anchor).addOnAttachStateChangeListener(this);
- mPopup.setAnchorView(anchor);
- } else {
- return false;
- }
-
- mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter), mPopupMaxWidth));
- mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
- mPopup.show();
- mPopup.getListView().setOnKeyListener(this);
- return true;
- }
-
- public void dismiss() {
- if (isShowing()) {
- mPopup.dismiss();
- }
- }
-
- public void onDismiss() {
- mPopup = null;
- mMenu.close();
- if (mTreeObserver != null) {
- if (!mTreeObserver.isAlive()) mTreeObserver = mAnchorView.getViewTreeObserver();
- mTreeObserver.removeGlobalOnLayoutListener(this);
- mTreeObserver = null;
- }
- ((View_HasStateListenerSupport)mAnchorView).removeOnAttachStateChangeListener(this);
- }
-
- public boolean isShowing() {
- return mPopup != null && mPopup.isShowing();
- }
-
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- MenuAdapter adapter = mAdapter;
- adapter.mAdapterMenu.performItemAction(adapter.getItem(position), 0);
- }
-
- public boolean onKey(View v, int keyCode, KeyEvent event) {
- if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_MENU) {
- dismiss();
- return true;
- }
- return false;
- }
-
- private int measureContentWidth(ListAdapter adapter) {
- // Menus don't tend to be long, so this is more sane than it looks.
- int width = 0;
- View itemView = null;
- int itemType = 0;
- final int widthMeasureSpec =
- MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
- final int heightMeasureSpec =
- MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
- final int count = adapter.getCount();
- for (int i = 0; i < count; i++) {
- final int positionType = adapter.getItemViewType(i);
- if (positionType != itemType) {
- itemType = positionType;
- itemView = null;
- }
- if (mMeasureParent == null) {
- mMeasureParent = new FrameLayout(mContext);
- }
- itemView = adapter.getView(i, itemView, mMeasureParent);
- itemView.measure(widthMeasureSpec, heightMeasureSpec);
- width = Math.max(width, itemView.getMeasuredWidth());
- }
- return width;
- }
-
- @Override
- public void onGlobalLayout() {
- if (isShowing()) {
- final View anchor = mAnchorView;
- if (anchor == null || !anchor.isShown()) {
- dismiss();
- } else if (isShowing()) {
- // Recompute window size and position
- mPopup.show();
- }
- }
- }
-
- @Override
- public void onViewAttachedToWindow(View v) {
- }
-
- @Override
- public void onViewDetachedFromWindow(View v) {
- if (mTreeObserver != null) {
- if (!mTreeObserver.isAlive()) mTreeObserver = v.getViewTreeObserver();
- mTreeObserver.removeGlobalOnLayoutListener(this);
- }
- ((View_HasStateListenerSupport)v).removeOnAttachStateChangeListener(this);
- }
-
- @Override
- public void initForMenu(Context context, MenuBuilder menu) {
- // Don't need to do anything; we added as a presenter in the constructor.
- }
-
- @Override
- public MenuView getMenuView(ViewGroup root) {
- throw new UnsupportedOperationException("MenuPopupHelpers manage their own views");
- }
-
- @Override
- public void updateMenuView(boolean cleared) {
- if (mAdapter != null) mAdapter.notifyDataSetChanged();
- }
-
- @Override
- public void setCallback(Callback cb) {
- mPresenterCallback = cb;
- }
-
- @Override
- public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
- if (subMenu.hasVisibleItems()) {
- MenuPopupHelper subPopup = new MenuPopupHelper(mContext, subMenu, mAnchorView, false);
- subPopup.setCallback(mPresenterCallback);
-
- boolean preserveIconSpacing = false;
- final int count = subMenu.size();
- for (int i = 0; i < count; i++) {
- MenuItem childItem = subMenu.getItem(i);
- if (childItem.isVisible() && childItem.getIcon() != null) {
- preserveIconSpacing = true;
- break;
- }
- }
- subPopup.setForceShowIcon(preserveIconSpacing);
-
- if (subPopup.tryShow()) {
- if (mPresenterCallback != null) {
- mPresenterCallback.onOpenSubMenu(subMenu);
- }
- return true;
- }
- }
- return false;
- }
-
- @Override
- public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
- // Only care about the (sub)menu we're presenting.
- if (menu != mMenu) return;
-
- dismiss();
- if (mPresenterCallback != null) {
- mPresenterCallback.onCloseMenu(menu, allMenusAreClosing);
- }
- }
-
- @Override
- public boolean flagActionItems() {
- return false;
- }
-
- public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) {
- return false;
- }
-
- public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) {
- return false;
- }
-
- @Override
- public int getId() {
- return 0;
- }
-
- @Override
- public Parcelable onSaveInstanceState() {
- return null;
- }
-
- @Override
- public void onRestoreInstanceState(Parcelable state) {
- }
-
- private class MenuAdapter extends BaseAdapter {
- private MenuBuilder mAdapterMenu;
- private int mExpandedIndex = -1;
-
- public MenuAdapter(MenuBuilder menu) {
- mAdapterMenu = menu;
- registerDataSetObserver(new ExpandedIndexObserver());
- findExpandedIndex();
- }
-
- public int getCount() {
- ArrayList items = mOverflowOnly ?
- mAdapterMenu.getNonActionItems() : mAdapterMenu.getVisibleItems();
- if (mExpandedIndex < 0) {
- return items.size();
- }
- return items.size() - 1;
- }
-
- public MenuItemImpl getItem(int position) {
- ArrayList items = mOverflowOnly ?
- mAdapterMenu.getNonActionItems() : mAdapterMenu.getVisibleItems();
- if (mExpandedIndex >= 0 && position >= mExpandedIndex) {
- position++;
- }
- return items.get(position);
- }
-
- public long getItemId(int position) {
- // Since a menu item's ID is optional, we'll use the position as an
- // ID for the item in the AdapterView
- return position;
- }
-
- public View getView(int position, View convertView, ViewGroup parent) {
- if (convertView == null) {
- convertView = mInflater.inflate(ITEM_LAYOUT, parent, false);
- }
-
- MenuView.ItemView itemView = (MenuView.ItemView) convertView;
- if (mForceShowIcon) {
- ((ListMenuItemView) convertView).setForceShowIcon(true);
- }
- itemView.initialize(getItem(position), 0);
- return convertView;
- }
-
- void findExpandedIndex() {
- final MenuItemImpl expandedItem = mMenu.getExpandedItem();
- if (expandedItem != null) {
- final ArrayList items = mMenu.getNonActionItems();
- final int count = items.size();
- for (int i = 0; i < count; i++) {
- final MenuItemImpl item = items.get(i);
- if (item == expandedItem) {
- mExpandedIndex = i;
- return;
- }
- }
- }
- mExpandedIndex = -1;
- }
- }
-
- private class ExpandedIndexObserver extends DataSetObserver {
- @Override
- public void onChanged() {
- mAdapter.findExpandedIndex();
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java
deleted file mode 100644
index c3f35472c5..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2011 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.actionbarsherlock.internal.view.menu;
-
-import android.content.Context;
-import android.os.Parcelable;
-import android.view.ViewGroup;
-
-/**
- * A MenuPresenter is responsible for building views for a Menu object.
- * It takes over some responsibility from the old style monolithic MenuBuilder class.
- */
-public interface MenuPresenter {
- /**
- * Called by menu implementation to notify another component of open/close events.
- */
- public interface Callback {
- /**
- * Called when a menu is closing.
- * @param menu
- * @param allMenusAreClosing
- */
- public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing);
-
- /**
- * Called when a submenu opens. Useful for notifying the application
- * of menu state so that it does not attempt to hide the action bar
- * while a submenu is open or similar.
- *
- * @param subMenu Submenu currently being opened
- * @return true if the Callback will handle presenting the submenu, false if
- * the presenter should attempt to do so.
- */
- public boolean onOpenSubMenu(MenuBuilder subMenu);
- }
-
- /**
- * Initialize this presenter for the given context and menu.
- * This method is called by MenuBuilder when a presenter is
- * added. See {@link MenuBuilder#addMenuPresenter(MenuPresenter)}
- *
- * @param context Context for this presenter; used for view creation and resource management
- * @param menu Menu to host
- */
- public void initForMenu(Context context, MenuBuilder menu);
-
- /**
- * Retrieve a MenuView to display the menu specified in
- * {@link #initForMenu(Context, Menu)}.
- *
- * @param root Intended parent of the MenuView.
- * @return A freshly created MenuView.
- */
- public MenuView getMenuView(ViewGroup root);
-
- /**
- * Update the menu UI in response to a change. Called by
- * MenuBuilder during the normal course of operation.
- *
- * @param cleared true if the menu was entirely cleared
- */
- public void updateMenuView(boolean cleared);
-
- /**
- * Set a callback object that will be notified of menu events
- * related to this specific presentation.
- * @param cb Callback that will be notified of future events
- */
- public void setCallback(Callback cb);
-
- /**
- * Called by Menu implementations to indicate that a submenu item
- * has been selected. An active Callback should be notified, and
- * if applicable the presenter should present the submenu.
- *
- * @param subMenu SubMenu being opened
- * @return true if the the event was handled, false otherwise.
- */
- public boolean onSubMenuSelected(SubMenuBuilder subMenu);
-
- /**
- * Called by Menu implementations to indicate that a menu or submenu is
- * closing. Presenter implementations should close the representation
- * of the menu indicated as necessary and notify a registered callback.
- *
- * @param menu Menu or submenu that is closing.
- * @param allMenusAreClosing True if all associated menus are closing.
- */
- public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing);
-
- /**
- * Called by Menu implementations to flag items that will be shown as actions.
- * @return true if this presenter changed the action status of any items.
- */
- public boolean flagActionItems();
-
- /**
- * Called when a menu item with a collapsable action view should expand its action view.
- *
- * @param menu Menu containing the item to be expanded
- * @param item Item to be expanded
- * @return true if this presenter expanded the action view, false otherwise.
- */
- public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item);
-
- /**
- * Called when a menu item with a collapsable action view should collapse its action view.
- *
- * @param menu Menu containing the item to be collapsed
- * @param item Item to be collapsed
- * @return true if this presenter collapsed the action view, false otherwise.
- */
- public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item);
-
- /**
- * Returns an ID for determining how to save/restore instance state.
- * @return a valid ID value.
- */
- public int getId();
-
- /**
- * Returns a Parcelable describing the current state of the presenter.
- * It will be passed to the {@link #onRestoreInstanceState(Parcelable)}
- * method of the presenter sharing the same ID later.
- * @return The saved instance state
- */
- public Parcelable onSaveInstanceState();
-
- /**
- * Supplies the previously saved instance state to be restored.
- * @param state The previously saved instance state
- */
- public void onRestoreInstanceState(Parcelable state);
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuView.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuView.java
deleted file mode 100644
index 323ba2d88d..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuView.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu;
-
-import android.graphics.drawable.Drawable;
-
-/**
- * Minimal interface for a menu view. {@link #initialize(MenuBuilder)} must be called for the
- * menu to be functional.
- *
- * @hide
- */
-public interface MenuView {
- /**
- * Initializes the menu to the given menu. This should be called after the
- * view is inflated.
- *
- * @param menu The menu that this MenuView should display.
- */
- public void initialize(MenuBuilder menu);
-
- /**
- * Returns the default animations to be used for this menu when entering/exiting.
- * @return A resource ID for the default animations to be used for this menu.
- */
- public int getWindowAnimations();
-
- /**
- * Minimal interface for a menu item view. {@link #initialize(MenuItemImpl, int)} must be called
- * for the item to be functional.
- */
- public interface ItemView {
- /**
- * Initializes with the provided MenuItemData. This should be called after the view is
- * inflated.
- * @param itemData The item that this ItemView should display.
- * @param menuType The type of this menu, one of
- * {@link MenuBuilder#TYPE_ICON}, {@link MenuBuilder#TYPE_EXPANDED},
- * {@link MenuBuilder#TYPE_DIALOG}).
- */
- public void initialize(MenuItemImpl itemData, int menuType);
-
- /**
- * Gets the item data that this view is displaying.
- * @return the item data, or null if there is not one
- */
- public MenuItemImpl getItemData();
-
- /**
- * Sets the title of the item view.
- * @param title The title to set.
- */
- public void setTitle(CharSequence title);
-
- /**
- * Sets the enabled state of the item view.
- * @param enabled Whether the item view should be enabled.
- */
- public void setEnabled(boolean enabled);
-
- /**
- * Displays the checkbox for the item view. This does not ensure the item view will be
- * checked, for that use {@link #setChecked}.
- * @param checkable Whether to display the checkbox or to hide it
- */
- public void setCheckable(boolean checkable);
-
- /**
- * Checks the checkbox for the item view. If the checkbox is hidden, it will NOT be
- * made visible, call {@link #setCheckable(boolean)} for that.
- * @param checked Whether the checkbox should be checked
- */
- public void setChecked(boolean checked);
-
- /**
- * Sets the shortcut for the item.
- * @param showShortcut Whether a shortcut should be shown(if false, the value of
- * shortcutKey should be ignored).
- * @param shortcutKey The shortcut key that should be shown on the ItemView.
- */
- public void setShortcut(boolean showShortcut, char shortcutKey);
-
- /**
- * Set the icon of this item view.
- * @param icon The icon of this item. null to hide the icon.
- */
- public void setIcon(Drawable icon);
-
- /**
- * Whether this item view prefers displaying the condensed title rather
- * than the normal title. If a condensed title is not available, the
- * normal title will be used.
- *
- * @return Whether this item view prefers displaying the condensed
- * title.
- */
- public boolean prefersCondensedTitle();
-
- /**
- * Whether this item view shows an icon.
- *
- * @return Whether this item view shows an icon.
- */
- public boolean showsIcon();
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java
deleted file mode 100644
index 64fc4aeaa0..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java
+++ /dev/null
@@ -1,180 +0,0 @@
-package com.actionbarsherlock.internal.view.menu;
-
-import java.util.WeakHashMap;
-import android.content.ComponentName;
-import android.content.Intent;
-import android.view.KeyEvent;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuItem;
-import com.actionbarsherlock.view.SubMenu;
-
-public class MenuWrapper implements Menu {
- private final android.view.Menu mNativeMenu;
-
- private final WeakHashMap mNativeMap =
- new WeakHashMap();
-
-
- public MenuWrapper(android.view.Menu nativeMenu) {
- mNativeMenu = nativeMenu;
- }
-
- public android.view.Menu unwrap() {
- return mNativeMenu;
- }
-
- private MenuItem addInternal(android.view.MenuItem nativeItem) {
- MenuItem item = new MenuItemWrapper(nativeItem);
- mNativeMap.put(nativeItem, item);
- return item;
- }
-
- @Override
- public MenuItem add(CharSequence title) {
- return addInternal(mNativeMenu.add(title));
- }
-
- @Override
- public MenuItem add(int titleRes) {
- return addInternal(mNativeMenu.add(titleRes));
- }
-
- @Override
- public MenuItem add(int groupId, int itemId, int order, CharSequence title) {
- return addInternal(mNativeMenu.add(groupId, itemId, order, title));
- }
-
- @Override
- public MenuItem add(int groupId, int itemId, int order, int titleRes) {
- return addInternal(mNativeMenu.add(groupId, itemId, order, titleRes));
- }
-
- private SubMenu addInternal(android.view.SubMenu nativeSubMenu) {
- SubMenu subMenu = new SubMenuWrapper(nativeSubMenu);
- android.view.MenuItem nativeItem = nativeSubMenu.getItem();
- MenuItem item = subMenu.getItem();
- mNativeMap.put(nativeItem, item);
- return subMenu;
- }
-
- @Override
- public SubMenu addSubMenu(CharSequence title) {
- return addInternal(mNativeMenu.addSubMenu(title));
- }
-
- @Override
- public SubMenu addSubMenu(int titleRes) {
- return addInternal(mNativeMenu.addSubMenu(titleRes));
- }
-
- @Override
- public SubMenu addSubMenu(int groupId, int itemId, int order, CharSequence title) {
- return addInternal(mNativeMenu.addSubMenu(groupId, itemId, order, title));
- }
-
- @Override
- public SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes) {
- return addInternal(mNativeMenu.addSubMenu(groupId, itemId, order, titleRes));
- }
-
- @Override
- public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) {
- android.view.MenuItem[] nativeOutItems = new android.view.MenuItem[outSpecificItems.length];
- int result = mNativeMenu.addIntentOptions(groupId, itemId, order, caller, specifics, intent, flags, nativeOutItems);
- for (int i = 0, length = outSpecificItems.length; i < length; i++) {
- outSpecificItems[i] = new MenuItemWrapper(nativeOutItems[i]);
- }
- return result;
- }
-
- @Override
- public void removeItem(int id) {
- mNativeMenu.removeItem(id);
- }
-
- @Override
- public void removeGroup(int groupId) {
- mNativeMenu.removeGroup(groupId);
- }
-
- @Override
- public void clear() {
- mNativeMap.clear();
- mNativeMenu.clear();
- }
-
- @Override
- public void setGroupCheckable(int group, boolean checkable, boolean exclusive) {
- mNativeMenu.setGroupCheckable(group, checkable, exclusive);
- }
-
- @Override
- public void setGroupVisible(int group, boolean visible) {
- mNativeMenu.setGroupVisible(group, visible);
- }
-
- @Override
- public void setGroupEnabled(int group, boolean enabled) {
- mNativeMenu.setGroupEnabled(group, enabled);
- }
-
- @Override
- public boolean hasVisibleItems() {
- return mNativeMenu.hasVisibleItems();
- }
-
- @Override
- public MenuItem findItem(int id) {
- android.view.MenuItem nativeItem = mNativeMenu.findItem(id);
- return findItem(nativeItem);
- }
-
- public MenuItem findItem(android.view.MenuItem nativeItem) {
- if (nativeItem == null) {
- return null;
- }
-
- MenuItem wrapped = mNativeMap.get(nativeItem);
- if (wrapped != null) {
- return wrapped;
- }
-
- return addInternal(nativeItem);
- }
-
- @Override
- public int size() {
- return mNativeMenu.size();
- }
-
- @Override
- public MenuItem getItem(int index) {
- android.view.MenuItem nativeItem = mNativeMenu.getItem(index);
- return findItem(nativeItem);
- }
-
- @Override
- public void close() {
- mNativeMenu.close();
- }
-
- @Override
- public boolean performShortcut(int keyCode, KeyEvent event, int flags) {
- return mNativeMenu.performShortcut(keyCode, event, flags);
- }
-
- @Override
- public boolean isShortcutKey(int keyCode, KeyEvent event) {
- return mNativeMenu.isShortcutKey(keyCode, event);
- }
-
- @Override
- public boolean performIdentifierAction(int id, int flags) {
- return mNativeMenu.performIdentifierAction(id, flags);
- }
-
- @Override
- public void setQwertyMode(boolean isQwerty) {
- mNativeMenu.setQwertyMode(isQwerty);
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuBuilder.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuBuilder.java
deleted file mode 100644
index 6679cf3860..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuBuilder.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu;
-
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.view.View;
-
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuItem;
-import com.actionbarsherlock.view.SubMenu;
-
-/**
- * The model for a sub menu, which is an extension of the menu. Most methods are proxied to
- * the parent menu.
- */
-public class SubMenuBuilder extends MenuBuilder implements SubMenu {
- private MenuBuilder mParentMenu;
- private MenuItemImpl mItem;
-
- public SubMenuBuilder(Context context, MenuBuilder parentMenu, MenuItemImpl item) {
- super(context);
-
- mParentMenu = parentMenu;
- mItem = item;
- }
-
- @Override
- public void setQwertyMode(boolean isQwerty) {
- mParentMenu.setQwertyMode(isQwerty);
- }
-
- @Override
- public boolean isQwertyMode() {
- return mParentMenu.isQwertyMode();
- }
-
- @Override
- public void setShortcutsVisible(boolean shortcutsVisible) {
- mParentMenu.setShortcutsVisible(shortcutsVisible);
- }
-
- @Override
- public boolean isShortcutsVisible() {
- return mParentMenu.isShortcutsVisible();
- }
-
- public Menu getParentMenu() {
- return mParentMenu;
- }
-
- public MenuItem getItem() {
- return mItem;
- }
-
- @Override
- public void setCallback(Callback callback) {
- mParentMenu.setCallback(callback);
- }
-
- @Override
- public MenuBuilder getRootMenu() {
- return mParentMenu;
- }
-
- @Override
- boolean dispatchMenuItemSelected(MenuBuilder menu, MenuItem item) {
- return super.dispatchMenuItemSelected(menu, item) ||
- mParentMenu.dispatchMenuItemSelected(menu, item);
- }
-
- public SubMenu setIcon(Drawable icon) {
- mItem.setIcon(icon);
- return this;
- }
-
- public SubMenu setIcon(int iconRes) {
- mItem.setIcon(iconRes);
- return this;
- }
-
- public SubMenu setHeaderIcon(Drawable icon) {
- return (SubMenu) super.setHeaderIconInt(icon);
- }
-
- public SubMenu setHeaderIcon(int iconRes) {
- return (SubMenu) super.setHeaderIconInt(iconRes);
- }
-
- public SubMenu setHeaderTitle(CharSequence title) {
- return (SubMenu) super.setHeaderTitleInt(title);
- }
-
- public SubMenu setHeaderTitle(int titleRes) {
- return (SubMenu) super.setHeaderTitleInt(titleRes);
- }
-
- public SubMenu setHeaderView(View view) {
- return (SubMenu) super.setHeaderViewInt(view);
- }
-
- @Override
- public boolean expandItemActionView(MenuItemImpl item) {
- return mParentMenu.expandItemActionView(item);
- }
-
- @Override
- public boolean collapseItemActionView(MenuItemImpl item) {
- return mParentMenu.collapseItemActionView(item);
- }
-
- @Override
- public String getActionViewStatesKey() {
- final int itemId = mItem != null ? mItem.getItemId() : 0;
- if (itemId == 0) {
- return null;
- }
- return super.getActionViewStatesKey() + ":" + itemId;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuWrapper.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuWrapper.java
deleted file mode 100644
index 7d307acb10..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuWrapper.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.actionbarsherlock.internal.view.menu;
-
-import android.graphics.drawable.Drawable;
-import android.view.View;
-import com.actionbarsherlock.view.MenuItem;
-import com.actionbarsherlock.view.SubMenu;
-
-public class SubMenuWrapper extends MenuWrapper implements SubMenu {
- private final android.view.SubMenu mNativeSubMenu;
- private MenuItem mItem = null;
-
- public SubMenuWrapper(android.view.SubMenu nativeSubMenu) {
- super(nativeSubMenu);
- mNativeSubMenu = nativeSubMenu;
- }
-
-
- @Override
- public SubMenu setHeaderTitle(int titleRes) {
- mNativeSubMenu.setHeaderTitle(titleRes);
- return this;
- }
-
- @Override
- public SubMenu setHeaderTitle(CharSequence title) {
- mNativeSubMenu.setHeaderTitle(title);
- return this;
- }
-
- @Override
- public SubMenu setHeaderIcon(int iconRes) {
- mNativeSubMenu.setHeaderIcon(iconRes);
- return this;
- }
-
- @Override
- public SubMenu setHeaderIcon(Drawable icon) {
- mNativeSubMenu.setHeaderIcon(icon);
- return this;
- }
-
- @Override
- public SubMenu setHeaderView(View view) {
- mNativeSubMenu.setHeaderView(view);
- return this;
- }
-
- @Override
- public void clearHeader() {
- mNativeSubMenu.clearHeader();
- }
-
- @Override
- public SubMenu setIcon(int iconRes) {
- mNativeSubMenu.setIcon(iconRes);
- return this;
- }
-
- @Override
- public SubMenu setIcon(Drawable icon) {
- mNativeSubMenu.setIcon(icon);
- return this;
- }
-
- @Override
- public MenuItem getItem() {
- if (mItem == null) {
- mItem = new MenuItemWrapper(mNativeSubMenu.getItem());
- }
- return mItem;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/AbsActionBarView.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/AbsActionBarView.java
deleted file mode 100644
index 3a4a446756..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/AbsActionBarView.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright (C) 2011 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.actionbarsherlock.internal.widget;
-
-import android.content.Context;
-import android.content.res.Configuration;
-import android.content.res.TypedArray;
-import android.os.Build;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.animation.DecelerateInterpolator;
-import android.view.animation.Interpolator;
-
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.internal.nineoldandroids.animation.Animator;
-import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet;
-import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator;
-import com.actionbarsherlock.internal.nineoldandroids.view.NineViewGroup;
-import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter;
-import com.actionbarsherlock.internal.view.menu.ActionMenuView;
-
-import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean;
-
-public abstract class AbsActionBarView extends NineViewGroup {
- protected ActionMenuView mMenuView;
- protected ActionMenuPresenter mActionMenuPresenter;
- protected ActionBarContainer mSplitView;
- protected boolean mSplitActionBar;
- protected boolean mSplitWhenNarrow;
- protected int mContentHeight;
-
- final Context mContext;
-
- protected Animator mVisibilityAnim;
- protected final VisibilityAnimListener mVisAnimListener = new VisibilityAnimListener();
-
- private static final /*Time*/Interpolator sAlphaInterpolator = new DecelerateInterpolator();
-
- private static final int FADE_DURATION = 200;
-
- public AbsActionBarView(Context context) {
- super(context);
- mContext = context;
- }
-
- public AbsActionBarView(Context context, AttributeSet attrs) {
- super(context, attrs);
- mContext = context;
- }
-
- public AbsActionBarView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- mContext = context;
- }
-
- /*
- * Must be public so we can dispatch pre-2.2 via ActionBarImpl.
- */
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
- super.onConfigurationChanged(newConfig);
- } else if (mMenuView != null) {
- mMenuView.onConfigurationChanged(newConfig);
- }
-
- // Action bar can change size on configuration changes.
- // Reread the desired height from the theme-specified style.
- TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar,
- R.attr.actionBarStyle, 0);
- setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0));
- a.recycle();
- if (mSplitWhenNarrow) {
- setSplitActionBar(getResources_getBoolean(getContext(),
- R.bool.abs__split_action_bar_is_narrow));
- }
- if (mActionMenuPresenter != null) {
- mActionMenuPresenter.onConfigurationChanged(newConfig);
- }
- }
-
- /**
- * Sets whether the bar should be split right now, no questions asked.
- * @param split true if the bar should split
- */
- public void setSplitActionBar(boolean split) {
- mSplitActionBar = split;
- }
-
- /**
- * Sets whether the bar should split if we enter a narrow screen configuration.
- * @param splitWhenNarrow true if the bar should check to split after a config change
- */
- public void setSplitWhenNarrow(boolean splitWhenNarrow) {
- mSplitWhenNarrow = splitWhenNarrow;
- }
-
- public void setContentHeight(int height) {
- mContentHeight = height;
- requestLayout();
- }
-
- public int getContentHeight() {
- return mContentHeight;
- }
-
- public void setSplitView(ActionBarContainer splitView) {
- mSplitView = splitView;
- }
-
- /**
- * @return Current visibility or if animating, the visibility being animated to.
- */
- public int getAnimatedVisibility() {
- if (mVisibilityAnim != null) {
- return mVisAnimListener.mFinalVisibility;
- }
- return getVisibility();
- }
-
- public void animateToVisibility(int visibility) {
- if (mVisibilityAnim != null) {
- mVisibilityAnim.cancel();
- }
- if (visibility == VISIBLE) {
- if (getVisibility() != VISIBLE) {
- setAlpha(0);
- if (mSplitView != null && mMenuView != null) {
- mMenuView.setAlpha(0);
- }
- }
- ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 1);
- anim.setDuration(FADE_DURATION);
- anim.setInterpolator(sAlphaInterpolator);
- if (mSplitView != null && mMenuView != null) {
- AnimatorSet set = new AnimatorSet();
- ObjectAnimator splitAnim = ObjectAnimator.ofFloat(mMenuView, "alpha", 1);
- splitAnim.setDuration(FADE_DURATION);
- set.addListener(mVisAnimListener.withFinalVisibility(visibility));
- set.play(anim).with(splitAnim);
- set.start();
- } else {
- anim.addListener(mVisAnimListener.withFinalVisibility(visibility));
- anim.start();
- }
- } else {
- ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 0);
- anim.setDuration(FADE_DURATION);
- anim.setInterpolator(sAlphaInterpolator);
- if (mSplitView != null && mMenuView != null) {
- AnimatorSet set = new AnimatorSet();
- ObjectAnimator splitAnim = ObjectAnimator.ofFloat(mMenuView, "alpha", 0);
- splitAnim.setDuration(FADE_DURATION);
- set.addListener(mVisAnimListener.withFinalVisibility(visibility));
- set.play(anim).with(splitAnim);
- set.start();
- } else {
- anim.addListener(mVisAnimListener.withFinalVisibility(visibility));
- anim.start();
- }
- }
- }
-
- @Override
- public void setVisibility(int visibility) {
- if (mVisibilityAnim != null) {
- mVisibilityAnim.end();
- }
- super.setVisibility(visibility);
- }
-
- public boolean showOverflowMenu() {
- if (mActionMenuPresenter != null) {
- return mActionMenuPresenter.showOverflowMenu();
- }
- return false;
- }
-
- public void postShowOverflowMenu() {
- post(new Runnable() {
- public void run() {
- showOverflowMenu();
- }
- });
- }
-
- public boolean hideOverflowMenu() {
- if (mActionMenuPresenter != null) {
- return mActionMenuPresenter.hideOverflowMenu();
- }
- return false;
- }
-
- public boolean isOverflowMenuShowing() {
- if (mActionMenuPresenter != null) {
- return mActionMenuPresenter.isOverflowMenuShowing();
- }
- return false;
- }
-
- public boolean isOverflowReserved() {
- return mActionMenuPresenter != null && mActionMenuPresenter.isOverflowReserved();
- }
-
- public void dismissPopupMenus() {
- if (mActionMenuPresenter != null) {
- mActionMenuPresenter.dismissPopupMenus();
- }
- }
-
- protected int measureChildView(View child, int availableWidth, int childSpecHeight,
- int spacing) {
- child.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST),
- childSpecHeight);
-
- availableWidth -= child.getMeasuredWidth();
- availableWidth -= spacing;
-
- return Math.max(0, availableWidth);
- }
-
- protected int positionChild(View child, int x, int y, int contentHeight) {
- int childWidth = child.getMeasuredWidth();
- int childHeight = child.getMeasuredHeight();
- int childTop = y + (contentHeight - childHeight) / 2;
-
- child.layout(x, childTop, x + childWidth, childTop + childHeight);
-
- return childWidth;
- }
-
- protected int positionChildInverse(View child, int x, int y, int contentHeight) {
- int childWidth = child.getMeasuredWidth();
- int childHeight = child.getMeasuredHeight();
- int childTop = y + (contentHeight - childHeight) / 2;
-
- child.layout(x - childWidth, childTop, x, childTop + childHeight);
-
- return childWidth;
- }
-
- protected class VisibilityAnimListener implements Animator.AnimatorListener {
- private boolean mCanceled = false;
- int mFinalVisibility;
-
- public VisibilityAnimListener withFinalVisibility(int visibility) {
- mFinalVisibility = visibility;
- return this;
- }
-
- @Override
- public void onAnimationStart(Animator animation) {
- setVisibility(VISIBLE);
- mVisibilityAnim = animation;
- mCanceled = false;
- }
-
- @Override
- public void onAnimationEnd(Animator animation) {
- if (mCanceled) return;
-
- mVisibilityAnim = null;
- setVisibility(mFinalVisibility);
- if (mSplitView != null && mMenuView != null) {
- mMenuView.setVisibility(mFinalVisibility);
- }
- }
-
- @Override
- public void onAnimationCancel(Animator animation) {
- mCanceled = true;
- }
-
- @Override
- public void onAnimationRepeat(Animator animation) {
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java
deleted file mode 100644
index 5e5aa28679..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.widget;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.drawable.Drawable;
-import android.util.AttributeSet;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout;
-
-/**
- * This class acts as a container for the action bar view and action mode context views.
- * It applies special styles as needed to help handle animated transitions between them.
- * @hide
- */
-public class ActionBarContainer extends NineFrameLayout {
- private boolean mIsTransitioning;
- private View mTabContainer;
- private ActionBarView mActionBarView;
-
- private Drawable mBackground;
- private Drawable mStackedBackground;
- private Drawable mSplitBackground;
- private boolean mIsSplit;
- private boolean mIsStacked;
-
- public ActionBarContainer(Context context) {
- this(context, null);
- }
-
- public ActionBarContainer(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- setBackgroundDrawable(null);
-
- TypedArray a = context.obtainStyledAttributes(attrs,
- R.styleable.SherlockActionBar);
- mBackground = a.getDrawable(R.styleable.SherlockActionBar_background);
- mStackedBackground = a.getDrawable(
- R.styleable.SherlockActionBar_backgroundStacked);
-
- if (getId() == R.id.abs__split_action_bar) {
- mIsSplit = true;
- mSplitBackground = a.getDrawable(
- R.styleable.SherlockActionBar_backgroundSplit);
- }
- a.recycle();
-
- setWillNotDraw(mIsSplit ? mSplitBackground == null :
- mBackground == null && mStackedBackground == null);
- }
-
- @Override
- public void onFinishInflate() {
- super.onFinishInflate();
- mActionBarView = (ActionBarView) findViewById(R.id.abs__action_bar);
- }
-
- public void setPrimaryBackground(Drawable bg) {
- mBackground = bg;
- invalidate();
- }
-
- public void setStackedBackground(Drawable bg) {
- mStackedBackground = bg;
- invalidate();
- }
-
- public void setSplitBackground(Drawable bg) {
- mSplitBackground = bg;
- invalidate();
- }
-
- /**
- * Set the action bar into a "transitioning" state. While transitioning
- * the bar will block focus and touch from all of its descendants. This
- * prevents the user from interacting with the bar while it is animating
- * in or out.
- *
- * @param isTransitioning true if the bar is currently transitioning, false otherwise.
- */
- public void setTransitioning(boolean isTransitioning) {
- mIsTransitioning = isTransitioning;
- setDescendantFocusability(isTransitioning ? FOCUS_BLOCK_DESCENDANTS
- : FOCUS_AFTER_DESCENDANTS);
- }
-
- @Override
- public boolean onInterceptTouchEvent(MotionEvent ev) {
- return mIsTransitioning || super.onInterceptTouchEvent(ev);
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- super.onTouchEvent(ev);
-
- // An action bar always eats touch events.
- return true;
- }
-
- @Override
- public boolean onHoverEvent(MotionEvent ev) {
- super.onHoverEvent(ev);
-
- // An action bar always eats hover events.
- return true;
- }
-
- public void setTabContainer(ScrollingTabContainerView tabView) {
- if (mTabContainer != null) {
- removeView(mTabContainer);
- }
- mTabContainer = tabView;
- if (tabView != null) {
- addView(tabView);
- final ViewGroup.LayoutParams lp = tabView.getLayoutParams();
- lp.width = LayoutParams.MATCH_PARENT;
- lp.height = LayoutParams.WRAP_CONTENT;
- tabView.setAllowCollapse(false);
- }
- }
-
- public View getTabContainer() {
- return mTabContainer;
- }
-
- @Override
- public void onDraw(Canvas canvas) {
- if (getWidth() == 0 || getHeight() == 0) {
- return;
- }
-
- if (mIsSplit) {
- if (mSplitBackground != null) mSplitBackground.draw(canvas);
- } else {
- if (mBackground != null) {
- mBackground.draw(canvas);
- }
- if (mStackedBackground != null && mIsStacked) {
- mStackedBackground.draw(canvas);
- }
- }
- }
-
- //This causes the animation reflection to fail on pre-HC platforms
- //@Override
- //public android.view.ActionMode startActionModeForChild(View child, android.view.ActionMode.Callback callback) {
- // // No starting an action mode for an action bar child! (Where would it go?)
- // return null;
- //}
-
- @Override
- public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-
- if (mActionBarView == null) return;
-
- final LayoutParams lp = (LayoutParams) mActionBarView.getLayoutParams();
- final int actionBarViewHeight = mActionBarView.isCollapsed() ? 0 :
- mActionBarView.getMeasuredHeight() + lp.topMargin + lp.bottomMargin;
-
- if (mTabContainer != null && mTabContainer.getVisibility() != GONE) {
- final int mode = MeasureSpec.getMode(heightMeasureSpec);
- if (mode == MeasureSpec.AT_MOST) {
- final int maxHeight = MeasureSpec.getSize(heightMeasureSpec);
- setMeasuredDimension(getMeasuredWidth(),
- Math.min(actionBarViewHeight + mTabContainer.getMeasuredHeight(),
- maxHeight));
- }
- }
- }
-
- @Override
- public void onLayout(boolean changed, int l, int t, int r, int b) {
- super.onLayout(changed, l, t, r, b);
-
- final boolean hasTabs = mTabContainer != null && mTabContainer.getVisibility() != GONE;
-
- if (mTabContainer != null && mTabContainer.getVisibility() != GONE) {
- final int containerHeight = getMeasuredHeight();
- final int tabHeight = mTabContainer.getMeasuredHeight();
-
- if ((mActionBarView.getDisplayOptions() & ActionBar.DISPLAY_SHOW_HOME) == 0) {
- // Not showing home, put tabs on top.
- final int count = getChildCount();
- for (int i = 0; i < count; i++) {
- final View child = getChildAt(i);
-
- if (child == mTabContainer) continue;
-
- if (!mActionBarView.isCollapsed()) {
- child.offsetTopAndBottom(tabHeight);
- }
- }
- mTabContainer.layout(l, 0, r, tabHeight);
- } else {
- mTabContainer.layout(l, containerHeight - tabHeight, r, containerHeight);
- }
- }
-
- boolean needsInvalidate = false;
- if (mIsSplit) {
- if (mSplitBackground != null) {
- mSplitBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
- needsInvalidate = true;
- }
- } else {
- if (mBackground != null) {
- mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(),
- mActionBarView.getRight(), mActionBarView.getBottom());
- needsInvalidate = true;
- }
- if ((mIsStacked = hasTabs && mStackedBackground != null)) {
- mStackedBackground.setBounds(mTabContainer.getLeft(), mTabContainer.getTop(),
- mTabContainer.getRight(), mTabContainer.getBottom());
- needsInvalidate = true;
- }
- }
-
- if (needsInvalidate) {
- invalidate();
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarContextView.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarContextView.java
deleted file mode 100644
index 9ec250f387..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarContextView.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.widget;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.animation.DecelerateInterpolator;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.internal.nineoldandroids.animation.Animator;
-import com.actionbarsherlock.internal.nineoldandroids.animation.Animator.AnimatorListener;
-import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet;
-import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator;
-import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy;
-import com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout;
-import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter;
-import com.actionbarsherlock.internal.view.menu.ActionMenuView;
-import com.actionbarsherlock.internal.view.menu.MenuBuilder;
-import com.actionbarsherlock.view.ActionMode;
-
-/**
- * @hide
- */
-public class ActionBarContextView extends AbsActionBarView implements AnimatorListener {
- //UNUSED private static final String TAG = "ActionBarContextView";
-
- private CharSequence mTitle;
- private CharSequence mSubtitle;
-
- private NineLinearLayout mClose;
- private View mCustomView;
- private LinearLayout mTitleLayout;
- private TextView mTitleView;
- private TextView mSubtitleView;
- private int mTitleStyleRes;
- private int mSubtitleStyleRes;
- private Drawable mSplitBackground;
-
- private Animator mCurrentAnimation;
- private boolean mAnimateInOnLayout;
- private int mAnimationMode;
-
- private static final int ANIMATE_IDLE = 0;
- private static final int ANIMATE_IN = 1;
- private static final int ANIMATE_OUT = 2;
-
- public ActionBarContextView(Context context) {
- this(context, null);
- }
-
- public ActionBarContextView(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.actionModeStyle);
- }
-
- public ActionBarContextView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
-
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionMode, defStyle, 0);
- setBackgroundDrawable(a.getDrawable(
- R.styleable.SherlockActionMode_background));
- mTitleStyleRes = a.getResourceId(
- R.styleable.SherlockActionMode_titleTextStyle, 0);
- mSubtitleStyleRes = a.getResourceId(
- R.styleable.SherlockActionMode_subtitleTextStyle, 0);
-
- mContentHeight = a.getLayoutDimension(
- R.styleable.SherlockActionMode_height, 0);
-
- mSplitBackground = a.getDrawable(
- R.styleable.SherlockActionMode_backgroundSplit);
-
- a.recycle();
- }
-
- @Override
- public void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- if (mActionMenuPresenter != null) {
- mActionMenuPresenter.hideOverflowMenu();
- mActionMenuPresenter.hideSubMenus();
- }
- }
-
- @Override
- public void setSplitActionBar(boolean split) {
- if (mSplitActionBar != split) {
- if (mActionMenuPresenter != null) {
- // Mode is already active; move everything over and adjust the menu itself.
- final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
- LayoutParams.MATCH_PARENT);
- if (!split) {
- mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
- mMenuView.setBackgroundDrawable(null);
- final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
- if (oldParent != null) oldParent.removeView(mMenuView);
- addView(mMenuView, layoutParams);
- } else {
- // Allow full screen width in split mode.
- mActionMenuPresenter.setWidthLimit(
- getContext().getResources().getDisplayMetrics().widthPixels, true);
- // No limit to the item count; use whatever will fit.
- mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
- // Span the whole width
- layoutParams.width = LayoutParams.MATCH_PARENT;
- layoutParams.height = mContentHeight;
- mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
- mMenuView.setBackgroundDrawable(mSplitBackground);
- final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
- if (oldParent != null) oldParent.removeView(mMenuView);
- mSplitView.addView(mMenuView, layoutParams);
- }
- }
- super.setSplitActionBar(split);
- }
- }
-
- public void setContentHeight(int height) {
- mContentHeight = height;
- }
-
- public void setCustomView(View view) {
- if (mCustomView != null) {
- removeView(mCustomView);
- }
- mCustomView = view;
- if (mTitleLayout != null) {
- removeView(mTitleLayout);
- mTitleLayout = null;
- }
- if (view != null) {
- addView(view);
- }
- requestLayout();
- }
-
- public void setTitle(CharSequence title) {
- mTitle = title;
- initTitle();
- }
-
- public void setSubtitle(CharSequence subtitle) {
- mSubtitle = subtitle;
- initTitle();
- }
-
- public CharSequence getTitle() {
- return mTitle;
- }
-
- public CharSequence getSubtitle() {
- return mSubtitle;
- }
-
- private void initTitle() {
- if (mTitleLayout == null) {
- LayoutInflater inflater = LayoutInflater.from(getContext());
- inflater.inflate(R.layout.abs__action_bar_title_item, this);
- mTitleLayout = (LinearLayout) getChildAt(getChildCount() - 1);
- mTitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_title);
- mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_subtitle);
- if (mTitleStyleRes != 0) {
- mTitleView.setTextAppearance(mContext, mTitleStyleRes);
- }
- if (mSubtitleStyleRes != 0) {
- mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes);
- }
- }
-
- mTitleView.setText(mTitle);
- mSubtitleView.setText(mSubtitle);
-
- final boolean hasTitle = !TextUtils.isEmpty(mTitle);
- final boolean hasSubtitle = !TextUtils.isEmpty(mSubtitle);
- mSubtitleView.setVisibility(hasSubtitle ? VISIBLE : GONE);
- mTitleLayout.setVisibility(hasTitle || hasSubtitle ? VISIBLE : GONE);
- if (mTitleLayout.getParent() == null) {
- addView(mTitleLayout);
- }
- }
-
- public void initForMode(final ActionMode mode) {
- if (mClose == null) {
- LayoutInflater inflater = LayoutInflater.from(mContext);
- mClose = (NineLinearLayout)inflater.inflate(R.layout.abs__action_mode_close_item, this, false);
- addView(mClose);
- } else if (mClose.getParent() == null) {
- addView(mClose);
- }
-
- View closeButton = mClose.findViewById(R.id.abs__action_mode_close_button);
- closeButton.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- mode.finish();
- }
- });
-
- final MenuBuilder menu = (MenuBuilder) mode.getMenu();
- if (mActionMenuPresenter != null) {
- mActionMenuPresenter.dismissPopupMenus();
- }
- mActionMenuPresenter = new ActionMenuPresenter(mContext);
- mActionMenuPresenter.setReserveOverflow(true);
-
- final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
- LayoutParams.MATCH_PARENT);
- if (!mSplitActionBar) {
- menu.addMenuPresenter(mActionMenuPresenter);
- mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
- mMenuView.setBackgroundDrawable(null);
- addView(mMenuView, layoutParams);
- } else {
- // Allow full screen width in split mode.
- mActionMenuPresenter.setWidthLimit(
- getContext().getResources().getDisplayMetrics().widthPixels, true);
- // No limit to the item count; use whatever will fit.
- mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
- // Span the whole width
- layoutParams.width = LayoutParams.MATCH_PARENT;
- layoutParams.height = mContentHeight;
- menu.addMenuPresenter(mActionMenuPresenter);
- mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
- mMenuView.setBackgroundDrawable(mSplitBackground);
- mSplitView.addView(mMenuView, layoutParams);
- }
-
- mAnimateInOnLayout = true;
- }
-
- public void closeMode() {
- if (mAnimationMode == ANIMATE_OUT) {
- // Called again during close; just finish what we were doing.
- return;
- }
- if (mClose == null) {
- killMode();
- return;
- }
-
- finishAnimation();
- mAnimationMode = ANIMATE_OUT;
- mCurrentAnimation = makeOutAnimation();
- mCurrentAnimation.start();
- }
-
- private void finishAnimation() {
- final Animator a = mCurrentAnimation;
- if (a != null) {
- mCurrentAnimation = null;
- a.end();
- }
- }
-
- public void killMode() {
- finishAnimation();
- removeAllViews();
- if (mSplitView != null) {
- mSplitView.removeView(mMenuView);
- }
- mCustomView = null;
- mMenuView = null;
- mAnimateInOnLayout = false;
- }
-
- @Override
- public boolean showOverflowMenu() {
- if (mActionMenuPresenter != null) {
- return mActionMenuPresenter.showOverflowMenu();
- }
- return false;
- }
-
- @Override
- public boolean hideOverflowMenu() {
- if (mActionMenuPresenter != null) {
- return mActionMenuPresenter.hideOverflowMenu();
- }
- return false;
- }
-
- @Override
- public boolean isOverflowMenuShowing() {
- if (mActionMenuPresenter != null) {
- return mActionMenuPresenter.isOverflowMenuShowing();
- }
- return false;
- }
-
- @Override
- protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
- // Used by custom views if they don't supply layout params. Everything else
- // added to an ActionBarContextView should have them already.
- return new MarginLayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
- }
-
- @Override
- public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) {
- return new MarginLayoutParams(getContext(), attrs);
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
- if (widthMode != MeasureSpec.EXACTLY) {
- throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
- "with android:layout_width=\"match_parent\" (or fill_parent)");
- }
-
- final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
- if (heightMode == MeasureSpec.UNSPECIFIED) {
- throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
- "with android:layout_height=\"wrap_content\"");
- }
-
- final int contentWidth = MeasureSpec.getSize(widthMeasureSpec);
-
- int maxHeight = mContentHeight > 0 ?
- mContentHeight : MeasureSpec.getSize(heightMeasureSpec);
-
- final int verticalPadding = getPaddingTop() + getPaddingBottom();
- int availableWidth = contentWidth - getPaddingLeft() - getPaddingRight();
- final int height = maxHeight - verticalPadding;
- final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
-
- if (mClose != null) {
- availableWidth = measureChildView(mClose, availableWidth, childSpecHeight, 0);
- MarginLayoutParams lp = (MarginLayoutParams) mClose.getLayoutParams();
- availableWidth -= lp.leftMargin + lp.rightMargin;
- }
-
- if (mMenuView != null && mMenuView.getParent() == this) {
- availableWidth = measureChildView(mMenuView, availableWidth,
- childSpecHeight, 0);
- }
-
- if (mTitleLayout != null && mCustomView == null) {
- availableWidth = measureChildView(mTitleLayout, availableWidth, childSpecHeight, 0);
- }
-
- if (mCustomView != null) {
- ViewGroup.LayoutParams lp = mCustomView.getLayoutParams();
- final int customWidthMode = lp.width != LayoutParams.WRAP_CONTENT ?
- MeasureSpec.EXACTLY : MeasureSpec.AT_MOST;
- final int customWidth = lp.width >= 0 ?
- Math.min(lp.width, availableWidth) : availableWidth;
- final int customHeightMode = lp.height != LayoutParams.WRAP_CONTENT ?
- MeasureSpec.EXACTLY : MeasureSpec.AT_MOST;
- final int customHeight = lp.height >= 0 ?
- Math.min(lp.height, height) : height;
- mCustomView.measure(MeasureSpec.makeMeasureSpec(customWidth, customWidthMode),
- MeasureSpec.makeMeasureSpec(customHeight, customHeightMode));
- }
-
- if (mContentHeight <= 0) {
- int measuredHeight = 0;
- final int count = getChildCount();
- for (int i = 0; i < count; i++) {
- View v = getChildAt(i);
- int paddedViewHeight = v.getMeasuredHeight() + verticalPadding;
- if (paddedViewHeight > measuredHeight) {
- measuredHeight = paddedViewHeight;
- }
- }
- setMeasuredDimension(contentWidth, measuredHeight);
- } else {
- setMeasuredDimension(contentWidth, maxHeight);
- }
- }
-
- private Animator makeInAnimation() {
- mClose.setTranslationX(-mClose.getWidth() -
- ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin);
- ObjectAnimator buttonAnimator = ObjectAnimator.ofFloat(mClose, "translationX", 0);
- buttonAnimator.setDuration(200);
- buttonAnimator.addListener(this);
- buttonAnimator.setInterpolator(new DecelerateInterpolator());
-
- AnimatorSet set = new AnimatorSet();
- AnimatorSet.Builder b = set.play(buttonAnimator);
-
- if (mMenuView != null) {
- final int count = mMenuView.getChildCount();
- if (count > 0) {
- for (int i = count - 1, j = 0; i >= 0; i--, j++) {
- AnimatorProxy child = AnimatorProxy.wrap(mMenuView.getChildAt(i));
- child.setScaleY(0);
- ObjectAnimator a = ObjectAnimator.ofFloat(child, "scaleY", 0, 1);
- a.setDuration(100);
- a.setStartDelay(j * 70);
- b.with(a);
- }
- }
- }
-
- return set;
- }
-
- private Animator makeOutAnimation() {
- ObjectAnimator buttonAnimator = ObjectAnimator.ofFloat(mClose, "translationX",
- -mClose.getWidth() - ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin);
- buttonAnimator.setDuration(200);
- buttonAnimator.addListener(this);
- buttonAnimator.setInterpolator(new DecelerateInterpolator());
-
- AnimatorSet set = new AnimatorSet();
- AnimatorSet.Builder b = set.play(buttonAnimator);
-
- if (mMenuView != null) {
- final int count = mMenuView.getChildCount();
- if (count > 0) {
- for (int i = 0; i < 0; i++) {
- AnimatorProxy child = AnimatorProxy.wrap(mMenuView.getChildAt(i));
- child.setScaleY(0);
- ObjectAnimator a = ObjectAnimator.ofFloat(child, "scaleY", 0);
- a.setDuration(100);
- a.setStartDelay(i * 70);
- b.with(a);
- }
- }
- }
-
- return set;
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- int x = getPaddingLeft();
- final int y = getPaddingTop();
- final int contentHeight = b - t - getPaddingTop() - getPaddingBottom();
-
- if (mClose != null && mClose.getVisibility() != GONE) {
- MarginLayoutParams lp = (MarginLayoutParams) mClose.getLayoutParams();
- x += lp.leftMargin;
- x += positionChild(mClose, x, y, contentHeight);
- x += lp.rightMargin;
-
- if (mAnimateInOnLayout) {
- mAnimationMode = ANIMATE_IN;
- mCurrentAnimation = makeInAnimation();
- mCurrentAnimation.start();
- mAnimateInOnLayout = false;
- }
- }
-
- if (mTitleLayout != null && mCustomView == null) {
- x += positionChild(mTitleLayout, x, y, contentHeight);
- }
-
- if (mCustomView != null) {
- x += positionChild(mCustomView, x, y, contentHeight);
- }
-
- x = r - l - getPaddingRight();
-
- if (mMenuView != null) {
- x -= positionChildInverse(mMenuView, x, y, contentHeight);
- }
- }
-
- @Override
- public void onAnimationStart(Animator animation) {
- }
-
- @Override
- public void onAnimationEnd(Animator animation) {
- if (mAnimationMode == ANIMATE_OUT) {
- killMode();
- }
- mAnimationMode = ANIMATE_IDLE;
- }
-
- @Override
- public void onAnimationCancel(Animator animation) {
- }
-
- @Override
- public void onAnimationRepeat(Animator animation) {
- }
-
- @Override
- public boolean shouldDelayChildPressedState() {
- return false;
- }
-
- @Override
- public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
- if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
- // Action mode started
- //TODO event.setSource(this);
- event.setClassName(getClass().getName());
- event.setPackageName(getContext().getPackageName());
- event.setContentDescription(mTitle);
- } else {
- //TODO super.onInitializeAccessibilityEvent(event);
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java
deleted file mode 100644
index 4636de17f0..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java
+++ /dev/null
@@ -1,1548 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.internal.widget;
-
-import org.xmlpull.v1.XmlPullParser;
-import android.app.Activity;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.res.AssetManager;
-import android.content.res.Configuration;
-import android.content.res.TypedArray;
-import android.content.res.XmlResourceParser;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.ViewParent;
-import android.view.accessibility.AccessibilityEvent;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.SpinnerAdapter;
-import android.widget.TextView;
-
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
-import com.actionbarsherlock.internal.ActionBarSherlockCompat;
-import com.actionbarsherlock.internal.view.menu.ActionMenuItem;
-import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter;
-import com.actionbarsherlock.internal.view.menu.ActionMenuView;
-import com.actionbarsherlock.internal.view.menu.MenuBuilder;
-import com.actionbarsherlock.internal.view.menu.MenuItemImpl;
-import com.actionbarsherlock.internal.view.menu.MenuPresenter;
-import com.actionbarsherlock.internal.view.menu.MenuView;
-import com.actionbarsherlock.internal.view.menu.SubMenuBuilder;
-import com.actionbarsherlock.view.CollapsibleActionView;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuItem;
-import com.actionbarsherlock.view.Window;
-
-import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean;
-
-/**
- * @hide
- */
-public class ActionBarView extends AbsActionBarView {
- private static final String TAG = "ActionBarView";
- private static final boolean DEBUG = false;
-
- /**
- * Display options applied by default
- */
- public static final int DISPLAY_DEFAULT = 0;
-
- /**
- * Display options that require re-layout as opposed to a simple invalidate
- */
- private static final int DISPLAY_RELAYOUT_MASK =
- ActionBar.DISPLAY_SHOW_HOME |
- ActionBar.DISPLAY_USE_LOGO |
- ActionBar.DISPLAY_HOME_AS_UP |
- ActionBar.DISPLAY_SHOW_CUSTOM |
- ActionBar.DISPLAY_SHOW_TITLE;
-
- private static final int DEFAULT_CUSTOM_GRAVITY = Gravity.LEFT | Gravity.CENTER_VERTICAL;
-
- private int mNavigationMode;
- private int mDisplayOptions = -1;
- private CharSequence mTitle;
- private CharSequence mSubtitle;
- private Drawable mIcon;
- private Drawable mLogo;
-
- private HomeView mHomeLayout;
- private HomeView mExpandedHomeLayout;
- private LinearLayout mTitleLayout;
- private TextView mTitleView;
- private TextView mSubtitleView;
- private View mTitleUpView;
-
- private IcsSpinner mSpinner;
- private IcsLinearLayout mListNavLayout;
- private ScrollingTabContainerView mTabScrollView;
- private View mCustomNavView;
- private IcsProgressBar mProgressView;
- private IcsProgressBar mIndeterminateProgressView;
-
- private int mProgressBarPadding;
- private int mItemPadding;
-
- private int mTitleStyleRes;
- private int mSubtitleStyleRes;
- private int mProgressStyle;
- private int mIndeterminateProgressStyle;
-
- private boolean mUserTitle;
- private boolean mIncludeTabs;
- private boolean mIsCollapsable;
- private boolean mIsCollapsed;
-
- private MenuBuilder mOptionsMenu;
-
- private ActionBarContextView mContextView;
-
- private ActionMenuItem mLogoNavItem;
-
- private SpinnerAdapter mSpinnerAdapter;
- private OnNavigationListener mCallback;
-
- //UNUSED private Runnable mTabSelector;
-
- private ExpandedActionViewMenuPresenter mExpandedMenuPresenter;
- View mExpandedActionView;
-
- Window.Callback mWindowCallback;
-
- @SuppressWarnings("rawtypes")
- private final IcsAdapterView.OnItemSelectedListener mNavItemSelectedListener =
- new IcsAdapterView.OnItemSelectedListener() {
- public void onItemSelected(IcsAdapterView parent, View view, int position, long id) {
- if (mCallback != null) {
- mCallback.onNavigationItemSelected(position, id);
- }
- }
- public void onNothingSelected(IcsAdapterView parent) {
- // Do nothing
- }
- };
-
- private final OnClickListener mExpandedActionViewUpListener = new OnClickListener() {
- @Override
- public void onClick(View v) {
- final MenuItemImpl item = mExpandedMenuPresenter.mCurrentExpandedItem;
- if (item != null) {
- item.collapseActionView();
- }
- }
- };
-
- private final OnClickListener mUpClickListener = new OnClickListener() {
- public void onClick(View v) {
- mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem);
- }
- };
-
- public ActionBarView(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- // Background is always provided by the container.
- setBackgroundResource(0);
-
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionBar,
- R.attr.actionBarStyle, 0);
-
- ApplicationInfo appInfo = context.getApplicationInfo();
- PackageManager pm = context.getPackageManager();
- mNavigationMode = a.getInt(R.styleable.SherlockActionBar_navigationMode,
- ActionBar.NAVIGATION_MODE_STANDARD);
- mTitle = a.getText(R.styleable.SherlockActionBar_title);
- mSubtitle = a.getText(R.styleable.SherlockActionBar_subtitle);
-
- mLogo = a.getDrawable(R.styleable.SherlockActionBar_logo);
- if (mLogo == null) {
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
- if (context instanceof Activity) {
- //Even though native methods existed in API 9 and 10 they don't work
- //so just parse the manifest to look for the logo pre-Honeycomb
- final int resId = loadLogoFromManifest((Activity) context);
- if (resId != 0) {
- mLogo = context.getResources().getDrawable(resId);
- }
- }
- } else {
- if (context instanceof Activity) {
- try {
- mLogo = pm.getActivityLogo(((Activity) context).getComponentName());
- } catch (NameNotFoundException e) {
- Log.e(TAG, "Activity component name not found!", e);
- }
- }
- if (mLogo == null) {
- mLogo = appInfo.loadLogo(pm);
- }
- }
- }
-
- mIcon = a.getDrawable(R.styleable.SherlockActionBar_icon);
- if (mIcon == null) {
- if (context instanceof Activity) {
- try {
- mIcon = pm.getActivityIcon(((Activity) context).getComponentName());
- } catch (NameNotFoundException e) {
- Log.e(TAG, "Activity component name not found!", e);
- }
- }
- if (mIcon == null) {
- mIcon = appInfo.loadIcon(pm);
- }
- }
-
- final LayoutInflater inflater = LayoutInflater.from(context);
-
- final int homeResId = a.getResourceId(
- R.styleable.SherlockActionBar_homeLayout,
- R.layout.abs__action_bar_home);
-
- mHomeLayout = (HomeView) inflater.inflate(homeResId, this, false);
-
- mExpandedHomeLayout = (HomeView) inflater.inflate(homeResId, this, false);
- mExpandedHomeLayout.setUp(true);
- mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener);
- mExpandedHomeLayout.setContentDescription(getResources().getText(
- R.string.abs__action_bar_up_description));
-
- mTitleStyleRes = a.getResourceId(R.styleable.SherlockActionBar_titleTextStyle, 0);
- mSubtitleStyleRes = a.getResourceId(R.styleable.SherlockActionBar_subtitleTextStyle, 0);
- mProgressStyle = a.getResourceId(R.styleable.SherlockActionBar_progressBarStyle, 0);
- mIndeterminateProgressStyle = a.getResourceId(
- R.styleable.SherlockActionBar_indeterminateProgressStyle, 0);
-
- mProgressBarPadding = a.getDimensionPixelOffset(R.styleable.SherlockActionBar_progressBarPadding, 0);
- mItemPadding = a.getDimensionPixelOffset(R.styleable.SherlockActionBar_itemPadding, 0);
-
- setDisplayOptions(a.getInt(R.styleable.SherlockActionBar_displayOptions, DISPLAY_DEFAULT));
-
- final int customNavId = a.getResourceId(R.styleable.SherlockActionBar_customNavigationLayout, 0);
- if (customNavId != 0) {
- mCustomNavView = inflater.inflate(customNavId, this, false);
- mNavigationMode = ActionBar.NAVIGATION_MODE_STANDARD;
- setDisplayOptions(mDisplayOptions | ActionBar.DISPLAY_SHOW_CUSTOM);
- }
-
- mContentHeight = a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0);
-
- a.recycle();
-
- mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle);
- mHomeLayout.setOnClickListener(mUpClickListener);
- mHomeLayout.setClickable(true);
- mHomeLayout.setFocusable(true);
- }
-
- /**
- * Attempt to programmatically load the logo from the manifest file of an
- * activity by using an XML pull parser. This should allow us to read the
- * logo attribute regardless of the platform it is being run on.
- *
- * @param activity Activity instance.
- * @return Logo resource ID.
- */
- private static int loadLogoFromManifest(Activity activity) {
- int logo = 0;
- try {
- final String thisPackage = activity.getClass().getName();
- if (DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage);
-
- final String packageName = activity.getApplicationInfo().packageName;
- final AssetManager am = activity.createPackageContext(packageName, 0).getAssets();
- final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");
-
- int eventType = xml.getEventType();
- while (eventType != XmlPullParser.END_DOCUMENT) {
- if (eventType == XmlPullParser.START_TAG) {
- String name = xml.getName();
-
- if ("application".equals(name)) {
- //Check if the has the attribute
- if (DEBUG) Log.d(TAG, "Got ");
-
- for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
- if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));
-
- if ("logo".equals(xml.getAttributeName(i))) {
- logo = xml.getAttributeResourceValue(i, 0);
- break; //out of for loop
- }
- }
- } else if ("activity".equals(name)) {
- //Check if the is us and has the attribute
- if (DEBUG) Log.d(TAG, "Got ");
- Integer activityLogo = null;
- String activityPackage = null;
- boolean isOurActivity = false;
-
- for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
- if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));
-
- //We need both uiOptions and name attributes
- String attrName = xml.getAttributeName(i);
- if ("logo".equals(attrName)) {
- activityLogo = xml.getAttributeResourceValue(i, 0);
- } else if ("name".equals(attrName)) {
- activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i));
- if (!thisPackage.equals(activityPackage)) {
- break; //on to the next
- }
- isOurActivity = true;
- }
-
- //Make sure we have both attributes before processing
- if ((activityLogo != null) && (activityPackage != null)) {
- //Our activity, logo specified, override with our value
- logo = activityLogo.intValue();
- }
- }
- if (isOurActivity) {
- //If we matched our activity but it had no logo don't
- //do any more processing of the manifest
- break;
- }
- }
- }
- eventType = xml.nextToken();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(logo));
- return logo;
- }
-
- /*
- * Must be public so we can dispatch pre-2.2 via ActionBarImpl.
- */
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
-
- mTitleView = null;
- mSubtitleView = null;
- mTitleUpView = null;
- if (mTitleLayout != null && mTitleLayout.getParent() == this) {
- removeView(mTitleLayout);
- }
- mTitleLayout = null;
- if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
- initTitle();
- }
-
- if (mTabScrollView != null && mIncludeTabs) {
- ViewGroup.LayoutParams lp = mTabScrollView.getLayoutParams();
- if (lp != null) {
- lp.width = LayoutParams.WRAP_CONTENT;
- lp.height = LayoutParams.MATCH_PARENT;
- }
- mTabScrollView.setAllowCollapse(true);
- }
- }
-
- /**
- * Set the window callback used to invoke menu items; used for dispatching home button presses.
- * @param cb Window callback to dispatch to
- */
- public void setWindowCallback(Window.Callback cb) {
- mWindowCallback = cb;
- }
-
- @Override
- public void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- //UNUSED removeCallbacks(mTabSelector);
- if (mActionMenuPresenter != null) {
- mActionMenuPresenter.hideOverflowMenu();
- mActionMenuPresenter.hideSubMenus();
- }
- }
-
- @Override
- public boolean shouldDelayChildPressedState() {
- return false;
- }
-
- public void initProgress() {
- mProgressView = new IcsProgressBar(mContext, null, 0, mProgressStyle);
- mProgressView.setId(R.id.abs__progress_horizontal);
- mProgressView.setMax(10000);
- addView(mProgressView);
- }
-
- public void initIndeterminateProgress() {
- mIndeterminateProgressView = new IcsProgressBar(mContext, null, 0, mIndeterminateProgressStyle);
- mIndeterminateProgressView.setId(R.id.abs__progress_circular);
- addView(mIndeterminateProgressView);
- }
-
- @Override
- public void setSplitActionBar(boolean splitActionBar) {
- if (mSplitActionBar != splitActionBar) {
- if (mMenuView != null) {
- final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
- if (oldParent != null) {
- oldParent.removeView(mMenuView);
- }
- if (splitActionBar) {
- if (mSplitView != null) {
- mSplitView.addView(mMenuView);
- }
- } else {
- addView(mMenuView);
- }
- }
- if (mSplitView != null) {
- mSplitView.setVisibility(splitActionBar ? VISIBLE : GONE);
- }
- super.setSplitActionBar(splitActionBar);
- }
- }
-
- public boolean isSplitActionBar() {
- return mSplitActionBar;
- }
-
- public boolean hasEmbeddedTabs() {
- return mIncludeTabs;
- }
-
- public void setEmbeddedTabView(ScrollingTabContainerView tabs) {
- if (mTabScrollView != null) {
- removeView(mTabScrollView);
- }
- mTabScrollView = tabs;
- mIncludeTabs = tabs != null;
- if (mIncludeTabs && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
- addView(mTabScrollView);
- ViewGroup.LayoutParams lp = mTabScrollView.getLayoutParams();
- lp.width = LayoutParams.WRAP_CONTENT;
- lp.height = LayoutParams.MATCH_PARENT;
- tabs.setAllowCollapse(true);
- }
- }
-
- public void setCallback(OnNavigationListener callback) {
- mCallback = callback;
- }
-
- public void setMenu(Menu menu, MenuPresenter.Callback cb) {
- if (menu == mOptionsMenu) return;
-
- if (mOptionsMenu != null) {
- mOptionsMenu.removeMenuPresenter(mActionMenuPresenter);
- mOptionsMenu.removeMenuPresenter(mExpandedMenuPresenter);
- }
-
- MenuBuilder builder = (MenuBuilder) menu;
- mOptionsMenu = builder;
- if (mMenuView != null) {
- final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
- if (oldParent != null) {
- oldParent.removeView(mMenuView);
- }
- }
- if (mActionMenuPresenter == null) {
- mActionMenuPresenter = new ActionMenuPresenter(mContext);
- mActionMenuPresenter.setCallback(cb);
- mActionMenuPresenter.setId(R.id.abs__action_menu_presenter);
- mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
- }
-
- ActionMenuView menuView;
- final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
- LayoutParams.MATCH_PARENT);
- if (!mSplitActionBar) {
- mActionMenuPresenter.setExpandedActionViewsExclusive(
- getResources_getBoolean(getContext(),
- R.bool.abs__action_bar_expanded_action_views_exclusive));
- configPresenters(builder);
- menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
- final ViewGroup oldParent = (ViewGroup) menuView.getParent();
- if (oldParent != null && oldParent != this) {
- oldParent.removeView(menuView);
- }
- addView(menuView, layoutParams);
- } else {
- mActionMenuPresenter.setExpandedActionViewsExclusive(false);
- // Allow full screen width in split mode.
- mActionMenuPresenter.setWidthLimit(
- getContext().getResources().getDisplayMetrics().widthPixels, true);
- // No limit to the item count; use whatever will fit.
- mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
- // Span the whole width
- layoutParams.width = LayoutParams.MATCH_PARENT;
- configPresenters(builder);
- menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
- if (mSplitView != null) {
- final ViewGroup oldParent = (ViewGroup) menuView.getParent();
- if (oldParent != null && oldParent != mSplitView) {
- oldParent.removeView(menuView);
- }
- menuView.setVisibility(getAnimatedVisibility());
- mSplitView.addView(menuView, layoutParams);
- } else {
- // We'll add this later if we missed it this time.
- menuView.setLayoutParams(layoutParams);
- }
- }
- mMenuView = menuView;
- }
-
- private void configPresenters(MenuBuilder builder) {
- if (builder != null) {
- builder.addMenuPresenter(mActionMenuPresenter);
- builder.addMenuPresenter(mExpandedMenuPresenter);
- } else {
- mActionMenuPresenter.initForMenu(mContext, null);
- mExpandedMenuPresenter.initForMenu(mContext, null);
- mActionMenuPresenter.updateMenuView(true);
- mExpandedMenuPresenter.updateMenuView(true);
- }
- }
-
- public boolean hasExpandedActionView() {
- return mExpandedMenuPresenter != null &&
- mExpandedMenuPresenter.mCurrentExpandedItem != null;
- }
-
- public void collapseActionView() {
- final MenuItemImpl item = mExpandedMenuPresenter == null ? null :
- mExpandedMenuPresenter.mCurrentExpandedItem;
- if (item != null) {
- item.collapseActionView();
- }
- }
-
- public void setCustomNavigationView(View view) {
- final boolean showCustom = (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0;
- if (mCustomNavView != null && showCustom) {
- removeView(mCustomNavView);
- }
- mCustomNavView = view;
- if (mCustomNavView != null && showCustom) {
- addView(mCustomNavView);
- }
- }
-
- public CharSequence getTitle() {
- return mTitle;
- }
-
- /**
- * Set the action bar title. This will always replace or override window titles.
- * @param title Title to set
- *
- * @see #setWindowTitle(CharSequence)
- */
- public void setTitle(CharSequence title) {
- mUserTitle = true;
- setTitleImpl(title);
- }
-
- /**
- * Set the window title. A window title will always be replaced or overridden by a user title.
- * @param title Title to set
- *
- * @see #setTitle(CharSequence)
- */
- public void setWindowTitle(CharSequence title) {
- if (!mUserTitle) {
- setTitleImpl(title);
- }
- }
-
- private void setTitleImpl(CharSequence title) {
- mTitle = title;
- if (mTitleView != null) {
- mTitleView.setText(title);
- final boolean visible = mExpandedActionView == null &&
- (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0 &&
- (!TextUtils.isEmpty(mTitle) || !TextUtils.isEmpty(mSubtitle));
- mTitleLayout.setVisibility(visible ? VISIBLE : GONE);
- }
- if (mLogoNavItem != null) {
- mLogoNavItem.setTitle(title);
- }
- }
-
- public CharSequence getSubtitle() {
- return mSubtitle;
- }
-
- public void setSubtitle(CharSequence subtitle) {
- mSubtitle = subtitle;
- if (mSubtitleView != null) {
- mSubtitleView.setText(subtitle);
- mSubtitleView.setVisibility(subtitle != null ? VISIBLE : GONE);
- final boolean visible = mExpandedActionView == null &&
- (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0 &&
- (!TextUtils.isEmpty(mTitle) || !TextUtils.isEmpty(mSubtitle));
- mTitleLayout.setVisibility(visible ? VISIBLE : GONE);
- }
- }
-
- public void setHomeButtonEnabled(boolean enable) {
- mHomeLayout.setEnabled(enable);
- mHomeLayout.setFocusable(enable);
- // Make sure the home button has an accurate content description for accessibility.
- if (!enable) {
- mHomeLayout.setContentDescription(null);
- } else if ((mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
- mHomeLayout.setContentDescription(mContext.getResources().getText(
- R.string.abs__action_bar_up_description));
- } else {
- mHomeLayout.setContentDescription(mContext.getResources().getText(
- R.string.abs__action_bar_home_description));
- }
- }
-
- public void setDisplayOptions(int options) {
- final int flagsChanged = mDisplayOptions == -1 ? -1 : options ^ mDisplayOptions;
- mDisplayOptions = options;
-
- if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) {
- final boolean showHome = (options & ActionBar.DISPLAY_SHOW_HOME) != 0;
- final int vis = showHome && mExpandedActionView == null ? VISIBLE : GONE;
- mHomeLayout.setVisibility(vis);
-
- if ((flagsChanged & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
- final boolean setUp = (options & ActionBar.DISPLAY_HOME_AS_UP) != 0;
- mHomeLayout.setUp(setUp);
-
- // Showing home as up implicitly enables interaction with it.
- // In honeycomb it was always enabled, so make this transition
- // a bit easier for developers in the common case.
- // (It would be silly to show it as up without responding to it.)
- if (setUp) {
- setHomeButtonEnabled(true);
- }
- }
-
- if ((flagsChanged & ActionBar.DISPLAY_USE_LOGO) != 0) {
- final boolean logoVis = mLogo != null && (options & ActionBar.DISPLAY_USE_LOGO) != 0;
- mHomeLayout.setIcon(logoVis ? mLogo : mIcon);
- }
-
- if ((flagsChanged & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
- if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
- initTitle();
- } else {
- removeView(mTitleLayout);
- }
- }
-
- if (mTitleLayout != null && (flagsChanged &
- (ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) {
- final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
- mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
- mTitleLayout.setEnabled(!showHome && homeAsUp);
- }
-
- if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) {
- if ((options & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
- addView(mCustomNavView);
- } else {
- removeView(mCustomNavView);
- }
- }
-
- requestLayout();
- } else {
- invalidate();
- }
-
- // Make sure the home button has an accurate content description for accessibility.
- if (!mHomeLayout.isEnabled()) {
- mHomeLayout.setContentDescription(null);
- } else if ((options & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
- mHomeLayout.setContentDescription(mContext.getResources().getText(
- R.string.abs__action_bar_up_description));
- } else {
- mHomeLayout.setContentDescription(mContext.getResources().getText(
- R.string.abs__action_bar_home_description));
- }
- }
-
- public void setIcon(Drawable icon) {
- mIcon = icon;
- if (icon != null &&
- ((mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) == 0 || mLogo == null)) {
- mHomeLayout.setIcon(icon);
- }
- }
-
- public void setIcon(int resId) {
- setIcon(mContext.getResources().getDrawable(resId));
- }
-
- public void setLogo(Drawable logo) {
- mLogo = logo;
- if (logo != null && (mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) != 0) {
- mHomeLayout.setIcon(logo);
- }
- }
-
- public void setLogo(int resId) {
- setLogo(mContext.getResources().getDrawable(resId));
- }
-
- public void setNavigationMode(int mode) {
- final int oldMode = mNavigationMode;
- if (mode != oldMode) {
- switch (oldMode) {
- case ActionBar.NAVIGATION_MODE_LIST:
- if (mListNavLayout != null) {
- removeView(mListNavLayout);
- }
- break;
- case ActionBar.NAVIGATION_MODE_TABS:
- if (mTabScrollView != null && mIncludeTabs) {
- removeView(mTabScrollView);
- }
- }
-
- switch (mode) {
- case ActionBar.NAVIGATION_MODE_LIST:
- if (mSpinner == null) {
- mSpinner = new IcsSpinner(mContext, null,
- R.attr.actionDropDownStyle);
- mListNavLayout = (IcsLinearLayout) LayoutInflater.from(mContext)
- .inflate(R.layout.abs__action_bar_tab_bar_view, null);
- LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
- LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
- params.gravity = Gravity.CENTER;
- mListNavLayout.addView(mSpinner, params);
- }
- if (mSpinner.getAdapter() != mSpinnerAdapter) {
- mSpinner.setAdapter(mSpinnerAdapter);
- }
- mSpinner.setOnItemSelectedListener(mNavItemSelectedListener);
- addView(mListNavLayout);
- break;
- case ActionBar.NAVIGATION_MODE_TABS:
- if (mTabScrollView != null && mIncludeTabs) {
- addView(mTabScrollView);
- }
- break;
- }
- mNavigationMode = mode;
- requestLayout();
- }
- }
-
- public void setDropdownAdapter(SpinnerAdapter adapter) {
- mSpinnerAdapter = adapter;
- if (mSpinner != null) {
- mSpinner.setAdapter(adapter);
- }
- }
-
- public SpinnerAdapter getDropdownAdapter() {
- return mSpinnerAdapter;
- }
-
- public void setDropdownSelectedPosition(int position) {
- mSpinner.setSelection(position);
- }
-
- public int getDropdownSelectedPosition() {
- return mSpinner.getSelectedItemPosition();
- }
-
- public View getCustomNavigationView() {
- return mCustomNavView;
- }
-
- public int getNavigationMode() {
- return mNavigationMode;
- }
-
- public int getDisplayOptions() {
- return mDisplayOptions;
- }
-
- @Override
- protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
- // Used by custom nav views if they don't supply layout params. Everything else
- // added to an ActionBarView should have them already.
- return new ActionBar.LayoutParams(DEFAULT_CUSTOM_GRAVITY);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
-
- addView(mHomeLayout);
-
- if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
- final ViewParent parent = mCustomNavView.getParent();
- if (parent != this) {
- if (parent instanceof ViewGroup) {
- ((ViewGroup) parent).removeView(mCustomNavView);
- }
- addView(mCustomNavView);
- }
- }
- }
-
- private void initTitle() {
- if (mTitleLayout == null) {
- LayoutInflater inflater = LayoutInflater.from(getContext());
- mTitleLayout = (LinearLayout) inflater.inflate(R.layout.abs__action_bar_title_item,
- this, false);
- mTitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_title);
- mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_subtitle);
- mTitleUpView = mTitleLayout.findViewById(R.id.abs__up);
-
- mTitleLayout.setOnClickListener(mUpClickListener);
-
- if (mTitleStyleRes != 0) {
- mTitleView.setTextAppearance(mContext, mTitleStyleRes);
- }
- if (mTitle != null) {
- mTitleView.setText(mTitle);
- }
-
- if (mSubtitleStyleRes != 0) {
- mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes);
- }
- if (mSubtitle != null) {
- mSubtitleView.setText(mSubtitle);
- mSubtitleView.setVisibility(VISIBLE);
- }
-
- final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
- final boolean showHome = (mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0;
- mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
- mTitleLayout.setEnabled(homeAsUp && !showHome);
- }
-
- addView(mTitleLayout);
- if (mExpandedActionView != null ||
- (TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mSubtitle))) {
- // Don't show while in expanded mode or with empty text
- mTitleLayout.setVisibility(GONE);
- }
- }
-
- public void setContextView(ActionBarContextView view) {
- mContextView = view;
- }
-
- public void setCollapsable(boolean collapsable) {
- mIsCollapsable = collapsable;
- }
-
- public boolean isCollapsed() {
- return mIsCollapsed;
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- final int childCount = getChildCount();
- if (mIsCollapsable) {
- int visibleChildren = 0;
- for (int i = 0; i < childCount; i++) {
- final View child = getChildAt(i);
- if (child.getVisibility() != GONE &&
- !(child == mMenuView && mMenuView.getChildCount() == 0)) {
- visibleChildren++;
- }
- }
-
- if (visibleChildren == 0) {
- // No size for an empty action bar when collapsable.
- setMeasuredDimension(0, 0);
- mIsCollapsed = true;
- return;
- }
- }
- mIsCollapsed = false;
-
- int widthMode = MeasureSpec.getMode(widthMeasureSpec);
- if (widthMode != MeasureSpec.EXACTLY) {
- throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
- "with android:layout_width=\"match_parent\" (or fill_parent)");
- }
-
- int heightMode = MeasureSpec.getMode(heightMeasureSpec);
- if (heightMode != MeasureSpec.AT_MOST) {
- throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
- "with android:layout_height=\"wrap_content\"");
- }
-
- int contentWidth = MeasureSpec.getSize(widthMeasureSpec);
-
- int maxHeight = mContentHeight > 0 ?
- mContentHeight : MeasureSpec.getSize(heightMeasureSpec);
-
- final int verticalPadding = getPaddingTop() + getPaddingBottom();
- final int paddingLeft = getPaddingLeft();
- final int paddingRight = getPaddingRight();
- final int height = maxHeight - verticalPadding;
- final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
-
- int availableWidth = contentWidth - paddingLeft - paddingRight;
- int leftOfCenter = availableWidth / 2;
- int rightOfCenter = leftOfCenter;
-
- HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout;
-
- if (homeLayout.getVisibility() != GONE) {
- final ViewGroup.LayoutParams lp = homeLayout.getLayoutParams();
- int homeWidthSpec;
- if (lp.width < 0) {
- homeWidthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
- } else {
- homeWidthSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY);
- }
- homeLayout.measure(homeWidthSpec,
- MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
- final int homeWidth = homeLayout.getMeasuredWidth() + homeLayout.getLeftOffset();
- availableWidth = Math.max(0, availableWidth - homeWidth);
- leftOfCenter = Math.max(0, availableWidth - homeWidth);
- }
-
- if (mMenuView != null && mMenuView.getParent() == this) {
- availableWidth = measureChildView(mMenuView, availableWidth,
- childSpecHeight, 0);
- rightOfCenter = Math.max(0, rightOfCenter - mMenuView.getMeasuredWidth());
- }
-
- if (mIndeterminateProgressView != null &&
- mIndeterminateProgressView.getVisibility() != GONE) {
- availableWidth = measureChildView(mIndeterminateProgressView, availableWidth,
- childSpecHeight, 0);
- rightOfCenter = Math.max(0,
- rightOfCenter - mIndeterminateProgressView.getMeasuredWidth());
- }
-
- final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE &&
- (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0;
-
- if (mExpandedActionView == null) {
- switch (mNavigationMode) {
- case ActionBar.NAVIGATION_MODE_LIST:
- if (mListNavLayout != null) {
- final int itemPaddingSize = showTitle ? mItemPadding * 2 : mItemPadding;
- availableWidth = Math.max(0, availableWidth - itemPaddingSize);
- leftOfCenter = Math.max(0, leftOfCenter - itemPaddingSize);
- mListNavLayout.measure(
- MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST),
- MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
- final int listNavWidth = mListNavLayout.getMeasuredWidth();
- availableWidth = Math.max(0, availableWidth - listNavWidth);
- leftOfCenter = Math.max(0, leftOfCenter - listNavWidth);
- }
- break;
- case ActionBar.NAVIGATION_MODE_TABS:
- if (mTabScrollView != null) {
- final int itemPaddingSize = showTitle ? mItemPadding * 2 : mItemPadding;
- availableWidth = Math.max(0, availableWidth - itemPaddingSize);
- leftOfCenter = Math.max(0, leftOfCenter - itemPaddingSize);
- mTabScrollView.measure(
- MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST),
- MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
- final int tabWidth = mTabScrollView.getMeasuredWidth();
- availableWidth = Math.max(0, availableWidth - tabWidth);
- leftOfCenter = Math.max(0, leftOfCenter - tabWidth);
- }
- break;
- }
- }
-
- View customView = null;
- if (mExpandedActionView != null) {
- customView = mExpandedActionView;
- } else if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 &&
- mCustomNavView != null) {
- customView = mCustomNavView;
- }
-
- if (customView != null) {
- final ViewGroup.LayoutParams lp = generateLayoutParams(customView.getLayoutParams());
- final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ?
- (ActionBar.LayoutParams) lp : null;
-
- int horizontalMargin = 0;
- int verticalMargin = 0;
- if (ablp != null) {
- horizontalMargin = ablp.leftMargin + ablp.rightMargin;
- verticalMargin = ablp.topMargin + ablp.bottomMargin;
- }
-
- // If the action bar is wrapping to its content height, don't allow a custom
- // view to MATCH_PARENT.
- int customNavHeightMode;
- if (mContentHeight <= 0) {
- customNavHeightMode = MeasureSpec.AT_MOST;
- } else {
- customNavHeightMode = lp.height != LayoutParams.WRAP_CONTENT ?
- MeasureSpec.EXACTLY : MeasureSpec.AT_MOST;
- }
- final int customNavHeight = Math.max(0,
- (lp.height >= 0 ? Math.min(lp.height, height) : height) - verticalMargin);
-
- final int customNavWidthMode = lp.width != LayoutParams.WRAP_CONTENT ?
- MeasureSpec.EXACTLY : MeasureSpec.AT_MOST;
- int customNavWidth = Math.max(0,
- (lp.width >= 0 ? Math.min(lp.width, availableWidth) : availableWidth)
- - horizontalMargin);
- final int hgrav = (ablp != null ? ablp.gravity : DEFAULT_CUSTOM_GRAVITY) &
- Gravity.HORIZONTAL_GRAVITY_MASK;
-
- // Centering a custom view is treated specially; we try to center within the whole
- // action bar rather than in the available space.
- if (hgrav == Gravity.CENTER_HORIZONTAL && lp.width == LayoutParams.MATCH_PARENT) {
- customNavWidth = Math.min(leftOfCenter, rightOfCenter) * 2;
- }
-
- customView.measure(
- MeasureSpec.makeMeasureSpec(customNavWidth, customNavWidthMode),
- MeasureSpec.makeMeasureSpec(customNavHeight, customNavHeightMode));
- availableWidth -= horizontalMargin + customView.getMeasuredWidth();
- }
-
- if (mExpandedActionView == null && showTitle) {
- availableWidth = measureChildView(mTitleLayout, availableWidth,
- MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.EXACTLY), 0);
- leftOfCenter = Math.max(0, leftOfCenter - mTitleLayout.getMeasuredWidth());
- }
-
- if (mContentHeight <= 0) {
- int measuredHeight = 0;
- for (int i = 0; i < childCount; i++) {
- View v = getChildAt(i);
- int paddedViewHeight = v.getMeasuredHeight() + verticalPadding;
- if (paddedViewHeight > measuredHeight) {
- measuredHeight = paddedViewHeight;
- }
- }
- setMeasuredDimension(contentWidth, measuredHeight);
- } else {
- setMeasuredDimension(contentWidth, maxHeight);
- }
-
- if (mContextView != null) {
- mContextView.setContentHeight(getMeasuredHeight());
- }
-
- if (mProgressView != null && mProgressView.getVisibility() != GONE) {
- mProgressView.measure(MeasureSpec.makeMeasureSpec(
- contentWidth - mProgressBarPadding * 2, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST));
- }
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- int x = getPaddingLeft();
- final int y = getPaddingTop();
- final int contentHeight = b - t - getPaddingTop() - getPaddingBottom();
-
- if (contentHeight <= 0) {
- // Nothing to do if we can't see anything.
- return;
- }
-
- HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout;
- if (homeLayout.getVisibility() != GONE) {
- final int leftOffset = homeLayout.getLeftOffset();
- x += positionChild(homeLayout, x + leftOffset, y, contentHeight) + leftOffset;
- }
-
- if (mExpandedActionView == null) {
- final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE &&
- (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0;
- if (showTitle) {
- x += positionChild(mTitleLayout, x, y, contentHeight);
- }
-
- switch (mNavigationMode) {
- case ActionBar.NAVIGATION_MODE_STANDARD:
- break;
- case ActionBar.NAVIGATION_MODE_LIST:
- if (mListNavLayout != null) {
- if (showTitle) x += mItemPadding;
- x += positionChild(mListNavLayout, x, y, contentHeight) + mItemPadding;
- }
- break;
- case ActionBar.NAVIGATION_MODE_TABS:
- if (mTabScrollView != null) {
- if (showTitle) x += mItemPadding;
- x += positionChild(mTabScrollView, x, y, contentHeight) + mItemPadding;
- }
- break;
- }
- }
-
- int menuLeft = r - l - getPaddingRight();
- if (mMenuView != null && mMenuView.getParent() == this) {
- positionChildInverse(mMenuView, menuLeft, y, contentHeight);
- menuLeft -= mMenuView.getMeasuredWidth();
- }
-
- if (mIndeterminateProgressView != null &&
- mIndeterminateProgressView.getVisibility() != GONE) {
- positionChildInverse(mIndeterminateProgressView, menuLeft, y, contentHeight);
- menuLeft -= mIndeterminateProgressView.getMeasuredWidth();
- }
-
- View customView = null;
- if (mExpandedActionView != null) {
- customView = mExpandedActionView;
- } else if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 &&
- mCustomNavView != null) {
- customView = mCustomNavView;
- }
- if (customView != null) {
- ViewGroup.LayoutParams lp = customView.getLayoutParams();
- final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ?
- (ActionBar.LayoutParams) lp : null;
-
- final int gravity = ablp != null ? ablp.gravity : DEFAULT_CUSTOM_GRAVITY;
- final int navWidth = customView.getMeasuredWidth();
-
- int topMargin = 0;
- int bottomMargin = 0;
- if (ablp != null) {
- x += ablp.leftMargin;
- menuLeft -= ablp.rightMargin;
- topMargin = ablp.topMargin;
- bottomMargin = ablp.bottomMargin;
- }
-
- int hgravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
- // See if we actually have room to truly center; if not push against left or right.
- if (hgravity == Gravity.CENTER_HORIZONTAL) {
- final int centeredLeft = ((getRight() - getLeft()) - navWidth) / 2;
- if (centeredLeft < x) {
- hgravity = Gravity.LEFT;
- } else if (centeredLeft + navWidth > menuLeft) {
- hgravity = Gravity.RIGHT;
- }
- } else if (gravity == -1) {
- hgravity = Gravity.LEFT;
- }
-
- int xpos = 0;
- switch (hgravity) {
- case Gravity.CENTER_HORIZONTAL:
- xpos = ((getRight() - getLeft()) - navWidth) / 2;
- break;
- case Gravity.LEFT:
- xpos = x;
- break;
- case Gravity.RIGHT:
- xpos = menuLeft - navWidth;
- break;
- }
-
- int vgravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
-
- if (gravity == -1) {
- vgravity = Gravity.CENTER_VERTICAL;
- }
-
- int ypos = 0;
- switch (vgravity) {
- case Gravity.CENTER_VERTICAL:
- final int paddedTop = getPaddingTop();
- final int paddedBottom = getBottom() - getTop() - getPaddingBottom();
- ypos = ((paddedBottom - paddedTop) - customView.getMeasuredHeight()) / 2;
- break;
- case Gravity.TOP:
- ypos = getPaddingTop() + topMargin;
- break;
- case Gravity.BOTTOM:
- ypos = getHeight() - getPaddingBottom() - customView.getMeasuredHeight()
- - bottomMargin;
- break;
- }
- final int customWidth = customView.getMeasuredWidth();
- customView.layout(xpos, ypos, xpos + customWidth,
- ypos + customView.getMeasuredHeight());
- x += customWidth;
- }
-
- if (mProgressView != null) {
- mProgressView.bringToFront();
- final int halfProgressHeight = mProgressView.getMeasuredHeight() / 2;
- mProgressView.layout(mProgressBarPadding, -halfProgressHeight,
- mProgressBarPadding + mProgressView.getMeasuredWidth(), halfProgressHeight);
- }
- }
-
- @Override
- public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) {
- return new ActionBar.LayoutParams(getContext(), attrs);
- }
-
- @Override
- public ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) {
- if (lp == null) {
- lp = generateDefaultLayoutParams();
- }
- return lp;
- }
-
- @Override
- public Parcelable onSaveInstanceState() {
- Parcelable superState = super.onSaveInstanceState();
- SavedState state = new SavedState(superState);
-
- if (mExpandedMenuPresenter != null && mExpandedMenuPresenter.mCurrentExpandedItem != null) {
- state.expandedMenuItemId = mExpandedMenuPresenter.mCurrentExpandedItem.getItemId();
- }
-
- state.isOverflowOpen = isOverflowMenuShowing();
-
- return state;
- }
-
- @Override
- public void onRestoreInstanceState(Parcelable p) {
- SavedState state = (SavedState) p;
-
- super.onRestoreInstanceState(state.getSuperState());
-
- if (state.expandedMenuItemId != 0 &&
- mExpandedMenuPresenter != null && mOptionsMenu != null) {
- final MenuItem item = mOptionsMenu.findItem(state.expandedMenuItemId);
- if (item != null) {
- item.expandActionView();
- }
- }
-
- if (state.isOverflowOpen) {
- postShowOverflowMenu();
- }
- }
-
- static class SavedState extends BaseSavedState {
- int expandedMenuItemId;
- boolean isOverflowOpen;
-
- SavedState(Parcelable superState) {
- super(superState);
- }
-
- private SavedState(Parcel in) {
- super(in);
- expandedMenuItemId = in.readInt();
- isOverflowOpen = in.readInt() != 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- super.writeToParcel(out, flags);
- out.writeInt(expandedMenuItemId);
- out.writeInt(isOverflowOpen ? 1 : 0);
- }
-
- public static final Parcelable.Creator CREATOR =
- new Parcelable.Creator() {
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
-
- public static class HomeView extends FrameLayout {
- private View mUpView;
- private ImageView mIconView;
- private int mUpWidth;
-
- public HomeView(Context context) {
- this(context, null);
- }
-
- public HomeView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public void setUp(boolean isUp) {
- mUpView.setVisibility(isUp ? VISIBLE : GONE);
- }
-
- public void setIcon(Drawable icon) {
- mIconView.setImageDrawable(icon);
- }
-
- @Override
- public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
- onPopulateAccessibilityEvent(event);
- return true;
- }
-
- @Override
- public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- super.onPopulateAccessibilityEvent(event);
- }
- final CharSequence cdesc = getContentDescription();
- if (!TextUtils.isEmpty(cdesc)) {
- event.getText().add(cdesc);
- }
- }
-
- @Override
- public boolean dispatchHoverEvent(MotionEvent event) {
- // Don't allow children to hover; we want this to be treated as a single component.
- return onHoverEvent(event);
- }
-
- @Override
- protected void onFinishInflate() {
- mUpView = findViewById(R.id.abs__up);
- mIconView = (ImageView) findViewById(R.id.abs__home);
- }
-
- public int getLeftOffset() {
- return mUpView.getVisibility() == GONE ? mUpWidth : 0;
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- measureChildWithMargins(mUpView, widthMeasureSpec, 0, heightMeasureSpec, 0);
- final LayoutParams upLp = (LayoutParams) mUpView.getLayoutParams();
- mUpWidth = upLp.leftMargin + mUpView.getMeasuredWidth() + upLp.rightMargin;
- int width = mUpView.getVisibility() == GONE ? 0 : mUpWidth;
- int height = upLp.topMargin + mUpView.getMeasuredHeight() + upLp.bottomMargin;
- measureChildWithMargins(mIconView, widthMeasureSpec, width, heightMeasureSpec, 0);
- final LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams();
- width += iconLp.leftMargin + mIconView.getMeasuredWidth() + iconLp.rightMargin;
- height = Math.max(height,
- iconLp.topMargin + mIconView.getMeasuredHeight() + iconLp.bottomMargin);
-
- final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
- final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
- final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
- final int heightSize = MeasureSpec.getSize(heightMeasureSpec);
-
- switch (widthMode) {
- case MeasureSpec.AT_MOST:
- width = Math.min(width, widthSize);
- break;
- case MeasureSpec.EXACTLY:
- width = widthSize;
- break;
- case MeasureSpec.UNSPECIFIED:
- default:
- break;
- }
- switch (heightMode) {
- case MeasureSpec.AT_MOST:
- height = Math.min(height, heightSize);
- break;
- case MeasureSpec.EXACTLY:
- height = heightSize;
- break;
- case MeasureSpec.UNSPECIFIED:
- default:
- break;
- }
- setMeasuredDimension(width, height);
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- final int vCenter = (b - t) / 2;
- //UNUSED int width = r - l;
- int upOffset = 0;
- if (mUpView.getVisibility() != GONE) {
- final LayoutParams upLp = (LayoutParams) mUpView.getLayoutParams();
- final int upHeight = mUpView.getMeasuredHeight();
- final int upWidth = mUpView.getMeasuredWidth();
- final int upTop = vCenter - upHeight / 2;
- mUpView.layout(0, upTop, upWidth, upTop + upHeight);
- upOffset = upLp.leftMargin + upWidth + upLp.rightMargin;
- //UNUSED width -= upOffset;
- l += upOffset;
- }
- final LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams();
- final int iconHeight = mIconView.getMeasuredHeight();
- final int iconWidth = mIconView.getMeasuredWidth();
- final int hCenter = (r - l) / 2;
- final int iconLeft = upOffset + Math.max(iconLp.leftMargin, hCenter - iconWidth / 2);
- final int iconTop = Math.max(iconLp.topMargin, vCenter - iconHeight / 2);
- mIconView.layout(iconLeft, iconTop, iconLeft + iconWidth, iconTop + iconHeight);
- }
- }
-
- private class ExpandedActionViewMenuPresenter implements MenuPresenter {
- MenuBuilder mMenu;
- MenuItemImpl mCurrentExpandedItem;
-
- @Override
- public void initForMenu(Context context, MenuBuilder menu) {
- // Clear the expanded action view when menus change.
- if (mMenu != null && mCurrentExpandedItem != null) {
- mMenu.collapseItemActionView(mCurrentExpandedItem);
- }
- mMenu = menu;
- }
-
- @Override
- public MenuView getMenuView(ViewGroup root) {
- return null;
- }
-
- @Override
- public void updateMenuView(boolean cleared) {
- // Make sure the expanded item we have is still there.
- if (mCurrentExpandedItem != null) {
- boolean found = false;
-
- if (mMenu != null) {
- final int count = mMenu.size();
- for (int i = 0; i < count; i++) {
- final MenuItem item = mMenu.getItem(i);
- if (item == mCurrentExpandedItem) {
- found = true;
- break;
- }
- }
- }
-
- if (!found) {
- // The item we had expanded disappeared. Collapse.
- collapseItemActionView(mMenu, mCurrentExpandedItem);
- }
- }
- }
-
- @Override
- public void setCallback(Callback cb) {
- }
-
- @Override
- public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
- return false;
- }
-
- @Override
- public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
- }
-
- @Override
- public boolean flagActionItems() {
- return false;
- }
-
- @Override
- public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) {
- mExpandedActionView = item.getActionView();
- mExpandedHomeLayout.setIcon(mIcon.getConstantState().newDrawable(/* TODO getResources() */));
- mCurrentExpandedItem = item;
- if (mExpandedActionView.getParent() != ActionBarView.this) {
- addView(mExpandedActionView);
- }
- if (mExpandedHomeLayout.getParent() != ActionBarView.this) {
- addView(mExpandedHomeLayout);
- }
- mHomeLayout.setVisibility(GONE);
- if (mTitleLayout != null) mTitleLayout.setVisibility(GONE);
- if (mTabScrollView != null) mTabScrollView.setVisibility(GONE);
- if (mSpinner != null) mSpinner.setVisibility(GONE);
- if (mCustomNavView != null) mCustomNavView.setVisibility(GONE);
- requestLayout();
- item.setActionViewExpanded(true);
-
- if (mExpandedActionView instanceof CollapsibleActionView) {
- ((CollapsibleActionView) mExpandedActionView).onActionViewExpanded();
- }
-
- return true;
- }
-
- @Override
- public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) {
- // Do this before detaching the actionview from the hierarchy, in case
- // it needs to dismiss the soft keyboard, etc.
- if (mExpandedActionView instanceof CollapsibleActionView) {
- ((CollapsibleActionView) mExpandedActionView).onActionViewCollapsed();
- }
-
- removeView(mExpandedActionView);
- removeView(mExpandedHomeLayout);
- mExpandedActionView = null;
- if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) {
- mHomeLayout.setVisibility(VISIBLE);
- }
- if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
- if (mTitleLayout == null) {
- initTitle();
- } else {
- mTitleLayout.setVisibility(VISIBLE);
- }
- }
- if (mTabScrollView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
- mTabScrollView.setVisibility(VISIBLE);
- }
- if (mSpinner != null && mNavigationMode == ActionBar.NAVIGATION_MODE_LIST) {
- mSpinner.setVisibility(VISIBLE);
- }
- if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
- mCustomNavView.setVisibility(VISIBLE);
- }
- mExpandedHomeLayout.setIcon(null);
- mCurrentExpandedItem = null;
- requestLayout();
- item.setActionViewExpanded(false);
-
- return true;
- }
-
- @Override
- public int getId() {
- return 0;
- }
-
- @Override
- public Parcelable onSaveInstanceState() {
- return null;
- }
-
- @Override
- public void onRestoreInstanceState(Parcelable state) {
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java
deleted file mode 100644
index fa3698f3b4..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.actionbarsherlock.internal.widget;
-
-import java.util.Locale;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.os.Build;
-import android.util.AttributeSet;
-import android.widget.Button;
-
-public class CapitalizingButton extends Button {
- private static final boolean SANS_ICE_CREAM = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH;
- private static final boolean IS_GINGERBREAD = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD;
-
- private static final int[] R_styleable_Button = new int[] {
- android.R.attr.textAllCaps
- };
- private static final int R_styleable_Button_textAllCaps = 0;
-
- private boolean mAllCaps;
-
- public CapitalizingButton(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- TypedArray a = context.obtainStyledAttributes(attrs, R_styleable_Button);
- mAllCaps = a.getBoolean(R_styleable_Button_textAllCaps, true);
- a.recycle();
- }
-
- public void setTextCompat(CharSequence text) {
- if (SANS_ICE_CREAM && mAllCaps && text != null) {
- if (IS_GINGERBREAD) {
- setText(text.toString().toUpperCase(Locale.ROOT));
- } else {
- setText(text.toString().toUpperCase());
- }
- } else {
- setText(text);
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java
deleted file mode 100644
index 673ec554f4..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.actionbarsherlock.internal.widget;
-
-import java.util.Locale;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.os.Build;
-import android.util.AttributeSet;
-import android.widget.TextView;
-
-public class CapitalizingTextView extends TextView {
- private static final boolean SANS_ICE_CREAM = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH;
- private static final boolean IS_GINGERBREAD = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD;
-
- private static final int[] R_styleable_TextView = new int[] {
- android.R.attr.textAllCaps
- };
- private static final int R_styleable_TextView_textAllCaps = 0;
-
- private boolean mAllCaps;
-
- public CapitalizingTextView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public CapitalizingTextView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
-
- TypedArray a = context.obtainStyledAttributes(attrs, R_styleable_TextView, defStyle, 0);
- mAllCaps = a.getBoolean(R_styleable_TextView_textAllCaps, true);
- a.recycle();
- }
-
- public void setTextCompat(CharSequence text) {
- if (SANS_ICE_CREAM && mAllCaps && text != null) {
- if (IS_GINGERBREAD) {
- setText(text.toString().toUpperCase(Locale.ROOT));
- } else {
- setText(text.toString().toUpperCase());
- }
- } else {
- setText(text);
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java
deleted file mode 100644
index ad1b4f0a85..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.actionbarsherlock.internal.widget;
-
-import static android.view.View.MeasureSpec.EXACTLY;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-import android.util.TypedValue;
-import android.widget.LinearLayout;
-import com.actionbarsherlock.R;
-
-public class FakeDialogPhoneWindow extends LinearLayout {
- final TypedValue mMinWidthMajor = new TypedValue();
- final TypedValue mMinWidthMinor = new TypedValue();
-
- public FakeDialogPhoneWindow(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockTheme);
-
- a.getValue(R.styleable.SherlockTheme_windowMinWidthMajor, mMinWidthMajor);
- a.getValue(R.styleable.SherlockTheme_windowMinWidthMinor, mMinWidthMinor);
-
- a.recycle();
- }
-
- /* Stolen from PhoneWindow */
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
- final boolean isPortrait = metrics.widthPixels < metrics.heightPixels;
-
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-
- int width = getMeasuredWidth();
- boolean measure = false;
-
- widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, EXACTLY);
-
- final TypedValue tv = isPortrait ? mMinWidthMinor : mMinWidthMajor;
-
- if (tv.type != TypedValue.TYPE_NULL) {
- final int min;
- if (tv.type == TypedValue.TYPE_DIMENSION) {
- min = (int)tv.getDimension(metrics);
- } else if (tv.type == TypedValue.TYPE_FRACTION) {
- min = (int)tv.getFraction(metrics.widthPixels, metrics.widthPixels);
- } else {
- min = 0;
- }
-
- if (width < min) {
- widthMeasureSpec = MeasureSpec.makeMeasureSpec(min, EXACTLY);
- measure = true;
- }
- }
-
- // TODO: Support height?
-
- if (measure) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java
deleted file mode 100644
index ce0cb3bcaa..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java
+++ /dev/null
@@ -1,479 +0,0 @@
-/*
- * Copyright (C) 2006 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.actionbarsherlock.internal.widget;
-
-import android.content.Context;
-import android.database.DataSetObserver;
-import android.graphics.Rect;
-import android.os.Build;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.util.AttributeSet;
-import android.util.SparseArray;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.SpinnerAdapter;
-
-/**
- * An abstract base class for spinner widgets. SDK users will probably not
- * need to use this class.
- *
- * @attr ref android.R.styleable#AbsSpinner_entries
- */
-public abstract class IcsAbsSpinner extends IcsAdapterView {
- private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
-
- SpinnerAdapter mAdapter;
-
- int mHeightMeasureSpec;
- int mWidthMeasureSpec;
- boolean mBlockLayoutRequests;
-
- int mSelectionLeftPadding = 0;
- int mSelectionTopPadding = 0;
- int mSelectionRightPadding = 0;
- int mSelectionBottomPadding = 0;
- final Rect mSpinnerPadding = new Rect();
-
- final RecycleBin mRecycler = new RecycleBin();
- private DataSetObserver mDataSetObserver;
-
- /** Temporary frame to hold a child View's frame rectangle */
- private Rect mTouchFrame;
-
- public IcsAbsSpinner(Context context) {
- super(context);
- initAbsSpinner();
- }
-
- public IcsAbsSpinner(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public IcsAbsSpinner(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- initAbsSpinner();
-
- /*
- TypedArray a = context.obtainStyledAttributes(attrs,
- com.android.internal.R.styleable.AbsSpinner, defStyle, 0);
-
- CharSequence[] entries = a.getTextArray(R.styleable.AbsSpinner_entries);
- if (entries != null) {
- ArrayAdapter adapter =
- new ArrayAdapter(context,
- R.layout.simple_spinner_item, entries);
- adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
- setAdapter(adapter);
- }
-
- a.recycle();
- */
- }
-
- /**
- * Common code for different constructor flavors
- */
- private void initAbsSpinner() {
- setFocusable(true);
- setWillNotDraw(false);
- }
-
- /**
- * The Adapter is used to provide the data which backs this Spinner.
- * It also provides methods to transform spinner items based on their position
- * relative to the selected item.
- * @param adapter The SpinnerAdapter to use for this Spinner
- */
- @Override
- public void setAdapter(SpinnerAdapter adapter) {
- if (null != mAdapter) {
- mAdapter.unregisterDataSetObserver(mDataSetObserver);
- resetList();
- }
-
- mAdapter = adapter;
-
- mOldSelectedPosition = INVALID_POSITION;
- mOldSelectedRowId = INVALID_ROW_ID;
-
- if (mAdapter != null) {
- mOldItemCount = mItemCount;
- mItemCount = mAdapter.getCount();
- checkFocus();
-
- mDataSetObserver = new AdapterDataSetObserver();
- mAdapter.registerDataSetObserver(mDataSetObserver);
-
- int position = mItemCount > 0 ? 0 : INVALID_POSITION;
-
- setSelectedPositionInt(position);
- setNextSelectedPositionInt(position);
-
- if (mItemCount == 0) {
- // Nothing selected
- checkSelectionChanged();
- }
-
- } else {
- checkFocus();
- resetList();
- // Nothing selected
- checkSelectionChanged();
- }
-
- requestLayout();
- }
-
- /**
- * Clear out all children from the list
- */
- void resetList() {
- mDataChanged = false;
- mNeedSync = false;
-
- removeAllViewsInLayout();
- mOldSelectedPosition = INVALID_POSITION;
- mOldSelectedRowId = INVALID_ROW_ID;
-
- setSelectedPositionInt(INVALID_POSITION);
- setNextSelectedPositionInt(INVALID_POSITION);
- invalidate();
- }
-
- /**
- * @see android.view.View#measure(int, int)
- *
- * Figure out the dimensions of this Spinner. The width comes from
- * the widthMeasureSpec as Spinnners can't have their width set to
- * UNSPECIFIED. The height is based on the height of the selected item
- * plus padding.
- */
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int widthMode = MeasureSpec.getMode(widthMeasureSpec);
- int widthSize;
- int heightSize;
-
- final int mPaddingLeft = getPaddingLeft();
- final int mPaddingTop = getPaddingTop();
- final int mPaddingRight = getPaddingRight();
- final int mPaddingBottom = getPaddingBottom();
-
- mSpinnerPadding.left = mPaddingLeft > mSelectionLeftPadding ? mPaddingLeft
- : mSelectionLeftPadding;
- mSpinnerPadding.top = mPaddingTop > mSelectionTopPadding ? mPaddingTop
- : mSelectionTopPadding;
- mSpinnerPadding.right = mPaddingRight > mSelectionRightPadding ? mPaddingRight
- : mSelectionRightPadding;
- mSpinnerPadding.bottom = mPaddingBottom > mSelectionBottomPadding ? mPaddingBottom
- : mSelectionBottomPadding;
-
- if (mDataChanged) {
- handleDataChanged();
- }
-
- int preferredHeight = 0;
- int preferredWidth = 0;
- boolean needsMeasuring = true;
-
- int selectedPosition = getSelectedItemPosition();
- if (selectedPosition >= 0 && mAdapter != null && selectedPosition < mAdapter.getCount()) {
- // Try looking in the recycler. (Maybe we were measured once already)
- View view = mRecycler.get(selectedPosition);
- if (view == null) {
- // Make a new one
- view = mAdapter.getView(selectedPosition, null, this);
- }
-
- if (view != null) {
- // Put in recycler for re-measuring and/or layout
- mRecycler.put(selectedPosition, view);
- }
-
- if (view != null) {
- if (view.getLayoutParams() == null) {
- mBlockLayoutRequests = true;
- view.setLayoutParams(generateDefaultLayoutParams());
- mBlockLayoutRequests = false;
- }
- measureChild(view, widthMeasureSpec, heightMeasureSpec);
-
- preferredHeight = getChildHeight(view) + mSpinnerPadding.top + mSpinnerPadding.bottom;
- preferredWidth = getChildWidth(view) + mSpinnerPadding.left + mSpinnerPadding.right;
-
- needsMeasuring = false;
- }
- }
-
- if (needsMeasuring) {
- // No views -- just use padding
- preferredHeight = mSpinnerPadding.top + mSpinnerPadding.bottom;
- if (widthMode == MeasureSpec.UNSPECIFIED) {
- preferredWidth = mSpinnerPadding.left + mSpinnerPadding.right;
- }
- }
-
- preferredHeight = Math.max(preferredHeight, getSuggestedMinimumHeight());
- preferredWidth = Math.max(preferredWidth, getSuggestedMinimumWidth());
-
- if (IS_HONEYCOMB) {
- heightSize = resolveSizeAndState(preferredHeight, heightMeasureSpec, 0);
- widthSize = resolveSizeAndState(preferredWidth, widthMeasureSpec, 0);
- } else {
- heightSize = resolveSize(preferredHeight, heightMeasureSpec);
- widthSize = resolveSize(preferredWidth, widthMeasureSpec);
- }
-
- setMeasuredDimension(widthSize, heightSize);
- mHeightMeasureSpec = heightMeasureSpec;
- mWidthMeasureSpec = widthMeasureSpec;
- }
-
- int getChildHeight(View child) {
- return child.getMeasuredHeight();
- }
-
- int getChildWidth(View child) {
- return child.getMeasuredWidth();
- }
-
- @Override
- protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
- return new ViewGroup.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.WRAP_CONTENT);
- }
-
- void recycleAllViews() {
- final int childCount = getChildCount();
- final IcsAbsSpinner.RecycleBin recycleBin = mRecycler;
- final int position = mFirstPosition;
-
- // All views go in recycler
- for (int i = 0; i < childCount; i++) {
- View v = getChildAt(i);
- int index = position + i;
- recycleBin.put(index, v);
- }
- }
-
- /**
- * Jump directly to a specific item in the adapter data.
- */
- public void setSelection(int position, boolean animate) {
- // Animate only if requested position is already on screen somewhere
- boolean shouldAnimate = animate && mFirstPosition <= position &&
- position <= mFirstPosition + getChildCount() - 1;
- setSelectionInt(position, shouldAnimate);
- }
-
- @Override
- public void setSelection(int position) {
- setNextSelectedPositionInt(position);
- requestLayout();
- invalidate();
- }
-
-
- /**
- * Makes the item at the supplied position selected.
- *
- * @param position Position to select
- * @param animate Should the transition be animated
- *
- */
- void setSelectionInt(int position, boolean animate) {
- if (position != mOldSelectedPosition) {
- mBlockLayoutRequests = true;
- int delta = position - mSelectedPosition;
- setNextSelectedPositionInt(position);
- layout(delta, animate);
- mBlockLayoutRequests = false;
- }
- }
-
- abstract void layout(int delta, boolean animate);
-
- @Override
- public View getSelectedView() {
- if (mItemCount > 0 && mSelectedPosition >= 0) {
- return getChildAt(mSelectedPosition - mFirstPosition);
- } else {
- return null;
- }
- }
-
- /**
- * Override to prevent spamming ourselves with layout requests
- * as we place views
- *
- * @see android.view.View#requestLayout()
- */
- @Override
- public void requestLayout() {
- if (!mBlockLayoutRequests) {
- super.requestLayout();
- }
- }
-
- @Override
- public SpinnerAdapter getAdapter() {
- return mAdapter;
- }
-
- @Override
- public int getCount() {
- return mItemCount;
- }
-
- /**
- * Maps a point to a position in the list.
- *
- * @param x X in local coordinate
- * @param y Y in local coordinate
- * @return The position of the item which contains the specified point, or
- * {@link #INVALID_POSITION} if the point does not intersect an item.
- */
- public int pointToPosition(int x, int y) {
- Rect frame = mTouchFrame;
- if (frame == null) {
- mTouchFrame = new Rect();
- frame = mTouchFrame;
- }
-
- final int count = getChildCount();
- for (int i = count - 1; i >= 0; i--) {
- View child = getChildAt(i);
- if (child.getVisibility() == View.VISIBLE) {
- child.getHitRect(frame);
- if (frame.contains(x, y)) {
- return mFirstPosition + i;
- }
- }
- }
- return INVALID_POSITION;
- }
-
- static class SavedState extends BaseSavedState {
- long selectedId;
- int position;
-
- /**
- * Constructor called from {@link AbsSpinner#onSaveInstanceState()}
- */
- SavedState(Parcelable superState) {
- super(superState);
- }
-
- /**
- * Constructor called from {@link #CREATOR}
- */
- private SavedState(Parcel in) {
- super(in);
- selectedId = in.readLong();
- position = in.readInt();
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- super.writeToParcel(out, flags);
- out.writeLong(selectedId);
- out.writeInt(position);
- }
-
- @Override
- public String toString() {
- return "AbsSpinner.SavedState{"
- + Integer.toHexString(System.identityHashCode(this))
- + " selectedId=" + selectedId
- + " position=" + position + "}";
- }
-
- public static final Parcelable.Creator CREATOR
- = new Parcelable.Creator() {
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
-
- @Override
- public Parcelable onSaveInstanceState() {
- Parcelable superState = super.onSaveInstanceState();
- SavedState ss = new SavedState(superState);
- ss.selectedId = getSelectedItemId();
- if (ss.selectedId >= 0) {
- ss.position = getSelectedItemPosition();
- } else {
- ss.position = INVALID_POSITION;
- }
- return ss;
- }
-
- @Override
- public void onRestoreInstanceState(Parcelable state) {
- SavedState ss = (SavedState) state;
-
- super.onRestoreInstanceState(ss.getSuperState());
-
- if (ss.selectedId >= 0) {
- mDataChanged = true;
- mNeedSync = true;
- mSyncRowId = ss.selectedId;
- mSyncPosition = ss.position;
- mSyncMode = SYNC_SELECTED_POSITION;
- requestLayout();
- }
- }
-
- class RecycleBin {
- private final SparseArray mScrapHeap = new SparseArray();
-
- public void put(int position, View v) {
- mScrapHeap.put(position, v);
- }
-
- View get(int position) {
- // System.out.print("Looking for " + position);
- View result = mScrapHeap.get(position);
- if (result != null) {
- // System.out.println(" HIT");
- mScrapHeap.delete(position);
- } else {
- // System.out.println(" MISS");
- }
- return result;
- }
-
- void clear() {
- final SparseArray scrapHeap = mScrapHeap;
- final int count = scrapHeap.size();
- for (int i = 0; i < count; i++) {
- final View view = scrapHeap.valueAt(i);
- if (view != null) {
- removeDetachedView(view, true);
- }
- }
- scrapHeap.clear();
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsAdapterView.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsAdapterView.java
deleted file mode 100644
index c786dc5c19..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsAdapterView.java
+++ /dev/null
@@ -1,1160 +0,0 @@
-/*
- * Copyright (C) 2006 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.actionbarsherlock.internal.widget;
-
-import android.content.Context;
-import android.database.DataSetObserver;
-import android.os.Parcelable;
-import android.os.SystemClock;
-import android.util.AttributeSet;
-import android.util.SparseArray;
-import android.view.ContextMenu;
-import android.view.SoundEffectConstants;
-import android.view.View;
-import android.view.ViewDebug;
-import android.view.ViewGroup;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityNodeInfo;
-import android.widget.Adapter;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ListView;
-
-
-/**
- * An AdapterView is a view whose children are determined by an {@link Adapter}.
- *
- *
- * See {@link ListView}, {@link GridView}, {@link Spinner} and
- * {@link Gallery} for commonly used subclasses of AdapterView.
- *
- *
- */
-public abstract class IcsAdapterView extends ViewGroup {
-
- /**
- * The item view type returned by {@link Adapter#getItemViewType(int)} when
- * the adapter does not want the item's view recycled.
- */
- public static final int ITEM_VIEW_TYPE_IGNORE = -1;
-
- /**
- * The item view type returned by {@link Adapter#getItemViewType(int)} when
- * the item is a header or footer.
- */
- public static final int ITEM_VIEW_TYPE_HEADER_OR_FOOTER = -2;
-
- /**
- * The position of the first child displayed
- */
- @ViewDebug.ExportedProperty(category = "scrolling")
- int mFirstPosition = 0;
-
- /**
- * The offset in pixels from the top of the AdapterView to the top
- * of the view to select during the next layout.
- */
- int mSpecificTop;
-
- /**
- * Position from which to start looking for mSyncRowId
- */
- int mSyncPosition;
-
- /**
- * Row id to look for when data has changed
- */
- long mSyncRowId = INVALID_ROW_ID;
-
- /**
- * Height of the view when mSyncPosition and mSyncRowId where set
- */
- long mSyncHeight;
-
- /**
- * True if we need to sync to mSyncRowId
- */
- boolean mNeedSync = false;
-
- /**
- * Indicates whether to sync based on the selection or position. Possible
- * values are {@link #SYNC_SELECTED_POSITION} or
- * {@link #SYNC_FIRST_POSITION}.
- */
- int mSyncMode;
-
- /**
- * Our height after the last layout
- */
- private int mLayoutHeight;
-
- /**
- * Sync based on the selected child
- */
- static final int SYNC_SELECTED_POSITION = 0;
-
- /**
- * Sync based on the first child displayed
- */
- static final int SYNC_FIRST_POSITION = 1;
-
- /**
- * Maximum amount of time to spend in {@link #findSyncPosition()}
- */
- static final int SYNC_MAX_DURATION_MILLIS = 100;
-
- /**
- * Indicates that this view is currently being laid out.
- */
- boolean mInLayout = false;
-
- /**
- * The listener that receives notifications when an item is selected.
- */
- OnItemSelectedListener mOnItemSelectedListener;
-
- /**
- * The listener that receives notifications when an item is clicked.
- */
- OnItemClickListener mOnItemClickListener;
-
- /**
- * The listener that receives notifications when an item is long clicked.
- */
- OnItemLongClickListener mOnItemLongClickListener;
-
- /**
- * True if the data has changed since the last layout
- */
- boolean mDataChanged;
-
- /**
- * The position within the adapter's data set of the item to select
- * during the next layout.
- */
- @ViewDebug.ExportedProperty(category = "list")
- int mNextSelectedPosition = INVALID_POSITION;
-
- /**
- * The item id of the item to select during the next layout.
- */
- long mNextSelectedRowId = INVALID_ROW_ID;
-
- /**
- * The position within the adapter's data set of the currently selected item.
- */
- @ViewDebug.ExportedProperty(category = "list")
- int mSelectedPosition = INVALID_POSITION;
-
- /**
- * The item id of the currently selected item.
- */
- long mSelectedRowId = INVALID_ROW_ID;
-
- /**
- * View to show if there are no items to show.
- */
- private View mEmptyView;
-
- /**
- * The number of items in the current adapter.
- */
- @ViewDebug.ExportedProperty(category = "list")
- int mItemCount;
-
- /**
- * The number of items in the adapter before a data changed event occurred.
- */
- int mOldItemCount;
-
- /**
- * Represents an invalid position. All valid positions are in the range 0 to 1 less than the
- * number of items in the current adapter.
- */
- public static final int INVALID_POSITION = -1;
-
- /**
- * Represents an empty or invalid row id
- */
- public static final long INVALID_ROW_ID = Long.MIN_VALUE;
-
- /**
- * The last selected position we used when notifying
- */
- int mOldSelectedPosition = INVALID_POSITION;
-
- /**
- * The id of the last selected position we used when notifying
- */
- long mOldSelectedRowId = INVALID_ROW_ID;
-
- /**
- * Indicates what focusable state is requested when calling setFocusable().
- * In addition to this, this view has other criteria for actually
- * determining the focusable state (such as whether its empty or the text
- * filter is shown).
- *
- * @see #setFocusable(boolean)
- * @see #checkFocus()
- */
- private boolean mDesiredFocusableState;
- private boolean mDesiredFocusableInTouchModeState;
-
- private SelectionNotifier mSelectionNotifier;
- /**
- * When set to true, calls to requestLayout() will not propagate up the parent hierarchy.
- * This is used to layout the children during a layout pass.
- */
- boolean mBlockLayoutRequests = false;
-
- public IcsAdapterView(Context context) {
- super(context);
- }
-
- public IcsAdapterView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public IcsAdapterView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- /**
- * Register a callback to be invoked when an item in this AdapterView has
- * been clicked.
- *
- * @param listener The callback that will be invoked.
- */
- public void setOnItemClickListener(OnItemClickListener listener) {
- mOnItemClickListener = listener;
- }
-
- /**
- * @return The callback to be invoked with an item in this AdapterView has
- * been clicked, or null id no callback has been set.
- */
- public final OnItemClickListener getOnItemClickListener() {
- return mOnItemClickListener;
- }
-
- /**
- * Call the OnItemClickListener, if it is defined.
- *
- * @param view The view within the AdapterView that was clicked.
- * @param position The position of the view in the adapter.
- * @param id The row id of the item that was clicked.
- * @return True if there was an assigned OnItemClickListener that was
- * called, false otherwise is returned.
- */
- public boolean performItemClick(View view, int position, long id) {
- if (mOnItemClickListener != null) {
- playSoundEffect(SoundEffectConstants.CLICK);
- if (view != null) {
- view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
- }
- mOnItemClickListener.onItemClick(/*this*/null, view, position, id);
- return true;
- }
-
- return false;
- }
-
- /**
- * Interface definition for a callback to be invoked when an item in this
- * view has been clicked and held.
- */
- public interface OnItemLongClickListener {
- /**
- * Callback method to be invoked when an item in this view has been
- * clicked and held.
- *
- * Implementers can call getItemAtPosition(position) if they need to access
- * the data associated with the selected item.
- *
- * @param parent The AbsListView where the click happened
- * @param view The view within the AbsListView that was clicked
- * @param position The position of the view in the list
- * @param id The row id of the item that was clicked
- *
- * @return true if the callback consumed the long click, false otherwise
- */
- boolean onItemLongClick(IcsAdapterView> parent, View view, int position, long id);
- }
-
-
- /**
- * Register a callback to be invoked when an item in this AdapterView has
- * been clicked and held
- *
- * @param listener The callback that will run
- */
- public void setOnItemLongClickListener(OnItemLongClickListener listener) {
- if (!isLongClickable()) {
- setLongClickable(true);
- }
- mOnItemLongClickListener = listener;
- }
-
- /**
- * @return The callback to be invoked with an item in this AdapterView has
- * been clicked and held, or null id no callback as been set.
- */
- public final OnItemLongClickListener getOnItemLongClickListener() {
- return mOnItemLongClickListener;
- }
-
- /**
- * Interface definition for a callback to be invoked when
- * an item in this view has been selected.
- */
- public interface OnItemSelectedListener {
- /**
- *
Callback method to be invoked when an item in this view has been
- * selected. This callback is invoked only when the newly selected
- * position is different from the previously selected position or if
- * there was no selected item.
- *
- * Impelmenters can call getItemAtPosition(position) if they need to access the
- * data associated with the selected item.
- *
- * @param parent The AdapterView where the selection happened
- * @param view The view within the AdapterView that was clicked
- * @param position The position of the view in the adapter
- * @param id The row id of the item that is selected
- */
- void onItemSelected(IcsAdapterView> parent, View view, int position, long id);
-
- /**
- * Callback method to be invoked when the selection disappears from this
- * view. The selection can disappear for instance when touch is activated
- * or when the adapter becomes empty.
- *
- * @param parent The AdapterView that now contains no selected item.
- */
- void onNothingSelected(IcsAdapterView> parent);
- }
-
-
- /**
- * Register a callback to be invoked when an item in this AdapterView has
- * been selected.
- *
- * @param listener The callback that will run
- */
- public void setOnItemSelectedListener(OnItemSelectedListener listener) {
- mOnItemSelectedListener = listener;
- }
-
- public final OnItemSelectedListener getOnItemSelectedListener() {
- return mOnItemSelectedListener;
- }
-
- /**
- * Extra menu information provided to the
- * {@link android.view.View.OnCreateContextMenuListener#onCreateContextMenu(ContextMenu, View, ContextMenuInfo) }
- * callback when a context menu is brought up for this AdapterView.
- *
- */
- public static class AdapterContextMenuInfo implements ContextMenu.ContextMenuInfo {
-
- public AdapterContextMenuInfo(View targetView, int position, long id) {
- this.targetView = targetView;
- this.position = position;
- this.id = id;
- }
-
- /**
- * The child view for which the context menu is being displayed. This
- * will be one of the children of this AdapterView.
- */
- public View targetView;
-
- /**
- * The position in the adapter for which the context menu is being
- * displayed.
- */
- public int position;
-
- /**
- * The row id of the item for which the context menu is being displayed.
- */
- public long id;
- }
-
- /**
- * Returns the adapter currently associated with this widget.
- *
- * @return The adapter used to provide this view's content.
- */
- public abstract T getAdapter();
-
- /**
- * Sets the adapter that provides the data and the views to represent the data
- * in this widget.
- *
- * @param adapter The adapter to use to create this view's content.
- */
- public abstract void setAdapter(T adapter);
-
- /**
- * This method is not supported and throws an UnsupportedOperationException when called.
- *
- * @param child Ignored.
- *
- * @throws UnsupportedOperationException Every time this method is invoked.
- */
- @Override
- public void addView(View child) {
- throw new UnsupportedOperationException("addView(View) is not supported in AdapterView");
- }
-
- /**
- * This method is not supported and throws an UnsupportedOperationException when called.
- *
- * @param child Ignored.
- * @param index Ignored.
- *
- * @throws UnsupportedOperationException Every time this method is invoked.
- */
- @Override
- public void addView(View child, int index) {
- throw new UnsupportedOperationException("addView(View, int) is not supported in AdapterView");
- }
-
- /**
- * This method is not supported and throws an UnsupportedOperationException when called.
- *
- * @param child Ignored.
- * @param params Ignored.
- *
- * @throws UnsupportedOperationException Every time this method is invoked.
- */
- @Override
- public void addView(View child, LayoutParams params) {
- throw new UnsupportedOperationException("addView(View, LayoutParams) "
- + "is not supported in AdapterView");
- }
-
- /**
- * This method is not supported and throws an UnsupportedOperationException when called.
- *
- * @param child Ignored.
- * @param index Ignored.
- * @param params Ignored.
- *
- * @throws UnsupportedOperationException Every time this method is invoked.
- */
- @Override
- public void addView(View child, int index, LayoutParams params) {
- throw new UnsupportedOperationException("addView(View, int, LayoutParams) "
- + "is not supported in AdapterView");
- }
-
- /**
- * This method is not supported and throws an UnsupportedOperationException when called.
- *
- * @param child Ignored.
- *
- * @throws UnsupportedOperationException Every time this method is invoked.
- */
- @Override
- public void removeView(View child) {
- throw new UnsupportedOperationException("removeView(View) is not supported in AdapterView");
- }
-
- /**
- * This method is not supported and throws an UnsupportedOperationException when called.
- *
- * @param index Ignored.
- *
- * @throws UnsupportedOperationException Every time this method is invoked.
- */
- @Override
- public void removeViewAt(int index) {
- throw new UnsupportedOperationException("removeViewAt(int) is not supported in AdapterView");
- }
-
- /**
- * This method is not supported and throws an UnsupportedOperationException when called.
- *
- * @throws UnsupportedOperationException Every time this method is invoked.
- */
- @Override
- public void removeAllViews() {
- throw new UnsupportedOperationException("removeAllViews() is not supported in AdapterView");
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- mLayoutHeight = getHeight();
- }
-
- /**
- * Return the position of the currently selected item within the adapter's data set
- *
- * @return int Position (starting at 0), or {@link #INVALID_POSITION} if there is nothing selected.
- */
- @ViewDebug.CapturedViewProperty
- public int getSelectedItemPosition() {
- return mNextSelectedPosition;
- }
-
- /**
- * @return The id corresponding to the currently selected item, or {@link #INVALID_ROW_ID}
- * if nothing is selected.
- */
- @ViewDebug.CapturedViewProperty
- public long getSelectedItemId() {
- return mNextSelectedRowId;
- }
-
- /**
- * @return The view corresponding to the currently selected item, or null
- * if nothing is selected
- */
- public abstract View getSelectedView();
-
- /**
- * @return The data corresponding to the currently selected item, or
- * null if there is nothing selected.
- */
- public Object getSelectedItem() {
- T adapter = getAdapter();
- int selection = getSelectedItemPosition();
- if (adapter != null && adapter.getCount() > 0 && selection >= 0) {
- return adapter.getItem(selection);
- } else {
- return null;
- }
- }
-
- /**
- * @return The number of items owned by the Adapter associated with this
- * AdapterView. (This is the number of data items, which may be
- * larger than the number of visible views.)
- */
- @ViewDebug.CapturedViewProperty
- public int getCount() {
- return mItemCount;
- }
-
- /**
- * Get the position within the adapter's data set for the view, where view is a an adapter item
- * or a descendant of an adapter item.
- *
- * @param view an adapter item, or a descendant of an adapter item. This must be visible in this
- * AdapterView at the time of the call.
- * @return the position within the adapter's data set of the view, or {@link #INVALID_POSITION}
- * if the view does not correspond to a list item (or it is not currently visible).
- */
- public int getPositionForView(View view) {
- View listItem = view;
- try {
- View v;
- while (!(v = (View) listItem.getParent()).equals(this)) {
- listItem = v;
- }
- } catch (ClassCastException e) {
- // We made it up to the window without find this list view
- return INVALID_POSITION;
- }
-
- // Search the children for the list item
- final int childCount = getChildCount();
- for (int i = 0; i < childCount; i++) {
- if (getChildAt(i).equals(listItem)) {
- return mFirstPosition + i;
- }
- }
-
- // Child not found!
- return INVALID_POSITION;
- }
-
- /**
- * Returns the position within the adapter's data set for the first item
- * displayed on screen.
- *
- * @return The position within the adapter's data set
- */
- public int getFirstVisiblePosition() {
- return mFirstPosition;
- }
-
- /**
- * Returns the position within the adapter's data set for the last item
- * displayed on screen.
- *
- * @return The position within the adapter's data set
- */
- public int getLastVisiblePosition() {
- return mFirstPosition + getChildCount() - 1;
- }
-
- /**
- * Sets the currently selected item. To support accessibility subclasses that
- * override this method must invoke the overriden super method first.
- *
- * @param position Index (starting at 0) of the data item to be selected.
- */
- public abstract void setSelection(int position);
-
- /**
- * Sets the view to show if the adapter is empty
- */
- public void setEmptyView(View emptyView) {
- mEmptyView = emptyView;
-
- final T adapter = getAdapter();
- final boolean empty = ((adapter == null) || adapter.isEmpty());
- updateEmptyStatus(empty);
- }
-
- /**
- * When the current adapter is empty, the AdapterView can display a special view
- * call the empty view. The empty view is used to provide feedback to the user
- * that no data is available in this AdapterView.
- *
- * @return The view to show if the adapter is empty.
- */
- public View getEmptyView() {
- return mEmptyView;
- }
-
- /**
- * Indicates whether this view is in filter mode. Filter mode can for instance
- * be enabled by a user when typing on the keyboard.
- *
- * @return True if the view is in filter mode, false otherwise.
- */
- boolean isInFilterMode() {
- return false;
- }
-
- @Override
- public void setFocusable(boolean focusable) {
- final T adapter = getAdapter();
- final boolean empty = adapter == null || adapter.getCount() == 0;
-
- mDesiredFocusableState = focusable;
- if (!focusable) {
- mDesiredFocusableInTouchModeState = false;
- }
-
- super.setFocusable(focusable && (!empty || isInFilterMode()));
- }
-
- @Override
- public void setFocusableInTouchMode(boolean focusable) {
- final T adapter = getAdapter();
- final boolean empty = adapter == null || adapter.getCount() == 0;
-
- mDesiredFocusableInTouchModeState = focusable;
- if (focusable) {
- mDesiredFocusableState = true;
- }
-
- super.setFocusableInTouchMode(focusable && (!empty || isInFilterMode()));
- }
-
- void checkFocus() {
- final T adapter = getAdapter();
- final boolean empty = adapter == null || adapter.getCount() == 0;
- final boolean focusable = !empty || isInFilterMode();
- // The order in which we set focusable in touch mode/focusable may matter
- // for the client, see View.setFocusableInTouchMode() comments for more
- // details
- super.setFocusableInTouchMode(focusable && mDesiredFocusableInTouchModeState);
- super.setFocusable(focusable && mDesiredFocusableState);
- if (mEmptyView != null) {
- updateEmptyStatus((adapter == null) || adapter.isEmpty());
- }
- }
-
- /**
- * Update the status of the list based on the empty parameter. If empty is true and
- * we have an empty view, display it. In all the other cases, make sure that the listview
- * is VISIBLE and that the empty view is GONE (if it's not null).
- */
- private void updateEmptyStatus(boolean empty) {
- if (isInFilterMode()) {
- empty = false;
- }
-
- if (empty) {
- if (mEmptyView != null) {
- mEmptyView.setVisibility(View.VISIBLE);
- setVisibility(View.GONE);
- } else {
- // If the caller just removed our empty view, make sure the list view is visible
- setVisibility(View.VISIBLE);
- }
-
- // We are now GONE, so pending layouts will not be dispatched.
- // Force one here to make sure that the state of the list matches
- // the state of the adapter.
- if (mDataChanged) {
- this.onLayout(false, getLeft(), getTop(), getRight(), getBottom());
- }
- } else {
- if (mEmptyView != null) mEmptyView.setVisibility(View.GONE);
- setVisibility(View.VISIBLE);
- }
- }
-
- /**
- * Gets the data associated with the specified position in the list.
- *
- * @param position Which data to get
- * @return The data associated with the specified position in the list
- */
- public Object getItemAtPosition(int position) {
- T adapter = getAdapter();
- return (adapter == null || position < 0) ? null : adapter.getItem(position);
- }
-
- public long getItemIdAtPosition(int position) {
- T adapter = getAdapter();
- return (adapter == null || position < 0) ? INVALID_ROW_ID : adapter.getItemId(position);
- }
-
- @Override
- public void setOnClickListener(OnClickListener l) {
- throw new RuntimeException("Don't call setOnClickListener for an AdapterView. "
- + "You probably want setOnItemClickListener instead");
- }
-
- /**
- * Override to prevent freezing of any views created by the adapter.
- */
- @Override
- protected void dispatchSaveInstanceState(SparseArray container) {
- dispatchFreezeSelfOnly(container);
- }
-
- /**
- * Override to prevent thawing of any views created by the adapter.
- */
- @Override
- protected void dispatchRestoreInstanceState(SparseArray container) {
- dispatchThawSelfOnly(container);
- }
-
- class AdapterDataSetObserver extends DataSetObserver {
-
- private Parcelable mInstanceState = null;
-
- @Override
- public void onChanged() {
- mDataChanged = true;
- mOldItemCount = mItemCount;
- mItemCount = getAdapter().getCount();
-
- // Detect the case where a cursor that was previously invalidated has
- // been repopulated with new data.
- if (IcsAdapterView.this.getAdapter().hasStableIds() && mInstanceState != null
- && mOldItemCount == 0 && mItemCount > 0) {
- IcsAdapterView.this.onRestoreInstanceState(mInstanceState);
- mInstanceState = null;
- } else {
- rememberSyncState();
- }
- checkFocus();
- requestLayout();
- }
-
- @Override
- public void onInvalidated() {
- mDataChanged = true;
-
- if (IcsAdapterView.this.getAdapter().hasStableIds()) {
- // Remember the current state for the case where our hosting activity is being
- // stopped and later restarted
- mInstanceState = IcsAdapterView.this.onSaveInstanceState();
- }
-
- // Data is invalid so we should reset our state
- mOldItemCount = mItemCount;
- mItemCount = 0;
- mSelectedPosition = INVALID_POSITION;
- mSelectedRowId = INVALID_ROW_ID;
- mNextSelectedPosition = INVALID_POSITION;
- mNextSelectedRowId = INVALID_ROW_ID;
- mNeedSync = false;
-
- checkFocus();
- requestLayout();
- }
-
- public void clearSavedState() {
- mInstanceState = null;
- }
- }
-
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- removeCallbacks(mSelectionNotifier);
- }
-
- private class SelectionNotifier implements Runnable {
- public void run() {
- if (mDataChanged) {
- // Data has changed between when this SelectionNotifier
- // was posted and now. We need to wait until the AdapterView
- // has been synched to the new data.
- if (getAdapter() != null) {
- post(this);
- }
- } else {
- fireOnSelected();
- }
- }
- }
-
- void selectionChanged() {
- if (mOnItemSelectedListener != null) {
- if (mInLayout || mBlockLayoutRequests) {
- // If we are in a layout traversal, defer notification
- // by posting. This ensures that the view tree is
- // in a consistent state and is able to accomodate
- // new layout or invalidate requests.
- if (mSelectionNotifier == null) {
- mSelectionNotifier = new SelectionNotifier();
- }
- post(mSelectionNotifier);
- } else {
- fireOnSelected();
- }
- }
-
- // we fire selection events here not in View
- if (mSelectedPosition != ListView.INVALID_POSITION && isShown() && !isInTouchMode()) {
- sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
- }
- }
-
- private void fireOnSelected() {
- if (mOnItemSelectedListener == null)
- return;
-
- int selection = this.getSelectedItemPosition();
- if (selection >= 0) {
- View v = getSelectedView();
- mOnItemSelectedListener.onItemSelected(this, v, selection,
- getAdapter().getItemId(selection));
- } else {
- mOnItemSelectedListener.onNothingSelected(this);
- }
- }
-
- @Override
- public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
- View selectedView = getSelectedView();
- if (selectedView != null && selectedView.getVisibility() == VISIBLE
- && selectedView.dispatchPopulateAccessibilityEvent(event)) {
- return true;
- }
- return false;
- }
-
- @Override
- public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
- if (super.onRequestSendAccessibilityEvent(child, event)) {
- // Add a record for ourselves as well.
- AccessibilityEvent record = AccessibilityEvent.obtain();
- onInitializeAccessibilityEvent(record);
- // Populate with the text of the requesting child.
- child.dispatchPopulateAccessibilityEvent(record);
- event.appendRecord(record);
- return true;
- }
- return false;
- }
-
- @Override
- public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
- super.onInitializeAccessibilityNodeInfo(info);
- info.setScrollable(isScrollableForAccessibility());
- View selectedView = getSelectedView();
- if (selectedView != null) {
- info.setEnabled(selectedView.isEnabled());
- }
- }
-
- @Override
- public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
- super.onInitializeAccessibilityEvent(event);
- event.setScrollable(isScrollableForAccessibility());
- View selectedView = getSelectedView();
- if (selectedView != null) {
- event.setEnabled(selectedView.isEnabled());
- }
- event.setCurrentItemIndex(getSelectedItemPosition());
- event.setFromIndex(getFirstVisiblePosition());
- event.setToIndex(getLastVisiblePosition());
- event.setItemCount(getCount());
- }
-
- private boolean isScrollableForAccessibility() {
- T adapter = getAdapter();
- if (adapter != null) {
- final int itemCount = adapter.getCount();
- return itemCount > 0
- && (getFirstVisiblePosition() > 0 || getLastVisiblePosition() < itemCount - 1);
- }
- return false;
- }
-
- @Override
- protected boolean canAnimate() {
- return super.canAnimate() && mItemCount > 0;
- }
-
- void handleDataChanged() {
- final int count = mItemCount;
- boolean found = false;
-
- if (count > 0) {
-
- int newPos;
-
- // Find the row we are supposed to sync to
- if (mNeedSync) {
- // Update this first, since setNextSelectedPositionInt inspects
- // it
- mNeedSync = false;
-
- // See if we can find a position in the new data with the same
- // id as the old selection
- newPos = findSyncPosition();
- if (newPos >= 0) {
- // Verify that new selection is selectable
- int selectablePos = lookForSelectablePosition(newPos, true);
- if (selectablePos == newPos) {
- // Same row id is selected
- setNextSelectedPositionInt(newPos);
- found = true;
- }
- }
- }
- if (!found) {
- // Try to use the same position if we can't find matching data
- newPos = getSelectedItemPosition();
-
- // Pin position to the available range
- if (newPos >= count) {
- newPos = count - 1;
- }
- if (newPos < 0) {
- newPos = 0;
- }
-
- // Make sure we select something selectable -- first look down
- int selectablePos = lookForSelectablePosition(newPos, true);
- if (selectablePos < 0) {
- // Looking down didn't work -- try looking up
- selectablePos = lookForSelectablePosition(newPos, false);
- }
- if (selectablePos >= 0) {
- setNextSelectedPositionInt(selectablePos);
- checkSelectionChanged();
- found = true;
- }
- }
- }
- if (!found) {
- // Nothing is selected
- mSelectedPosition = INVALID_POSITION;
- mSelectedRowId = INVALID_ROW_ID;
- mNextSelectedPosition = INVALID_POSITION;
- mNextSelectedRowId = INVALID_ROW_ID;
- mNeedSync = false;
- checkSelectionChanged();
- }
- }
-
- void checkSelectionChanged() {
- if ((mSelectedPosition != mOldSelectedPosition) || (mSelectedRowId != mOldSelectedRowId)) {
- selectionChanged();
- mOldSelectedPosition = mSelectedPosition;
- mOldSelectedRowId = mSelectedRowId;
- }
- }
-
- /**
- * Searches the adapter for a position matching mSyncRowId. The search starts at mSyncPosition
- * and then alternates between moving up and moving down until 1) we find the right position, or
- * 2) we run out of time, or 3) we have looked at every position
- *
- * @return Position of the row that matches mSyncRowId, or {@link #INVALID_POSITION} if it can't
- * be found
- */
- int findSyncPosition() {
- int count = mItemCount;
-
- if (count == 0) {
- return INVALID_POSITION;
- }
-
- long idToMatch = mSyncRowId;
- int seed = mSyncPosition;
-
- // If there isn't a selection don't hunt for it
- if (idToMatch == INVALID_ROW_ID) {
- return INVALID_POSITION;
- }
-
- // Pin seed to reasonable values
- seed = Math.max(0, seed);
- seed = Math.min(count - 1, seed);
-
- long endTime = SystemClock.uptimeMillis() + SYNC_MAX_DURATION_MILLIS;
-
- long rowId;
-
- // first position scanned so far
- int first = seed;
-
- // last position scanned so far
- int last = seed;
-
- // True if we should move down on the next iteration
- boolean next = false;
-
- // True when we have looked at the first item in the data
- boolean hitFirst;
-
- // True when we have looked at the last item in the data
- boolean hitLast;
-
- // Get the item ID locally (instead of getItemIdAtPosition), so
- // we need the adapter
- T adapter = getAdapter();
- if (adapter == null) {
- return INVALID_POSITION;
- }
-
- while (SystemClock.uptimeMillis() <= endTime) {
- rowId = adapter.getItemId(seed);
- if (rowId == idToMatch) {
- // Found it!
- return seed;
- }
-
- hitLast = last == count - 1;
- hitFirst = first == 0;
-
- if (hitLast && hitFirst) {
- // Looked at everything
- break;
- }
-
- if (hitFirst || (next && !hitLast)) {
- // Either we hit the top, or we are trying to move down
- last++;
- seed = last;
- // Try going up next time
- next = false;
- } else if (hitLast || (!next && !hitFirst)) {
- // Either we hit the bottom, or we are trying to move up
- first--;
- seed = first;
- // Try going down next time
- next = true;
- }
-
- }
-
- return INVALID_POSITION;
- }
-
- /**
- * Find a position that can be selected (i.e., is not a separator).
- *
- * @param position The starting position to look at.
- * @param lookDown Whether to look down for other positions.
- * @return The next selectable position starting at position and then searching either up or
- * down. Returns {@link #INVALID_POSITION} if nothing can be found.
- */
- int lookForSelectablePosition(int position, boolean lookDown) {
- return position;
- }
-
- /**
- * Utility to keep mSelectedPosition and mSelectedRowId in sync
- * @param position Our current position
- */
- void setSelectedPositionInt(int position) {
- mSelectedPosition = position;
- mSelectedRowId = getItemIdAtPosition(position);
- }
-
- /**
- * Utility to keep mNextSelectedPosition and mNextSelectedRowId in sync
- * @param position Intended value for mSelectedPosition the next time we go
- * through layout
- */
- void setNextSelectedPositionInt(int position) {
- mNextSelectedPosition = position;
- mNextSelectedRowId = getItemIdAtPosition(position);
- // If we are trying to sync to the selection, update that too
- if (mNeedSync && mSyncMode == SYNC_SELECTED_POSITION && position >= 0) {
- mSyncPosition = position;
- mSyncRowId = mNextSelectedRowId;
- }
- }
-
- /**
- * Remember enough information to restore the screen state when the data has
- * changed.
- *
- */
- void rememberSyncState() {
- if (getChildCount() > 0) {
- mNeedSync = true;
- mSyncHeight = mLayoutHeight;
- if (mSelectedPosition >= 0) {
- // Sync the selection state
- View v = getChildAt(mSelectedPosition - mFirstPosition);
- mSyncRowId = mNextSelectedRowId;
- mSyncPosition = mNextSelectedPosition;
- if (v != null) {
- mSpecificTop = v.getTop();
- }
- mSyncMode = SYNC_SELECTED_POSITION;
- } else {
- // Sync the based on the offset of the first view
- View v = getChildAt(0);
- T adapter = getAdapter();
- if (mFirstPosition >= 0 && mFirstPosition < adapter.getCount()) {
- mSyncRowId = adapter.getItemId(mFirstPosition);
- } else {
- mSyncRowId = NO_ID;
- }
- mSyncPosition = mFirstPosition;
- if (v != null) {
- mSpecificTop = v.getTop();
- }
- mSyncMode = SYNC_FIRST_POSITION;
- }
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java
deleted file mode 100644
index 1b4463a595..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java
+++ /dev/null
@@ -1,272 +0,0 @@
-package com.actionbarsherlock.internal.widget;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.drawable.Drawable;
-import android.util.AttributeSet;
-import android.view.View;
-import com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout;
-
-/**
- * A simple extension of a regular linear layout that supports the divider API
- * of Android 4.0+. The dividers are added adjacent to the children by changing
- * their layout params. If you need to rely on the margins which fall in the
- * same orientation as the layout you should wrap the child in a simple
- * {@link android.widget.FrameLayout} so it can receive the margin.
- */
-public class IcsLinearLayout extends NineLinearLayout {
- private static final int[] LinearLayout = new int[] {
- /* 0 */ android.R.attr.divider,
- /* 1 */ android.R.attr.showDividers,
- /* 2 */ android.R.attr.dividerPadding,
- };
- private static final int LinearLayout_divider = 0;
- private static final int LinearLayout_showDividers = 1;
- private static final int LinearLayout_dividerPadding = 2;
-
- /**
- * Don't show any dividers.
- */
- public static final int SHOW_DIVIDER_NONE = 0;
- /**
- * Show a divider at the beginning of the group.
- */
- public static final int SHOW_DIVIDER_BEGINNING = 1;
- /**
- * Show dividers between each item in the group.
- */
- public static final int SHOW_DIVIDER_MIDDLE = 2;
- /**
- * Show a divider at the end of the group.
- */
- public static final int SHOW_DIVIDER_END = 4;
-
-
- private Drawable mDivider;
- private int mDividerWidth;
- private int mDividerHeight;
- private int mShowDividers;
- private int mDividerPadding;
-
-
- public IcsLinearLayout(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- TypedArray a = context.obtainStyledAttributes(attrs, /*com.android.internal.R.styleable.*/LinearLayout);
-
- setDividerDrawable(a.getDrawable(/*com.android.internal.R.styleable.*/LinearLayout_divider));
- mShowDividers = a.getInt(/*com.android.internal.R.styleable.*/LinearLayout_showDividers, SHOW_DIVIDER_NONE);
- mDividerPadding = a.getDimensionPixelSize(/*com.android.internal.R.styleable.*/LinearLayout_dividerPadding, 0);
-
- a.recycle();
- }
-
- /**
- * Set how dividers should be shown between items in this layout
- *
- * @param showDividers One or more of {@link #SHOW_DIVIDER_BEGINNING},
- * {@link #SHOW_DIVIDER_MIDDLE}, or {@link #SHOW_DIVIDER_END},
- * or {@link #SHOW_DIVIDER_NONE} to show no dividers.
- */
- public void setShowDividers(int showDividers) {
- if (showDividers != mShowDividers) {
- requestLayout();
- invalidate(); //XXX This is required if you are toggling a divider off
- }
- mShowDividers = showDividers;
- }
-
- /**
- * @return A flag set indicating how dividers should be shown around items.
- * @see #setShowDividers(int)
- */
- public int getShowDividers() {
- return mShowDividers;
- }
-
- /**
- * Set a drawable to be used as a divider between items.
- * @param divider Drawable that will divide each item.
- * @see #setShowDividers(int)
- */
- public void setDividerDrawable(Drawable divider) {
- if (divider == mDivider) {
- return;
- }
- mDivider = divider;
- if (divider != null) {
- mDividerWidth = divider.getIntrinsicWidth();
- mDividerHeight = divider.getIntrinsicHeight();
- } else {
- mDividerWidth = 0;
- mDividerHeight = 0;
- }
- setWillNotDraw(divider == null);
- requestLayout();
- }
-
- /**
- * Set padding displayed on both ends of dividers.
- *
- * @param padding Padding value in pixels that will be applied to each end
- *
- * @see #setShowDividers(int)
- * @see #setDividerDrawable(Drawable)
- * @see #getDividerPadding()
- */
- public void setDividerPadding(int padding) {
- mDividerPadding = padding;
- }
-
- /**
- * Get the padding size used to inset dividers in pixels
- *
- * @see #setShowDividers(int)
- * @see #setDividerDrawable(Drawable)
- * @see #setDividerPadding(int)
- */
- public int getDividerPadding() {
- return mDividerPadding;
- }
-
- /**
- * Get the width of the current divider drawable.
- *
- * @hide Used internally by framework.
- */
- public int getDividerWidth() {
- return mDividerWidth;
- }
-
- @Override
- protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) {
- final int index = indexOfChild(child);
- final int orientation = getOrientation();
- final LayoutParams params = (LayoutParams) child.getLayoutParams();
- if (hasDividerBeforeChildAt(index)) {
- if (orientation == VERTICAL) {
- //Account for the divider by pushing everything up
- params.topMargin = mDividerHeight;
- } else {
- //Account for the divider by pushing everything left
- params.leftMargin = mDividerWidth;
- }
- }
-
- final int count = getChildCount();
- if (index == count - 1) {
- if (hasDividerBeforeChildAt(count)) {
- if (orientation == VERTICAL) {
- params.bottomMargin = mDividerHeight;
- } else {
- params.rightMargin = mDividerWidth;
- }
- }
- }
- super.measureChildWithMargins(child, parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed);
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- if (mDivider != null) {
- if (getOrientation() == VERTICAL) {
- drawDividersVertical(canvas);
- } else {
- drawDividersHorizontal(canvas);
- }
- }
- super.onDraw(canvas);
- }
-
- void drawDividersVertical(Canvas canvas) {
- final int count = getChildCount();
- for (int i = 0; i < count; i++) {
- final View child = getChildAt(i);
-
- if (child != null && child.getVisibility() != GONE) {
- if (hasDividerBeforeChildAt(i)) {
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- final int top = child.getTop() - lp.topMargin/* - mDividerHeight*/;
- drawHorizontalDivider(canvas, top);
- }
- }
- }
-
- if (hasDividerBeforeChildAt(count)) {
- final View child = getChildAt(count - 1);
- int bottom = 0;
- if (child == null) {
- bottom = getHeight() - getPaddingBottom() - mDividerHeight;
- } else {
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- bottom = child.getBottom()/* + lp.bottomMargin*/;
- }
- drawHorizontalDivider(canvas, bottom);
- }
- }
-
- void drawDividersHorizontal(Canvas canvas) {
- final int count = getChildCount();
- for (int i = 0; i < count; i++) {
- final View child = getChildAt(i);
-
- if (child != null && child.getVisibility() != GONE) {
- if (hasDividerBeforeChildAt(i)) {
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- final int left = child.getLeft() - lp.leftMargin/* - mDividerWidth*/;
- drawVerticalDivider(canvas, left);
- }
- }
- }
-
- if (hasDividerBeforeChildAt(count)) {
- final View child = getChildAt(count - 1);
- int right = 0;
- if (child == null) {
- right = getWidth() - getPaddingRight() - mDividerWidth;
- } else {
- final LayoutParams lp = (LayoutParams) child.getLayoutParams();
- right = child.getRight()/* + lp.rightMargin*/;
- }
- drawVerticalDivider(canvas, right);
- }
- }
-
- void drawHorizontalDivider(Canvas canvas, int top) {
- mDivider.setBounds(getPaddingLeft() + mDividerPadding, top,
- getWidth() - getPaddingRight() - mDividerPadding, top + mDividerHeight);
- mDivider.draw(canvas);
- }
-
- void drawVerticalDivider(Canvas canvas, int left) {
- mDivider.setBounds(left, getPaddingTop() + mDividerPadding,
- left + mDividerWidth, getHeight() - getPaddingBottom() - mDividerPadding);
- mDivider.draw(canvas);
- }
-
- /**
- * Determines where to position dividers between children.
- *
- * @param childIndex Index of child to check for preceding divider
- * @return true if there should be a divider before the child at childIndex
- * @hide Pending API consideration. Currently only used internally by the system.
- */
- protected boolean hasDividerBeforeChildAt(int childIndex) {
- if (childIndex == 0) {
- return (mShowDividers & SHOW_DIVIDER_BEGINNING) != 0;
- } else if (childIndex == getChildCount()) {
- return (mShowDividers & SHOW_DIVIDER_END) != 0;
- } else if ((mShowDividers & SHOW_DIVIDER_MIDDLE) != 0) {
- boolean hasVisibleViewBefore = false;
- for (int i = childIndex - 1; i >= 0; i--) {
- if (getChildAt(i).getVisibility() != GONE) {
- hasVisibleViewBefore = true;
- break;
- }
- }
- return hasVisibleViewBefore;
- }
- return false;
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java
deleted file mode 100644
index d13c6cea97..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java
+++ /dev/null
@@ -1,644 +0,0 @@
-package com.actionbarsherlock.internal.widget;
-
-import com.actionbarsherlock.R;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.database.DataSetObserver;
-import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.os.Handler;
-import android.util.AttributeSet;
-import android.view.ContextThemeWrapper;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.View.MeasureSpec;
-import android.view.View.OnTouchListener;
-import android.view.ViewGroup;
-import android.view.ViewParent;
-import android.widget.AbsListView;
-import android.widget.AdapterView;
-import android.widget.LinearLayout;
-import android.widget.ListAdapter;
-import android.widget.ListView;
-import android.widget.PopupWindow;
-
-/**
- * A proxy between pre- and post-Honeycomb implementations of this class.
- */
-public class IcsListPopupWindow {
- /**
- * This value controls the length of time that the user
- * must leave a pointer down without scrolling to expand
- * the autocomplete dropdown list to cover the IME.
- */
- private static final int EXPAND_LIST_TIMEOUT = 250;
-
- private Context mContext;
- private PopupWindow mPopup;
- private ListAdapter mAdapter;
- private DropDownListView mDropDownList;
-
- private int mDropDownHeight = ViewGroup.LayoutParams.WRAP_CONTENT;
- private int mDropDownWidth = ViewGroup.LayoutParams.WRAP_CONTENT;
- private int mDropDownHorizontalOffset;
- private int mDropDownVerticalOffset;
- private boolean mDropDownVerticalOffsetSet;
-
- private int mListItemExpandMaximum = Integer.MAX_VALUE;
-
- private View mPromptView;
- private int mPromptPosition = POSITION_PROMPT_ABOVE;
-
- private DataSetObserver mObserver;
-
- private View mDropDownAnchorView;
-
- private Drawable mDropDownListHighlight;
-
- private AdapterView.OnItemClickListener mItemClickListener;
- private AdapterView.OnItemSelectedListener mItemSelectedListener;
-
- private final ResizePopupRunnable mResizePopupRunnable = new ResizePopupRunnable();
- private final PopupTouchInterceptor mTouchInterceptor = new PopupTouchInterceptor();
- private final PopupScrollListener mScrollListener = new PopupScrollListener();
- private final ListSelectorHider mHideSelector = new ListSelectorHider();
-
- private Handler mHandler = new Handler();
-
- private Rect mTempRect = new Rect();
-
- private boolean mModal;
-
- public static final int POSITION_PROMPT_ABOVE = 0;
- public static final int POSITION_PROMPT_BELOW = 1;
-
- public IcsListPopupWindow(Context context) {
- this(context, null, R.attr.listPopupWindowStyle);
- }
-
- public IcsListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr) {
- mContext = context;
- mPopup = new PopupWindow(context, attrs, defStyleAttr);
- mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
- }
-
- public IcsListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- mContext = context;
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
- Context wrapped = new ContextThemeWrapper(context, defStyleRes);
- mPopup = new PopupWindow(wrapped, attrs, defStyleAttr);
- } else {
- mPopup = new PopupWindow(context, attrs, defStyleAttr, defStyleRes);
- }
- mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
- }
-
- public void setAdapter(ListAdapter adapter) {
- if (mObserver == null) {
- mObserver = new PopupDataSetObserver();
- } else if (mAdapter != null) {
- mAdapter.unregisterDataSetObserver(mObserver);
- }
- mAdapter = adapter;
- if (mAdapter != null) {
- adapter.registerDataSetObserver(mObserver);
- }
-
- if (mDropDownList != null) {
- mDropDownList.setAdapter(mAdapter);
- }
- }
-
- public void setPromptPosition(int position) {
- mPromptPosition = position;
- }
-
- public void setModal(boolean modal) {
- mModal = true;
- mPopup.setFocusable(modal);
- }
-
- public void setBackgroundDrawable(Drawable d) {
- mPopup.setBackgroundDrawable(d);
- }
-
- public void setAnchorView(View anchor) {
- mDropDownAnchorView = anchor;
- }
-
- public void setHorizontalOffset(int offset) {
- mDropDownHorizontalOffset = offset;
- }
-
- public void setVerticalOffset(int offset) {
- mDropDownVerticalOffset = offset;
- mDropDownVerticalOffsetSet = true;
- }
-
- public void setContentWidth(int width) {
- Drawable popupBackground = mPopup.getBackground();
- if (popupBackground != null) {
- popupBackground.getPadding(mTempRect);
- mDropDownWidth = mTempRect.left + mTempRect.right + width;
- } else {
- mDropDownWidth = width;
- }
- }
-
- public void setOnItemClickListener(AdapterView.OnItemClickListener clickListener) {
- mItemClickListener = clickListener;
- }
-
- public void show() {
- int height = buildDropDown();
-
- int widthSpec = 0;
- int heightSpec = 0;
-
- boolean noInputMethod = isInputMethodNotNeeded();
- //XXX mPopup.setAllowScrollingAnchorParent(!noInputMethod);
-
- if (mPopup.isShowing()) {
- if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) {
- // The call to PopupWindow's update method below can accept -1 for any
- // value you do not want to update.
- widthSpec = -1;
- } else if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) {
- widthSpec = mDropDownAnchorView.getWidth();
- } else {
- widthSpec = mDropDownWidth;
- }
-
- if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
- // The call to PopupWindow's update method below can accept -1 for any
- // value you do not want to update.
- heightSpec = noInputMethod ? height : ViewGroup.LayoutParams.MATCH_PARENT;
- if (noInputMethod) {
- mPopup.setWindowLayoutMode(
- mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ?
- ViewGroup.LayoutParams.MATCH_PARENT : 0, 0);
- } else {
- mPopup.setWindowLayoutMode(
- mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ?
- ViewGroup.LayoutParams.MATCH_PARENT : 0,
- ViewGroup.LayoutParams.MATCH_PARENT);
- }
- } else if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) {
- heightSpec = height;
- } else {
- heightSpec = mDropDownHeight;
- }
-
- mPopup.setOutsideTouchable(true);
-
- mPopup.update(mDropDownAnchorView, mDropDownHorizontalOffset,
- mDropDownVerticalOffset, widthSpec, heightSpec);
- } else {
- if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) {
- widthSpec = ViewGroup.LayoutParams.MATCH_PARENT;
- } else {
- if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) {
- mPopup.setWidth(mDropDownAnchorView.getWidth());
- } else {
- mPopup.setWidth(mDropDownWidth);
- }
- }
-
- if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
- heightSpec = ViewGroup.LayoutParams.MATCH_PARENT;
- } else {
- if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) {
- mPopup.setHeight(height);
- } else {
- mPopup.setHeight(mDropDownHeight);
- }
- }
-
- mPopup.setWindowLayoutMode(widthSpec, heightSpec);
- //XXX mPopup.setClipToScreenEnabled(true);
-
- // use outside touchable to dismiss drop down when touching outside of it, so
- // only set this if the dropdown is not always visible
- mPopup.setOutsideTouchable(true);
- mPopup.setTouchInterceptor(mTouchInterceptor);
- mPopup.showAsDropDown(mDropDownAnchorView,
- mDropDownHorizontalOffset, mDropDownVerticalOffset);
- mDropDownList.setSelection(ListView.INVALID_POSITION);
-
- if (!mModal || mDropDownList.isInTouchMode()) {
- clearListSelection();
- }
- if (!mModal) {
- mHandler.post(mHideSelector);
- }
- }
- }
-
- public void dismiss() {
- mPopup.dismiss();
- if (mPromptView != null) {
- final ViewParent parent = mPromptView.getParent();
- if (parent instanceof ViewGroup) {
- final ViewGroup group = (ViewGroup) parent;
- group.removeView(mPromptView);
- }
- }
- mPopup.setContentView(null);
- mDropDownList = null;
- mHandler.removeCallbacks(mResizePopupRunnable);
- }
-
- public void setOnDismissListener(PopupWindow.OnDismissListener listener) {
- mPopup.setOnDismissListener(listener);
- }
-
- public void setInputMethodMode(int mode) {
- mPopup.setInputMethodMode(mode);
- }
-
- public void clearListSelection() {
- final DropDownListView list = mDropDownList;
- if (list != null) {
- // WARNING: Please read the comment where mListSelectionHidden is declared
- list.mListSelectionHidden = true;
- //XXX list.hideSelector();
- list.requestLayout();
- }
- }
-
- public boolean isShowing() {
- return mPopup.isShowing();
- }
-
- private boolean isInputMethodNotNeeded() {
- return mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED;
- }
-
- public ListView getListView() {
- return mDropDownList;
- }
-
- private int buildDropDown() {
- ViewGroup dropDownView;
- int otherHeights = 0;
-
- if (mDropDownList == null) {
- Context context = mContext;
-
- mDropDownList = new DropDownListView(context, !mModal);
- if (mDropDownListHighlight != null) {
- mDropDownList.setSelector(mDropDownListHighlight);
- }
- mDropDownList.setAdapter(mAdapter);
- mDropDownList.setOnItemClickListener(mItemClickListener);
- mDropDownList.setFocusable(true);
- mDropDownList.setFocusableInTouchMode(true);
- mDropDownList.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- public void onItemSelected(AdapterView> parent, View view,
- int position, long id) {
-
- if (position != -1) {
- DropDownListView dropDownList = mDropDownList;
-
- if (dropDownList != null) {
- dropDownList.mListSelectionHidden = false;
- }
- }
- }
-
- public void onNothingSelected(AdapterView> parent) {
- }
- });
- mDropDownList.setOnScrollListener(mScrollListener);
-
- if (mItemSelectedListener != null) {
- mDropDownList.setOnItemSelectedListener(mItemSelectedListener);
- }
-
- dropDownView = mDropDownList;
-
- View hintView = mPromptView;
- if (hintView != null) {
- // if an hint has been specified, we accomodate more space for it and
- // add a text view in the drop down menu, at the bottom of the list
- LinearLayout hintContainer = new LinearLayout(context);
- hintContainer.setOrientation(LinearLayout.VERTICAL);
-
- LinearLayout.LayoutParams hintParams = new LinearLayout.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT, 0, 1.0f
- );
-
- switch (mPromptPosition) {
- case POSITION_PROMPT_BELOW:
- hintContainer.addView(dropDownView, hintParams);
- hintContainer.addView(hintView);
- break;
-
- case POSITION_PROMPT_ABOVE:
- hintContainer.addView(hintView);
- hintContainer.addView(dropDownView, hintParams);
- break;
-
- default:
- break;
- }
-
- // measure the hint's height to find how much more vertical space
- // we need to add to the drop down's height
- int widthSpec = MeasureSpec.makeMeasureSpec(mDropDownWidth, MeasureSpec.AT_MOST);
- int heightSpec = MeasureSpec.UNSPECIFIED;
- hintView.measure(widthSpec, heightSpec);
-
- hintParams = (LinearLayout.LayoutParams) hintView.getLayoutParams();
- otherHeights = hintView.getMeasuredHeight() + hintParams.topMargin
- + hintParams.bottomMargin;
-
- dropDownView = hintContainer;
- }
-
- mPopup.setContentView(dropDownView);
- } else {
- dropDownView = (ViewGroup) mPopup.getContentView();
- final View view = mPromptView;
- if (view != null) {
- LinearLayout.LayoutParams hintParams =
- (LinearLayout.LayoutParams) view.getLayoutParams();
- otherHeights = view.getMeasuredHeight() + hintParams.topMargin
- + hintParams.bottomMargin;
- }
- }
-
- // getMaxAvailableHeight() subtracts the padding, so we put it back
- // to get the available height for the whole window
- int padding = 0;
- Drawable background = mPopup.getBackground();
- if (background != null) {
- background.getPadding(mTempRect);
- padding = mTempRect.top + mTempRect.bottom;
-
- // If we don't have an explicit vertical offset, determine one from the window
- // background so that content will line up.
- if (!mDropDownVerticalOffsetSet) {
- mDropDownVerticalOffset = -mTempRect.top;
- }
- }
-
- // Max height available on the screen for a popup.
- boolean ignoreBottomDecorations =
- mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED;
- final int maxHeight = /*mPopup.*/getMaxAvailableHeight(
- mDropDownAnchorView, mDropDownVerticalOffset, ignoreBottomDecorations);
-
- if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
- return maxHeight + padding;
- }
-
- final int listContent = /*mDropDownList.*/measureHeightOfChildren(MeasureSpec.UNSPECIFIED,
- 0, -1/*ListView.NO_POSITION*/, maxHeight - otherHeights, -1);
- // add padding only if the list has items in it, that way we don't show
- // the popup if it is not needed
- if (listContent > 0) otherHeights += padding;
-
- return listContent + otherHeights;
- }
-
- private int getMaxAvailableHeight(View anchor, int yOffset, boolean ignoreBottomDecorations) {
- final Rect displayFrame = new Rect();
- anchor.getWindowVisibleDisplayFrame(displayFrame);
-
- final int[] anchorPos = new int[2];
- anchor.getLocationOnScreen(anchorPos);
-
- int bottomEdge = displayFrame.bottom;
- if (ignoreBottomDecorations) {
- Resources res = anchor.getContext().getResources();
- bottomEdge = res.getDisplayMetrics().heightPixels;
- }
- final int distanceToBottom = bottomEdge - (anchorPos[1] + anchor.getHeight()) - yOffset;
- final int distanceToTop = anchorPos[1] - displayFrame.top + yOffset;
-
- // anchorPos[1] is distance from anchor to top of screen
- int returnedHeight = Math.max(distanceToBottom, distanceToTop);
- if (mPopup.getBackground() != null) {
- mPopup.getBackground().getPadding(mTempRect);
- returnedHeight -= mTempRect.top + mTempRect.bottom;
- }
-
- return returnedHeight;
- }
-
- private int measureHeightOfChildren(int widthMeasureSpec, int startPosition, int endPosition,
- final int maxHeight, int disallowPartialChildPosition) {
-
- final ListAdapter adapter = mAdapter;
- if (adapter == null) {
- return mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom();
- }
-
- // Include the padding of the list
- int returnedHeight = mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom();
- final int dividerHeight = ((mDropDownList.getDividerHeight() > 0) && mDropDownList.getDivider() != null) ? mDropDownList.getDividerHeight() : 0;
- // The previous height value that was less than maxHeight and contained
- // no partial children
- int prevHeightWithoutPartialChild = 0;
- int i;
- View child;
-
- // mItemCount - 1 since endPosition parameter is inclusive
- endPosition = (endPosition == -1/*NO_POSITION*/) ? adapter.getCount() - 1 : endPosition;
-
- for (i = startPosition; i <= endPosition; ++i) {
- child = mAdapter.getView(i, null, mDropDownList);
- if (mDropDownList.getCacheColorHint() != 0) {
- child.setDrawingCacheBackgroundColor(mDropDownList.getCacheColorHint());
- }
-
- measureScrapChild(child, i, widthMeasureSpec);
-
- if (i > 0) {
- // Count the divider for all but one child
- returnedHeight += dividerHeight;
- }
-
- returnedHeight += child.getMeasuredHeight();
-
- if (returnedHeight >= maxHeight) {
- // We went over, figure out which height to return. If returnedHeight > maxHeight,
- // then the i'th position did not fit completely.
- return (disallowPartialChildPosition >= 0) // Disallowing is enabled (> -1)
- && (i > disallowPartialChildPosition) // We've past the min pos
- && (prevHeightWithoutPartialChild > 0) // We have a prev height
- && (returnedHeight != maxHeight) // i'th child did not fit completely
- ? prevHeightWithoutPartialChild
- : maxHeight;
- }
-
- if ((disallowPartialChildPosition >= 0) && (i >= disallowPartialChildPosition)) {
- prevHeightWithoutPartialChild = returnedHeight;
- }
- }
-
- // At this point, we went through the range of children, and they each
- // completely fit, so return the returnedHeight
- return returnedHeight;
- }
- private void measureScrapChild(View child, int position, int widthMeasureSpec) {
- ListView.LayoutParams p = (ListView.LayoutParams) child.getLayoutParams();
- if (p == null) {
- p = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.WRAP_CONTENT, 0);
- child.setLayoutParams(p);
- }
- //XXX p.viewType = mAdapter.getItemViewType(position);
- //XXX p.forceAdd = true;
-
- int childWidthSpec = ViewGroup.getChildMeasureSpec(widthMeasureSpec,
- mDropDownList.getPaddingLeft() + mDropDownList.getPaddingRight(), p.width);
- int lpHeight = p.height;
- int childHeightSpec;
- if (lpHeight > 0) {
- childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY);
- } else {
- childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
- }
- child.measure(childWidthSpec, childHeightSpec);
- }
-
- private static class DropDownListView extends ListView {
- /*
- * WARNING: This is a workaround for a touch mode issue.
- *
- * Touch mode is propagated lazily to windows. This causes problems in
- * the following scenario:
- * - Type something in the AutoCompleteTextView and get some results
- * - Move down with the d-pad to select an item in the list
- * - Move up with the d-pad until the selection disappears
- * - Type more text in the AutoCompleteTextView *using the soft keyboard*
- * and get new results; you are now in touch mode
- * - The selection comes back on the first item in the list, even though
- * the list is supposed to be in touch mode
- *
- * Using the soft keyboard triggers the touch mode change but that change
- * is propagated to our window only after the first list layout, therefore
- * after the list attempts to resurrect the selection.
- *
- * The trick to work around this issue is to pretend the list is in touch
- * mode when we know that the selection should not appear, that is when
- * we know the user moved the selection away from the list.
- *
- * This boolean is set to true whenever we explicitly hide the list's
- * selection and reset to false whenever we know the user moved the
- * selection back to the list.
- *
- * When this boolean is true, isInTouchMode() returns true, otherwise it
- * returns super.isInTouchMode().
- */
- private boolean mListSelectionHidden;
-
- private boolean mHijackFocus;
-
- public DropDownListView(Context context, boolean hijackFocus) {
- super(context, null, /*com.android.internal.*/R.attr.dropDownListViewStyle);
- mHijackFocus = hijackFocus;
- // TODO: Add an API to control this
- setCacheColorHint(0); // Transparent, since the background drawable could be anything.
- }
-
- //XXX @Override
- //View obtainView(int position, boolean[] isScrap) {
- // View view = super.obtainView(position, isScrap);
-
- // if (view instanceof TextView) {
- // ((TextView) view).setHorizontallyScrolling(true);
- // }
-
- // return view;
- //}
-
- @Override
- public boolean isInTouchMode() {
- // WARNING: Please read the comment where mListSelectionHidden is declared
- return (mHijackFocus && mListSelectionHidden) || super.isInTouchMode();
- }
-
- @Override
- public boolean hasWindowFocus() {
- return mHijackFocus || super.hasWindowFocus();
- }
-
- @Override
- public boolean isFocused() {
- return mHijackFocus || super.isFocused();
- }
-
- @Override
- public boolean hasFocus() {
- return mHijackFocus || super.hasFocus();
- }
- }
-
- private class PopupDataSetObserver extends DataSetObserver {
- @Override
- public void onChanged() {
- if (isShowing()) {
- // Resize the popup to fit new content
- show();
- }
- }
-
- @Override
- public void onInvalidated() {
- dismiss();
- }
- }
-
- private class ListSelectorHider implements Runnable {
- public void run() {
- clearListSelection();
- }
- }
-
- private class ResizePopupRunnable implements Runnable {
- public void run() {
- if (mDropDownList != null && mDropDownList.getCount() > mDropDownList.getChildCount() &&
- mDropDownList.getChildCount() <= mListItemExpandMaximum) {
- mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
- show();
- }
- }
- }
-
- private class PopupTouchInterceptor implements OnTouchListener {
- public boolean onTouch(View v, MotionEvent event) {
- final int action = event.getAction();
- final int x = (int) event.getX();
- final int y = (int) event.getY();
-
- if (action == MotionEvent.ACTION_DOWN &&
- mPopup != null && mPopup.isShowing() &&
- (x >= 0 && x < mPopup.getWidth() && y >= 0 && y < mPopup.getHeight())) {
- mHandler.postDelayed(mResizePopupRunnable, EXPAND_LIST_TIMEOUT);
- } else if (action == MotionEvent.ACTION_UP) {
- mHandler.removeCallbacks(mResizePopupRunnable);
- }
- return false;
- }
- }
-
- private class PopupScrollListener implements ListView.OnScrollListener {
- public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
- int totalItemCount) {
-
- }
-
- public void onScrollStateChanged(AbsListView view, int scrollState) {
- if (scrollState == SCROLL_STATE_TOUCH_SCROLL &&
- !isInputMethodNotNeeded() && mPopup.getContentView() != null) {
- mHandler.removeCallbacks(mResizePopupRunnable);
- mResizePopupRunnable.run();
- }
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java
deleted file mode 100644
index 1c02d4acad..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java
+++ /dev/null
@@ -1,1193 +0,0 @@
-/*
- * Copyright (C) 2006 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.actionbarsherlock.internal.widget;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Bitmap;
-import android.graphics.BitmapShader;
-import android.graphics.Canvas;
-import android.graphics.Rect;
-import android.graphics.Shader;
-import android.graphics.drawable.Animatable;
-import android.graphics.drawable.AnimationDrawable;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.ClipDrawable;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.LayerDrawable;
-import android.graphics.drawable.ShapeDrawable;
-import android.graphics.drawable.shapes.RoundRectShape;
-import android.graphics.drawable.shapes.Shape;
-import android.os.Build;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.os.SystemClock;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewDebug;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityManager;
-import android.view.animation.AlphaAnimation;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
-import android.view.animation.Interpolator;
-import android.view.animation.LinearInterpolator;
-import android.view.animation.Transformation;
-import android.widget.RemoteViews.RemoteView;
-
-
-/**
- *
- * Visual indicator of progress in some operation. Displays a bar to the user
- * representing how far the operation has progressed; the application can
- * change the amount of progress (modifying the length of the bar) as it moves
- * forward. There is also a secondary progress displayable on a progress bar
- * which is useful for displaying intermediate progress, such as the buffer
- * level during a streaming playback progress bar.
- *
- *
- *
- * A progress bar can also be made indeterminate. In indeterminate mode, the
- * progress bar shows a cyclic animation without an indication of progress. This mode is used by
- * applications when the length of the task is unknown. The indeterminate progress bar can be either
- * a spinning wheel or a horizontal bar.
- *
- *
- *
The following code example shows how a progress bar can be used from
- * a worker thread to update the user interface to notify the user of progress:
- *
To add a progress bar to a layout file, you can use the {@code <ProgressBar>} element.
- * By default, the progress bar is a spinning wheel (an indeterminate indicator). To change to a
- * horizontal progress bar, apply the {@link android.R.style#Widget_ProgressBar_Horizontal
- * Widget.ProgressBar.Horizontal} style, like so:
If you will use the progress bar to show real progress, you must use the horizontal bar. You
- * can then increment the progress with {@link #incrementProgressBy incrementProgressBy()} or
- * {@link #setProgress setProgress()}. By default, the progress bar is full when it reaches 100. If
- * necessary, you can adjust the maximum value (the value for a full bar) using the {@link
- * android.R.styleable#ProgressBar_max android:max} attribute. Other attributes available are listed
- * below.
- *
- *
Another common style to apply to the progress bar is {@link
- * android.R.style#Widget_ProgressBar_Small Widget.ProgressBar.Small}, which shows a smaller
- * version of the spinning wheel—useful when waiting for content to load.
- * For example, you can insert this kind of progress bar into your default layout for
- * a view that will be populated by some content fetched from the Internet—the spinning wheel
- * appears immediately and when your application receives the content, it replaces the progress bar
- * with the loaded content. For example:
The "inverse" styles provide an inverse color scheme for the spinner, which may be necessary
- * if your application uses a light colored theme (a white background).
Indicate whether this progress bar is in indeterminate mode.
- *
- * @return true if the progress bar is in indeterminate mode
- */
- @ViewDebug.ExportedProperty(category = "progress")
- public synchronized boolean isIndeterminate() {
- return mIndeterminate;
- }
-
- /**
- *
Change the indeterminate mode for this progress bar. In indeterminate
- * mode, the progress is ignored and the progress bar shows an infinite
- * animation instead.
- *
- * If this progress bar's style only supports indeterminate mode (such as the circular
- * progress bars), then this will be ignored.
- *
- * @param indeterminate true to enable the indeterminate mode
- */
- public synchronized void setIndeterminate(boolean indeterminate) {
- if ((!mOnlyIndeterminate || !mIndeterminate) && indeterminate != mIndeterminate) {
- mIndeterminate = indeterminate;
-
- if (indeterminate) {
- // swap between indeterminate and regular backgrounds
- mCurrentDrawable = mIndeterminateDrawable;
- startAnimation();
- } else {
- mCurrentDrawable = mProgressDrawable;
- stopAnimation();
- }
- }
- }
-
- /**
- *
Get the drawable used to draw the progress bar in
- * indeterminate mode.
- *
- * @attr ref android.R.styleable#Spinner_prompt
- */
-public class IcsSpinner extends IcsAbsSpinner implements OnClickListener {
- //private static final String TAG = "Spinner";
-
- // Only measure this many items to get a decent max width.
- private static final int MAX_ITEMS_MEASURED = 15;
-
- /**
- * Use a dialog window for selecting spinner options.
- */
- //public static final int MODE_DIALOG = 0;
-
- /**
- * Use a dropdown anchored to the Spinner for selecting spinner options.
- */
- public static final int MODE_DROPDOWN = 1;
-
- /**
- * Use the theme-supplied value to select the dropdown mode.
- */
- //private static final int MODE_THEME = -1;
-
- private SpinnerPopup mPopup;
- private DropDownAdapter mTempAdapter;
- int mDropDownWidth;
-
- private int mGravity;
- private boolean mDisableChildrenWhenDisabled;
-
- private Rect mTempRect = new Rect();
-
- public IcsSpinner(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.actionDropDownStyle);
- }
-
- /**
- * Construct a new spinner with the given context's theme, the supplied attribute set,
- * and default style.
- *
- * @param context The Context the view is running in, through which it can
- * access the current theme, resources, etc.
- * @param attrs The attributes of the XML tag that is inflating the view.
- * @param defStyle The default style to apply to this view. If 0, no style
- * will be applied (beyond what is included in the theme). This may
- * either be an attribute resource, whose value will be retrieved
- * from the current theme, or an explicit style resource.
- */
- public IcsSpinner(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
-
- TypedArray a = context.obtainStyledAttributes(attrs,
- R.styleable.SherlockSpinner, defStyle, 0);
-
-
- DropdownPopup popup = new DropdownPopup(context, attrs, defStyle);
-
- mDropDownWidth = a.getLayoutDimension(
- R.styleable.SherlockSpinner_android_dropDownWidth,
- ViewGroup.LayoutParams.WRAP_CONTENT);
- popup.setBackgroundDrawable(a.getDrawable(
- R.styleable.SherlockSpinner_android_popupBackground));
- final int verticalOffset = a.getDimensionPixelOffset(
- R.styleable.SherlockSpinner_android_dropDownVerticalOffset, 0);
- if (verticalOffset != 0) {
- popup.setVerticalOffset(verticalOffset);
- }
-
- final int horizontalOffset = a.getDimensionPixelOffset(
- R.styleable.SherlockSpinner_android_dropDownHorizontalOffset, 0);
- if (horizontalOffset != 0) {
- popup.setHorizontalOffset(horizontalOffset);
- }
-
- mPopup = popup;
-
- mGravity = a.getInt(R.styleable.SherlockSpinner_android_gravity, Gravity.CENTER);
-
- mPopup.setPromptText(a.getString(R.styleable.SherlockSpinner_android_prompt));
-
- mDisableChildrenWhenDisabled = true;
-
- a.recycle();
-
- // Base constructor can call setAdapter before we initialize mPopup.
- // Finish setting things up if this happened.
- if (mTempAdapter != null) {
- mPopup.setAdapter(mTempAdapter);
- mTempAdapter = null;
- }
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- super.setEnabled(enabled);
- if (mDisableChildrenWhenDisabled) {
- final int count = getChildCount();
- for (int i = 0; i < count; i++) {
- getChildAt(i).setEnabled(enabled);
- }
- }
- }
-
- /**
- * Describes how the selected item view is positioned. Currently only the horizontal component
- * is used. The default is determined by the current theme.
- *
- * @param gravity See {@link android.view.Gravity}
- *
- * @attr ref android.R.styleable#Spinner_gravity
- */
- public void setGravity(int gravity) {
- if (mGravity != gravity) {
- if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == 0) {
- gravity |= Gravity.LEFT;
- }
- mGravity = gravity;
- requestLayout();
- }
- }
-
- @Override
- public void setAdapter(SpinnerAdapter adapter) {
- super.setAdapter(adapter);
-
- if (mPopup != null) {
- mPopup.setAdapter(new DropDownAdapter(adapter));
- } else {
- mTempAdapter = new DropDownAdapter(adapter);
- }
- }
-
- @Override
- public int getBaseline() {
- View child = null;
-
- if (getChildCount() > 0) {
- child = getChildAt(0);
- } else if (mAdapter != null && mAdapter.getCount() > 0) {
- child = makeAndAddView(0);
- mRecycler.put(0, child);
- removeAllViewsInLayout();
- }
-
- if (child != null) {
- final int childBaseline = child.getBaseline();
- return childBaseline >= 0 ? child.getTop() + childBaseline : -1;
- } else {
- return -1;
- }
- }
-
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
-
- if (mPopup != null && mPopup.isShowing()) {
- mPopup.dismiss();
- }
- }
-
- /**
- *
A spinner does not support item click events. Calling this method
- * will raise an exception.
- *
- * @param l this listener will be ignored
- */
- @Override
- public void setOnItemClickListener(OnItemClickListener l) {
- throw new RuntimeException("setOnItemClickListener cannot be used with a spinner.");
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- if (mPopup != null && MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.AT_MOST) {
- final int measuredWidth = getMeasuredWidth();
- setMeasuredDimension(Math.min(Math.max(measuredWidth,
- measureContentWidth(getAdapter(), getBackground())),
- MeasureSpec.getSize(widthMeasureSpec)),
- getMeasuredHeight());
- }
- }
-
- /**
- * @see android.view.View#onLayout(boolean,int,int,int,int)
- *
- * Creates and positions all views
- *
- */
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- super.onLayout(changed, l, t, r, b);
- mInLayout = true;
- layout(0, false);
- mInLayout = false;
- }
-
- /**
- * Creates and positions all views for this Spinner.
- *
- * @param delta Change in the selected position. +1 moves selection is moving to the right,
- * so views are scrolling to the left. -1 means selection is moving to the left.
- */
- @Override
- void layout(int delta, boolean animate) {
- int childrenLeft = mSpinnerPadding.left;
- int childrenWidth = getRight() - getLeft() - mSpinnerPadding.left - mSpinnerPadding.right;
-
- if (mDataChanged) {
- handleDataChanged();
- }
-
- // Handle the empty set by removing all views
- if (mItemCount == 0) {
- resetList();
- return;
- }
-
- if (mNextSelectedPosition >= 0) {
- setSelectedPositionInt(mNextSelectedPosition);
- }
-
- recycleAllViews();
-
- // Clear out old views
- removeAllViewsInLayout();
-
- // Make selected view and position it
- mFirstPosition = mSelectedPosition;
- View sel = makeAndAddView(mSelectedPosition);
- int width = sel.getMeasuredWidth();
- int selectedOffset = childrenLeft;
- switch (mGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
- case Gravity.CENTER_HORIZONTAL:
- selectedOffset = childrenLeft + (childrenWidth / 2) - (width / 2);
- break;
- case Gravity.RIGHT:
- selectedOffset = childrenLeft + childrenWidth - width;
- break;
- }
- sel.offsetLeftAndRight(selectedOffset);
-
- // Flush any cached views that did not get reused above
- mRecycler.clear();
-
- invalidate();
-
- checkSelectionChanged();
-
- mDataChanged = false;
- mNeedSync = false;
- setNextSelectedPositionInt(mSelectedPosition);
- }
-
- /**
- * Obtain a view, either by pulling an existing view from the recycler or
- * by getting a new one from the adapter. If we are animating, make sure
- * there is enough information in the view's layout parameters to animate
- * from the old to new positions.
- *
- * @param position Position in the spinner for the view to obtain
- * @return A view that has been added to the spinner
- */
- private View makeAndAddView(int position) {
-
- View child;
-
- if (!mDataChanged) {
- child = mRecycler.get(position);
- if (child != null) {
- // Position the view
- setUpChild(child);
-
- return child;
- }
- }
-
- // Nothing found in the recycler -- ask the adapter for a view
- child = mAdapter.getView(position, null, this);
-
- // Position the view
- setUpChild(child);
-
- return child;
- }
-
- /**
- * Helper for makeAndAddView to set the position of a view
- * and fill out its layout paramters.
- *
- * @param child The view to position
- */
- private void setUpChild(View child) {
-
- // Respect layout params that are already in the view. Otherwise
- // make some up...
- ViewGroup.LayoutParams lp = child.getLayoutParams();
- if (lp == null) {
- lp = generateDefaultLayoutParams();
- }
-
- addViewInLayout(child, 0, lp);
-
- child.setSelected(hasFocus());
- if (mDisableChildrenWhenDisabled) {
- child.setEnabled(isEnabled());
- }
-
- // Get measure specs
- int childHeightSpec = ViewGroup.getChildMeasureSpec(mHeightMeasureSpec,
- mSpinnerPadding.top + mSpinnerPadding.bottom, lp.height);
- int childWidthSpec = ViewGroup.getChildMeasureSpec(mWidthMeasureSpec,
- mSpinnerPadding.left + mSpinnerPadding.right, lp.width);
-
- // Measure child
- child.measure(childWidthSpec, childHeightSpec);
-
- int childLeft;
- int childRight;
-
- // Position vertically based on gravity setting
- int childTop = mSpinnerPadding.top
- + ((getMeasuredHeight() - mSpinnerPadding.bottom -
- mSpinnerPadding.top - child.getMeasuredHeight()) / 2);
- int childBottom = childTop + child.getMeasuredHeight();
-
- int width = child.getMeasuredWidth();
- childLeft = 0;
- childRight = childLeft + width;
-
- child.layout(childLeft, childTop, childRight, childBottom);
- }
-
- @Override
- public boolean performClick() {
- boolean handled = super.performClick();
-
- if (!handled) {
- handled = true;
-
- if (!mPopup.isShowing()) {
- mPopup.show();
- }
- }
-
- return handled;
- }
-
- public void onClick(DialogInterface dialog, int which) {
- setSelection(which);
- dialog.dismiss();
- }
-
- /**
- * Sets the prompt to display when the dialog is shown.
- * @param prompt the prompt to set
- */
- public void setPrompt(CharSequence prompt) {
- mPopup.setPromptText(prompt);
- }
-
- /**
- * Sets the prompt to display when the dialog is shown.
- * @param promptId the resource ID of the prompt to display when the dialog is shown
- */
- public void setPromptId(int promptId) {
- setPrompt(getContext().getText(promptId));
- }
-
- /**
- * @return The prompt to display when the dialog is shown
- */
- public CharSequence getPrompt() {
- return mPopup.getHintText();
- }
-
- int measureContentWidth(SpinnerAdapter adapter, Drawable background) {
- if (adapter == null) {
- return 0;
- }
-
- int width = 0;
- View itemView = null;
- int itemType = 0;
- final int widthMeasureSpec =
- MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
- final int heightMeasureSpec =
- MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
-
- // Make sure the number of items we'll measure is capped. If it's a huge data set
- // with wildly varying sizes, oh well.
- int start = Math.max(0, getSelectedItemPosition());
- final int end = Math.min(adapter.getCount(), start + MAX_ITEMS_MEASURED);
- final int count = end - start;
- start = Math.max(0, start - (MAX_ITEMS_MEASURED - count));
- for (int i = start; i < end; i++) {
- final int positionType = adapter.getItemViewType(i);
- if (positionType != itemType) {
- itemType = positionType;
- itemView = null;
- }
- itemView = adapter.getView(i, itemView, this);
- if (itemView.getLayoutParams() == null) {
- itemView.setLayoutParams(new ViewGroup.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT,
- ViewGroup.LayoutParams.WRAP_CONTENT));
- }
- itemView.measure(widthMeasureSpec, heightMeasureSpec);
- width = Math.max(width, itemView.getMeasuredWidth());
- }
-
- // Add background padding to measured width
- if (background != null) {
- background.getPadding(mTempRect);
- width += mTempRect.left + mTempRect.right;
- }
-
- return width;
- }
-
- /**
- *
Wrapper class for an Adapter. Transforms the embedded Adapter instance
- * into a ListAdapter.
Creates a new ListAdapter wrapper for the specified adapter.
- *
- * @param adapter the Adapter to transform into a ListAdapter
- */
- public DropDownAdapter(SpinnerAdapter adapter) {
- this.mAdapter = adapter;
- if (adapter instanceof ListAdapter) {
- this.mListAdapter = (ListAdapter) adapter;
- }
- }
-
- public int getCount() {
- return mAdapter == null ? 0 : mAdapter.getCount();
- }
-
- public Object getItem(int position) {
- return mAdapter == null ? null : mAdapter.getItem(position);
- }
-
- public long getItemId(int position) {
- return mAdapter == null ? -1 : mAdapter.getItemId(position);
- }
-
- public View getView(int position, View convertView, ViewGroup parent) {
- return getDropDownView(position, convertView, parent);
- }
-
- public View getDropDownView(int position, View convertView, ViewGroup parent) {
- return mAdapter == null ? null :
- mAdapter.getDropDownView(position, convertView, parent);
- }
-
- public boolean hasStableIds() {
- return mAdapter != null && mAdapter.hasStableIds();
- }
-
- public void registerDataSetObserver(DataSetObserver observer) {
- if (mAdapter != null) {
- mAdapter.registerDataSetObserver(observer);
- }
- }
-
- public void unregisterDataSetObserver(DataSetObserver observer) {
- if (mAdapter != null) {
- mAdapter.unregisterDataSetObserver(observer);
- }
- }
-
- /**
- * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call.
- * Otherwise, return true.
- */
- public boolean areAllItemsEnabled() {
- final ListAdapter adapter = mListAdapter;
- if (adapter != null) {
- return adapter.areAllItemsEnabled();
- } else {
- return true;
- }
- }
-
- /**
- * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call.
- * Otherwise, return true.
- */
- public boolean isEnabled(int position) {
- final ListAdapter adapter = mListAdapter;
- if (adapter != null) {
- return adapter.isEnabled(position);
- } else {
- return true;
- }
- }
-
- public int getItemViewType(int position) {
- return 0;
- }
-
- public int getViewTypeCount() {
- return 1;
- }
-
- public boolean isEmpty() {
- return getCount() == 0;
- }
- }
-
- /**
- * Implements some sort of popup selection interface for selecting a spinner option.
- * Allows for different spinner modes.
- */
- private interface SpinnerPopup {
- public void setAdapter(ListAdapter adapter);
-
- /**
- * Show the popup
- */
- public void show();
-
- /**
- * Dismiss the popup
- */
- public void dismiss();
-
- /**
- * @return true if the popup is showing, false otherwise.
- */
- public boolean isShowing();
-
- /**
- * Set hint text to be displayed to the user. This should provide
- * a description of the choice being made.
- * @param hintText Hint text to set.
- */
- public void setPromptText(CharSequence hintText);
- public CharSequence getHintText();
- }
-
- /*
- private class DialogPopup implements SpinnerPopup, DialogInterface.OnClickListener {
- private AlertDialog mPopup;
- private ListAdapter mListAdapter;
- private CharSequence mPrompt;
-
- public void dismiss() {
- mPopup.dismiss();
- mPopup = null;
- }
-
- public boolean isShowing() {
- return mPopup != null ? mPopup.isShowing() : false;
- }
-
- public void setAdapter(ListAdapter adapter) {
- mListAdapter = adapter;
- }
-
- public void setPromptText(CharSequence hintText) {
- mPrompt = hintText;
- }
-
- public CharSequence getHintText() {
- return mPrompt;
- }
-
- public void show() {
- AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
- if (mPrompt != null) {
- builder.setTitle(mPrompt);
- }
- mPopup = builder.setSingleChoiceItems(mListAdapter,
- getSelectedItemPosition(), this).show();
- }
-
- public void onClick(DialogInterface dialog, int which) {
- setSelection(which);
- dismiss();
- }
- }
- */
-
- private class DropdownPopup extends IcsListPopupWindow implements SpinnerPopup {
- private CharSequence mHintText;
- private ListAdapter mAdapter;
-
- public DropdownPopup(Context context, AttributeSet attrs, int defStyleRes) {
- super(context, attrs, 0, defStyleRes);
-
- setAnchorView(IcsSpinner.this);
- setModal(true);
- setPromptPosition(POSITION_PROMPT_ABOVE);
- setOnItemClickListener(new OnItemClickListener() {
- @SuppressWarnings("rawtypes")
- public void onItemClick(AdapterView parent, View v, int position, long id) {
- IcsSpinner.this.setSelection(position);
- dismiss();
- }
- });
- }
-
- @Override
- public void setAdapter(ListAdapter adapter) {
- super.setAdapter(adapter);
- mAdapter = adapter;
- }
-
- public CharSequence getHintText() {
- return mHintText;
- }
-
- public void setPromptText(CharSequence hintText) {
- // Hint text is ignored for dropdowns, but maintain it here.
- mHintText = hintText;
- }
-
- @Override
- public void show() {
- final int spinnerPaddingLeft = IcsSpinner.this.getPaddingLeft();
- if (mDropDownWidth == WRAP_CONTENT) {
- final int spinnerWidth = IcsSpinner.this.getWidth();
- final int spinnerPaddingRight = IcsSpinner.this.getPaddingRight();
- setContentWidth(Math.max(
- measureContentWidth((SpinnerAdapter) mAdapter, getBackground()),
- spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight));
- } else if (mDropDownWidth == MATCH_PARENT) {
- final int spinnerWidth = IcsSpinner.this.getWidth();
- final int spinnerPaddingRight = IcsSpinner.this.getPaddingRight();
- setContentWidth(spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight);
- } else {
- setContentWidth(mDropDownWidth);
- }
- final Drawable background = getBackground();
- int bgOffset = 0;
- if (background != null) {
- background.getPadding(mTempRect);
- bgOffset = -mTempRect.left;
- }
- setHorizontalOffset(bgOffset + spinnerPaddingLeft);
- setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
- super.show();
- getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
- setSelection(IcsSpinner.this.getSelectedItemPosition());
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsView.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsView.java
deleted file mode 100644
index a7185d082c..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/IcsView.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.actionbarsherlock.internal.widget;
-
-import android.view.View;
-
-final class IcsView {
- //No instances
- private IcsView() {}
-
- /**
- * Return only the state bits of {@link #getMeasuredWidthAndState()}
- * and {@link #getMeasuredHeightAndState()}, combined into one integer.
- * The width component is in the regular bits {@link #MEASURED_STATE_MASK}
- * and the height component is at the shifted bits
- * {@link #MEASURED_HEIGHT_STATE_SHIFT}>>{@link #MEASURED_STATE_MASK}.
- */
- public static int getMeasuredStateInt(View child) {
- return (child.getMeasuredWidth()&View.MEASURED_STATE_MASK)
- | ((child.getMeasuredHeight()>>View.MEASURED_HEIGHT_STATE_SHIFT)
- & (View.MEASURED_STATE_MASK>>View.MEASURED_HEIGHT_STATE_SHIFT));
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java
deleted file mode 100644
index 1a532e06c1..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
- * Copyright (C) 2011 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.actionbarsherlock.internal.widget;
-
-import android.content.Context;
-import android.content.res.Configuration;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import android.text.TextUtils.TruncateAt;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.ViewParent;
-import android.view.animation.DecelerateInterpolator;
-import android.view.animation.Interpolator;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.ListView;
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.internal.nineoldandroids.animation.Animator;
-import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator;
-import com.actionbarsherlock.internal.nineoldandroids.widget.NineHorizontalScrollView;
-
-/**
- * This widget implements the dynamic action bar tab behavior that can change
- * across different configurations or circumstances.
- */
-public class ScrollingTabContainerView extends NineHorizontalScrollView
- implements IcsAdapterView.OnItemSelectedListener {
- //UNUSED private static final String TAG = "ScrollingTabContainerView";
- Runnable mTabSelector;
- private TabClickListener mTabClickListener;
-
- private IcsLinearLayout mTabLayout;
- private IcsSpinner mTabSpinner;
- private boolean mAllowCollapse;
-
- private LayoutInflater mInflater;
-
- int mMaxTabWidth;
- private int mContentHeight;
- private int mSelectedTabIndex;
-
- protected Animator mVisibilityAnim;
- protected final VisibilityAnimListener mVisAnimListener = new VisibilityAnimListener();
-
- private static final /*Time*/Interpolator sAlphaInterpolator = new DecelerateInterpolator();
-
- private static final int FADE_DURATION = 200;
-
- public ScrollingTabContainerView(Context context) {
- super(context);
- setHorizontalScrollBarEnabled(false);
-
- TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar,
- R.attr.actionBarStyle, 0);
- setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0));
- a.recycle();
-
- mInflater = LayoutInflater.from(context);
-
- mTabLayout = createTabLayout();
- addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
- ViewGroup.LayoutParams.MATCH_PARENT));
- }
-
- @Override
- public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
- final boolean lockedExpanded = widthMode == MeasureSpec.EXACTLY;
- setFillViewport(lockedExpanded);
-
- final int childCount = mTabLayout.getChildCount();
- if (childCount > 1 &&
- (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST)) {
- if (childCount > 2) {
- mMaxTabWidth = (int) (MeasureSpec.getSize(widthMeasureSpec) * 0.4f);
- } else {
- mMaxTabWidth = MeasureSpec.getSize(widthMeasureSpec) / 2;
- }
- } else {
- mMaxTabWidth = -1;
- }
-
- heightMeasureSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.EXACTLY);
-
- final boolean canCollapse = !lockedExpanded && mAllowCollapse;
-
- if (canCollapse) {
- // See if we should expand
- mTabLayout.measure(MeasureSpec.UNSPECIFIED, heightMeasureSpec);
- if (mTabLayout.getMeasuredWidth() > MeasureSpec.getSize(widthMeasureSpec)) {
- performCollapse();
- } else {
- performExpand();
- }
- } else {
- performExpand();
- }
-
- final int oldWidth = getMeasuredWidth();
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- final int newWidth = getMeasuredWidth();
-
- if (lockedExpanded && oldWidth != newWidth) {
- // Recenter the tab display if we're at a new (scrollable) size.
- setTabSelected(mSelectedTabIndex);
- }
- }
-
- /**
- * Indicates whether this view is collapsed into a dropdown menu instead
- * of traditional tabs.
- * @return true if showing as a spinner
- */
- private boolean isCollapsed() {
- return mTabSpinner != null && mTabSpinner.getParent() == this;
- }
-
- public void setAllowCollapse(boolean allowCollapse) {
- mAllowCollapse = allowCollapse;
- }
-
- private void performCollapse() {
- if (isCollapsed()) return;
-
- if (mTabSpinner == null) {
- mTabSpinner = createSpinner();
- }
- removeView(mTabLayout);
- addView(mTabSpinner, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
- ViewGroup.LayoutParams.MATCH_PARENT));
- if (mTabSpinner.getAdapter() == null) {
- mTabSpinner.setAdapter(new TabAdapter());
- }
- if (mTabSelector != null) {
- removeCallbacks(mTabSelector);
- mTabSelector = null;
- }
- mTabSpinner.setSelection(mSelectedTabIndex);
- }
-
- private boolean performExpand() {
- if (!isCollapsed()) return false;
-
- removeView(mTabSpinner);
- addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
- ViewGroup.LayoutParams.MATCH_PARENT));
- setTabSelected(mTabSpinner.getSelectedItemPosition());
- return false;
- }
-
- public void setTabSelected(int position) {
- mSelectedTabIndex = position;
- final int tabCount = mTabLayout.getChildCount();
- for (int i = 0; i < tabCount; i++) {
- final View child = mTabLayout.getChildAt(i);
- final boolean isSelected = i == position;
- child.setSelected(isSelected);
- if (isSelected) {
- animateToTab(position);
- }
- }
- }
-
- public void setContentHeight(int contentHeight) {
- mContentHeight = contentHeight;
- requestLayout();
- }
-
- private IcsLinearLayout createTabLayout() {
- final IcsLinearLayout tabLayout = (IcsLinearLayout) LayoutInflater.from(getContext())
- .inflate(R.layout.abs__action_bar_tab_bar_view, null);
- tabLayout.setLayoutParams(new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));
- return tabLayout;
- }
-
- private IcsSpinner createSpinner() {
- final IcsSpinner spinner = new IcsSpinner(getContext(), null,
- R.attr.actionDropDownStyle);
- spinner.setLayoutParams(new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));
- spinner.setOnItemSelectedListener(this);
- return spinner;
- }
-
- @Override
- protected void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
-
- // Action bar can change size on configuration changes.
- // Reread the desired height from the theme-specified style.
- TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar,
- R.attr.actionBarStyle, 0);
- setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0));
- a.recycle();
- }
-
- public void animateToVisibility(int visibility) {
- if (mVisibilityAnim != null) {
- mVisibilityAnim.cancel();
- }
- if (visibility == VISIBLE) {
- if (getVisibility() != VISIBLE) {
- setAlpha(0);
- }
- ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 1);
- anim.setDuration(FADE_DURATION);
- anim.setInterpolator(sAlphaInterpolator);
-
- anim.addListener(mVisAnimListener.withFinalVisibility(visibility));
- anim.start();
- } else {
- ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 0);
- anim.setDuration(FADE_DURATION);
- anim.setInterpolator(sAlphaInterpolator);
-
- anim.addListener(mVisAnimListener.withFinalVisibility(visibility));
- anim.start();
- }
- }
-
- public void animateToTab(final int position) {
- final View tabView = mTabLayout.getChildAt(position);
- if (mTabSelector != null) {
- removeCallbacks(mTabSelector);
- }
- mTabSelector = new Runnable() {
- public void run() {
- final int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2;
- smoothScrollTo(scrollPos, 0);
- mTabSelector = null;
- }
- };
- post(mTabSelector);
- }
-
- @Override
- public void onAttachedToWindow() {
- super.onAttachedToWindow();
- if (mTabSelector != null) {
- // Re-post the selector we saved
- post(mTabSelector);
- }
- }
-
- @Override
- public void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- if (mTabSelector != null) {
- removeCallbacks(mTabSelector);
- }
- }
-
- private TabView createTabView(ActionBar.Tab tab, boolean forAdapter) {
- //Workaround for not being able to pass a defStyle on pre-3.0
- final TabView tabView = (TabView)mInflater.inflate(R.layout.abs__action_bar_tab, null);
- tabView.init(this, tab, forAdapter);
-
- if (forAdapter) {
- tabView.setBackgroundDrawable(null);
- tabView.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT,
- mContentHeight));
- } else {
- tabView.setFocusable(true);
-
- if (mTabClickListener == null) {
- mTabClickListener = new TabClickListener();
- }
- tabView.setOnClickListener(mTabClickListener);
- }
- return tabView;
- }
-
- public void addTab(ActionBar.Tab tab, boolean setSelected) {
- TabView tabView = createTabView(tab, false);
- mTabLayout.addView(tabView, new IcsLinearLayout.LayoutParams(0,
- LayoutParams.MATCH_PARENT, 1));
- if (mTabSpinner != null) {
- ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
- }
- if (setSelected) {
- tabView.setSelected(true);
- }
- if (mAllowCollapse) {
- requestLayout();
- }
- }
-
- public void addTab(ActionBar.Tab tab, int position, boolean setSelected) {
- final TabView tabView = createTabView(tab, false);
- mTabLayout.addView(tabView, position, new IcsLinearLayout.LayoutParams(
- 0, LayoutParams.MATCH_PARENT, 1));
- if (mTabSpinner != null) {
- ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
- }
- if (setSelected) {
- tabView.setSelected(true);
- }
- if (mAllowCollapse) {
- requestLayout();
- }
- }
-
- public void updateTab(int position) {
- ((TabView) mTabLayout.getChildAt(position)).update();
- if (mTabSpinner != null) {
- ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
- }
- if (mAllowCollapse) {
- requestLayout();
- }
- }
-
- public void removeTabAt(int position) {
- mTabLayout.removeViewAt(position);
- if (mTabSpinner != null) {
- ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
- }
- if (mAllowCollapse) {
- requestLayout();
- }
- }
-
- public void removeAllTabs() {
- mTabLayout.removeAllViews();
- if (mTabSpinner != null) {
- ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
- }
- if (mAllowCollapse) {
- requestLayout();
- }
- }
-
- @Override
- public void onItemSelected(IcsAdapterView> parent, View view, int position, long id) {
- TabView tabView = (TabView) view;
- tabView.getTab().select();
- }
-
- @Override
- public void onNothingSelected(IcsAdapterView> parent) {
- }
-
- public static class TabView extends LinearLayout {
- private ScrollingTabContainerView mParent;
- private ActionBar.Tab mTab;
- private CapitalizingTextView mTextView;
- private ImageView mIconView;
- private View mCustomView;
-
- public TabView(Context context, AttributeSet attrs) {
- //TODO super(context, null, R.attr.actionBarTabStyle);
- super(context, attrs);
- }
-
- public void init(ScrollingTabContainerView parent, ActionBar.Tab tab, boolean forList) {
- mParent = parent;
- mTab = tab;
-
- if (forList) {
- setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
- }
-
- update();
- }
-
- public void bindTab(ActionBar.Tab tab) {
- mTab = tab;
- update();
- }
-
- @Override
- public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-
- // Re-measure if we went beyond our maximum size.
- if (mParent.mMaxTabWidth > 0 && getMeasuredWidth() > mParent.mMaxTabWidth) {
- super.onMeasure(MeasureSpec.makeMeasureSpec(mParent.mMaxTabWidth, MeasureSpec.EXACTLY),
- heightMeasureSpec);
- }
- }
-
- public void update() {
- final ActionBar.Tab tab = mTab;
- final View custom = tab.getCustomView();
- if (custom != null) {
- final ViewParent customParent = custom.getParent();
- if (customParent != this) {
- if (customParent != null) ((ViewGroup) customParent).removeView(custom);
- addView(custom);
- }
- mCustomView = custom;
- if (mTextView != null) mTextView.setVisibility(GONE);
- if (mIconView != null) {
- mIconView.setVisibility(GONE);
- mIconView.setImageDrawable(null);
- }
- } else {
- if (mCustomView != null) {
- removeView(mCustomView);
- mCustomView = null;
- }
-
- final Drawable icon = tab.getIcon();
- final CharSequence text = tab.getText();
-
- if (icon != null) {
- if (mIconView == null) {
- ImageView iconView = new ImageView(getContext());
- LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,
- LayoutParams.WRAP_CONTENT);
- lp.gravity = Gravity.CENTER_VERTICAL;
- iconView.setLayoutParams(lp);
- addView(iconView, 0);
- mIconView = iconView;
- }
- mIconView.setImageDrawable(icon);
- mIconView.setVisibility(VISIBLE);
- } else if (mIconView != null) {
- mIconView.setVisibility(GONE);
- mIconView.setImageDrawable(null);
- }
-
- if (text != null) {
- if (mTextView == null) {
- CapitalizingTextView textView = new CapitalizingTextView(getContext(), null,
- R.attr.actionBarTabTextStyle);
- textView.setEllipsize(TruncateAt.END);
- LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,
- LayoutParams.WRAP_CONTENT);
- lp.gravity = Gravity.CENTER_VERTICAL;
- textView.setLayoutParams(lp);
- addView(textView);
- mTextView = textView;
- }
- mTextView.setTextCompat(text);
- mTextView.setVisibility(VISIBLE);
- } else if (mTextView != null) {
- mTextView.setVisibility(GONE);
- mTextView.setText(null);
- }
-
- if (mIconView != null) {
- mIconView.setContentDescription(tab.getContentDescription());
- }
- }
- }
-
- public ActionBar.Tab getTab() {
- return mTab;
- }
- }
-
- private class TabAdapter extends BaseAdapter {
- @Override
- public int getCount() {
- return mTabLayout.getChildCount();
- }
-
- @Override
- public Object getItem(int position) {
- return ((TabView) mTabLayout.getChildAt(position)).getTab();
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- if (convertView == null) {
- convertView = createTabView((ActionBar.Tab) getItem(position), true);
- } else {
- ((TabView) convertView).bindTab((ActionBar.Tab) getItem(position));
- }
- return convertView;
- }
- }
-
- private class TabClickListener implements OnClickListener {
- public void onClick(View view) {
- TabView tabView = (TabView) view;
- tabView.getTab().select();
- final int tabCount = mTabLayout.getChildCount();
- for (int i = 0; i < tabCount; i++) {
- final View child = mTabLayout.getChildAt(i);
- child.setSelected(child == view);
- }
- }
- }
-
- protected class VisibilityAnimListener implements Animator.AnimatorListener {
- private boolean mCanceled = false;
- private int mFinalVisibility;
-
- public VisibilityAnimListener withFinalVisibility(int visibility) {
- mFinalVisibility = visibility;
- return this;
- }
-
- @Override
- public void onAnimationStart(Animator animation) {
- setVisibility(VISIBLE);
- mVisibilityAnim = animation;
- mCanceled = false;
- }
-
- @Override
- public void onAnimationEnd(Animator animation) {
- if (mCanceled) return;
-
- mVisibilityAnim = null;
- setVisibility(mFinalVisibility);
- }
-
- @Override
- public void onAnimationCancel(Animator animation) {
- mCanceled = true;
- }
-
- @Override
- public void onAnimationRepeat(Animator animation) {
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/ActionMode.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/ActionMode.java
deleted file mode 100644
index 81b4cd4d20..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/ActionMode.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright (C) 2010 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.actionbarsherlock.view;
-
-import android.view.View;
-
-
-/**
- * Represents a contextual mode of the user interface. Action modes can be used for
- * modal interactions with content and replace parts of the normal UI until finished.
- * Examples of good action modes include selection modes, search, content editing, etc.
- */
-public abstract class ActionMode {
- private Object mTag;
-
- /**
- * Set a tag object associated with this ActionMode.
- *
- *
Like the tag available to views, this allows applications to associate arbitrary
- * data with an ActionMode for later reference.
- *
- * @param tag Tag to associate with this ActionMode
- *
- * @see #getTag()
- */
- public void setTag(Object tag) {
- mTag = tag;
- }
-
- /**
- * Retrieve the tag object associated with this ActionMode.
- *
- *
Like the tag available to views, this allows applications to associate arbitrary
- * data with an ActionMode for later reference.
- *
- * @return Tag associated with this ActionMode
- *
- * @see #setTag(Object)
- */
- public Object getTag() {
- return mTag;
- }
-
- /**
- * Set the title of the action mode. This method will have no visible effect if
- * a custom view has been set.
- *
- * @param title Title string to set
- *
- * @see #setTitle(int)
- * @see #setCustomView(View)
- */
- public abstract void setTitle(CharSequence title);
-
- /**
- * Set the title of the action mode. This method will have no visible effect if
- * a custom view has been set.
- *
- * @param resId Resource ID of a string to set as the title
- *
- * @see #setTitle(CharSequence)
- * @see #setCustomView(View)
- */
- public abstract void setTitle(int resId);
-
- /**
- * Set the subtitle of the action mode. This method will have no visible effect if
- * a custom view has been set.
- *
- * @param subtitle Subtitle string to set
- *
- * @see #setSubtitle(int)
- * @see #setCustomView(View)
- */
- public abstract void setSubtitle(CharSequence subtitle);
-
- /**
- * Set the subtitle of the action mode. This method will have no visible effect if
- * a custom view has been set.
- *
- * @param resId Resource ID of a string to set as the subtitle
- *
- * @see #setSubtitle(CharSequence)
- * @see #setCustomView(View)
- */
- public abstract void setSubtitle(int resId);
-
- /**
- * Set a custom view for this action mode. The custom view will take the place of
- * the title and subtitle. Useful for things like search boxes.
- *
- * @param view Custom view to use in place of the title/subtitle.
- *
- * @see #setTitle(CharSequence)
- * @see #setSubtitle(CharSequence)
- */
- public abstract void setCustomView(View view);
-
- /**
- * Invalidate the action mode and refresh menu content. The mode's
- * {@link ActionMode.Callback} will have its
- * {@link Callback#onPrepareActionMode(ActionMode, Menu)} method called.
- * If it returns true the menu will be scanned for updated content and any relevant changes
- * will be reflected to the user.
- */
- public abstract void invalidate();
-
- /**
- * Finish and close this action mode. The action mode's {@link ActionMode.Callback} will
- * have its {@link Callback#onDestroyActionMode(ActionMode)} method called.
- */
- public abstract void finish();
-
- /**
- * Returns the menu of actions that this action mode presents.
- * @return The action mode's menu.
- */
- public abstract Menu getMenu();
-
- /**
- * Returns the current title of this action mode.
- * @return Title text
- */
- public abstract CharSequence getTitle();
-
- /**
- * Returns the current subtitle of this action mode.
- * @return Subtitle text
- */
- public abstract CharSequence getSubtitle();
-
- /**
- * Returns the current custom view for this action mode.
- * @return The current custom view
- */
- public abstract View getCustomView();
-
- /**
- * Returns a {@link MenuInflater} with the ActionMode's context.
- */
- public abstract MenuInflater getMenuInflater();
-
- /**
- * Returns whether the UI presenting this action mode can take focus or not.
- * This is used by internal components within the framework that would otherwise
- * present an action mode UI that requires focus, such as an EditText as a custom view.
- *
- * @return true if the UI used to show this action mode can take focus
- * @hide Internal use only
- */
- public boolean isUiFocusable() {
- return true;
- }
-
- /**
- * Callback interface for action modes. Supplied to
- * {@link View#startActionMode(Callback)}, a Callback
- * configures and handles events raised by a user's interaction with an action mode.
- *
- *
An action mode's lifecycle is as follows:
- *
- *
{@link Callback#onCreateActionMode(ActionMode, Menu)} once on initial
- * creation
- *
{@link Callback#onPrepareActionMode(ActionMode, Menu)} after creation
- * and any time the {@link ActionMode} is invalidated
- *
{@link Callback#onActionItemClicked(ActionMode, MenuItem)} any time a
- * contextual action button is clicked
- *
{@link Callback#onDestroyActionMode(ActionMode)} when the action mode
- * is closed
- *
- */
- public interface Callback {
- /**
- * Called when action mode is first created. The menu supplied will be used to
- * generate action buttons for the action mode.
- *
- * @param mode ActionMode being created
- * @param menu Menu used to populate action buttons
- * @return true if the action mode should be created, false if entering this
- * mode should be aborted.
- */
- public boolean onCreateActionMode(ActionMode mode, Menu menu);
-
- /**
- * Called to refresh an action mode's action menu whenever it is invalidated.
- *
- * @param mode ActionMode being prepared
- * @param menu Menu used to populate action buttons
- * @return true if the menu or action mode was updated, false otherwise.
- */
- public boolean onPrepareActionMode(ActionMode mode, Menu menu);
-
- /**
- * Called to report a user click on an action button.
- *
- * @param mode The current ActionMode
- * @param item The item that was clicked
- * @return true if this callback handled the event, false if the standard MenuItem
- * invocation should continue.
- */
- public boolean onActionItemClicked(ActionMode mode, MenuItem item);
-
- /**
- * Called when an action mode is about to be exited and destroyed.
- *
- * @param mode The current ActionMode being destroyed
- */
- public void onDestroyActionMode(ActionMode mode);
- }
-}
\ No newline at end of file
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/ActionProvider.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/ActionProvider.java
deleted file mode 100644
index ae7cb1fe03..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/ActionProvider.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (C) 2011 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.actionbarsherlock.view;
-
-import android.content.Context;
-import android.view.View;
-
-/**
- * This class is a mediator for accomplishing a given task, for example sharing a file.
- * It is responsible for creating a view that performs an action that accomplishes the task.
- * This class also implements other functions such a performing a default action.
- *
- * An ActionProvider can be optionally specified for a {@link MenuItem} and in such a
- * case it will be responsible for creating the action view that appears in the
- * {@link android.app.ActionBar} as a substitute for the menu item when the item is
- * displayed as an action item. Also the provider is responsible for performing a
- * default action if a menu item placed on the overflow menu of the ActionBar is
- * selected and none of the menu item callbacks has handled the selection. For this
- * case the provider can also optionally provide a sub-menu for accomplishing the
- * task at hand.
- *
- *
- * There are two ways for using an action provider for creating and handling of action views:
- *
- *
- * Setting the action provider on a {@link MenuItem} directly by calling
- * {@link MenuItem#setActionProvider(ActionProvider)}.
- *
- *
- * Declaring the action provider in the menu XML resource. For example:
- *
- *
- * @see MenuItem#setActionProvider(ActionProvider)
- * @see MenuItem#getActionProvider()
- */
-public abstract class ActionProvider {
- private SubUiVisibilityListener mSubUiVisibilityListener;
-
- /**
- * Creates a new instance.
- *
- * @param context Context for accessing resources.
- */
- public ActionProvider(Context context) {
- }
-
- /**
- * Factory method for creating new action views.
- *
- * @return A new action view.
- */
- public abstract View onCreateActionView();
-
- /**
- * Performs an optional default action.
- *
- * For the case of an action provider placed in a menu item not shown as an action this
- * method is invoked if previous callbacks for processing menu selection has handled
- * the event.
- *
- *
- * A menu item selection is processed in the following order:
- *
- *
- * Receiving a call to {@link MenuItem.OnMenuItemClickListener#onMenuItemClick
- * MenuItem.OnMenuItemClickListener.onMenuItemClick}.
- *
- *
- * Receiving a call to {@link android.app.Activity#onOptionsItemSelected(MenuItem)
- * Activity.onOptionsItemSelected(MenuItem)}
- *
- *
- * Receiving a call to {@link android.app.Fragment#onOptionsItemSelected(MenuItem)
- * Fragment.onOptionsItemSelected(MenuItem)}
- *
- *
- * Launching the {@link android.content.Intent} set via
- * {@link MenuItem#setIntent(android.content.Intent) MenuItem.setIntent(android.content.Intent)}
- *
- *
- * Invoking this method.
- *
- *
- *
- *
- * The default implementation does not perform any action and returns false.
- *
- */
- public boolean onPerformDefaultAction() {
- return false;
- }
-
- /**
- * Determines if this ActionProvider has a submenu associated with it.
- *
- *
Associated submenus will be shown when an action view is not. This
- * provider instance will receive a call to {@link #onPrepareSubMenu(SubMenu)}
- * after the call to {@link #onPerformDefaultAction()} and before a submenu is
- * displayed to the user.
- *
- * @return true if the item backed by this provider should have an associated submenu
- */
- public boolean hasSubMenu() {
- return false;
- }
-
- /**
- * Called to prepare an associated submenu for the menu item backed by this ActionProvider.
- *
- *
if {@link #hasSubMenu()} returns true, this method will be called when the
- * menu item is selected to prepare the submenu for presentation to the user. Apps
- * may use this to create or alter submenu content right before display.
- *
- * @param subMenu Submenu that will be displayed
- */
- public void onPrepareSubMenu(SubMenu subMenu) {
- }
-
- /**
- * Notify the system that the visibility of an action view's sub-UI such as
- * an anchored popup has changed. This will affect how other system
- * visibility notifications occur.
- *
- * @hide Pending future API approval
- */
- public void subUiVisibilityChanged(boolean isVisible) {
- if (mSubUiVisibilityListener != null) {
- mSubUiVisibilityListener.onSubUiVisibilityChanged(isVisible);
- }
- }
-
- /**
- * @hide Internal use only
- */
- public void setSubUiVisibilityListener(SubUiVisibilityListener listener) {
- mSubUiVisibilityListener = listener;
- }
-
- /**
- * @hide Internal use only
- */
- public interface SubUiVisibilityListener {
- public void onSubUiVisibilityChanged(boolean isVisible);
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java
deleted file mode 100644
index 43281b013c..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2011 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.actionbarsherlock.view;
-
-/**
- * When a {@link View} implements this interface it will receive callbacks
- * when expanded or collapsed as an action view alongside the optional,
- * app-specified callbacks to {@link OnActionExpandListener}.
- *
- *
See {@link MenuItem} for more information about action views.
- * See {@link android.app.ActionBar} for more information about the action bar.
- */
-public interface CollapsibleActionView {
- /**
- * Called when this view is expanded as an action view.
- * See {@link MenuItem#expandActionView()}.
- */
- public void onActionViewExpanded();
-
- /**
- * Called when this view is collapsed as an action view.
- * See {@link MenuItem#collapseActionView()}.
- */
- public void onActionViewCollapsed();
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/Menu.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/Menu.java
deleted file mode 100644
index 951f4ccef8..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/Menu.java
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * Copyright (C) 2006 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.actionbarsherlock.view;
-
-import android.content.ComponentName;
-import android.content.Intent;
-import android.view.KeyEvent;
-
-/**
- * Interface for managing the items in a menu.
- *
- * By default, every Activity supports an options menu of actions or options.
- * You can add items to this menu and handle clicks on your additions. The
- * easiest way of adding menu items is inflating an XML file into the
- * {@link Menu} via {@link MenuInflater}. The easiest way of attaching code to
- * clicks is via {@link Activity#onOptionsItemSelected(MenuItem)} and
- * {@link Activity#onContextItemSelected(MenuItem)}.
- *
- * Different menu types support different features:
- *
- *
Context menus: Do not support item shortcuts and item icons.
- *
Options menus: The icon menus do not support item check
- * marks and only show the item's
- * {@link MenuItem#setTitleCondensed(CharSequence) condensed title}. The
- * expanded menus (only available if six or more menu items are visible,
- * reached via the 'More' item in the icon menu) do not show item icons, and
- * item check marks are discouraged.
- *
Sub menus: Do not support item icons, or nested sub menus.
- *
- *
- *
- *
Developer Guides
- *
For more information about creating menus, read the
- * Menus developer guide.
- *
- */
-public interface Menu {
-
- /**
- * This is the part of an order integer that the user can provide.
- * @hide
- */
- static final int USER_MASK = 0x0000ffff;
- /**
- * Bit shift of the user portion of the order integer.
- * @hide
- */
- static final int USER_SHIFT = 0;
-
- /**
- * This is the part of an order integer that supplies the category of the
- * item.
- * @hide
- */
- static final int CATEGORY_MASK = 0xffff0000;
- /**
- * Bit shift of the category portion of the order integer.
- * @hide
- */
- static final int CATEGORY_SHIFT = 16;
-
- /**
- * Value to use for group and item identifier integers when you don't care
- * about them.
- */
- static final int NONE = 0;
-
- /**
- * First value for group and item identifier integers.
- */
- static final int FIRST = 1;
-
- // Implementation note: Keep these CATEGORY_* in sync with the category enum
- // in attrs.xml
-
- /**
- * Category code for the order integer for items/groups that are part of a
- * container -- or/add this with your base value.
- */
- static final int CATEGORY_CONTAINER = 0x00010000;
-
- /**
- * Category code for the order integer for items/groups that are provided by
- * the system -- or/add this with your base value.
- */
- static final int CATEGORY_SYSTEM = 0x00020000;
-
- /**
- * Category code for the order integer for items/groups that are
- * user-supplied secondary (infrequently used) options -- or/add this with
- * your base value.
- */
- static final int CATEGORY_SECONDARY = 0x00030000;
-
- /**
- * Category code for the order integer for items/groups that are
- * alternative actions on the data that is currently displayed -- or/add
- * this with your base value.
- */
- static final int CATEGORY_ALTERNATIVE = 0x00040000;
-
- /**
- * Flag for {@link #addIntentOptions}: if set, do not automatically remove
- * any existing menu items in the same group.
- */
- static final int FLAG_APPEND_TO_GROUP = 0x0001;
-
- /**
- * Flag for {@link #performShortcut}: if set, do not close the menu after
- * executing the shortcut.
- */
- static final int FLAG_PERFORM_NO_CLOSE = 0x0001;
-
- /**
- * Flag for {@link #performShortcut(int, KeyEvent, int)}: if set, always
- * close the menu after executing the shortcut. Closing the menu also resets
- * the prepared state.
- */
- static final int FLAG_ALWAYS_PERFORM_CLOSE = 0x0002;
-
- /**
- * Add a new item to the menu. This item displays the given title for its
- * label.
- *
- * @param title The text to display for the item.
- * @return The newly added menu item.
- */
- public MenuItem add(CharSequence title);
-
- /**
- * Add a new item to the menu. This item displays the given title for its
- * label.
- *
- * @param titleRes Resource identifier of title string.
- * @return The newly added menu item.
- */
- public MenuItem add(int titleRes);
-
- /**
- * Add a new item to the menu. This item displays the given title for its
- * label.
- *
- * @param groupId The group identifier that this item should be part of.
- * This can be used to define groups of items for batch state
- * changes. Normally use {@link #NONE} if an item should not be in a
- * group.
- * @param itemId Unique item ID. Use {@link #NONE} if you do not need a
- * unique ID.
- * @param order The order for the item. Use {@link #NONE} if you do not care
- * about the order. See {@link MenuItem#getOrder()}.
- * @param title The text to display for the item.
- * @return The newly added menu item.
- */
- public MenuItem add(int groupId, int itemId, int order, CharSequence title);
-
- /**
- * Variation on {@link #add(int, int, int, CharSequence)} that takes a
- * string resource identifier instead of the string itself.
- *
- * @param groupId The group identifier that this item should be part of.
- * This can also be used to define groups of items for batch state
- * changes. Normally use {@link #NONE} if an item should not be in a
- * group.
- * @param itemId Unique item ID. Use {@link #NONE} if you do not need a
- * unique ID.
- * @param order The order for the item. Use {@link #NONE} if you do not care
- * about the order. See {@link MenuItem#getOrder()}.
- * @param titleRes Resource identifier of title string.
- * @return The newly added menu item.
- */
- public MenuItem add(int groupId, int itemId, int order, int titleRes);
-
- /**
- * Add a new sub-menu to the menu. This item displays the given title for
- * its label. To modify other attributes on the submenu's menu item, use
- * {@link SubMenu#getItem()}.
- *
- * @param title The text to display for the item.
- * @return The newly added sub-menu
- */
- SubMenu addSubMenu(final CharSequence title);
-
- /**
- * Add a new sub-menu to the menu. This item displays the given title for
- * its label. To modify other attributes on the submenu's menu item, use
- * {@link SubMenu#getItem()}.
- *
- * @param titleRes Resource identifier of title string.
- * @return The newly added sub-menu
- */
- SubMenu addSubMenu(final int titleRes);
-
- /**
- * Add a new sub-menu to the menu. This item displays the given
- * title for its label. To modify other attributes on the
- * submenu's menu item, use {@link SubMenu#getItem()}.
- *
- * Note that you can only have one level of sub-menus, i.e. you cannnot add
- * a subMenu to a subMenu: An {@link UnsupportedOperationException} will be
- * thrown if you try.
- *
- * @param groupId The group identifier that this item should be part of.
- * This can also be used to define groups of items for batch state
- * changes. Normally use {@link #NONE} if an item should not be in a
- * group.
- * @param itemId Unique item ID. Use {@link #NONE} if you do not need a
- * unique ID.
- * @param order The order for the item. Use {@link #NONE} if you do not care
- * about the order. See {@link MenuItem#getOrder()}.
- * @param title The text to display for the item.
- * @return The newly added sub-menu
- */
- SubMenu addSubMenu(final int groupId, final int itemId, int order, final CharSequence title);
-
- /**
- * Variation on {@link #addSubMenu(int, int, int, CharSequence)} that takes
- * a string resource identifier for the title instead of the string itself.
- *
- * @param groupId The group identifier that this item should be part of.
- * This can also be used to define groups of items for batch state
- * changes. Normally use {@link #NONE} if an item should not be in a group.
- * @param itemId Unique item ID. Use {@link #NONE} if you do not need a unique ID.
- * @param order The order for the item. Use {@link #NONE} if you do not care about the
- * order. See {@link MenuItem#getOrder()}.
- * @param titleRes Resource identifier of title string.
- * @return The newly added sub-menu
- */
- SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes);
-
- /**
- * Add a group of menu items corresponding to actions that can be performed
- * for a particular Intent. The Intent is most often configured with a null
- * action, the data that the current activity is working with, and includes
- * either the {@link Intent#CATEGORY_ALTERNATIVE} or
- * {@link Intent#CATEGORY_SELECTED_ALTERNATIVE} to find activities that have
- * said they would like to be included as optional action. You can, however,
- * use any Intent you want.
- *
- *
- * See {@link android.content.pm.PackageManager#queryIntentActivityOptions}
- * for more * details on the caller, specifics, and
- * intent arguments. The list returned by that function is used
- * to populate the resulting menu items.
- *
- *
- * All of the menu items of possible options for the intent will be added
- * with the given group and id. You can use the group to control ordering of
- * the items in relation to other items in the menu. Normally this function
- * will automatically remove any existing items in the menu in the same
- * group and place a divider above and below the added items; this behavior
- * can be modified with the flags parameter. For each of the
- * generated items {@link MenuItem#setIntent} is called to associate the
- * appropriate Intent with the item; this means the activity will
- * automatically be started for you without having to do anything else.
- *
- * @param groupId The group identifier that the items should be part of.
- * This can also be used to define groups of items for batch state
- * changes. Normally use {@link #NONE} if the items should not be in
- * a group.
- * @param itemId Unique item ID. Use {@link #NONE} if you do not need a
- * unique ID.
- * @param order The order for the items. Use {@link #NONE} if you do not
- * care about the order. See {@link MenuItem#getOrder()}.
- * @param caller The current activity component name as defined by
- * queryIntentActivityOptions().
- * @param specifics Specific items to place first as defined by
- * queryIntentActivityOptions().
- * @param intent Intent describing the kinds of items to populate in the
- * list as defined by queryIntentActivityOptions().
- * @param flags Additional options controlling how the items are added.
- * @param outSpecificItems Optional array in which to place the menu items
- * that were generated for each of the specifics that were
- * requested. Entries may be null if no activity was found for that
- * specific action.
- * @return The number of menu items that were added.
- *
- * @see #FLAG_APPEND_TO_GROUP
- * @see MenuItem#setIntent
- * @see android.content.pm.PackageManager#queryIntentActivityOptions
- */
- public int addIntentOptions(int groupId, int itemId, int order,
- ComponentName caller, Intent[] specifics,
- Intent intent, int flags, MenuItem[] outSpecificItems);
-
- /**
- * Remove the item with the given identifier.
- *
- * @param id The item to be removed. If there is no item with this
- * identifier, nothing happens.
- */
- public void removeItem(int id);
-
- /**
- * Remove all items in the given group.
- *
- * @param groupId The group to be removed. If there are no items in this
- * group, nothing happens.
- */
- public void removeGroup(int groupId);
-
- /**
- * Remove all existing items from the menu, leaving it empty as if it had
- * just been created.
- */
- public void clear();
-
- /**
- * Control whether a particular group of items can show a check mark. This
- * is similar to calling {@link MenuItem#setCheckable} on all of the menu items
- * with the given group identifier, but in addition you can control whether
- * this group contains a mutually-exclusive set items. This should be called
- * after the items of the group have been added to the menu.
- *
- * @param group The group of items to operate on.
- * @param checkable Set to true to allow a check mark, false to
- * disallow. The default is false.
- * @param exclusive If set to true, only one item in this group can be
- * checked at a time; checking an item will automatically
- * uncheck all others in the group. If set to false, each
- * item can be checked independently of the others.
- *
- * @see MenuItem#setCheckable
- * @see MenuItem#setChecked
- */
- public void setGroupCheckable(int group, boolean checkable, boolean exclusive);
-
- /**
- * Show or hide all menu items that are in the given group.
- *
- * @param group The group of items to operate on.
- * @param visible If true the items are visible, else they are hidden.
- *
- * @see MenuItem#setVisible
- */
- public void setGroupVisible(int group, boolean visible);
-
- /**
- * Enable or disable all menu items that are in the given group.
- *
- * @param group The group of items to operate on.
- * @param enabled If true the items will be enabled, else they will be disabled.
- *
- * @see MenuItem#setEnabled
- */
- public void setGroupEnabled(int group, boolean enabled);
-
- /**
- * Return whether the menu currently has item items that are visible.
- *
- * @return True if there is one or more item visible,
- * else false.
- */
- public boolean hasVisibleItems();
-
- /**
- * Return the menu item with a particular identifier.
- *
- * @param id The identifier to find.
- *
- * @return The menu item object, or null if there is no item with
- * this identifier.
- */
- public MenuItem findItem(int id);
-
- /**
- * Get the number of items in the menu. Note that this will change any
- * times items are added or removed from the menu.
- *
- * @return The item count.
- */
- public int size();
-
- /**
- * Gets the menu item at the given index.
- *
- * @param index The index of the menu item to return.
- * @return The menu item.
- * @exception IndexOutOfBoundsException
- * when {@code index < 0 || >= size()}
- */
- public MenuItem getItem(int index);
-
- /**
- * Closes the menu, if open.
- */
- public void close();
-
- /**
- * Execute the menu item action associated with the given shortcut
- * character.
- *
- * @param keyCode The keycode of the shortcut key.
- * @param event Key event message.
- * @param flags Additional option flags or 0.
- *
- * @return If the given shortcut exists and is shown, returns
- * true; else returns false.
- *
- * @see #FLAG_PERFORM_NO_CLOSE
- */
- public boolean performShortcut(int keyCode, KeyEvent event, int flags);
-
- /**
- * Is a keypress one of the defined shortcut keys for this window.
- * @param keyCode the key code from {@link KeyEvent} to check.
- * @param event the {@link KeyEvent} to use to help check.
- */
- boolean isShortcutKey(int keyCode, KeyEvent event);
-
- /**
- * Execute the menu item action associated with the given menu identifier.
- *
- * @param id Identifier associated with the menu item.
- * @param flags Additional option flags or 0.
- *
- * @return If the given identifier exists and is shown, returns
- * true; else returns false.
- *
- * @see #FLAG_PERFORM_NO_CLOSE
- */
- public boolean performIdentifierAction(int id, int flags);
-
-
- /**
- * Control whether the menu should be running in qwerty mode (alphabetic
- * shortcuts) or 12-key mode (numeric shortcuts).
- *
- * @param isQwerty If true the menu will use alphabetic shortcuts; else it
- * will use numeric shortcuts.
- */
- public void setQwertyMode(boolean isQwerty);
-}
-
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java
deleted file mode 100644
index 9694597490..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java
+++ /dev/null
@@ -1,472 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- * 2011 Jake Wharton
- *
- * 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.actionbarsherlock.view;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.content.res.XmlResourceParser;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.util.TypedValue;
-import android.util.Xml;
-import android.view.InflateException;
-import android.view.View;
-
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.internal.view.menu.MenuItemImpl;
-
-/**
- * This class is used to instantiate menu XML files into Menu objects.
- *
- * For performance reasons, menu inflation relies heavily on pre-processing of
- * XML files that is done at build time. Therefore, it is not currently possible
- * to use MenuInflater with an XmlPullParser over a plain XML file at runtime;
- * it only works with an XmlPullParser returned from a compiled resource (R.
- * something file.)
- */
-public class MenuInflater {
- private static final String LOG_TAG = "MenuInflater";
-
- /** Menu tag name in XML. */
- private static final String XML_MENU = "menu";
-
- /** Group tag name in XML. */
- private static final String XML_GROUP = "group";
-
- /** Item tag name in XML. */
- private static final String XML_ITEM = "item";
-
- private static final int NO_ID = 0;
-
- private static final Class>[] ACTION_VIEW_CONSTRUCTOR_SIGNATURE = new Class[] {Context.class};
-
- private static final Class>[] ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE = ACTION_VIEW_CONSTRUCTOR_SIGNATURE;
-
- private final Object[] mActionViewConstructorArguments;
-
- private final Object[] mActionProviderConstructorArguments;
-
- private Context mContext;
-
- /**
- * Constructs a menu inflater.
- *
- * @see Activity#getMenuInflater()
- */
- public MenuInflater(Context context) {
- mContext = context;
- mActionViewConstructorArguments = new Object[] {context};
- mActionProviderConstructorArguments = mActionViewConstructorArguments;
- }
-
- /**
- * Inflate a menu hierarchy from the specified XML resource. Throws
- * {@link InflateException} if there is an error.
- *
- * @param menuRes Resource ID for an XML layout resource to load (e.g.,
- * R.menu.main_activity)
- * @param menu The Menu to inflate into. The items and submenus will be
- * added to this Menu.
- */
- public void inflate(int menuRes, Menu menu) {
- XmlResourceParser parser = null;
- try {
- parser = mContext.getResources().getLayout(menuRes);
- AttributeSet attrs = Xml.asAttributeSet(parser);
-
- parseMenu(parser, attrs, menu);
- } catch (XmlPullParserException e) {
- throw new InflateException("Error inflating menu XML", e);
- } catch (IOException e) {
- throw new InflateException("Error inflating menu XML", e);
- } finally {
- if (parser != null) parser.close();
- }
- }
-
- /**
- * Called internally to fill the given menu. If a sub menu is seen, it will
- * call this recursively.
- */
- private void parseMenu(XmlPullParser parser, AttributeSet attrs, Menu menu)
- throws XmlPullParserException, IOException {
- MenuState menuState = new MenuState(menu);
-
- int eventType = parser.getEventType();
- String tagName;
- boolean lookingForEndOfUnknownTag = false;
- String unknownTagName = null;
-
- // This loop will skip to the menu start tag
- do {
- if (eventType == XmlPullParser.START_TAG) {
- tagName = parser.getName();
- if (tagName.equals(XML_MENU)) {
- // Go to next tag
- eventType = parser.next();
- break;
- }
-
- throw new RuntimeException("Expecting menu, got " + tagName);
- }
- eventType = parser.next();
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- boolean reachedEndOfMenu = false;
- while (!reachedEndOfMenu) {
- switch (eventType) {
- case XmlPullParser.START_TAG:
- if (lookingForEndOfUnknownTag) {
- break;
- }
-
- tagName = parser.getName();
- if (tagName.equals(XML_GROUP)) {
- menuState.readGroup(attrs);
- } else if (tagName.equals(XML_ITEM)) {
- menuState.readItem(attrs);
- } else if (tagName.equals(XML_MENU)) {
- // A menu start tag denotes a submenu for an item
- SubMenu subMenu = menuState.addSubMenuItem();
-
- // Parse the submenu into returned SubMenu
- parseMenu(parser, attrs, subMenu);
- } else {
- lookingForEndOfUnknownTag = true;
- unknownTagName = tagName;
- }
- break;
-
- case XmlPullParser.END_TAG:
- tagName = parser.getName();
- if (lookingForEndOfUnknownTag && tagName.equals(unknownTagName)) {
- lookingForEndOfUnknownTag = false;
- unknownTagName = null;
- } else if (tagName.equals(XML_GROUP)) {
- menuState.resetGroup();
- } else if (tagName.equals(XML_ITEM)) {
- // Add the item if it hasn't been added (if the item was
- // a submenu, it would have been added already)
- if (!menuState.hasAddedItem()) {
- if (menuState.itemActionProvider != null &&
- menuState.itemActionProvider.hasSubMenu()) {
- menuState.addSubMenuItem();
- } else {
- menuState.addItem();
- }
- }
- } else if (tagName.equals(XML_MENU)) {
- reachedEndOfMenu = true;
- }
- break;
-
- case XmlPullParser.END_DOCUMENT:
- throw new RuntimeException("Unexpected end of document");
- }
-
- eventType = parser.next();
- }
- }
-
- private static class InflatedOnMenuItemClickListener
- implements MenuItem.OnMenuItemClickListener {
- private static final Class>[] PARAM_TYPES = new Class[] { MenuItem.class };
-
- private Context mContext;
- private Method mMethod;
-
- public InflatedOnMenuItemClickListener(Context context, String methodName) {
- mContext = context;
- Class> c = context.getClass();
- try {
- mMethod = c.getMethod(methodName, PARAM_TYPES);
- } catch (Exception e) {
- InflateException ex = new InflateException(
- "Couldn't resolve menu item onClick handler " + methodName +
- " in class " + c.getName());
- ex.initCause(e);
- throw ex;
- }
- }
-
- public boolean onMenuItemClick(MenuItem item) {
- try {
- if (mMethod.getReturnType() == Boolean.TYPE) {
- return (Boolean) mMethod.invoke(mContext, item);
- } else {
- mMethod.invoke(mContext, item);
- return true;
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- /**
- * State for the current menu.
- *
- * Groups can not be nested unless there is another menu (which will have
- * its state class).
- */
- private class MenuState {
- private Menu menu;
-
- /*
- * Group state is set on items as they are added, allowing an item to
- * override its group state. (As opposed to set on items at the group end tag.)
- */
- private int groupId;
- private int groupCategory;
- private int groupOrder;
- private int groupCheckable;
- private boolean groupVisible;
- private boolean groupEnabled;
-
- private boolean itemAdded;
- private int itemId;
- private int itemCategoryOrder;
- private CharSequence itemTitle;
- private CharSequence itemTitleCondensed;
- private int itemIconResId;
- private char itemAlphabeticShortcut;
- private char itemNumericShortcut;
- /**
- * Sync to attrs.xml enum:
- * - 0: none
- * - 1: all
- * - 2: exclusive
- */
- private int itemCheckable;
- private boolean itemChecked;
- private boolean itemVisible;
- private boolean itemEnabled;
-
- /**
- * Sync to attrs.xml enum, values in MenuItem:
- * - 0: never
- * - 1: ifRoom
- * - 2: always
- * - -1: Safe sentinel for "no value".
- */
- private int itemShowAsAction;
-
- private int itemActionViewLayout;
- private String itemActionViewClassName;
- private String itemActionProviderClassName;
-
- private String itemListenerMethodName;
-
- private ActionProvider itemActionProvider;
-
- private static final int defaultGroupId = NO_ID;
- private static final int defaultItemId = NO_ID;
- private static final int defaultItemCategory = 0;
- private static final int defaultItemOrder = 0;
- private static final int defaultItemCheckable = 0;
- private static final boolean defaultItemChecked = false;
- private static final boolean defaultItemVisible = true;
- private static final boolean defaultItemEnabled = true;
-
- public MenuState(final Menu menu) {
- this.menu = menu;
-
- resetGroup();
- }
-
- public void resetGroup() {
- groupId = defaultGroupId;
- groupCategory = defaultItemCategory;
- groupOrder = defaultItemOrder;
- groupCheckable = defaultItemCheckable;
- groupVisible = defaultItemVisible;
- groupEnabled = defaultItemEnabled;
- }
-
- /**
- * Called when the parser is pointing to a group tag.
- */
- public void readGroup(AttributeSet attrs) {
- TypedArray a = mContext.obtainStyledAttributes(attrs,
- R.styleable.SherlockMenuGroup);
-
- groupId = a.getResourceId(R.styleable.SherlockMenuGroup_android_id, defaultGroupId);
- groupCategory = a.getInt(R.styleable.SherlockMenuGroup_android_menuCategory, defaultItemCategory);
- groupOrder = a.getInt(R.styleable.SherlockMenuGroup_android_orderInCategory, defaultItemOrder);
- groupCheckable = a.getInt(R.styleable.SherlockMenuGroup_android_checkableBehavior, defaultItemCheckable);
- groupVisible = a.getBoolean(R.styleable.SherlockMenuGroup_android_visible, defaultItemVisible);
- groupEnabled = a.getBoolean(R.styleable.SherlockMenuGroup_android_enabled, defaultItemEnabled);
-
- a.recycle();
- }
-
- /**
- * Called when the parser is pointing to an item tag.
- */
- public void readItem(AttributeSet attrs) {
- TypedArray a = mContext.obtainStyledAttributes(attrs,
- R.styleable.SherlockMenuItem);
-
- // Inherit attributes from the group as default value
- itemId = a.getResourceId(R.styleable.SherlockMenuItem_android_id, defaultItemId);
- final int category = a.getInt(R.styleable.SherlockMenuItem_android_menuCategory, groupCategory);
- final int order = a.getInt(R.styleable.SherlockMenuItem_android_orderInCategory, groupOrder);
- itemCategoryOrder = (category & Menu.CATEGORY_MASK) | (order & Menu.USER_MASK);
- itemTitle = a.getText(R.styleable.SherlockMenuItem_android_title);
- itemTitleCondensed = a.getText(R.styleable.SherlockMenuItem_android_titleCondensed);
- itemIconResId = a.getResourceId(R.styleable.SherlockMenuItem_android_icon, 0);
- itemAlphabeticShortcut =
- getShortcut(a.getString(R.styleable.SherlockMenuItem_android_alphabeticShortcut));
- itemNumericShortcut =
- getShortcut(a.getString(R.styleable.SherlockMenuItem_android_numericShortcut));
- if (a.hasValue(R.styleable.SherlockMenuItem_android_checkable)) {
- // Item has attribute checkable, use it
- itemCheckable = a.getBoolean(R.styleable.SherlockMenuItem_android_checkable, false) ? 1 : 0;
- } else {
- // Item does not have attribute, use the group's (group can have one more state
- // for checkable that represents the exclusive checkable)
- itemCheckable = groupCheckable;
- }
-
- itemChecked = a.getBoolean(R.styleable.SherlockMenuItem_android_checked, defaultItemChecked);
- itemVisible = a.getBoolean(R.styleable.SherlockMenuItem_android_visible, groupVisible);
- itemEnabled = a.getBoolean(R.styleable.SherlockMenuItem_android_enabled, groupEnabled);
-
- TypedValue value = new TypedValue();
- a.getValue(R.styleable.SherlockMenuItem_android_showAsAction, value);
- itemShowAsAction = value.type == TypedValue.TYPE_INT_HEX ? value.data : -1;
-
- itemListenerMethodName = a.getString(R.styleable.SherlockMenuItem_android_onClick);
- itemActionViewLayout = a.getResourceId(R.styleable.SherlockMenuItem_android_actionLayout, 0);
- itemActionViewClassName = a.getString(R.styleable.SherlockMenuItem_android_actionViewClass);
- itemActionProviderClassName = a.getString(R.styleable.SherlockMenuItem_android_actionProviderClass);
-
- final boolean hasActionProvider = itemActionProviderClassName != null;
- if (hasActionProvider && itemActionViewLayout == 0 && itemActionViewClassName == null) {
- itemActionProvider = newInstance(itemActionProviderClassName,
- ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE,
- mActionProviderConstructorArguments);
- } else {
- if (hasActionProvider) {
- Log.w(LOG_TAG, "Ignoring attribute 'actionProviderClass'."
- + " Action view already specified.");
- }
- itemActionProvider = null;
- }
-
- a.recycle();
-
- itemAdded = false;
- }
-
- private char getShortcut(String shortcutString) {
- if (shortcutString == null) {
- return 0;
- } else {
- return shortcutString.charAt(0);
- }
- }
-
- private void setItem(MenuItem item) {
- item.setChecked(itemChecked)
- .setVisible(itemVisible)
- .setEnabled(itemEnabled)
- .setCheckable(itemCheckable >= 1)
- .setTitleCondensed(itemTitleCondensed)
- .setIcon(itemIconResId)
- .setAlphabeticShortcut(itemAlphabeticShortcut)
- .setNumericShortcut(itemNumericShortcut);
-
- if (itemShowAsAction >= 0) {
- item.setShowAsAction(itemShowAsAction);
- }
-
- if (itemListenerMethodName != null) {
- if (mContext.isRestricted()) {
- throw new IllegalStateException("The android:onClick attribute cannot "
- + "be used within a restricted context");
- }
- item.setOnMenuItemClickListener(
- new InflatedOnMenuItemClickListener(mContext, itemListenerMethodName));
- }
-
- if (itemCheckable >= 2) {
- if (item instanceof MenuItemImpl) {
- MenuItemImpl impl = (MenuItemImpl) item;
- impl.setExclusiveCheckable(true);
- } else {
- menu.setGroupCheckable(groupId, true, true);
- }
- }
-
- boolean actionViewSpecified = false;
- if (itemActionViewClassName != null) {
- View actionView = (View) newInstance(itemActionViewClassName,
- ACTION_VIEW_CONSTRUCTOR_SIGNATURE, mActionViewConstructorArguments);
- item.setActionView(actionView);
- actionViewSpecified = true;
- }
- if (itemActionViewLayout > 0) {
- if (!actionViewSpecified) {
- item.setActionView(itemActionViewLayout);
- actionViewSpecified = true;
- } else {
- Log.w(LOG_TAG, "Ignoring attribute 'itemActionViewLayout'."
- + " Action view already specified.");
- }
- }
- if (itemActionProvider != null) {
- item.setActionProvider(itemActionProvider);
- }
- }
-
- public void addItem() {
- itemAdded = true;
- setItem(menu.add(groupId, itemId, itemCategoryOrder, itemTitle));
- }
-
- public SubMenu addSubMenuItem() {
- itemAdded = true;
- SubMenu subMenu = menu.addSubMenu(groupId, itemId, itemCategoryOrder, itemTitle);
- setItem(subMenu.getItem());
- return subMenu;
- }
-
- public boolean hasAddedItem() {
- return itemAdded;
- }
-
- @SuppressWarnings("unchecked")
- private T newInstance(String className, Class>[] constructorSignature,
- Object[] arguments) {
- try {
- Class> clazz = mContext.getClassLoader().loadClass(className);
- Constructor> constructor = clazz.getConstructor(constructorSignature);
- return (T) constructor.newInstance(arguments);
- } catch (Exception e) {
- Log.w(LOG_TAG, "Cannot instantiate class: " + className, e);
- }
- return null;
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/MenuItem.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/MenuItem.java
deleted file mode 100644
index 7fc3aa4306..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/MenuItem.java
+++ /dev/null
@@ -1,598 +0,0 @@
-/*
- * Copyright (C) 2008 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.actionbarsherlock.view;
-
-import android.content.Intent;
-import android.graphics.drawable.Drawable;
-import android.view.ContextMenu.ContextMenuInfo;
-import android.view.View;
-
-/**
- * Interface for direct access to a previously created menu item.
- *
- * An Item is returned by calling one of the {@link android.view.Menu#add}
- * methods.
- *
- * For a feature set of specific menu types, see {@link Menu}.
- *
- *
- *
Developer Guides
- *
For information about creating menus, read the
- * Menus developer guide.
- *
- */
-public interface MenuItem {
- /*
- * These should be kept in sync with attrs.xml enum constants for showAsAction
- */
- /** Never show this item as a button in an Action Bar. */
- public static final int SHOW_AS_ACTION_NEVER = android.view.MenuItem.SHOW_AS_ACTION_NEVER;
- /** Show this item as a button in an Action Bar if the system decides there is room for it. */
- public static final int SHOW_AS_ACTION_IF_ROOM = android.view.MenuItem.SHOW_AS_ACTION_IF_ROOM;
- /**
- * Always show this item as a button in an Action Bar.
- * Use sparingly! If too many items are set to always show in the Action Bar it can
- * crowd the Action Bar and degrade the user experience on devices with smaller screens.
- * A good rule of thumb is to have no more than 2 items set to always show at a time.
- */
- public static final int SHOW_AS_ACTION_ALWAYS = android.view.MenuItem.SHOW_AS_ACTION_ALWAYS;
-
- /**
- * When this item is in the action bar, always show it with a text label even if
- * it also has an icon specified.
- */
- public static final int SHOW_AS_ACTION_WITH_TEXT = android.view.MenuItem.SHOW_AS_ACTION_WITH_TEXT;
-
- /**
- * This item's action view collapses to a normal menu item.
- * When expanded, the action view temporarily takes over
- * a larger segment of its container.
- */
- public static final int SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW = android.view.MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW;
-
- /**
- * Interface definition for a callback to be invoked when a menu item is
- * clicked.
- *
- * @see Activity#onContextItemSelected(MenuItem)
- * @see Activity#onOptionsItemSelected(MenuItem)
- */
- public interface OnMenuItemClickListener {
- /**
- * Called when a menu item has been invoked. This is the first code
- * that is executed; if it returns true, no other callbacks will be
- * executed.
- *
- * @param item The menu item that was invoked.
- *
- * @return Return true to consume this click and prevent others from
- * executing.
- */
- public boolean onMenuItemClick(MenuItem item);
- }
-
- /**
- * Interface definition for a callback to be invoked when a menu item
- * marked with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW} is
- * expanded or collapsed.
- *
- * @see MenuItem#expandActionView()
- * @see MenuItem#collapseActionView()
- * @see MenuItem#setShowAsActionFlags(int)
- */
- public interface OnActionExpandListener {
- /**
- * Called when a menu item with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}
- * is expanded.
- * @param item Item that was expanded
- * @return true if the item should expand, false if expansion should be suppressed.
- */
- public boolean onMenuItemActionExpand(MenuItem item);
-
- /**
- * Called when a menu item with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}
- * is collapsed.
- * @param item Item that was collapsed
- * @return true if the item should collapse, false if collapsing should be suppressed.
- */
- public boolean onMenuItemActionCollapse(MenuItem item);
- }
-
- /**
- * Return the identifier for this menu item. The identifier can not
- * be changed after the menu is created.
- *
- * @return The menu item's identifier.
- */
- public int getItemId();
-
- /**
- * Return the group identifier that this menu item is part of. The group
- * identifier can not be changed after the menu is created.
- *
- * @return The menu item's group identifier.
- */
- public int getGroupId();
-
- /**
- * Return the category and order within the category of this item. This
- * item will be shown before all items (within its category) that have
- * order greater than this value.
- *
- * An order integer contains the item's category (the upper bits of the
- * integer; set by or/add the category with the order within the
- * category) and the ordering of the item within that category (the
- * lower bits). Example categories are {@link Menu#CATEGORY_SYSTEM},
- * {@link Menu#CATEGORY_SECONDARY}, {@link Menu#CATEGORY_ALTERNATIVE},
- * {@link Menu#CATEGORY_CONTAINER}. See {@link Menu} for a full list.
- *
- * @return The order of this item.
- */
- public int getOrder();
-
- /**
- * Change the title associated with this item.
- *
- * @param title The new text to be displayed.
- * @return This Item so additional setters can be called.
- */
- public MenuItem setTitle(CharSequence title);
-
- /**
- * Change the title associated with this item.
- *
- * Some menu types do not sufficient space to show the full title, and
- * instead a condensed title is preferred. See {@link Menu} for more
- * information.
- *
- * @param title The resource id of the new text to be displayed.
- * @return This Item so additional setters can be called.
- * @see #setTitleCondensed(CharSequence)
- */
-
- public MenuItem setTitle(int title);
-
- /**
- * Retrieve the current title of the item.
- *
- * @return The title.
- */
- public CharSequence getTitle();
-
- /**
- * Change the condensed title associated with this item. The condensed
- * title is used in situations where the normal title may be too long to
- * be displayed.
- *
- * @param title The new text to be displayed as the condensed title.
- * @return This Item so additional setters can be called.
- */
- public MenuItem setTitleCondensed(CharSequence title);
-
- /**
- * Retrieve the current condensed title of the item. If a condensed
- * title was never set, it will return the normal title.
- *
- * @return The condensed title, if it exists.
- * Otherwise the normal title.
- */
- public CharSequence getTitleCondensed();
-
- /**
- * Change the icon associated with this item. This icon will not always be
- * shown, so the title should be sufficient in describing this item. See
- * {@link Menu} for the menu types that support icons.
- *
- * @param icon The new icon (as a Drawable) to be displayed.
- * @return This Item so additional setters can be called.
- */
- public MenuItem setIcon(Drawable icon);
-
- /**
- * Change the icon associated with this item. This icon will not always be
- * shown, so the title should be sufficient in describing this item. See
- * {@link Menu} for the menu types that support icons.
- *
- * This method will set the resource ID of the icon which will be used to
- * lazily get the Drawable when this item is being shown.
- *
- * @param iconRes The new icon (as a resource ID) to be displayed.
- * @return This Item so additional setters can be called.
- */
- public MenuItem setIcon(int iconRes);
-
- /**
- * Returns the icon for this item as a Drawable (getting it from resources if it hasn't been
- * loaded before).
- *
- * @return The icon as a Drawable.
- */
- public Drawable getIcon();
-
- /**
- * Change the Intent associated with this item. By default there is no
- * Intent associated with a menu item. If you set one, and nothing
- * else handles the item, then the default behavior will be to call
- * {@link android.content.Context#startActivity} with the given Intent.
- *
- *
Note that setIntent() can not be used with the versions of
- * {@link Menu#add} that take a Runnable, because {@link Runnable#run}
- * does not return a value so there is no way to tell if it handled the
- * item. In this case it is assumed that the Runnable always handles
- * the item, and the intent will never be started.
- *
- * @see #getIntent
- * @param intent The Intent to associated with the item. This Intent
- * object is not copied, so be careful not to
- * modify it later.
- * @return This Item so additional setters can be called.
- */
- public MenuItem setIntent(Intent intent);
-
- /**
- * Return the Intent associated with this item. This returns a
- * reference to the Intent which you can change as desired to modify
- * what the Item is holding.
- *
- * @see #setIntent
- * @return Returns the last value supplied to {@link #setIntent}, or
- * null.
- */
- public Intent getIntent();
-
- /**
- * Change both the numeric and alphabetic shortcut associated with this
- * item. Note that the shortcut will be triggered when the key that
- * generates the given character is pressed alone or along with with the alt
- * key. Also note that case is not significant and that alphabetic shortcut
- * characters will be displayed in lower case.
- *
- * See {@link Menu} for the menu types that support shortcuts.
- *
- * @param numericChar The numeric shortcut key. This is the shortcut when
- * using a numeric (e.g., 12-key) keyboard.
- * @param alphaChar The alphabetic shortcut key. This is the shortcut when
- * using a keyboard with alphabetic keys.
- * @return This Item so additional setters can be called.
- */
- public MenuItem setShortcut(char numericChar, char alphaChar);
-
- /**
- * Change the numeric shortcut associated with this item.
- *
- * See {@link Menu} for the menu types that support shortcuts.
- *
- * @param numericChar The numeric shortcut key. This is the shortcut when
- * using a 12-key (numeric) keyboard.
- * @return This Item so additional setters can be called.
- */
- public MenuItem setNumericShortcut(char numericChar);
-
- /**
- * Return the char for this menu item's numeric (12-key) shortcut.
- *
- * @return Numeric character to use as a shortcut.
- */
- public char getNumericShortcut();
-
- /**
- * Change the alphabetic shortcut associated with this item. The shortcut
- * will be triggered when the key that generates the given character is
- * pressed alone or along with with the alt key. Case is not significant and
- * shortcut characters will be displayed in lower case. Note that menu items
- * with the characters '\b' or '\n' as shortcuts will get triggered by the
- * Delete key or Carriage Return key, respectively.
- *
- * See {@link Menu} for the menu types that support shortcuts.
- *
- * @param alphaChar The alphabetic shortcut key. This is the shortcut when
- * using a keyboard with alphabetic keys.
- * @return This Item so additional setters can be called.
- */
- public MenuItem setAlphabeticShortcut(char alphaChar);
-
- /**
- * Return the char for this menu item's alphabetic shortcut.
- *
- * @return Alphabetic character to use as a shortcut.
- */
- public char getAlphabeticShortcut();
-
- /**
- * Control whether this item can display a check mark. Setting this does
- * not actually display a check mark (see {@link #setChecked} for that);
- * rather, it ensures there is room in the item in which to display a
- * check mark.
- *
- * See {@link Menu} for the menu types that support check marks.
- *
- * @param checkable Set to true to allow a check mark, false to
- * disallow. The default is false.
- * @see #setChecked
- * @see #isCheckable
- * @see Menu#setGroupCheckable
- * @return This Item so additional setters can be called.
- */
- public MenuItem setCheckable(boolean checkable);
-
- /**
- * Return whether the item can currently display a check mark.
- *
- * @return If a check mark can be displayed, returns true.
- *
- * @see #setCheckable
- */
- public boolean isCheckable();
-
- /**
- * Control whether this item is shown with a check mark. Note that you
- * must first have enabled checking with {@link #setCheckable} or else
- * the check mark will not appear. If this item is a member of a group that contains
- * mutually-exclusive items (set via {@link Menu#setGroupCheckable(int, boolean, boolean)},
- * the other items in the group will be unchecked.
- *
- * See {@link Menu} for the menu types that support check marks.
- *
- * @see #setCheckable
- * @see #isChecked
- * @see Menu#setGroupCheckable
- * @param checked Set to true to display a check mark, false to hide
- * it. The default value is false.
- * @return This Item so additional setters can be called.
- */
- public MenuItem setChecked(boolean checked);
-
- /**
- * Return whether the item is currently displaying a check mark.
- *
- * @return If a check mark is displayed, returns true.
- *
- * @see #setChecked
- */
- public boolean isChecked();
-
- /**
- * Sets the visibility of the menu item. Even if a menu item is not visible,
- * it may still be invoked via its shortcut (to completely disable an item,
- * set it to invisible and {@link #setEnabled(boolean) disabled}).
- *
- * @param visible If true then the item will be visible; if false it is
- * hidden.
- * @return This Item so additional setters can be called.
- */
- public MenuItem setVisible(boolean visible);
-
- /**
- * Return the visibility of the menu item.
- *
- * @return If true the item is visible; else it is hidden.
- */
- public boolean isVisible();
-
- /**
- * Sets whether the menu item is enabled. Disabling a menu item will not
- * allow it to be invoked via its shortcut. The menu item will still be
- * visible.
- *
- * @param enabled If true then the item will be invokable; if false it is
- * won't be invokable.
- * @return This Item so additional setters can be called.
- */
- public MenuItem setEnabled(boolean enabled);
-
- /**
- * Return the enabled state of the menu item.
- *
- * @return If true the item is enabled and hence invokable; else it is not.
- */
- public boolean isEnabled();
-
- /**
- * Check whether this item has an associated sub-menu. I.e. it is a
- * sub-menu of another menu.
- *
- * @return If true this item has a menu; else it is a
- * normal item.
- */
- public boolean hasSubMenu();
-
- /**
- * Get the sub-menu to be invoked when this item is selected, if it has
- * one. See {@link #hasSubMenu()}.
- *
- * @return The associated menu if there is one, else null
- */
- public SubMenu getSubMenu();
-
- /**
- * Set a custom listener for invocation of this menu item. In most
- * situations, it is more efficient and easier to use
- * {@link Activity#onOptionsItemSelected(MenuItem)} or
- * {@link Activity#onContextItemSelected(MenuItem)}.
- *
- * @param menuItemClickListener The object to receive invokations.
- * @return This Item so additional setters can be called.
- * @see Activity#onOptionsItemSelected(MenuItem)
- * @see Activity#onContextItemSelected(MenuItem)
- */
- public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener menuItemClickListener);
-
- /**
- * Gets the extra information linked to this menu item. This extra
- * information is set by the View that added this menu item to the
- * menu.
- *
- * @see OnCreateContextMenuListener
- * @return The extra information linked to the View that added this
- * menu item to the menu. This can be null.
- */
- public ContextMenuInfo getMenuInfo();
-
- /**
- * Sets how this item should display in the presence of an Action Bar.
- * The parameter actionEnum is a flag set. One of {@link #SHOW_AS_ACTION_ALWAYS},
- * {@link #SHOW_AS_ACTION_IF_ROOM}, or {@link #SHOW_AS_ACTION_NEVER} should
- * be used, and you may optionally OR the value with {@link #SHOW_AS_ACTION_WITH_TEXT}.
- * SHOW_AS_ACTION_WITH_TEXT requests that when the item is shown as an action,
- * it should be shown with a text label.
- *
- * @param actionEnum How the item should display. One of
- * {@link #SHOW_AS_ACTION_ALWAYS}, {@link #SHOW_AS_ACTION_IF_ROOM}, or
- * {@link #SHOW_AS_ACTION_NEVER}. SHOW_AS_ACTION_NEVER is the default.
- *
- * @see android.app.ActionBar
- * @see #setActionView(View)
- */
- public void setShowAsAction(int actionEnum);
-
- /**
- * Sets how this item should display in the presence of an Action Bar.
- * The parameter actionEnum is a flag set. One of {@link #SHOW_AS_ACTION_ALWAYS},
- * {@link #SHOW_AS_ACTION_IF_ROOM}, or {@link #SHOW_AS_ACTION_NEVER} should
- * be used, and you may optionally OR the value with {@link #SHOW_AS_ACTION_WITH_TEXT}.
- * SHOW_AS_ACTION_WITH_TEXT requests that when the item is shown as an action,
- * it should be shown with a text label.
- *
- *
Note: This method differs from {@link #setShowAsAction(int)} only in that it
- * returns the current MenuItem instance for call chaining.
- *
- * @param actionEnum How the item should display. One of
- * {@link #SHOW_AS_ACTION_ALWAYS}, {@link #SHOW_AS_ACTION_IF_ROOM}, or
- * {@link #SHOW_AS_ACTION_NEVER}. SHOW_AS_ACTION_NEVER is the default.
- *
- * @see android.app.ActionBar
- * @see #setActionView(View)
- * @return This MenuItem instance for call chaining.
- */
- public MenuItem setShowAsActionFlags(int actionEnum);
-
- /**
- * Set an action view for this menu item. An action view will be displayed in place
- * of an automatically generated menu item element in the UI when this item is shown
- * as an action within a parent.
- *
- * Note: Setting an action view overrides the action provider
- * set via {@link #setActionProvider(ActionProvider)}.
- *
- *
- * @param view View to use for presenting this item to the user.
- * @return This Item so additional setters can be called.
- *
- * @see #setShowAsAction(int)
- */
- public MenuItem setActionView(View view);
-
- /**
- * Set an action view for this menu item. An action view will be displayed in place
- * of an automatically generated menu item element in the UI when this item is shown
- * as an action within a parent.
- *
- * Note: Setting an action view overrides the action provider
- * set via {@link #setActionProvider(ActionProvider)}.
- *
- *
- * @param resId Layout resource to use for presenting this item to the user.
- * @return This Item so additional setters can be called.
- *
- * @see #setShowAsAction(int)
- */
- public MenuItem setActionView(int resId);
-
- /**
- * Returns the currently set action view for this menu item.
- *
- * @return This item's action view
- *
- * @see #setActionView(View)
- * @see #setShowAsAction(int)
- */
- public View getActionView();
-
- /**
- * Sets the {@link ActionProvider} responsible for creating an action view if
- * the item is placed on the action bar. The provider also provides a default
- * action invoked if the item is placed in the overflow menu.
- *
- * Note: Setting an action provider overrides the action view
- * set via {@link #setActionView(int)} or {@link #setActionView(View)}.
- *
- *
- * @param actionProvider The action provider.
- * @return This Item so additional setters can be called.
- *
- * @see ActionProvider
- */
- public MenuItem setActionProvider(ActionProvider actionProvider);
-
- /**
- * Gets the {@link ActionProvider}.
- *
- * @return The action provider.
- *
- * @see ActionProvider
- * @see #setActionProvider(ActionProvider)
- */
- public ActionProvider getActionProvider();
-
- /**
- * Expand the action view associated with this menu item.
- * The menu item must have an action view set, as well as
- * the showAsAction flag {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}.
- * If a listener has been set using {@link #setOnActionExpandListener(OnActionExpandListener)}
- * it will have its {@link OnActionExpandListener#onMenuItemActionExpand(MenuItem)}
- * method invoked. The listener may return false from this method to prevent expanding
- * the action view.
- *
- * @return true if the action view was expanded, false otherwise.
- */
- public boolean expandActionView();
-
- /**
- * Collapse the action view associated with this menu item.
- * The menu item must have an action view set, as well as the showAsAction flag
- * {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}. If a listener has been set using
- * {@link #setOnActionExpandListener(OnActionExpandListener)} it will have its
- * {@link OnActionExpandListener#onMenuItemActionCollapse(MenuItem)} method invoked.
- * The listener may return false from this method to prevent collapsing the action view.
- *
- * @return true if the action view was collapsed, false otherwise.
- */
- public boolean collapseActionView();
-
- /**
- * Returns true if this menu item's action view has been expanded.
- *
- * @return true if the item's action view is expanded, false otherwise.
- *
- * @see #expandActionView()
- * @see #collapseActionView()
- * @see #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
- * @see OnActionExpandListener
- */
- public boolean isActionViewExpanded();
-
- /**
- * Set an {@link OnActionExpandListener} on this menu item to be notified when
- * the associated action view is expanded or collapsed. The menu item must
- * be configured to expand or collapse its action view using the flag
- * {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}.
- *
- * @param listener Listener that will respond to expand/collapse events
- * @return This menu item instance for call chaining
- */
- public MenuItem setOnActionExpandListener(OnActionExpandListener listener);
-}
\ No newline at end of file
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/SubMenu.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/SubMenu.java
deleted file mode 100644
index 397fd1c2d7..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/SubMenu.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2007 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.actionbarsherlock.view;
-
-import android.graphics.drawable.Drawable;
-import android.view.View;
-
-/**
- * Subclass of {@link Menu} for sub menus.
- *
- * Sub menus do not support item icons, or nested sub menus.
- *
- *
- *
Developer Guides
- *
For information about creating menus, read the
- * Menus developer guide.
- *
- */
-
-public interface SubMenu extends Menu {
- /**
- * Sets the submenu header's title to the title given in titleRes
- * resource identifier.
- *
- * @param titleRes The string resource identifier used for the title.
- * @return This SubMenu so additional setters can be called.
- */
- public SubMenu setHeaderTitle(int titleRes);
-
- /**
- * Sets the submenu header's title to the title given in title.
- *
- * @param title The character sequence used for the title.
- * @return This SubMenu so additional setters can be called.
- */
- public SubMenu setHeaderTitle(CharSequence title);
-
- /**
- * Sets the submenu header's icon to the icon given in iconRes
- * resource id.
- *
- * @param iconRes The resource identifier used for the icon.
- * @return This SubMenu so additional setters can be called.
- */
- public SubMenu setHeaderIcon(int iconRes);
-
- /**
- * Sets the submenu header's icon to the icon given in icon
- * {@link Drawable}.
- *
- * @param icon The {@link Drawable} used for the icon.
- * @return This SubMenu so additional setters can be called.
- */
- public SubMenu setHeaderIcon(Drawable icon);
-
- /**
- * Sets the header of the submenu to the {@link View} given in
- * view. This replaces the header title and icon (and those
- * replace this).
- *
- * @param view The {@link View} used for the header.
- * @return This SubMenu so additional setters can be called.
- */
- public SubMenu setHeaderView(View view);
-
- /**
- * Clears the header of the submenu.
- */
- public void clearHeader();
-
- /**
- * Change the icon associated with this submenu's item in its parent menu.
- *
- * @see MenuItem#setIcon(int)
- * @param iconRes The new icon (as a resource ID) to be displayed.
- * @return This SubMenu so additional setters can be called.
- */
- public SubMenu setIcon(int iconRes);
-
- /**
- * Change the icon associated with this submenu's item in its parent menu.
- *
- * @see MenuItem#setIcon(Drawable)
- * @param icon The new icon (as a Drawable) to be displayed.
- * @return This SubMenu so additional setters can be called.
- */
- public SubMenu setIcon(Drawable icon);
-
- /**
- * Gets the {@link MenuItem} that represents this submenu in the parent
- * menu. Use this for setting additional item attributes.
- *
- * @return The {@link MenuItem} that launches the submenu when invoked.
- */
- public MenuItem getItem();
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/Window.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/Window.java
deleted file mode 100644
index a340a4291f..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/view/Window.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- * Copyright (C) 2011 Jake Wharton
- *
- * 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.actionbarsherlock.view;
-
-import android.content.Context;
-
-/**
- *
Abstract base class for a top-level window look and behavior policy. An
- * instance of this class should be used as the top-level view added to the
- * window manager. It provides standard UI policies such as a background, title
- * area, default key processing, etc.
- *
- *
The only existing implementation of this abstract class is
- * android.policy.PhoneWindow, which you should instantiate when needing a
- * Window. Eventually that class will be refactored and a factory method added
- * for creating Window instances without knowing about a particular
- * implementation.
- */
-public abstract class Window extends android.view.Window {
- public static final long FEATURE_ACTION_BAR = android.view.Window.FEATURE_ACTION_BAR;
- public static final long FEATURE_ACTION_BAR_OVERLAY = android.view.Window.FEATURE_ACTION_BAR_OVERLAY;
- public static final long FEATURE_ACTION_MODE_OVERLAY = android.view.Window.FEATURE_ACTION_MODE_OVERLAY;
- public static final long FEATURE_NO_TITLE = android.view.Window.FEATURE_NO_TITLE;
- public static final long FEATURE_PROGRESS = android.view.Window.FEATURE_PROGRESS;
- public static final long FEATURE_INDETERMINATE_PROGRESS = android.view.Window.FEATURE_INDETERMINATE_PROGRESS;
-
- /**
- * Create a new instance for a context.
- *
- * @param context Context.
- */
- private Window(Context context) {
- super(context);
- }
-
-
- public interface Callback {
- /**
- * Called when a panel's menu item has been selected by the user.
- *
- * @param featureId The panel that the menu is in.
- * @param item The menu item that was selected.
- *
- * @return boolean Return true to finish processing of selection, or
- * false to perform the normal menu handling (calling its
- * Runnable or sending a Message to its target Handler).
- */
- public boolean onMenuItemSelected(int featureId, MenuItem item);
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/widget/ActivityChooserModel.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/widget/ActivityChooserModel.java
deleted file mode 100644
index 379207471b..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/widget/ActivityChooserModel.java
+++ /dev/null
@@ -1,1131 +0,0 @@
-/*
- * Copyright (C) 2011 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.actionbarsherlock.widget;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ResolveInfo;
-import android.database.DataSetObservable;
-import android.os.Handler;
-import android.text.TextUtils;
-import android.util.Log;
-import android.util.Xml;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlSerializer;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Executor;
-
-/**
- *
- * This class represents a data model for choosing a component for handing a
- * given {@link Intent}. The model is responsible for querying the system for
- * activities that can handle the given intent and order found activities
- * based on historical data of previous choices. The historical data is stored
- * in an application private file. If a client does not want to have persistent
- * choice history the file can be omitted, thus the activities will be ordered
- * based on historical usage for the current session.
- *
- *
- * For each backing history file there is a singleton instance of this class. Thus,
- * several clients that specify the same history file will share the same model. Note
- * that if multiple clients are sharing the same model they should implement semantically
- * equivalent functionality since setting the model intent will change the found
- * activities and they may be inconsistent with the functionality of some of the clients.
- * For example, choosing a share activity can be implemented by a single backing
- * model and two different views for performing the selection. If however, one of the
- * views is used for sharing but the other for importing, for example, then each
- * view should be backed by a separate model.
- *
- *
- * The way clients interact with this class is as follows:
- *
- *
- *
- *
- * // Get a model and set it to a couple of clients with semantically similar function.
- * ActivityChooserModel dataModel =
- * ActivityChooserModel.get(context, "task_specific_history_file_name.xml");
- *
- * ActivityChooserModelClient modelClient1 = getActivityChooserModelClient1();
- * modelClient1.setActivityChooserModel(dataModel);
- *
- * ActivityChooserModelClient modelClient2 = getActivityChooserModelClient2();
- * modelClient2.setActivityChooserModel(dataModel);
- *
- * // Set an intent to choose a an activity for.
- * dataModel.setIntent(intent);
- *
- *
- *
- *
- * Note: This class is thread safe.
- *
- *
- * @hide
- */
-class ActivityChooserModel extends DataSetObservable {
-
- /**
- * Client that utilizes an {@link ActivityChooserModel}.
- */
- public interface ActivityChooserModelClient {
-
- /**
- * Sets the {@link ActivityChooserModel}.
- *
- * @param dataModel The model.
- */
- public void setActivityChooserModel(ActivityChooserModel dataModel);
- }
-
- /**
- * Defines a sorter that is responsible for sorting the activities
- * based on the provided historical choices and an intent.
- */
- public interface ActivitySorter {
-
- /**
- * Sorts the activities in descending order of relevance
- * based on previous history and an intent.
- *
- * @param intent The {@link Intent}.
- * @param activities Activities to be sorted.
- * @param historicalRecords Historical records.
- */
- // This cannot be done by a simple comparator since an Activity weight
- // is computed from history. Note that Activity implements Comparable.
- public void sort(Intent intent, List activities,
- List historicalRecords);
- }
-
- /**
- * Listener for choosing an activity.
- */
- public interface OnChooseActivityListener {
-
- /**
- * Called when an activity has been chosen. The client can decide whether
- * an activity can be chosen and if so the caller of
- * {@link ActivityChooserModel#chooseActivity(int)} will receive and {@link Intent}
- * for launching it.
- *
- * Note: Modifying the intent is not permitted and
- * any changes to the latter will be ignored.
- *
- *
- * @param host The listener's host model.
- * @param intent The intent for launching the chosen activity.
- * @return Whether the intent is handled and should not be delivered to clients.
- *
- * @see ActivityChooserModel#chooseActivity(int)
- */
- public boolean onChooseActivity(ActivityChooserModel host, Intent intent);
- }
-
- /**
- * Flag for selecting debug mode.
- */
- private static final boolean DEBUG = false;
-
- /**
- * Tag used for logging.
- */
- private static final String LOG_TAG = ActivityChooserModel.class.getSimpleName();
-
- /**
- * The root tag in the history file.
- */
- private static final String TAG_HISTORICAL_RECORDS = "historical-records";
-
- /**
- * The tag for a record in the history file.
- */
- private static final String TAG_HISTORICAL_RECORD = "historical-record";
-
- /**
- * Attribute for the activity.
- */
- private static final String ATTRIBUTE_ACTIVITY = "activity";
-
- /**
- * Attribute for the choice time.
- */
- private static final String ATTRIBUTE_TIME = "time";
-
- /**
- * Attribute for the choice weight.
- */
- private static final String ATTRIBUTE_WEIGHT = "weight";
-
- /**
- * The default name of the choice history file.
- */
- public static final String DEFAULT_HISTORY_FILE_NAME =
- "activity_choser_model_history.xml";
-
- /**
- * The default maximal length of the choice history.
- */
- public static final int DEFAULT_HISTORY_MAX_LENGTH = 50;
-
- /**
- * The amount with which to inflate a chosen activity when set as default.
- */
- private static final int DEFAULT_ACTIVITY_INFLATION = 5;
-
- /**
- * Default weight for a choice record.
- */
- private static final float DEFAULT_HISTORICAL_RECORD_WEIGHT = 1.0f;
-
- /**
- * The extension of the history file.
- */
- private static final String HISTORY_FILE_EXTENSION = ".xml";
-
- /**
- * An invalid item index.
- */
- private static final int INVALID_INDEX = -1;
-
- /**
- * Lock to guard the model registry.
- */
- private static final Object sRegistryLock = new Object();
-
- /**
- * This the registry for data models.
- */
- private static final Map sDataModelRegistry =
- new HashMap();
-
- /**
- * Lock for synchronizing on this instance.
- */
- private final Object mInstanceLock = new Object();
-
- /**
- * List of activities that can handle the current intent.
- */
- private final List mActivites = new ArrayList();
-
- /**
- * List with historical choice records.
- */
- private final List mHistoricalRecords = new ArrayList();
-
- /**
- * Context for accessing resources.
- */
- private final Context mContext;
-
- /**
- * The name of the history file that backs this model.
- */
- private final String mHistoryFileName;
-
- /**
- * The intent for which a activity is being chosen.
- */
- private Intent mIntent;
-
- /**
- * The sorter for ordering activities based on intent and past choices.
- */
- private ActivitySorter mActivitySorter = new DefaultSorter();
-
- /**
- * The maximal length of the choice history.
- */
- private int mHistoryMaxSize = DEFAULT_HISTORY_MAX_LENGTH;
-
- /**
- * Flag whether choice history can be read. In general many clients can
- * share the same data model and {@link #readHistoricalData()} may be called
- * by arbitrary of them any number of times. Therefore, this class guarantees
- * that the very first read succeeds and subsequent reads can be performed
- * only after a call to {@link #persistHistoricalData()} followed by change
- * of the share records.
- */
- private boolean mCanReadHistoricalData = true;
-
- /**
- * Flag whether the choice history was read. This is used to enforce that
- * before calling {@link #persistHistoricalData()} a call to
- * {@link #persistHistoricalData()} has been made. This aims to avoid a
- * scenario in which a choice history file exits, it is not read yet and
- * it is overwritten. Note that always all historical records are read in
- * full and the file is rewritten. This is necessary since we need to
- * purge old records that are outside of the sliding window of past choices.
- */
- private boolean mReadShareHistoryCalled = false;
-
- /**
- * Flag whether the choice records have changed. In general many clients can
- * share the same data model and {@link #persistHistoricalData()} may be called
- * by arbitrary of them any number of times. Therefore, this class guarantees
- * that choice history will be persisted only if it has changed.
- */
- private boolean mHistoricalRecordsChanged = true;
-
- /**
- * Hander for scheduling work on client tread.
- */
- private final Handler mHandler = new Handler();
-
- /**
- * Policy for controlling how the model handles chosen activities.
- */
- private OnChooseActivityListener mActivityChoserModelPolicy;
-
- /**
- * Gets the data model backed by the contents of the provided file with historical data.
- * Note that only one data model is backed by a given file, thus multiple calls with
- * the same file name will return the same model instance. If no such instance is present
- * it is created.
- *
- * Note: To use the default historical data file clients should explicitly
- * pass as file name {@link #DEFAULT_HISTORY_FILE_NAME}. If no persistence of the choice
- * history is desired clients should pass null for the file name. In such
- * case a new model is returned for each invocation.
- *
- *
- *
- * Always use difference historical data files for semantically different actions.
- * For example, sharing is different from importing.
- *
- *
- * @param context Context for loading resources.
- * @param historyFileName File name with choice history, null
- * if the model should not be backed by a file. In this case the activities
- * will be ordered only by data from the current session.
- *
- * @return The model.
- */
- public static ActivityChooserModel get(Context context, String historyFileName) {
- synchronized (sRegistryLock) {
- ActivityChooserModel dataModel = sDataModelRegistry.get(historyFileName);
- if (dataModel == null) {
- dataModel = new ActivityChooserModel(context, historyFileName);
- sDataModelRegistry.put(historyFileName, dataModel);
- }
- dataModel.readHistoricalData();
- return dataModel;
- }
- }
-
- /**
- * Creates a new instance.
- *
- * @param context Context for loading resources.
- * @param historyFileName The history XML file.
- */
- private ActivityChooserModel(Context context, String historyFileName) {
- mContext = context.getApplicationContext();
- if (!TextUtils.isEmpty(historyFileName)
- && !historyFileName.endsWith(HISTORY_FILE_EXTENSION)) {
- mHistoryFileName = historyFileName + HISTORY_FILE_EXTENSION;
- } else {
- mHistoryFileName = historyFileName;
- }
- }
-
- /**
- * Sets an intent for which to choose a activity.
- *
- * Note: Clients must set only semantically similar
- * intents for each data model.
- *
- *
- * @param intent The intent.
- */
- public void setIntent(Intent intent) {
- synchronized (mInstanceLock) {
- if (mIntent == intent) {
- return;
- }
- mIntent = intent;
- loadActivitiesLocked();
- }
- }
-
- /**
- * Gets the intent for which a activity is being chosen.
- *
- * @return The intent.
- */
- public Intent getIntent() {
- synchronized (mInstanceLock) {
- return mIntent;
- }
- }
-
- /**
- * Gets the number of activities that can handle the intent.
- *
- * @return The activity count.
- *
- * @see #setIntent(Intent)
- */
- public int getActivityCount() {
- synchronized (mInstanceLock) {
- return mActivites.size();
- }
- }
-
- /**
- * Gets an activity at a given index.
- *
- * @return The activity.
- *
- * @see ActivityResolveInfo
- * @see #setIntent(Intent)
- */
- public ResolveInfo getActivity(int index) {
- synchronized (mInstanceLock) {
- return mActivites.get(index).resolveInfo;
- }
- }
-
- /**
- * Gets the index of a the given activity.
- *
- * @param activity The activity index.
- *
- * @return The index if found, -1 otherwise.
- */
- public int getActivityIndex(ResolveInfo activity) {
- List activities = mActivites;
- final int activityCount = activities.size();
- for (int i = 0; i < activityCount; i++) {
- ActivityResolveInfo currentActivity = activities.get(i);
- if (currentActivity.resolveInfo == activity) {
- return i;
- }
- }
- return INVALID_INDEX;
- }
-
- /**
- * Chooses a activity to handle the current intent. This will result in
- * adding a historical record for that action and construct intent with
- * its component name set such that it can be immediately started by the
- * client.
- *
- * Note: By calling this method the client guarantees
- * that the returned intent will be started. This intent is returned to
- * the client solely to let additional customization before the start.
- *
- *
- * @return An {@link Intent} for launching the activity or null if the
- * policy has consumed the intent.
- *
- * @see HistoricalRecord
- * @see OnChooseActivityListener
- */
- public Intent chooseActivity(int index) {
- ActivityResolveInfo chosenActivity = mActivites.get(index);
-
- ComponentName chosenName = new ComponentName(
- chosenActivity.resolveInfo.activityInfo.packageName,
- chosenActivity.resolveInfo.activityInfo.name);
-
- Intent choiceIntent = new Intent(mIntent);
- choiceIntent.setComponent(chosenName);
-
- if (mActivityChoserModelPolicy != null) {
- // Do not allow the policy to change the intent.
- Intent choiceIntentCopy = new Intent(choiceIntent);
- final boolean handled = mActivityChoserModelPolicy.onChooseActivity(this,
- choiceIntentCopy);
- if (handled) {
- return null;
- }
- }
-
- HistoricalRecord historicalRecord = new HistoricalRecord(chosenName,
- System.currentTimeMillis(), DEFAULT_HISTORICAL_RECORD_WEIGHT);
- addHisoricalRecord(historicalRecord);
-
- return choiceIntent;
- }
-
- /**
- * Sets the listener for choosing an activity.
- *
- * @param listener The listener.
- */
- public void setOnChooseActivityListener(OnChooseActivityListener listener) {
- mActivityChoserModelPolicy = listener;
- }
-
- /**
- * Gets the default activity, The default activity is defined as the one
- * with highest rank i.e. the first one in the list of activities that can
- * handle the intent.
- *
- * @return The default activity, null id not activities.
- *
- * @see #getActivity(int)
- */
- public ResolveInfo getDefaultActivity() {
- synchronized (mInstanceLock) {
- if (!mActivites.isEmpty()) {
- return mActivites.get(0).resolveInfo;
- }
- }
- return null;
- }
-
- /**
- * Sets the default activity. The default activity is set by adding a
- * historical record with weight high enough that this activity will
- * become the highest ranked. Such a strategy guarantees that the default
- * will eventually change if not used. Also the weight of the record for
- * setting a default is inflated with a constant amount to guarantee that
- * it will stay as default for awhile.
- *
- * @param index The index of the activity to set as default.
- */
- public void setDefaultActivity(int index) {
- ActivityResolveInfo newDefaultActivity = mActivites.get(index);
- ActivityResolveInfo oldDefaultActivity = mActivites.get(0);
-
- final float weight;
- if (oldDefaultActivity != null) {
- // Add a record with weight enough to boost the chosen at the top.
- weight = oldDefaultActivity.weight - newDefaultActivity.weight
- + DEFAULT_ACTIVITY_INFLATION;
- } else {
- weight = DEFAULT_HISTORICAL_RECORD_WEIGHT;
- }
-
- ComponentName defaultName = new ComponentName(
- newDefaultActivity.resolveInfo.activityInfo.packageName,
- newDefaultActivity.resolveInfo.activityInfo.name);
- HistoricalRecord historicalRecord = new HistoricalRecord(defaultName,
- System.currentTimeMillis(), weight);
- addHisoricalRecord(historicalRecord);
- }
-
- /**
- * Reads the history data from the backing file if the latter
- * was provided. Calling this method more than once before a call
- * to {@link #persistHistoricalData()} has been made has no effect.
- *
- * Note: Historical data is read asynchronously and
- * as soon as the reading is completed any registered
- * {@link DataSetObserver}s will be notified. Also no historical
- * data is read until this method is invoked.
- *
- */
- private void readHistoricalData() {
- synchronized (mInstanceLock) {
- if (!mCanReadHistoricalData || !mHistoricalRecordsChanged) {
- return;
- }
- mCanReadHistoricalData = false;
- mReadShareHistoryCalled = true;
- if (!TextUtils.isEmpty(mHistoryFileName)) {
- /*AsyncTask.*/SERIAL_EXECUTOR.execute(new HistoryLoader());
- }
- }
- }
-
- private static final SerialExecutor SERIAL_EXECUTOR = new SerialExecutor();
-
- private static class SerialExecutor implements Executor {
- final LinkedList mTasks = new LinkedList();
- Runnable mActive;
-
- public synchronized void execute(final Runnable r) {
- mTasks.offer(new Runnable() {
- public void run() {
- try {
- r.run();
- } finally {
- scheduleNext();
- }
- }
- });
- if (mActive == null) {
- scheduleNext();
- }
- }
-
- protected synchronized void scheduleNext() {
- if ((mActive = mTasks.poll()) != null) {
- mActive.run();
- }
- }
- }
-
- /**
- * Persists the history data to the backing file if the latter
- * was provided. Calling this method before a call to {@link #readHistoricalData()}
- * throws an exception. Calling this method more than one without choosing an
- * activity has not effect.
- *
- * @throws IllegalStateException If this method is called before a call to
- * {@link #readHistoricalData()}.
- */
- private void persistHistoricalData() {
- synchronized (mInstanceLock) {
- if (!mReadShareHistoryCalled) {
- throw new IllegalStateException("No preceding call to #readHistoricalData");
- }
- if (!mHistoricalRecordsChanged) {
- return;
- }
- mHistoricalRecordsChanged = false;
- mCanReadHistoricalData = true;
- if (!TextUtils.isEmpty(mHistoryFileName)) {
- /*AsyncTask.*/SERIAL_EXECUTOR.execute(new HistoryPersister());
- }
- }
- }
-
- /**
- * Sets the sorter for ordering activities based on historical data and an intent.
- *
- * @param activitySorter The sorter.
- *
- * @see ActivitySorter
- */
- public void setActivitySorter(ActivitySorter activitySorter) {
- synchronized (mInstanceLock) {
- if (mActivitySorter == activitySorter) {
- return;
- }
- mActivitySorter = activitySorter;
- sortActivities();
- }
- }
-
- /**
- * Sorts the activities based on history and an intent. If
- * a sorter is not specified this a default implementation is used.
- *
- * @see #setActivitySorter(ActivitySorter)
- */
- private void sortActivities() {
- synchronized (mInstanceLock) {
- if (mActivitySorter != null && !mActivites.isEmpty()) {
- mActivitySorter.sort(mIntent, mActivites,
- Collections.unmodifiableList(mHistoricalRecords));
- notifyChanged();
- }
- }
- }
-
- /**
- * Sets the maximal size of the historical data. Defaults to
- * {@link #DEFAULT_HISTORY_MAX_LENGTH}
- *
- * Note: Setting this property will immediately
- * enforce the specified max history size by dropping enough old
- * historical records to enforce the desired size. Thus, any
- * records that exceed the history size will be discarded and
- * irreversibly lost.
- *
- *
- * @param historyMaxSize The max history size.
- */
- public void setHistoryMaxSize(int historyMaxSize) {
- synchronized (mInstanceLock) {
- if (mHistoryMaxSize == historyMaxSize) {
- return;
- }
- mHistoryMaxSize = historyMaxSize;
- pruneExcessiveHistoricalRecordsLocked();
- sortActivities();
- }
- }
-
- /**
- * Gets the history max size.
- *
- * @return The history max size.
- */
- public int getHistoryMaxSize() {
- synchronized (mInstanceLock) {
- return mHistoryMaxSize;
- }
- }
-
- /**
- * Gets the history size.
- *
- * @return The history size.
- */
- public int getHistorySize() {
- synchronized (mInstanceLock) {
- return mHistoricalRecords.size();
- }
- }
-
- /**
- * Adds a historical record.
- *
- * @param historicalRecord The record to add.
- * @return True if the record was added.
- */
- private boolean addHisoricalRecord(HistoricalRecord historicalRecord) {
- synchronized (mInstanceLock) {
- final boolean added = mHistoricalRecords.add(historicalRecord);
- if (added) {
- mHistoricalRecordsChanged = true;
- pruneExcessiveHistoricalRecordsLocked();
- persistHistoricalData();
- sortActivities();
- }
- return added;
- }
- }
-
- /**
- * Prunes older excessive records to guarantee {@link #mHistoryMaxSize}.
- */
- private void pruneExcessiveHistoricalRecordsLocked() {
- List choiceRecords = mHistoricalRecords;
- final int pruneCount = choiceRecords.size() - mHistoryMaxSize;
- if (pruneCount <= 0) {
- return;
- }
- mHistoricalRecordsChanged = true;
- for (int i = 0; i < pruneCount; i++) {
- HistoricalRecord prunedRecord = choiceRecords.remove(0);
- if (DEBUG) {
- Log.i(LOG_TAG, "Pruned: " + prunedRecord);
- }
- }
- }
-
- /**
- * Loads the activities.
- */
- private void loadActivitiesLocked() {
- mActivites.clear();
- if (mIntent != null) {
- List resolveInfos =
- mContext.getPackageManager().queryIntentActivities(mIntent, 0);
- final int resolveInfoCount = resolveInfos.size();
- for (int i = 0; i < resolveInfoCount; i++) {
- ResolveInfo resolveInfo = resolveInfos.get(i);
- mActivites.add(new ActivityResolveInfo(resolveInfo));
- }
- sortActivities();
- } else {
- notifyChanged();
- }
- }
-
- /**
- * Represents a record in the history.
- */
- public final static class HistoricalRecord {
-
- /**
- * The activity name.
- */
- public final ComponentName activity;
-
- /**
- * The choice time.
- */
- public final long time;
-
- /**
- * The record weight.
- */
- public final float weight;
-
- /**
- * Creates a new instance.
- *
- * @param activityName The activity component name flattened to string.
- * @param time The time the activity was chosen.
- * @param weight The weight of the record.
- */
- public HistoricalRecord(String activityName, long time, float weight) {
- this(ComponentName.unflattenFromString(activityName), time, weight);
- }
-
- /**
- * Creates a new instance.
- *
- * @param activityName The activity name.
- * @param time The time the activity was chosen.
- * @param weight The weight of the record.
- */
- public HistoricalRecord(ComponentName activityName, long time, float weight) {
- this.activity = activityName;
- this.time = time;
- this.weight = weight;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((activity == null) ? 0 : activity.hashCode());
- result = prime * result + (int) (time ^ (time >>> 32));
- result = prime * result + Float.floatToIntBits(weight);
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- HistoricalRecord other = (HistoricalRecord) obj;
- if (activity == null) {
- if (other.activity != null) {
- return false;
- }
- } else if (!activity.equals(other.activity)) {
- return false;
- }
- if (time != other.time) {
- return false;
- }
- if (Float.floatToIntBits(weight) != Float.floatToIntBits(other.weight)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("[");
- builder.append("; activity:").append(activity);
- builder.append("; time:").append(time);
- builder.append("; weight:").append(new BigDecimal(weight));
- builder.append("]");
- return builder.toString();
- }
- }
-
- /**
- * Represents an activity.
- */
- public final class ActivityResolveInfo implements Comparable {
-
- /**
- * The {@link ResolveInfo} of the activity.
- */
- public final ResolveInfo resolveInfo;
-
- /**
- * Weight of the activity. Useful for sorting.
- */
- public float weight;
-
- /**
- * Creates a new instance.
- *
- * @param resolveInfo activity {@link ResolveInfo}.
- */
- public ActivityResolveInfo(ResolveInfo resolveInfo) {
- this.resolveInfo = resolveInfo;
- }
-
- @Override
- public int hashCode() {
- return 31 + Float.floatToIntBits(weight);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ActivityResolveInfo other = (ActivityResolveInfo) obj;
- if (Float.floatToIntBits(weight) != Float.floatToIntBits(other.weight)) {
- return false;
- }
- return true;
- }
-
- public int compareTo(ActivityResolveInfo another) {
- return Float.floatToIntBits(another.weight) - Float.floatToIntBits(weight);
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("[");
- builder.append("resolveInfo:").append(resolveInfo.toString());
- builder.append("; weight:").append(new BigDecimal(weight));
- builder.append("]");
- return builder.toString();
- }
- }
-
- /**
- * Default activity sorter implementation.
- */
- private final class DefaultSorter implements ActivitySorter {
- private static final float WEIGHT_DECAY_COEFFICIENT = 0.95f;
-
- private final Map mPackageNameToActivityMap =
- new HashMap();
-
- public void sort(Intent intent, List activities,
- List historicalRecords) {
- Map packageNameToActivityMap =
- mPackageNameToActivityMap;
- packageNameToActivityMap.clear();
-
- final int activityCount = activities.size();
- for (int i = 0; i < activityCount; i++) {
- ActivityResolveInfo activity = activities.get(i);
- activity.weight = 0.0f;
- String packageName = activity.resolveInfo.activityInfo.packageName;
- packageNameToActivityMap.put(packageName, activity);
- }
-
- final int lastShareIndex = historicalRecords.size() - 1;
- float nextRecordWeight = 1;
- for (int i = lastShareIndex; i >= 0; i--) {
- HistoricalRecord historicalRecord = historicalRecords.get(i);
- String packageName = historicalRecord.activity.getPackageName();
- ActivityResolveInfo activity = packageNameToActivityMap.get(packageName);
- if (activity != null) {
- activity.weight += historicalRecord.weight * nextRecordWeight;
- nextRecordWeight = nextRecordWeight * WEIGHT_DECAY_COEFFICIENT;
- }
- }
-
- Collections.sort(activities);
-
- if (DEBUG) {
- for (int i = 0; i < activityCount; i++) {
- Log.i(LOG_TAG, "Sorted: " + activities.get(i));
- }
- }
- }
- }
-
- /**
- * Command for reading the historical records from a file off the UI thread.
- */
- private final class HistoryLoader implements Runnable {
-
- public void run() {
- FileInputStream fis = null;
- try {
- fis = mContext.openFileInput(mHistoryFileName);
- } catch (FileNotFoundException fnfe) {
- if (DEBUG) {
- Log.i(LOG_TAG, "Could not open historical records file: " + mHistoryFileName);
- }
- return;
- }
- try {
- XmlPullParser parser = Xml.newPullParser();
- parser.setInput(fis, null);
-
- int type = XmlPullParser.START_DOCUMENT;
- while (type != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
- type = parser.next();
- }
-
- if (!TAG_HISTORICAL_RECORDS.equals(parser.getName())) {
- throw new XmlPullParserException("Share records file does not start with "
- + TAG_HISTORICAL_RECORDS + " tag.");
- }
-
- List readRecords = new ArrayList();
-
- while (true) {
- type = parser.next();
- if (type == XmlPullParser.END_DOCUMENT) {
- break;
- }
- if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
- continue;
- }
- String nodeName = parser.getName();
- if (!TAG_HISTORICAL_RECORD.equals(nodeName)) {
- throw new XmlPullParserException("Share records file not well-formed.");
- }
-
- String activity = parser.getAttributeValue(null, ATTRIBUTE_ACTIVITY);
- final long time =
- Long.parseLong(parser.getAttributeValue(null, ATTRIBUTE_TIME));
- final float weight =
- Float.parseFloat(parser.getAttributeValue(null, ATTRIBUTE_WEIGHT));
-
- HistoricalRecord readRecord = new HistoricalRecord(activity, time,
- weight);
- readRecords.add(readRecord);
-
- if (DEBUG) {
- Log.i(LOG_TAG, "Read " + readRecord.toString());
- }
- }
-
- if (DEBUG) {
- Log.i(LOG_TAG, "Read " + readRecords.size() + " historical records.");
- }
-
- synchronized (mInstanceLock) {
- Set uniqueShareRecords =
- new LinkedHashSet(readRecords);
-
- // Make sure no duplicates. Example: Read a file with
- // one record, add one record, persist the two records,
- // add a record, read the persisted records - the
- // read two records should not be added again.
- List historicalRecords = mHistoricalRecords;
- final int historicalRecordsCount = historicalRecords.size();
- for (int i = historicalRecordsCount - 1; i >= 0; i--) {
- HistoricalRecord historicalRecord = historicalRecords.get(i);
- uniqueShareRecords.add(historicalRecord);
- }
-
- if (historicalRecords.size() == uniqueShareRecords.size()) {
- return;
- }
-
- // Make sure the oldest records go to the end.
- historicalRecords.clear();
- historicalRecords.addAll(uniqueShareRecords);
-
- mHistoricalRecordsChanged = true;
-
- // Do this on the client thread since the client may be on the UI
- // thread, wait for data changes which happen during sorting, and
- // perform UI modification based on the data change.
- mHandler.post(new Runnable() {
- public void run() {
- pruneExcessiveHistoricalRecordsLocked();
- sortActivities();
- }
- });
- }
- } catch (XmlPullParserException xppe) {
- Log.e(LOG_TAG, "Error reading historical recrod file: " + mHistoryFileName, xppe);
- } catch (IOException ioe) {
- Log.e(LOG_TAG, "Error reading historical recrod file: " + mHistoryFileName, ioe);
- } finally {
- if (fis != null) {
- try {
- fis.close();
- } catch (IOException ioe) {
- /* ignore */
- }
- }
- }
- }
- }
-
- /**
- * Command for persisting the historical records to a file off the UI thread.
- */
- private final class HistoryPersister implements Runnable {
-
- public void run() {
- FileOutputStream fos = null;
- List records = null;
-
- synchronized (mInstanceLock) {
- records = new ArrayList(mHistoricalRecords);
- }
-
- try {
- fos = mContext.openFileOutput(mHistoryFileName, Context.MODE_PRIVATE);
- } catch (FileNotFoundException fnfe) {
- Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, fnfe);
- return;
- }
-
- XmlSerializer serializer = Xml.newSerializer();
-
- try {
- serializer.setOutput(fos, null);
- serializer.startDocument("UTF-8", true);
- serializer.startTag(null, TAG_HISTORICAL_RECORDS);
-
- final int recordCount = records.size();
- for (int i = 0; i < recordCount; i++) {
- HistoricalRecord record = records.remove(0);
- serializer.startTag(null, TAG_HISTORICAL_RECORD);
- serializer.attribute(null, ATTRIBUTE_ACTIVITY, record.activity.flattenToString());
- serializer.attribute(null, ATTRIBUTE_TIME, String.valueOf(record.time));
- serializer.attribute(null, ATTRIBUTE_WEIGHT, String.valueOf(record.weight));
- serializer.endTag(null, TAG_HISTORICAL_RECORD);
- if (DEBUG) {
- Log.i(LOG_TAG, "Wrote " + record.toString());
- }
- }
-
- serializer.endTag(null, TAG_HISTORICAL_RECORDS);
- serializer.endDocument();
-
- if (DEBUG) {
- Log.i(LOG_TAG, "Wrote " + recordCount + " historical records.");
- }
- } catch (IllegalArgumentException iae) {
- Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, iae);
- } catch (IllegalStateException ise) {
- Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, ise);
- } catch (IOException ioe) {
- Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, ioe);
- } finally {
- if (fos != null) {
- try {
- fos.close();
- } catch (IOException e) {
- /* ignore */
- }
- }
- }
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/widget/ActivityChooserView.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/widget/ActivityChooserView.java
deleted file mode 100644
index da13bc99f2..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/widget/ActivityChooserView.java
+++ /dev/null
@@ -1,818 +0,0 @@
-/*
- * Copyright (C) 2011 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.actionbarsherlock.widget;
-
-import android.os.Build;
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.internal.widget.IcsLinearLayout;
-import com.actionbarsherlock.internal.widget.IcsListPopupWindow;
-import com.actionbarsherlock.view.ActionProvider;
-import com.actionbarsherlock.widget.ActivityChooserModel.ActivityChooserModelClient;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.database.DataSetObserver;
-import android.graphics.drawable.Drawable;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.ViewTreeObserver;
-import android.view.ViewTreeObserver.OnGlobalLayoutListener;
-import android.widget.AdapterView;
-import android.widget.BaseAdapter;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-import android.widget.PopupWindow;
-import android.widget.TextView;
-
-/**
- * This class is a view for choosing an activity for handling a given {@link Intent}.
- *
- * The view is composed of two adjacent buttons:
- *
- *
- * The left button is an immediate action and allows one click activity choosing.
- * Tapping this button immediately executes the intent without requiring any further
- * user input. Long press on this button shows a popup for changing the default
- * activity.
- *
- *
- * The right button is an overflow action and provides an optimized menu
- * of additional activities. Tapping this button shows a popup anchored to this
- * view, listing the most frequently used activities. This list is initially
- * limited to a small number of items in frequency used order. The last item,
- * "Show all..." serves as an affordance to display all available activities.
- *
- *
- *
- *
- * @hide
- */
-class ActivityChooserView extends ViewGroup implements ActivityChooserModelClient {
-
- /**
- * An adapter for displaying the activities in an {@link AdapterView}.
- */
- private final ActivityChooserViewAdapter mAdapter;
-
- /**
- * Implementation of various interfaces to avoid publishing them in the APIs.
- */
- private final Callbacks mCallbacks;
-
- /**
- * The content of this view.
- */
- private final IcsLinearLayout mActivityChooserContent;
-
- /**
- * Stores the background drawable to allow hiding and latter showing.
- */
- private final Drawable mActivityChooserContentBackground;
-
- /**
- * The expand activities action button;
- */
- private final FrameLayout mExpandActivityOverflowButton;
-
- /**
- * The image for the expand activities action button;
- */
- private final ImageView mExpandActivityOverflowButtonImage;
-
- /**
- * The default activities action button;
- */
- private final FrameLayout mDefaultActivityButton;
-
- /**
- * The image for the default activities action button;
- */
- private final ImageView mDefaultActivityButtonImage;
-
- /**
- * The maximal width of the list popup.
- */
- private final int mListPopupMaxWidth;
-
- /**
- * The ActionProvider hosting this view, if applicable.
- */
- ActionProvider mProvider;
-
- /**
- * Observer for the model data.
- */
- private final DataSetObserver mModelDataSetOberver = new DataSetObserver() {
-
- @Override
- public void onChanged() {
- super.onChanged();
- mAdapter.notifyDataSetChanged();
- }
- @Override
- public void onInvalidated() {
- super.onInvalidated();
- mAdapter.notifyDataSetInvalidated();
- }
- };
-
- private final OnGlobalLayoutListener mOnGlobalLayoutListener = new OnGlobalLayoutListener() {
- @Override
- public void onGlobalLayout() {
- if (isShowingPopup()) {
- if (!isShown()) {
- getListPopupWindow().dismiss();
- } else {
- getListPopupWindow().show();
- if (mProvider != null) {
- mProvider.subUiVisibilityChanged(true);
- }
- }
- }
- }
- };
-
- /**
- * Popup window for showing the activity overflow list.
- */
- private IcsListPopupWindow mListPopupWindow;
-
- /**
- * Listener for the dismissal of the popup/alert.
- */
- private PopupWindow.OnDismissListener mOnDismissListener;
-
- /**
- * Flag whether a default activity currently being selected.
- */
- private boolean mIsSelectingDefaultActivity;
-
- /**
- * The count of activities in the popup.
- */
- private int mInitialActivityCount = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT;
-
- /**
- * Flag whether this view is attached to a window.
- */
- private boolean mIsAttachedToWindow;
-
- /**
- * String resource for formatting content description of the default target.
- */
- private int mDefaultActionButtonContentDescription;
-
- private final Context mContext;
-
- /**
- * Create a new instance.
- *
- * @param context The application environment.
- */
- public ActivityChooserView(Context context) {
- this(context, null);
- }
-
- /**
- * Create a new instance.
- *
- * @param context The application environment.
- * @param attrs A collection of attributes.
- */
- public ActivityChooserView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- /**
- * Create a new instance.
- *
- * @param context The application environment.
- * @param attrs A collection of attributes.
- * @param defStyle The default style to apply to this view.
- */
- public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- mContext = context;
-
- TypedArray attributesArray = context.obtainStyledAttributes(attrs,
- R.styleable.SherlockActivityChooserView, defStyle, 0);
-
- mInitialActivityCount = attributesArray.getInt(
- R.styleable.SherlockActivityChooserView_initialActivityCount,
- ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT);
-
- Drawable expandActivityOverflowButtonDrawable = attributesArray.getDrawable(
- R.styleable.SherlockActivityChooserView_expandActivityOverflowButtonDrawable);
-
- attributesArray.recycle();
-
- LayoutInflater inflater = LayoutInflater.from(mContext);
- inflater.inflate(R.layout.abs__activity_chooser_view, this, true);
-
- mCallbacks = new Callbacks();
-
- mActivityChooserContent = (IcsLinearLayout) findViewById(R.id.abs__activity_chooser_view_content);
- mActivityChooserContentBackground = mActivityChooserContent.getBackground();
-
- mDefaultActivityButton = (FrameLayout) findViewById(R.id.abs__default_activity_button);
- mDefaultActivityButton.setOnClickListener(mCallbacks);
- mDefaultActivityButton.setOnLongClickListener(mCallbacks);
- mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.abs__image);
-
- mExpandActivityOverflowButton = (FrameLayout) findViewById(R.id.abs__expand_activities_button);
- mExpandActivityOverflowButton.setOnClickListener(mCallbacks);
- mExpandActivityOverflowButtonImage =
- (ImageView) mExpandActivityOverflowButton.findViewById(R.id.abs__image);
- mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable);
-
- mAdapter = new ActivityChooserViewAdapter();
- mAdapter.registerDataSetObserver(new DataSetObserver() {
- @Override
- public void onChanged() {
- super.onChanged();
- updateAppearance();
- }
- });
-
- Resources resources = context.getResources();
- mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2,
- resources.getDimensionPixelSize(R.dimen.abs__config_prefDialogWidth));
- }
-
- /**
- * {@inheritDoc}
- */
- public void setActivityChooserModel(ActivityChooserModel dataModel) {
- mAdapter.setDataModel(dataModel);
- if (isShowingPopup()) {
- dismissPopup();
- showPopup();
- }
- }
-
- /**
- * Sets the background for the button that expands the activity
- * overflow list.
- *
- * Note: Clients would like to set this drawable
- * as a clue about the action the chosen activity will perform. For
- * example, if a share activity is to be chosen the drawable should
- * give a clue that sharing is to be performed.
- *
- * @param drawable The drawable.
- */
- public void setExpandActivityOverflowButtonDrawable(Drawable drawable) {
- mExpandActivityOverflowButtonImage.setImageDrawable(drawable);
- }
-
- /**
- * Sets the content description for the button that expands the activity
- * overflow list.
- *
- * description as a clue about the action performed by the button.
- * For example, if a share activity is to be chosen the content
- * description should be something like "Share with".
- *
- * @param resourceId The content description resource id.
- */
- public void setExpandActivityOverflowButtonContentDescription(int resourceId) {
- CharSequence contentDescription = mContext.getString(resourceId);
- mExpandActivityOverflowButtonImage.setContentDescription(contentDescription);
- }
-
- /**
- * Set the provider hosting this view, if applicable.
- * @hide Internal use only
- */
- public void setProvider(ActionProvider provider) {
- mProvider = provider;
- }
-
- /**
- * Shows the popup window with activities.
- *
- * @return True if the popup was shown, false if already showing.
- */
- public boolean showPopup() {
- if (isShowingPopup() || !mIsAttachedToWindow) {
- return false;
- }
- mIsSelectingDefaultActivity = false;
- showPopupUnchecked(mInitialActivityCount);
- return true;
- }
-
- /**
- * Shows the popup no matter if it was already showing.
- *
- * @param maxActivityCount The max number of activities to display.
- */
- private void showPopupUnchecked(int maxActivityCount) {
- if (mAdapter.getDataModel() == null) {
- throw new IllegalStateException("No data model. Did you call #setDataModel?");
- }
-
- getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener);
-
- final boolean defaultActivityButtonShown =
- mDefaultActivityButton.getVisibility() == VISIBLE;
-
- final int activityCount = mAdapter.getActivityCount();
- final int maxActivityCountOffset = defaultActivityButtonShown ? 1 : 0;
- if (maxActivityCount != ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED
- && activityCount > maxActivityCount + maxActivityCountOffset) {
- mAdapter.setShowFooterView(true);
- mAdapter.setMaxActivityCount(maxActivityCount - 1);
- } else {
- mAdapter.setShowFooterView(false);
- mAdapter.setMaxActivityCount(maxActivityCount);
- }
-
- IcsListPopupWindow popupWindow = getListPopupWindow();
- if (!popupWindow.isShowing()) {
- if (mIsSelectingDefaultActivity || !defaultActivityButtonShown) {
- mAdapter.setShowDefaultActivity(true, defaultActivityButtonShown);
- } else {
- mAdapter.setShowDefaultActivity(false, false);
- }
- final int contentWidth = Math.min(mAdapter.measureContentWidth(), mListPopupMaxWidth);
- popupWindow.setContentWidth(contentWidth);
- popupWindow.show();
- if (mProvider != null) {
- mProvider.subUiVisibilityChanged(true);
- }
- popupWindow.getListView().setContentDescription(mContext.getString(
- R.string.abs__activitychooserview_choose_application));
- }
- }
-
- /**
- * Dismisses the popup window with activities.
- *
- * @return True if dismissed, false if already dismissed.
- */
- public boolean dismissPopup() {
- if (isShowingPopup()) {
- getListPopupWindow().dismiss();
- ViewTreeObserver viewTreeObserver = getViewTreeObserver();
- if (viewTreeObserver.isAlive()) {
- viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener);
- }
- }
- return true;
- }
-
- /**
- * Gets whether the popup window with activities is shown.
- *
- * @return True if the popup is shown.
- */
- public boolean isShowingPopup() {
- return getListPopupWindow().isShowing();
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- ActivityChooserModel dataModel = mAdapter.getDataModel();
- if (dataModel != null) {
- dataModel.registerObserver(mModelDataSetOberver);
- }
- mIsAttachedToWindow = true;
- }
-
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- ActivityChooserModel dataModel = mAdapter.getDataModel();
- if (dataModel != null) {
- dataModel.unregisterObserver(mModelDataSetOberver);
- }
- ViewTreeObserver viewTreeObserver = getViewTreeObserver();
- if (viewTreeObserver.isAlive()) {
- viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener);
- }
- mIsAttachedToWindow = false;
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- View child = mActivityChooserContent;
- // If the default action is not visible we want to be as tall as the
- // ActionBar so if this widget is used in the latter it will look as
- // a normal action button.
- if (mDefaultActivityButton.getVisibility() != VISIBLE) {
- heightMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec),
- MeasureSpec.EXACTLY);
- }
- measureChild(child, widthMeasureSpec, heightMeasureSpec);
- setMeasuredDimension(child.getMeasuredWidth(), child.getMeasuredHeight());
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- mActivityChooserContent.layout(0, 0, right - left, bottom - top);
- if (getListPopupWindow().isShowing()) {
- showPopupUnchecked(mAdapter.getMaxActivityCount());
- } else {
- dismissPopup();
- }
- }
-
- public ActivityChooserModel getDataModel() {
- return mAdapter.getDataModel();
- }
-
- /**
- * Sets a listener to receive a callback when the popup is dismissed.
- *
- * @param listener The listener to be notified.
- */
- public void setOnDismissListener(PopupWindow.OnDismissListener listener) {
- mOnDismissListener = listener;
- }
-
- /**
- * Sets the initial count of items shown in the activities popup
- * i.e. the items before the popup is expanded. This is an upper
- * bound since it is not guaranteed that such number of intent
- * handlers exist.
- *
- * @param itemCount The initial popup item count.
- */
- public void setInitialActivityCount(int itemCount) {
- mInitialActivityCount = itemCount;
- }
-
- /**
- * Sets a content description of the default action button. This
- * resource should be a string taking one formatting argument and
- * will be used for formatting the content description of the button
- * dynamically as the default target changes. For example, a resource
- * pointing to the string "share with %1$s" will result in a content
- * description "share with Bluetooth" for the Bluetooth activity.
- *
- * @param resourceId The resource id.
- */
- public void setDefaultActionButtonContentDescription(int resourceId) {
- mDefaultActionButtonContentDescription = resourceId;
- }
-
- /**
- * Gets the list popup window which is lazily initialized.
- *
- * @return The popup.
- */
- private IcsListPopupWindow getListPopupWindow() {
- if (mListPopupWindow == null) {
- mListPopupWindow = new IcsListPopupWindow(getContext());
- mListPopupWindow.setAdapter(mAdapter);
- mListPopupWindow.setAnchorView(ActivityChooserView.this);
- mListPopupWindow.setModal(true);
- mListPopupWindow.setOnItemClickListener(mCallbacks);
- mListPopupWindow.setOnDismissListener(mCallbacks);
- }
- return mListPopupWindow;
- }
-
- /**
- * Updates the buttons state.
- */
- private void updateAppearance() {
- // Expand overflow button.
- if (mAdapter.getCount() > 0) {
- mExpandActivityOverflowButton.setEnabled(true);
- } else {
- mExpandActivityOverflowButton.setEnabled(false);
- }
- // Default activity button.
- final int activityCount = mAdapter.getActivityCount();
- final int historySize = mAdapter.getHistorySize();
- if (activityCount > 0 && historySize > 0) {
- mDefaultActivityButton.setVisibility(VISIBLE);
- ResolveInfo activity = mAdapter.getDefaultActivity();
- PackageManager packageManager = mContext.getPackageManager();
- mDefaultActivityButtonImage.setImageDrawable(activity.loadIcon(packageManager));
- if (mDefaultActionButtonContentDescription != 0) {
- CharSequence label = activity.loadLabel(packageManager);
- String contentDescription = mContext.getString(
- mDefaultActionButtonContentDescription, label);
- mDefaultActivityButton.setContentDescription(contentDescription);
- }
- } else {
- mDefaultActivityButton.setVisibility(View.GONE);
- }
- // Activity chooser content.
- if (mDefaultActivityButton.getVisibility() == VISIBLE) {
- mActivityChooserContent.setBackgroundDrawable(mActivityChooserContentBackground);
- } else {
- mActivityChooserContent.setBackgroundDrawable(null);
- }
- }
-
- /**
- * Interface implementation to avoid publishing them in the APIs.
- */
- private class Callbacks implements AdapterView.OnItemClickListener,
- View.OnClickListener, View.OnLongClickListener, PopupWindow.OnDismissListener {
-
- // AdapterView#OnItemClickListener
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- ActivityChooserViewAdapter adapter = (ActivityChooserViewAdapter) parent.getAdapter();
- final int itemViewType = adapter.getItemViewType(position);
- switch (itemViewType) {
- case ActivityChooserViewAdapter.ITEM_VIEW_TYPE_FOOTER: {
- showPopupUnchecked(ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED);
- } break;
- case ActivityChooserViewAdapter.ITEM_VIEW_TYPE_ACTIVITY: {
- dismissPopup();
- if (mIsSelectingDefaultActivity) {
- // The item at position zero is the default already.
- if (position > 0) {
- mAdapter.getDataModel().setDefaultActivity(position);
- }
- } else {
- // If the default target is not shown in the list, the first
- // item in the model is default action => adjust index
- position = mAdapter.getShowDefaultActivity() ? position : position + 1;
- Intent launchIntent = mAdapter.getDataModel().chooseActivity(position);
- if (launchIntent != null) {
- mContext.startActivity(launchIntent);
- }
- }
- } break;
- default:
- throw new IllegalArgumentException();
- }
- }
-
- // View.OnClickListener
- public void onClick(View view) {
- if (view == mDefaultActivityButton) {
- dismissPopup();
- ResolveInfo defaultActivity = mAdapter.getDefaultActivity();
- final int index = mAdapter.getDataModel().getActivityIndex(defaultActivity);
- Intent launchIntent = mAdapter.getDataModel().chooseActivity(index);
- if (launchIntent != null) {
- mContext.startActivity(launchIntent);
- }
- } else if (view == mExpandActivityOverflowButton) {
- mIsSelectingDefaultActivity = false;
- showPopupUnchecked(mInitialActivityCount);
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- // OnLongClickListener#onLongClick
- @Override
- public boolean onLongClick(View view) {
- if (view == mDefaultActivityButton) {
- if (mAdapter.getCount() > 0) {
- mIsSelectingDefaultActivity = true;
- showPopupUnchecked(mInitialActivityCount);
- }
- } else {
- throw new IllegalArgumentException();
- }
- return true;
- }
-
- // PopUpWindow.OnDismissListener#onDismiss
- public void onDismiss() {
- notifyOnDismissListener();
- if (mProvider != null) {
- mProvider.subUiVisibilityChanged(false);
- }
- }
-
- private void notifyOnDismissListener() {
- if (mOnDismissListener != null) {
- mOnDismissListener.onDismiss();
- }
- }
- }
-
- private static class SetActivated {
- public static void invoke(View view, boolean activated) {
- view.setActivated(activated);
- }
- }
-
- private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
-
- /**
- * Adapter for backing the list of activities shown in the popup.
- */
- private class ActivityChooserViewAdapter extends BaseAdapter {
-
- public static final int MAX_ACTIVITY_COUNT_UNLIMITED = Integer.MAX_VALUE;
-
- public static final int MAX_ACTIVITY_COUNT_DEFAULT = 4;
-
- private static final int ITEM_VIEW_TYPE_ACTIVITY = 0;
-
- private static final int ITEM_VIEW_TYPE_FOOTER = 1;
-
- private static final int ITEM_VIEW_TYPE_COUNT = 3;
-
- private ActivityChooserModel mDataModel;
-
- private int mMaxActivityCount = MAX_ACTIVITY_COUNT_DEFAULT;
-
- private boolean mShowDefaultActivity;
-
- private boolean mHighlightDefaultActivity;
-
- private boolean mShowFooterView;
-
- public void setDataModel(ActivityChooserModel dataModel) {
- ActivityChooserModel oldDataModel = mAdapter.getDataModel();
- if (oldDataModel != null && isShown()) {
- oldDataModel.unregisterObserver(mModelDataSetOberver);
- }
- mDataModel = dataModel;
- if (dataModel != null && isShown()) {
- dataModel.registerObserver(mModelDataSetOberver);
- }
- notifyDataSetChanged();
- }
-
- @Override
- public int getItemViewType(int position) {
- if (mShowFooterView && position == getCount() - 1) {
- return ITEM_VIEW_TYPE_FOOTER;
- } else {
- return ITEM_VIEW_TYPE_ACTIVITY;
- }
- }
-
- @Override
- public int getViewTypeCount() {
- return ITEM_VIEW_TYPE_COUNT;
- }
-
- public int getCount() {
- int count = 0;
- int activityCount = mDataModel.getActivityCount();
- if (!mShowDefaultActivity && mDataModel.getDefaultActivity() != null) {
- activityCount--;
- }
- count = Math.min(activityCount, mMaxActivityCount);
- if (mShowFooterView) {
- count++;
- }
- return count;
- }
-
- public Object getItem(int position) {
- final int itemViewType = getItemViewType(position);
- switch (itemViewType) {
- case ITEM_VIEW_TYPE_FOOTER:
- return null;
- case ITEM_VIEW_TYPE_ACTIVITY:
- if (!mShowDefaultActivity && mDataModel.getDefaultActivity() != null) {
- position++;
- }
- return mDataModel.getActivity(position);
- default:
- throw new IllegalArgumentException();
- }
- }
-
- public long getItemId(int position) {
- return position;
- }
-
- public View getView(int position, View convertView, ViewGroup parent) {
- final int itemViewType = getItemViewType(position);
- switch (itemViewType) {
- case ITEM_VIEW_TYPE_FOOTER:
- if (convertView == null || convertView.getId() != ITEM_VIEW_TYPE_FOOTER) {
- convertView = LayoutInflater.from(getContext()).inflate(
- R.layout.abs__activity_chooser_view_list_item, parent, false);
- convertView.setId(ITEM_VIEW_TYPE_FOOTER);
- TextView titleView = (TextView) convertView.findViewById(R.id.abs__title);
- titleView.setText(mContext.getString(
- R.string.abs__activity_chooser_view_see_all));
- }
- return convertView;
- case ITEM_VIEW_TYPE_ACTIVITY:
- if (convertView == null || convertView.getId() != R.id.abs__list_item) {
- convertView = LayoutInflater.from(getContext()).inflate(
- R.layout.abs__activity_chooser_view_list_item, parent, false);
- }
- PackageManager packageManager = mContext.getPackageManager();
- // Set the icon
- ImageView iconView = (ImageView) convertView.findViewById(R.id.abs__icon);
- ResolveInfo activity = (ResolveInfo) getItem(position);
- iconView.setImageDrawable(activity.loadIcon(packageManager));
- // Set the title.
- TextView titleView = (TextView) convertView.findViewById(R.id.abs__title);
- titleView.setText(activity.loadLabel(packageManager));
- if (IS_HONEYCOMB) {
- // Highlight the default.
- if (mShowDefaultActivity && position == 0 && mHighlightDefaultActivity) {
- SetActivated.invoke(convertView, true);
- } else {
- SetActivated.invoke(convertView, false);
- }
- }
- return convertView;
- default:
- throw new IllegalArgumentException();
- }
- }
-
- public int measureContentWidth() {
- // The user may have specified some of the target not to be shown but we
- // want to measure all of them since after expansion they should fit.
- final int oldMaxActivityCount = mMaxActivityCount;
- mMaxActivityCount = MAX_ACTIVITY_COUNT_UNLIMITED;
-
- int contentWidth = 0;
- View itemView = null;
-
- final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
- final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
- final int count = getCount();
-
- for (int i = 0; i < count; i++) {
- itemView = getView(i, itemView, null);
- itemView.measure(widthMeasureSpec, heightMeasureSpec);
- contentWidth = Math.max(contentWidth, itemView.getMeasuredWidth());
- }
-
- mMaxActivityCount = oldMaxActivityCount;
-
- return contentWidth;
- }
-
- public void setMaxActivityCount(int maxActivityCount) {
- if (mMaxActivityCount != maxActivityCount) {
- mMaxActivityCount = maxActivityCount;
- notifyDataSetChanged();
- }
- }
-
- public ResolveInfo getDefaultActivity() {
- return mDataModel.getDefaultActivity();
- }
-
- public void setShowFooterView(boolean showFooterView) {
- if (mShowFooterView != showFooterView) {
- mShowFooterView = showFooterView;
- notifyDataSetChanged();
- }
- }
-
- public int getActivityCount() {
- return mDataModel.getActivityCount();
- }
-
- public int getHistorySize() {
- return mDataModel.getHistorySize();
- }
-
- public int getMaxActivityCount() {
- return mMaxActivityCount;
- }
-
- public ActivityChooserModel getDataModel() {
- return mDataModel;
- }
-
- public void setShowDefaultActivity(boolean showDefaultActivity,
- boolean highlightDefaultActivity) {
- if (mShowDefaultActivity != showDefaultActivity
- || mHighlightDefaultActivity != highlightDefaultActivity) {
- mShowDefaultActivity = showDefaultActivity;
- mHighlightDefaultActivity = highlightDefaultActivity;
- notifyDataSetChanged();
- }
- }
-
- public boolean getShowDefaultActivity() {
- return mShowDefaultActivity;
- }
- }
-}
diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java
deleted file mode 100644
index 83e9f0ca9f..0000000000
--- a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Copyright (C) 2011 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.actionbarsherlock.widget;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.graphics.drawable.Drawable;
-import android.util.TypedValue;
-import android.view.View;
-
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.view.ActionProvider;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuItem;
-import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener;
-import com.actionbarsherlock.view.SubMenu;
-import com.actionbarsherlock.widget.ActivityChooserModel.OnChooseActivityListener;
-
-/**
- * This is a provider for a share action. It is responsible for creating views
- * that enable data sharing and also to show a sub menu with sharing activities
- * if the hosting item is placed on the overflow menu.
- *
- * Here is how to use the action provider with custom backing file in a {@link MenuItem}:
- *
- *
- *
- *
- * // In Activity#onCreateOptionsMenu
- * public boolean onCreateOptionsMenu(Menu menu) {
- * // Get the menu item.
- * MenuItem menuItem = menu.findItem(R.id.my_menu_item);
- * // Get the provider and hold onto it to set/change the share intent.
- * mShareActionProvider = (ShareActionProvider) menuItem.getActionProvider();
- * // Set history different from the default before getting the action
- * // view since a call to {@link MenuItem#getActionView() MenuItem.getActionView()} calls
- * // {@link ActionProvider#onCreateActionView()} which uses the backing file name. Omit this
- * // line if using the default share history file is desired.
- * mShareActionProvider.setShareHistoryFileName("custom_share_history.xml");
- * . . .
- * }
- *
- * // Somewhere in the application.
- * public void doShare(Intent shareIntent) {
- * // When you want to share set the share intent.
- * mShareActionProvider.setShareIntent(shareIntent);
- * }
- *
- *
- *
- *
- * Note: While the sample snippet demonstrates how to use this provider
- * in the context of a menu item, the use of the provider is not limited to menu items.
- *
- *
- * @see ActionProvider
- */
-public class ShareActionProvider extends ActionProvider {
-
- /**
- * Listener for the event of selecting a share target.
- */
- public interface OnShareTargetSelectedListener {
-
- /**
- * Called when a share target has been selected. The client can
- * decide whether to handle the intent or rely on the default
- * behavior which is launching it.
- *
- * Note: Modifying the intent is not permitted and
- * any changes to the latter will be ignored.
- *
- *
- * @param source The source of the notification.
- * @param intent The intent for launching the chosen share target.
- * @return Whether the client has handled the intent.
- */
- public boolean onShareTargetSelected(ShareActionProvider source, Intent intent);
- }
-
- /**
- * The default for the maximal number of activities shown in the sub-menu.
- */
- private static final int DEFAULT_INITIAL_ACTIVITY_COUNT = 4;
-
- /**
- * The the maximum number activities shown in the sub-menu.
- */
- private int mMaxShownActivityCount = DEFAULT_INITIAL_ACTIVITY_COUNT;
-
- /**
- * Listener for handling menu item clicks.
- */
- private final ShareMenuItemOnMenuItemClickListener mOnMenuItemClickListener =
- new ShareMenuItemOnMenuItemClickListener();
-
- /**
- * The default name for storing share history.
- */
- public static final String DEFAULT_SHARE_HISTORY_FILE_NAME = "share_history.xml";
-
- /**
- * Context for accessing resources.
- */
- private final Context mContext;
-
- /**
- * The name of the file with share history data.
- */
- private String mShareHistoryFileName = DEFAULT_SHARE_HISTORY_FILE_NAME;
-
- private OnShareTargetSelectedListener mOnShareTargetSelectedListener;
-
- private OnChooseActivityListener mOnChooseActivityListener;
-
- /**
- * Creates a new instance.
- *
- * @param context Context for accessing resources.
- */
- public ShareActionProvider(Context context) {
- super(context);
- mContext = context;
- }
-
- /**
- * Sets a listener to be notified when a share target has been selected.
- * The listener can optionally decide to handle the selection and
- * not rely on the default behavior which is to launch the activity.
- *
- * Note: If you choose the backing share history file
- * you will still be notified in this callback.
- *
- * @param listener The listener.
- */
- public void setOnShareTargetSelectedListener(OnShareTargetSelectedListener listener) {
- mOnShareTargetSelectedListener = listener;
- setActivityChooserPolicyIfNeeded();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public View onCreateActionView() {
- // Create the view and set its data model.
- ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
- ActivityChooserView activityChooserView = new ActivityChooserView(mContext);
- activityChooserView.setActivityChooserModel(dataModel);
-
- // Lookup and set the expand action icon.
- TypedValue outTypedValue = new TypedValue();
- mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true);
- Drawable drawable = mContext.getResources().getDrawable(outTypedValue.resourceId);
- activityChooserView.setExpandActivityOverflowButtonDrawable(drawable);
- activityChooserView.setProvider(this);
-
- // Set content description.
- activityChooserView.setDefaultActionButtonContentDescription(
- R.string.abs__shareactionprovider_share_with_application);
- activityChooserView.setExpandActivityOverflowButtonContentDescription(
- R.string.abs__shareactionprovider_share_with);
-
- return activityChooserView;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean hasSubMenu() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onPrepareSubMenu(SubMenu subMenu) {
- // Clear since the order of items may change.
- subMenu.clear();
-
- ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
- PackageManager packageManager = mContext.getPackageManager();
-
- final int expandedActivityCount = dataModel.getActivityCount();
- final int collapsedActivityCount = Math.min(expandedActivityCount, mMaxShownActivityCount);
-
- // Populate the sub-menu with a sub set of the activities.
- for (int i = 0; i < collapsedActivityCount; i++) {
- ResolveInfo activity = dataModel.getActivity(i);
- subMenu.add(0, i, i, activity.loadLabel(packageManager))
- .setIcon(activity.loadIcon(packageManager))
- .setOnMenuItemClickListener(mOnMenuItemClickListener);
- }
-
- if (collapsedActivityCount < expandedActivityCount) {
- // Add a sub-menu for showing all activities as a list item.
- SubMenu expandedSubMenu = subMenu.addSubMenu(Menu.NONE, collapsedActivityCount,
- collapsedActivityCount,
- mContext.getString(R.string.abs__activity_chooser_view_see_all));
- for (int i = 0; i < expandedActivityCount; i++) {
- ResolveInfo activity = dataModel.getActivity(i);
- expandedSubMenu.add(0, i, i, activity.loadLabel(packageManager))
- .setIcon(activity.loadIcon(packageManager))
- .setOnMenuItemClickListener(mOnMenuItemClickListener);
- }
- }
- }
-
- /**
- * Sets the file name of a file for persisting the share history which
- * history will be used for ordering share targets. This file will be used
- * for all view created by {@link #onCreateActionView()}. Defaults to
- * {@link #DEFAULT_SHARE_HISTORY_FILE_NAME}. Set to null
- * if share history should not be persisted between sessions.
- *
- * Note: The history file name can be set any time, however
- * only the action views created by {@link #onCreateActionView()} after setting
- * the file name will be backed by the provided file.
- *
- *
- * @param shareHistoryFile The share history file name.
- */
- public void setShareHistoryFileName(String shareHistoryFile) {
- mShareHistoryFileName = shareHistoryFile;
- setActivityChooserPolicyIfNeeded();
- }
-
- /**
- * Sets an intent with information about the share action. Here is a
- * sample for constructing a share intent:
- *
- *
- *
- * Intent shareIntent = new Intent(Intent.ACTION_SEND);
- * shareIntent.setType("image/*");
- * Uri uri = Uri.fromFile(new File(getFilesDir(), "foo.jpg"));
- * shareIntent.putExtra(Intent.EXTRA_STREAM, uri.toString());
- *
- *
- *
- *
- * @param shareIntent The share intent.
- *
- * @see Intent#ACTION_SEND
- * @see Intent#ACTION_SEND_MULTIPLE
- */
- public void setShareIntent(Intent shareIntent) {
- ActivityChooserModel dataModel = ActivityChooserModel.get(mContext,
- mShareHistoryFileName);
- dataModel.setIntent(shareIntent);
- }
-
- /**
- * Reusable listener for handling share item clicks.
- */
- private class ShareMenuItemOnMenuItemClickListener implements OnMenuItemClickListener {
- @Override
- public boolean onMenuItemClick(MenuItem item) {
- ActivityChooserModel dataModel = ActivityChooserModel.get(mContext,
- mShareHistoryFileName);
- final int itemId = item.getItemId();
- Intent launchIntent = dataModel.chooseActivity(itemId);
- if (launchIntent != null) {
- mContext.startActivity(launchIntent);
- }
- return true;
- }
- }
-
- /**
- * Set the activity chooser policy of the model backed by the current
- * share history file if needed which is if there is a registered callback.
- */
- private void setActivityChooserPolicyIfNeeded() {
- if (mOnShareTargetSelectedListener == null) {
- return;
- }
- if (mOnChooseActivityListener == null) {
- mOnChooseActivityListener = new ShareAcitivityChooserModelPolicy();
- }
- ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
- dataModel.setOnChooseActivityListener(mOnChooseActivityListener);
- }
-
- /**
- * Policy that delegates to the {@link OnShareTargetSelectedListener}, if such.
- */
- private class ShareAcitivityChooserModelPolicy implements OnChooseActivityListener {
- @Override
- public boolean onChooseActivity(ActivityChooserModel host, Intent intent) {
- if (mOnShareTargetSelectedListener != null) {
- return mOnShareTargetSelectedListener.onShareTargetSelected(
- ShareActionProvider.this, intent);
- }
- return false;
- }
- }
-}
diff --git a/android-libraries/TreeViewList/.classpath b/android-libraries/TreeViewList/.classpath
deleted file mode 100644
index a4f1e40546..0000000000
--- a/android-libraries/TreeViewList/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/android-libraries/TreeViewList/.project b/android-libraries/TreeViewList/.project
deleted file mode 100644
index c9d4fdaccf..0000000000
--- a/android-libraries/TreeViewList/.project
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
- TreeViewList
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
diff --git a/android-libraries/TreeViewList/AndroidManifest.xml b/android-libraries/TreeViewList/AndroidManifest.xml
deleted file mode 100644
index 28a7fe08e6..0000000000
--- a/android-libraries/TreeViewList/AndroidManifest.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android-libraries/TreeViewList/gen/pl/polidea/treeview/BuildConfig.java b/android-libraries/TreeViewList/gen/pl/polidea/treeview/BuildConfig.java
deleted file mode 100644
index 18bc91b3b7..0000000000
--- a/android-libraries/TreeViewList/gen/pl/polidea/treeview/BuildConfig.java
+++ /dev/null
@@ -1,6 +0,0 @@
-/** Automatically generated file. DO NOT MODIFY */
-package pl.polidea.treeview;
-
-public final class BuildConfig {
- public final static boolean DEBUG = true;
-}
\ No newline at end of file
diff --git a/android-libraries/TreeViewList/gen/pl/polidea/treeview/R.java b/android-libraries/TreeViewList/gen/pl/polidea/treeview/R.java
deleted file mode 100644
index 3ef9b35472..0000000000
--- a/android-libraries/TreeViewList/gen/pl/polidea/treeview/R.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/* AUTO-GENERATED FILE. DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * aapt tool from the resource data it found. It
- * should not be modified by hand.
- */
-
-package pl.polidea.treeview;
-
-public final class R {
- public static final class attr {
- /**
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int collapsible=0x7f010000;
- /**
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int handle_trackball_press=0x7f010004;
- /**
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- */
- public static int indent_width=0x7f010003;
- /**
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
- */
- public static int indicator_background=0x7f010006;
- /**
Must be one or more (separated by '|') of the following constant values.
-
-
-
-
-
Constant
Value
Description
-
top
0x30
Push object to the top of its container, not changing its size.
-
bottom
0x50
Push object to the bottom of its container, not changing its size.
-
left
0x03
Push object to the left of its container, not changing its size.
-
right
0x05
Push object to the right of its container, not changing its size.
-
center_vertical
0x10
Place object in the vertical center of its container, not changing its size.
-
fill_vertical
0x70
Grow the vertical size of the object if needed so it completely fills its container.
-
center_horizontal
0x01
Place object in the horizontal center of its container, not changing its size.
-
fill_horizontal
0x07
Grow the horizontal size of the object if needed so it completely fills its container.
-
center
0x11
Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.
-
fill
0x77
Grow the horizontal and vertical size of the object if needed so it completely fills its container.
-
clip_vertical
0x80
Additional option that can be set to have the top and/or bottom edges of the child clipped to its container's bounds.
- The clip will be based on the vertical gravity: a top gravity will clip the bottom edge, a bottom gravity will clip the top
- edge, and neither will clip both edges.
-
clip_horizontal
0x08
Additional option that can be set to have the left and/or right edges of the child clipped to its container's bounds.
- The clip will be based on the horizontal gravity: a left gravity will clip the right edge, a right gravity will clip the
- left edge, and neither will clip both edges.
-
- */
- public static int indicator_gravity=0x7f010005;
- /**
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
- */
- public static int row_background=0x7f010007;
- /**
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
- */
- public static int src_collapsed=0x7f010002;
- /**
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
- */
- public static int src_expanded=0x7f010001;
- }
- public static final class drawable {
- public static int collapsed=0x7f020000;
- public static int divider=0x7f020001;
- public static int expanded=0x7f020002;
- public static int ic_launcher=0x7f020003;
- public static int list_selector_background=0x7f020004;
- public static int list_selector_background_disabled=0x7f020005;
- public static int list_selector_background_focus=0x7f020006;
- public static int list_selector_background_longpress=0x7f020007;
- public static int list_selector_background_pressed=0x7f020008;
- public static int list_selector_background_transition=0x7f020009;
- }
- public static final class id {
- public static int bottom=0x7f040001;
- public static int center=0x7f040008;
- public static int center_horizontal=0x7f040006;
- public static int center_vertical=0x7f040004;
- public static int clip_horizontal=0x7f04000b;
- public static int clip_vertical=0x7f04000a;
- public static int fill=0x7f040009;
- public static int fill_horizontal=0x7f040007;
- public static int fill_vertical=0x7f040005;
- public static int left=0x7f040002;
- public static int right=0x7f040003;
- public static int top=0x7f040000;
- public static int treeview_list_item_frame=0x7f04000e;
- public static int treeview_list_item_image=0x7f04000d;
- public static int treeview_list_item_image_layout=0x7f04000c;
- }
- public static final class layout {
- public static int tree_list_item_wrapper=0x7f030000;
- }
- public static final class style {
- public static int treeViewListStyle=0x7f050000;
- }
- public static final class styleable {
- /** Attributes that can be used with a TreeViewList.
-
This symbol is the offset where the {@link pl.polidea.treeview.R.attr#collapsible}
- attribute's value can be found in the {@link #TreeViewList} array.
-
-
-
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- @attr name android:collapsible
- */
- public static final int TreeViewList_collapsible = 0;
- /**
-
This symbol is the offset where the {@link pl.polidea.treeview.R.attr#handle_trackball_press}
- attribute's value can be found in the {@link #TreeViewList} array.
-
-
-
Must be a boolean value, either "true" or "false".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- @attr name android:handle_trackball_press
- */
- public static final int TreeViewList_handle_trackball_press = 4;
- /**
-
This symbol is the offset where the {@link pl.polidea.treeview.R.attr#indent_width}
- attribute's value can be found in the {@link #TreeViewList} array.
-
-
-
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
-Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
-in (inches), mm (millimeters).
-
This may also be a reference to a resource (in the form
-"@[package:]type:name") or
-theme attribute (in the form
-"?[package:][type:]name")
-containing a value of this type.
- @attr name android:indent_width
- */
- public static final int TreeViewList_indent_width = 3;
- /**
-
This symbol is the offset where the {@link pl.polidea.treeview.R.attr#indicator_background}
- attribute's value can be found in the {@link #TreeViewList} array.
-
-
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
- @attr name android:indicator_background
- */
- public static final int TreeViewList_indicator_background = 6;
- /**
-
This symbol is the offset where the {@link pl.polidea.treeview.R.attr#indicator_gravity}
- attribute's value can be found in the {@link #TreeViewList} array.
-
-
-
Must be one or more (separated by '|') of the following constant values.
-
-
-
-
-
Constant
Value
Description
-
top
0x30
Push object to the top of its container, not changing its size.
-
bottom
0x50
Push object to the bottom of its container, not changing its size.
-
left
0x03
Push object to the left of its container, not changing its size.
-
right
0x05
Push object to the right of its container, not changing its size.
-
center_vertical
0x10
Place object in the vertical center of its container, not changing its size.
-
fill_vertical
0x70
Grow the vertical size of the object if needed so it completely fills its container.
-
center_horizontal
0x01
Place object in the horizontal center of its container, not changing its size.
-
fill_horizontal
0x07
Grow the horizontal size of the object if needed so it completely fills its container.
-
center
0x11
Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.
-
fill
0x77
Grow the horizontal and vertical size of the object if needed so it completely fills its container.
-
clip_vertical
0x80
Additional option that can be set to have the top and/or bottom edges of the child clipped to its container's bounds.
- The clip will be based on the vertical gravity: a top gravity will clip the bottom edge, a bottom gravity will clip the top
- edge, and neither will clip both edges.
-
clip_horizontal
0x08
Additional option that can be set to have the left and/or right edges of the child clipped to its container's bounds.
- The clip will be based on the horizontal gravity: a left gravity will clip the right edge, a right gravity will clip the
- left edge, and neither will clip both edges.
-
- @attr name android:indicator_gravity
- */
- public static final int TreeViewList_indicator_gravity = 5;
- /**
-
This symbol is the offset where the {@link pl.polidea.treeview.R.attr#row_background}
- attribute's value can be found in the {@link #TreeViewList} array.
-
-
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
- @attr name android:row_background
- */
- public static final int TreeViewList_row_background = 7;
- /**
-
This symbol is the offset where the {@link pl.polidea.treeview.R.attr#src_collapsed}
- attribute's value can be found in the {@link #TreeViewList} array.
-
-
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
- @attr name android:src_collapsed
- */
- public static final int TreeViewList_src_collapsed = 2;
- /**
-
This symbol is the offset where the {@link pl.polidea.treeview.R.attr#src_expanded}
- attribute's value can be found in the {@link #TreeViewList} array.
-
-
-
May be a reference to another resource, in the form "@[+][package:]type:name"
-or to a theme attribute in the form "?[package:][type:]name".
-
May be a color value, in the form of "#rgb", "#argb",
-"#rrggbb", or "#aarrggbb".
- @attr name android:src_expanded
- */
- public static final int TreeViewList_src_expanded = 1;
- };
-}
diff --git a/android-libraries/TreeViewList/proguard.cfg b/android-libraries/TreeViewList/proguard.cfg
deleted file mode 100644
index b1cdf17b5b..0000000000
--- a/android-libraries/TreeViewList/proguard.cfg
+++ /dev/null
@@ -1,40 +0,0 @@
--optimizationpasses 5
--dontusemixedcaseclassnames
--dontskipnonpubliclibraryclasses
--dontpreverify
--verbose
--optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-
--keep public class * extends android.app.Activity
--keep public class * extends android.app.Application
--keep public class * extends android.app.Service
--keep public class * extends android.content.BroadcastReceiver
--keep public class * extends android.content.ContentProvider
--keep public class * extends android.app.backup.BackupAgentHelper
--keep public class * extends android.preference.Preference
--keep public class com.android.vending.licensing.ILicensingService
-
--keepclasseswithmembernames class * {
- native ;
-}
-
--keepclasseswithmembers class * {
- public (android.content.Context, android.util.AttributeSet);
-}
-
--keepclasseswithmembers class * {
- public (android.content.Context, android.util.AttributeSet, int);
-}
-
--keepclassmembers class * extends android.app.Activity {
- public void *(android.view.View);
-}
-
--keepclassmembers enum * {
- public static **[] values();
- public static ** valueOf(java.lang.String);
-}
-
--keep class * implements android.os.Parcelable {
- public static final android.os.Parcelable$Creator *;
-}
diff --git a/android-libraries/TreeViewList/project.properties b/android-libraries/TreeViewList/project.properties
deleted file mode 100644
index 5fa344c933..0000000000
--- a/android-libraries/TreeViewList/project.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-15
-android.library=true
diff --git a/android-libraries/TreeViewList/res/drawable-hdpi/collapsed.png b/android-libraries/TreeViewList/res/drawable-hdpi/collapsed.png
deleted file mode 100644
index c1e1f3d516..0000000000
Binary files a/android-libraries/TreeViewList/res/drawable-hdpi/collapsed.png and /dev/null differ
diff --git a/android-libraries/TreeViewList/res/drawable-hdpi/expanded.png b/android-libraries/TreeViewList/res/drawable-hdpi/expanded.png
deleted file mode 100644
index cec254aa7f..0000000000
Binary files a/android-libraries/TreeViewList/res/drawable-hdpi/expanded.png and /dev/null differ
diff --git a/android-libraries/TreeViewList/res/drawable-hdpi/ic_launcher.png b/android-libraries/TreeViewList/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index 8074c4c571..0000000000
Binary files a/android-libraries/TreeViewList/res/drawable-hdpi/ic_launcher.png and /dev/null differ
diff --git a/android-libraries/TreeViewList/res/drawable-ldpi/collapsed.png b/android-libraries/TreeViewList/res/drawable-ldpi/collapsed.png
deleted file mode 100644
index a52e846afa..0000000000
Binary files a/android-libraries/TreeViewList/res/drawable-ldpi/collapsed.png and /dev/null differ
diff --git a/android-libraries/TreeViewList/res/drawable-ldpi/expanded.png b/android-libraries/TreeViewList/res/drawable-ldpi/expanded.png
deleted file mode 100644
index d8b7ab894e..0000000000
Binary files a/android-libraries/TreeViewList/res/drawable-ldpi/expanded.png and /dev/null differ
diff --git a/android-libraries/TreeViewList/res/drawable-ldpi/ic_launcher.png b/android-libraries/TreeViewList/res/drawable-ldpi/ic_launcher.png
deleted file mode 100644
index 1095584ec2..0000000000
Binary files a/android-libraries/TreeViewList/res/drawable-ldpi/ic_launcher.png and /dev/null differ
diff --git a/android-libraries/TreeViewList/res/drawable-mdpi/collapsed.png b/android-libraries/TreeViewList/res/drawable-mdpi/collapsed.png
deleted file mode 100644
index b23555145f..0000000000
Binary files a/android-libraries/TreeViewList/res/drawable-mdpi/collapsed.png and /dev/null differ
diff --git a/android-libraries/TreeViewList/res/drawable-mdpi/expanded.png b/android-libraries/TreeViewList/res/drawable-mdpi/expanded.png
deleted file mode 100644
index f7377cb30c..0000000000
Binary files a/android-libraries/TreeViewList/res/drawable-mdpi/expanded.png and /dev/null differ
diff --git a/android-libraries/TreeViewList/res/drawable-mdpi/ic_launcher.png b/android-libraries/TreeViewList/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644
index a07c69fa5a..0000000000
Binary files a/android-libraries/TreeViewList/res/drawable-mdpi/ic_launcher.png and /dev/null differ
diff --git a/android-libraries/TreeViewList/res/drawable/divider.xml b/android-libraries/TreeViewList/res/drawable/divider.xml
deleted file mode 100644
index 5f37949925..0000000000
--- a/android-libraries/TreeViewList/res/drawable/divider.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
diff --git a/android-libraries/TreeViewList/res/drawable/list_selector_background.xml b/android-libraries/TreeViewList/res/drawable/list_selector_background.xml
deleted file mode 100644
index 2b21b0c1c4..0000000000
--- a/android-libraries/TreeViewList/res/drawable/list_selector_background.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android-libraries/TreeViewList/res/drawable/list_selector_background_disabled.9.png b/android-libraries/TreeViewList/res/drawable/list_selector_background_disabled.9.png
deleted file mode 100644
index bf970b0509..0000000000
Binary files a/android-libraries/TreeViewList/res/drawable/list_selector_background_disabled.9.png and /dev/null differ
diff --git a/android-libraries/TreeViewList/res/drawable/list_selector_background_focus.9.png b/android-libraries/TreeViewList/res/drawable/list_selector_background_focus.9.png
deleted file mode 100644
index c3e2415866..0000000000
Binary files a/android-libraries/TreeViewList/res/drawable/list_selector_background_focus.9.png and /dev/null differ
diff --git a/android-libraries/TreeViewList/res/drawable/list_selector_background_longpress.9.png b/android-libraries/TreeViewList/res/drawable/list_selector_background_longpress.9.png
deleted file mode 100644
index 5cbb251a7d..0000000000
Binary files a/android-libraries/TreeViewList/res/drawable/list_selector_background_longpress.9.png and /dev/null differ
diff --git a/android-libraries/TreeViewList/res/drawable/list_selector_background_pressed.9.png b/android-libraries/TreeViewList/res/drawable/list_selector_background_pressed.9.png
deleted file mode 100644
index 02b4e9a536..0000000000
Binary files a/android-libraries/TreeViewList/res/drawable/list_selector_background_pressed.9.png and /dev/null differ
diff --git a/android-libraries/TreeViewList/res/drawable/list_selector_background_transition.xml b/android-libraries/TreeViewList/res/drawable/list_selector_background_transition.xml
deleted file mode 100644
index 0dec1335df..0000000000
--- a/android-libraries/TreeViewList/res/drawable/list_selector_background_transition.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
diff --git a/android-libraries/TreeViewList/res/layout/tree_list_item_wrapper.xml b/android-libraries/TreeViewList/res/layout/tree_list_item_wrapper.xml
deleted file mode 100644
index 9512a0c807..0000000000
--- a/android-libraries/TreeViewList/res/layout/tree_list_item_wrapper.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/android-libraries/TreeViewList/res/values/attrs.xml b/android-libraries/TreeViewList/res/values/attrs.xml
deleted file mode 100644
index 30060a4c7e..0000000000
--- a/android-libraries/TreeViewList/res/values/attrs.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android-libraries/TreeViewList/res/values/styles.xml b/android-libraries/TreeViewList/res/values/styles.xml
deleted file mode 100644
index 005c60078f..0000000000
--- a/android-libraries/TreeViewList/res/values/styles.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
diff --git a/android-libraries/TreeViewList/src/pl/polidea/treeview/AbstractTreeViewAdapter.java b/android-libraries/TreeViewList/src/pl/polidea/treeview/AbstractTreeViewAdapter.java
deleted file mode 100644
index 7f2b366ade..0000000000
--- a/android-libraries/TreeViewList/src/pl/polidea/treeview/AbstractTreeViewAdapter.java
+++ /dev/null
@@ -1,315 +0,0 @@
-package pl.polidea.treeview;
-
-import android.app.Activity;
-import android.content.Context;
-import android.database.DataSetObserver;
-import android.graphics.drawable.Drawable;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.FrameLayout;
-import android.widget.FrameLayout.LayoutParams;
-import android.widget.ImageView;
-import android.widget.ImageView.ScaleType;
-import android.widget.LinearLayout;
-import android.widget.ListAdapter;
-
-/**
- * Adapter used to feed the table view.
- *
- * @param
- * class for ID of the tree
- */
-public abstract class AbstractTreeViewAdapter extends BaseAdapter implements
- ListAdapter {
- private final TreeStateManager treeStateManager;
- private final int numberOfLevels;
- private final LayoutInflater layoutInflater;
-
- private int indentWidth = 0;
- private int indicatorGravity = 0;
- private Drawable collapsedDrawable;
- private Drawable expandedDrawable;
- private Drawable indicatorBackgroundDrawable;
- private Drawable rowBackgroundDrawable;
-
- private final OnClickListener indicatorClickListener = new OnClickListener() {
- @Override
- public void onClick(final View v) {
- @SuppressWarnings("unchecked")
- final T id = (T) v.getTag();
- expandCollapse(id);
- }
- };
-
- private boolean collapsible;
- private final Activity activity;
-
- public Activity getActivity() {
- return activity;
- }
-
- protected TreeStateManager getManager() {
- return treeStateManager;
- }
-
- protected void expandCollapse(final T id) {
- final TreeNodeInfo info = treeStateManager.getNodeInfo(id);
- if (!info.isWithChildren()) {
- // ignore - no default action
- return;
- }
- if (info.isExpanded()) {
- treeStateManager.collapseChildren(id);
- } else {
- treeStateManager.expandDirectChildren(id);
- }
- }
-
- private void calculateIndentWidth() {
- if (expandedDrawable != null) {
- indentWidth = Math.max(getIndentWidth(),
- expandedDrawable.getIntrinsicWidth());
- }
- if (collapsedDrawable != null) {
- indentWidth = Math.max(getIndentWidth(),
- collapsedDrawable.getIntrinsicWidth());
- }
- }
-
- public AbstractTreeViewAdapter(final Activity activity,
- final TreeStateManager treeStateManager, final int numberOfLevels) {
- this.activity = activity;
- this.treeStateManager = treeStateManager;
- this.layoutInflater = (LayoutInflater) activity
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- this.numberOfLevels = numberOfLevels;
- this.collapsedDrawable = null;
- this.expandedDrawable = null;
- this.rowBackgroundDrawable = null;
- this.indicatorBackgroundDrawable = null;
- }
-
- @Override
- public void registerDataSetObserver(final DataSetObserver observer) {
- treeStateManager.registerDataSetObserver(observer);
- }
-
- @Override
- public void unregisterDataSetObserver(final DataSetObserver observer) {
- treeStateManager.unregisterDataSetObserver(observer);
- }
-
- @Override
- public int getCount() {
- return treeStateManager.getVisibleCount();
- }
-
- @Override
- public Object getItem(final int position) {
- return getItemId(position);
- }
-
- public T getTreeId(final int position) {
- return treeStateManager.getVisibleList().get(position);
- }
-
- public TreeNodeInfo getTreeNodeInfo(final int position) {
- return treeStateManager.getNodeInfo(getTreeId(position));
- }
-
- @Override
- public boolean hasStableIds() { // NOPMD
- return true;
- }
-
- @Override
- public int getItemViewType(final int position) {
- return getTreeNodeInfo(position).getLevel();
- }
-
- @Override
- public int getViewTypeCount() {
- return numberOfLevels;
- }
-
- @Override
- public boolean isEmpty() {
- return getCount() == 0;
- }
-
- @Override
- public boolean areAllItemsEnabled() { // NOPMD
- return true;
- }
-
- @Override
- public boolean isEnabled(final int position) { // NOPMD
- return true;
- }
-
- protected int getTreeListItemWrapperId() {
- return R.layout.tree_list_item_wrapper;
- }
-
- @Override
- public final View getView(final int position, final View convertView,
- final ViewGroup parent) {
- final TreeNodeInfo nodeInfo = getTreeNodeInfo(position);
- if (convertView == null) {
- final LinearLayout layout = (LinearLayout) layoutInflater.inflate(
- getTreeListItemWrapperId(), null);
- return populateTreeItem(layout, getNewChildView(nodeInfo),
- nodeInfo, true);
- } else {
- final LinearLayout linear = (LinearLayout) convertView;
- final FrameLayout frameLayout = (FrameLayout) linear
- .findViewById(R.id.treeview_list_item_frame);
- final View childView = frameLayout.getChildAt(0);
- updateView(childView, nodeInfo);
- return populateTreeItem(linear, childView, nodeInfo, false);
- }
- }
-
- /**
- * Called when new view is to be created.
- *
- * @param treeNodeInfo
- * node info
- * @return view that should be displayed as tree content
- */
- public abstract View getNewChildView(TreeNodeInfo treeNodeInfo);
-
- /**
- * Called when new view is going to be reused. You should update the view
- * and fill it in with the data required to display the new information. You
- * can also create a new view, which will mean that the old view will not be
- * reused.
- *
- * @param view
- * view that should be updated with the new values
- * @param treeNodeInfo
- * node info used to populate the view
- * @return view to used as row indented content
- */
- public abstract View updateView(View view, TreeNodeInfo treeNodeInfo);
-
- /**
- * Retrieves background drawable for the node.
- *
- * @param treeNodeInfo
- * node info
- * @return drawable returned as background for the whole row. Might be null,
- * then default background is used
- */
- public Drawable getBackgroundDrawable(final TreeNodeInfo treeNodeInfo) { // NOPMD
- return null;
- }
-
- private Drawable getDrawableOrDefaultBackground(final Drawable r) {
- if (r == null) {
- return activity.getResources()
- .getDrawable(R.drawable.list_selector_background).mutate();
- } else {
- return r;
- }
- }
-
- public final LinearLayout populateTreeItem(final LinearLayout layout,
- final View childView, final TreeNodeInfo nodeInfo,
- final boolean newChildView) {
- final Drawable individualRowDrawable = getBackgroundDrawable(nodeInfo);
- layout.setBackgroundDrawable(individualRowDrawable == null ? getDrawableOrDefaultBackground(rowBackgroundDrawable)
- : individualRowDrawable);
- final LinearLayout.LayoutParams indicatorLayoutParams = new LinearLayout.LayoutParams(
- calculateIndentation(nodeInfo), LayoutParams.FILL_PARENT);
- final LinearLayout indicatorLayout = (LinearLayout) layout
- .findViewById(R.id.treeview_list_item_image_layout);
- indicatorLayout.setGravity(indicatorGravity);
- indicatorLayout.setLayoutParams(indicatorLayoutParams);
- final ImageView image = (ImageView) layout
- .findViewById(R.id.treeview_list_item_image);
- image.setImageDrawable(getDrawable(nodeInfo));
- image.setBackgroundDrawable(getDrawableOrDefaultBackground(indicatorBackgroundDrawable));
- image.setScaleType(ScaleType.CENTER);
- image.setTag(nodeInfo.getId());
- if (nodeInfo.isWithChildren() && collapsible) {
- image.setOnClickListener(indicatorClickListener);
- } else {
- image.setOnClickListener(null);
- }
- layout.setTag(nodeInfo.getId());
- final FrameLayout frameLayout = (FrameLayout) layout
- .findViewById(R.id.treeview_list_item_frame);
- final FrameLayout.LayoutParams childParams = new FrameLayout.LayoutParams(
- LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
- if (newChildView) {
- frameLayout.addView(childView, childParams);
- }
- frameLayout.setTag(nodeInfo.getId());
- return layout;
- }
-
- protected int calculateIndentation(final TreeNodeInfo nodeInfo) {
- return getIndentWidth() * (nodeInfo.getLevel() + (collapsible ? 1 : 0));
- }
-
- private Drawable getDrawable(final TreeNodeInfo nodeInfo) {
- if (!nodeInfo.isWithChildren() || !collapsible) {
- return getDrawableOrDefaultBackground(indicatorBackgroundDrawable);
- }
- if (nodeInfo.isExpanded()) {
- return expandedDrawable;
- } else {
- return collapsedDrawable;
- }
- }
-
- public void setIndicatorGravity(final int indicatorGravity) {
- this.indicatorGravity = indicatorGravity;
- }
-
- public void setCollapsedDrawable(final Drawable collapsedDrawable) {
- this.collapsedDrawable = collapsedDrawable;
- calculateIndentWidth();
- }
-
- public void setExpandedDrawable(final Drawable expandedDrawable) {
- this.expandedDrawable = expandedDrawable;
- calculateIndentWidth();
- }
-
- public void setIndentWidth(final int indentWidth) {
- this.indentWidth = indentWidth;
- calculateIndentWidth();
- }
-
- public void setRowBackgroundDrawable(final Drawable rowBackgroundDrawable) {
- this.rowBackgroundDrawable = rowBackgroundDrawable;
- }
-
- public void setIndicatorBackgroundDrawable(
- final Drawable indicatorBackgroundDrawable) {
- this.indicatorBackgroundDrawable = indicatorBackgroundDrawable;
- }
-
- public void setCollapsible(final boolean collapsible) {
- this.collapsible = collapsible;
- }
-
- public void refresh() {
- treeStateManager.refresh();
- }
-
- private int getIndentWidth() {
- return indentWidth;
- }
-
- @SuppressWarnings("unchecked")
- public void handleItemClick(final View view, final Object id) {
- expandCollapse((T) id);
- }
-
-}
diff --git a/android-libraries/TreeViewList/src/pl/polidea/treeview/InMemoryTreeNode.java b/android-libraries/TreeViewList/src/pl/polidea/treeview/InMemoryTreeNode.java
deleted file mode 100644
index 6035369f92..0000000000
--- a/android-libraries/TreeViewList/src/pl/polidea/treeview/InMemoryTreeNode.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package pl.polidea.treeview;
-
-import java.io.Serializable;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Node. It is package protected so that it cannot be used outside.
- *
- * @param
- * type of the identifier used by the tree
- */
-class InMemoryTreeNode implements Serializable {
- private static final long serialVersionUID = 1L;
- private final T id;
- private final T parent;
- private final int level;
- private boolean visible = true;
- private final List> children = new LinkedList>();
- private List childIdListCache = null;
-
- public InMemoryTreeNode(final T id, final T parent, final int level,
- final boolean visible) {
- super();
- this.id = id;
- this.parent = parent;
- this.level = level;
- this.visible = visible;
- }
-
- public int indexOf(final T id) {
- return getChildIdList().indexOf(id);
- }
-
- /**
- * Cache is built lasily only if needed. The cache is cleaned on any
- * structure change for that node!).
- *
- * @return list of ids of children
- */
- public synchronized List getChildIdList() {
- if (childIdListCache == null) {
- childIdListCache = new LinkedList();
- for (final InMemoryTreeNode n : children) {
- childIdListCache.add(n.getId());
- }
- }
- return childIdListCache;
- }
-
- public boolean isVisible() {
- return visible;
- }
-
- public void setVisible(final boolean visible) {
- this.visible = visible;
- }
-
- public int getChildrenListSize() {
- return children.size();
- }
-
- public synchronized InMemoryTreeNode add(final int index, final T child,
- final boolean visible) {
- childIdListCache = null;
- // Note! top levell children are always visible (!)
- final InMemoryTreeNode newNode = new InMemoryTreeNode(child,
- getId(), getLevel() + 1, getId() == null ? true : visible);
- children.add(index, newNode);
- return newNode;
- }
-
- /**
- * Note. This method should technically return unmodifiable collection, but
- * for performance reason on small devices we do not do it.
- *
- * @return children list
- */
- public List> getChildren() {
- return children;
- }
-
- public synchronized void clearChildren() {
- children.clear();
- childIdListCache = null;
- }
-
- public synchronized void removeChild(final T child) {
- final int childIndex = indexOf(child);
- if (childIndex != -1) {
- children.remove(childIndex);
- childIdListCache = null;
- }
- }
-
- @Override
- public String toString() {
- return "InMemoryTreeNode [id=" + getId() + ", parent=" + getParent()
- + ", level=" + getLevel() + ", visible=" + visible
- + ", children=" + children + ", childIdListCache="
- + childIdListCache + "]";
- }
-
- T getId() {
- return id;
- }
-
- T getParent() {
- return parent;
- }
-
- int getLevel() {
- return level;
- }
-
-}
\ No newline at end of file
diff --git a/android-libraries/TreeViewList/src/pl/polidea/treeview/InMemoryTreeStateManager.java b/android-libraries/TreeViewList/src/pl/polidea/treeview/InMemoryTreeStateManager.java
deleted file mode 100644
index bae675bf87..0000000000
--- a/android-libraries/TreeViewList/src/pl/polidea/treeview/InMemoryTreeStateManager.java
+++ /dev/null
@@ -1,374 +0,0 @@
-package pl.polidea.treeview;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import android.database.DataSetObserver;
-
-/**
- * In-memory manager of tree state.
- *
- * @param
- * type of identifier
- */
-public class InMemoryTreeStateManager implements TreeStateManager {
- private static final long serialVersionUID = 1L;
- private final Map> allNodes = new HashMap>();
- private final InMemoryTreeNode topSentinel = new InMemoryTreeNode(
- null, null, -1, true);
- private transient List visibleListCache = null; // lasy initialised
- private transient List unmodifiableVisibleList = null;
- private boolean visibleByDefault = true;
- private final transient Set observers = new HashSet();
-
- private synchronized void internalDataSetChanged() {
- visibleListCache = null;
- unmodifiableVisibleList = null;
- for (final DataSetObserver observer : observers) {
- observer.onChanged();
- }
- }
-
- /**
- * If true new nodes are visible by default.
- *
- * @param visibleByDefault
- * if true, then newly added nodes are expanded by default
- */
- public void setVisibleByDefault(final boolean visibleByDefault) {
- this.visibleByDefault = visibleByDefault;
- }
-
- private InMemoryTreeNode getNodeFromTreeOrThrow(final T id) {
- if (id == null) {
- throw new NodeNotInTreeException("(null)");
- }
- final InMemoryTreeNode node = allNodes.get(id);
- if (node == null) {
- throw new NodeNotInTreeException(id.toString());
- }
- return node;
- }
-
- private InMemoryTreeNode getNodeFromTreeOrThrowAllowRoot(final T id) {
- if (id == null) {
- return topSentinel;
- }
- return getNodeFromTreeOrThrow(id);
- }
-
- private void expectNodeNotInTreeYet(final T id) {
- final InMemoryTreeNode node = allNodes.get(id);
- if (node != null) {
- throw new NodeAlreadyInTreeException(id.toString(), node.toString());
- }
- }
-
- @Override
- public synchronized TreeNodeInfo getNodeInfo(final T id) {
- final InMemoryTreeNode node = getNodeFromTreeOrThrow(id);
- final List> children = node.getChildren();
- boolean expanded = false;
- if (!children.isEmpty() && children.get(0).isVisible()) {
- expanded = true;
- }
- return new TreeNodeInfo(id, node.getLevel(), !children.isEmpty(),
- node.isVisible(), expanded);
- }
-
- @Override
- public synchronized List getChildren(final T id) {
- final InMemoryTreeNode node = getNodeFromTreeOrThrowAllowRoot(id);
- return node.getChildIdList();
- }
-
- @Override
- public synchronized T getParent(final T id) {
- final InMemoryTreeNode node = getNodeFromTreeOrThrowAllowRoot(id);
- return node.getParent();
- }
-
- private boolean getChildrenVisibility(final InMemoryTreeNode node) {
- boolean visibility;
- final List> children = node.getChildren();
- if (children.isEmpty()) {
- visibility = visibleByDefault;
- } else {
- visibility = children.get(0).isVisible();
- }
- return visibility;
- }
-
- @Override
- public synchronized void addBeforeChild(final T parent, final T newChild,
- final T beforeChild) {
- expectNodeNotInTreeYet(newChild);
- final InMemoryTreeNode node = getNodeFromTreeOrThrowAllowRoot(parent);
- final boolean visibility = getChildrenVisibility(node);
- // top nodes are always expanded.
- if (beforeChild == null) {
- final InMemoryTreeNode added = node.add(0, newChild, visibility);
- allNodes.put(newChild, added);
- } else {
- final int index = node.indexOf(beforeChild);
- final InMemoryTreeNode added = node.add(index == -1 ? 0 : index,
- newChild, visibility);
- allNodes.put(newChild, added);
- }
- if (visibility) {
- internalDataSetChanged();
- }
- }
-
- @Override
- public synchronized void addAfterChild(final T parent, final T newChild,
- final T afterChild) {
- expectNodeNotInTreeYet(newChild);
- final InMemoryTreeNode node = getNodeFromTreeOrThrowAllowRoot(parent);
- final boolean visibility = getChildrenVisibility(node);
- if (afterChild == null) {
- final InMemoryTreeNode added = node.add(
- node.getChildrenListSize(), newChild, visibility);
- allNodes.put(newChild, added);
- } else {
- final int index = node.indexOf(afterChild);
- final InMemoryTreeNode added = node.add(
- index == -1 ? node.getChildrenListSize() : index, newChild,
- visibility);
- allNodes.put(newChild, added);
- }
- if (visibility) {
- internalDataSetChanged();
- }
- }
-
- @Override
- public synchronized void removeNodeRecursively(final T id) {
- final InMemoryTreeNode node = getNodeFromTreeOrThrowAllowRoot(id);
- final boolean visibleNodeChanged = removeNodeRecursively(node);
- final T parent = node.getParent();
- final InMemoryTreeNode parentNode = getNodeFromTreeOrThrowAllowRoot(parent);
- parentNode.removeChild(id);
- if (visibleNodeChanged) {
- internalDataSetChanged();
- }
- }
-
- private boolean removeNodeRecursively(final InMemoryTreeNode node) {
- boolean visibleNodeChanged = false;
- for (final InMemoryTreeNode child : node.getChildren()) {
- if (removeNodeRecursively(child)) {
- visibleNodeChanged = true;
- }
- }
- node.clearChildren();
- if (node.getId() != null) {
- allNodes.remove(node.getId());
- if (node.isVisible()) {
- visibleNodeChanged = true;
- }
- }
- return visibleNodeChanged;
- }
-
- private void setChildrenVisibility(final InMemoryTreeNode node,
- final boolean visible, final boolean recursive) {
- for (final InMemoryTreeNode child : node.getChildren()) {
- child.setVisible(visible);
- if (recursive) {
- setChildrenVisibility(child, visible, true);
- }
- }
- }
-
- @Override
- public synchronized void expandDirectChildren(final T id) {
- final InMemoryTreeNode node = getNodeFromTreeOrThrowAllowRoot(id);
- setChildrenVisibility(node, true, false);
- internalDataSetChanged();
- }
-
- @Override
- public synchronized void expandEverythingBelow(final T id) {
- final InMemoryTreeNode node = getNodeFromTreeOrThrowAllowRoot(id);
- setChildrenVisibility(node, true, true);
- internalDataSetChanged();
- }
-
- @Override
- public synchronized void collapseChildren(final T id) {
- final InMemoryTreeNode node = getNodeFromTreeOrThrowAllowRoot(id);
- if (node == topSentinel) {
- for (final InMemoryTreeNode n : topSentinel.getChildren()) {
- setChildrenVisibility(n, false, true);
- }
- } else {
- setChildrenVisibility(node, false, true);
- }
- internalDataSetChanged();
- }
-
- @Override
- public synchronized T getNextSibling(final T id) {
- final T parent = getParent(id);
- final InMemoryTreeNode parentNode = getNodeFromTreeOrThrowAllowRoot(parent);
- boolean returnNext = false;
- for (final InMemoryTreeNode child : parentNode.getChildren()) {
- if (returnNext) {
- return child.getId();
- }
- if (child.getId().equals(id)) {
- returnNext = true;
- }
- }
- return null;
- }
-
- @Override
- public synchronized T getPreviousSibling(final T id) {
- final T parent = getParent(id);
- final InMemoryTreeNode parentNode = getNodeFromTreeOrThrowAllowRoot(parent);
- final T previousSibling = null;
- for (final InMemoryTreeNode child : parentNode.getChildren()) {
- if (child.getId().equals(id)) {
- return previousSibling;
- }
- }
- return null;
- }
-
- @Override
- public synchronized boolean isInTree(final T id) {
- return allNodes.containsKey(id);
- }
-
- @Override
- public synchronized int getVisibleCount() {
- return getVisibleList().size();
- }
-
- @Override
- public synchronized List getVisibleList() {
- T currentId = null;
- if (visibleListCache == null) {
- visibleListCache = new ArrayList(allNodes.size());
- do {
- currentId = getNextVisible(currentId);
- if (currentId == null) {
- break;
- } else {
- visibleListCache.add(currentId);
- }
- } while (true);
- }
- if (unmodifiableVisibleList == null) {
- unmodifiableVisibleList = Collections
- .unmodifiableList(visibleListCache);
- }
- return unmodifiableVisibleList;
- }
-
- public synchronized T getNextVisible(final T id) {
- final InMemoryTreeNode node = getNodeFromTreeOrThrowAllowRoot(id);
- if (!node.isVisible()) {
- return null;
- }
- final List> children = node.getChildren();
- if (!children.isEmpty()) {
- final InMemoryTreeNode firstChild = children.get(0);
- if (firstChild.isVisible()) {
- return firstChild.getId();
- }
- }
- final T sibl = getNextSibling(id);
- if (sibl != null) {
- return sibl;
- }
- T parent = node.getParent();
- do {
- if (parent == null) {
- return null;
- }
- final T parentSibling = getNextSibling(parent);
- if (parentSibling != null) {
- return parentSibling;
- }
- parent = getNodeFromTreeOrThrow(parent).getParent();
- } while (true);
- }
-
- @Override
- public synchronized void registerDataSetObserver(
- final DataSetObserver observer) {
- observers.add(observer);
- }
-
- @Override
- public synchronized void unregisterDataSetObserver(
- final DataSetObserver observer) {
- observers.remove(observer);
- }
-
- @Override
- public int getLevel(final T id) {
- return getNodeFromTreeOrThrow(id).getLevel();
- }
-
- @Override
- public Integer[] getHierarchyDescription(final T id) {
- final int level = getLevel(id);
- final Integer[] hierarchy = new Integer[level + 1];
- int currentLevel = level;
- T currentId = id;
- T parent = getParent(currentId);
- while (currentLevel >= 0) {
- hierarchy[currentLevel--] = getChildren(parent).indexOf(currentId);
- currentId = parent;
- parent = getParent(parent);
- }
- return hierarchy;
- }
-
- private void appendToSb(final StringBuilder sb, final T id) {
- if (id != null) {
- final TreeNodeInfo node = getNodeInfo(id);
- final int indent = node.getLevel() * 4;
- final char[] indentString = new char[indent];
- Arrays.fill(indentString, ' ');
- sb.append(indentString);
- sb.append(node.toString());
- sb.append(Arrays.asList(getHierarchyDescription(id)).toString());
- sb.append("\n");
- }
- final List children = getChildren(id);
- for (final T child : children) {
- appendToSb(sb, child);
- }
- }
-
- @Override
- public synchronized String toString() {
- final StringBuilder sb = new StringBuilder();
- appendToSb(sb, null);
- return sb.toString();
- }
-
- @Override
- public synchronized void clear() {
- allNodes.clear();
- topSentinel.clearChildren();
- internalDataSetChanged();
- }
-
- @Override
- public void refresh() {
- internalDataSetChanged();
- }
-
-}
diff --git a/android-libraries/TreeViewList/src/pl/polidea/treeview/NodeAlreadyInTreeException.java b/android-libraries/TreeViewList/src/pl/polidea/treeview/NodeAlreadyInTreeException.java
deleted file mode 100644
index 680d0266d9..0000000000
--- a/android-libraries/TreeViewList/src/pl/polidea/treeview/NodeAlreadyInTreeException.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package pl.polidea.treeview;
-
-/**
- * The node being added is already in the tree.
- *
- */
-public class NodeAlreadyInTreeException extends RuntimeException {
- private static final long serialVersionUID = 1L;
-
- public NodeAlreadyInTreeException(final String id, final String oldNode) {
- super("The node has already been added to the tree: " + id + ". Old node is:" + oldNode);
- }
-
-}
diff --git a/android-libraries/TreeViewList/src/pl/polidea/treeview/NodeNotInTreeException.java b/android-libraries/TreeViewList/src/pl/polidea/treeview/NodeNotInTreeException.java
deleted file mode 100644
index f20450e1d2..0000000000
--- a/android-libraries/TreeViewList/src/pl/polidea/treeview/NodeNotInTreeException.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package pl.polidea.treeview;
-
-/**
- * This exception is thrown when the tree does not contain node requested.
- *
- */
-public class NodeNotInTreeException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
-
- public NodeNotInTreeException(final String id) {
- super("The tree does not contain the node specified: " + id);
- }
-
-}
diff --git a/android-libraries/TreeViewList/src/pl/polidea/treeview/TreeBuilder.java b/android-libraries/TreeViewList/src/pl/polidea/treeview/TreeBuilder.java
deleted file mode 100644
index 13b499c473..0000000000
--- a/android-libraries/TreeViewList/src/pl/polidea/treeview/TreeBuilder.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package pl.polidea.treeview;
-
-import android.util.Log;
-
-/**
- * Allows to build tree easily in sequential mode (you have to know levels of
- * all the tree elements upfront). You should rather use this class rather than
- * manager if you build initial tree from some external data source.
- *
- * @param
- */
-public class TreeBuilder {
- private static final String TAG = TreeBuilder.class.getSimpleName();
-
- private final TreeStateManager manager;
-
- private T lastAddedId = null;
- private int lastLevel = -1;
-
- public TreeBuilder(final TreeStateManager manager) {
- this.manager = manager;
- }
-
- public void clear() {
- manager.clear();
- }
-
- /**
- * Adds new relation to existing tree. Child is set as the last child of the
- * parent node. Parent has to already exist in the tree, child cannot yet
- * exist. This method is mostly useful in case you add entries layer by
- * layer - i.e. first top level entries, then children for all parents, then
- * grand-children and so on.
- *
- * @param parent
- * parent id
- * @param child
- * child id
- */
- public synchronized void addRelation(final T parent, final T child) {
- Log.d(TAG, "Adding relation parent:" + parent + " -> child: " + child);
- manager.addAfterChild(parent, child, null);
- lastAddedId = child;
- lastLevel = manager.getLevel(child);
- }
-
- /**
- * Adds sequentially new node. Using this method is the simplest way of
- * building tree - if you have all the elements in the sequence as they
- * should be displayed in fully-expanded tree. You can combine it with add
- * relation - for example you can add information about few levels using
- * {@link addRelation} and then after the right level is added as parent,
- * you can continue adding them using sequential operation.
- *
- * @param id
- * id of the node
- * @param level
- * its level
- */
- public synchronized void sequentiallyAddNextNode(final T id, final int level) {
- Log.d(TAG, "Adding sequentiall node " + id + " at level " + level);
- if (lastAddedId == null) {
- addNodeToParentOneLevelDown(null, id, level);
- } else {
- if (level <= lastLevel) {
- final T parent = findParentAtLevel(lastAddedId, level - 1);
- addNodeToParentOneLevelDown(parent, id, level);
- } else {
- addNodeToParentOneLevelDown(lastAddedId, id, level);
- }
- }
- }
-
- /**
- * Find parent of the node at the level specified.
- *
- * @param node
- * node from which we start
- * @param levelToFind
- * level which we are looking for
- * @return the node found (null if it is topmost node).
- */
- private T findParentAtLevel(final T node, final int levelToFind) {
- T parent = manager.getParent(node);
- while (parent != null) {
- if (manager.getLevel(parent) == levelToFind) {
- break;
- }
- parent = manager.getParent(parent);
- }
- return parent;
- }
-
- /**
- * Adds note to parent at the level specified. But it verifies that the
- * level is one level down than the parent!
- *
- * @param parent
- * parent parent
- * @param id
- * new node id
- * @param level
- * should always be parent's level + 1
- */
- private void addNodeToParentOneLevelDown(final T parent, final T id,
- final int level) {
- if (parent == null && level != 0) {
- throw new TreeConfigurationException("Trying to add new id " + id
- + " to top level with level != 0 (" + level + ")");
- }
- if (parent != null && manager.getLevel(parent) != level - 1) {
- throw new TreeConfigurationException("Trying to add new id " + id
- + " <" + level + "> to " + parent + " <"
- + manager.getLevel(parent)
- + ">. The difference in levels up is bigger than 1.");
- }
- manager.addAfterChild(parent, id, null);
- setLastAdded(id, level);
- }
-
- private void setLastAdded(final T id, final int level) {
- lastAddedId = id;
- lastLevel = level;
- }
-
-}
diff --git a/android-libraries/TreeViewList/src/pl/polidea/treeview/TreeConfigurationException.java b/android-libraries/TreeViewList/src/pl/polidea/treeview/TreeConfigurationException.java
deleted file mode 100644
index 1fa72e04cf..0000000000
--- a/android-libraries/TreeViewList/src/pl/polidea/treeview/TreeConfigurationException.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package pl.polidea.treeview;
-
-/**
- * Exception thrown when there is a problem with configuring tree.
- *
- */
-public class TreeConfigurationException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
-
- public TreeConfigurationException(final String detailMessage) {
- super(detailMessage);
- }
-
-}
diff --git a/android-libraries/TreeViewList/src/pl/polidea/treeview/TreeNodeInfo.java b/android-libraries/TreeViewList/src/pl/polidea/treeview/TreeNodeInfo.java
deleted file mode 100644
index 32d18dd446..0000000000
--- a/android-libraries/TreeViewList/src/pl/polidea/treeview/TreeNodeInfo.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package pl.polidea.treeview;
-
-/**
- * Information about the node.
- *
- * @param
- * type of the id for the tree
- */
-public class TreeNodeInfo {
- private final T id;
- private final int level;
- private final boolean withChildren;
- private final boolean visible;
- private final boolean expanded;
-
- /**
- * Creates the node information.
- *
- * @param id
- * id of the node
- * @param level
- * level of the node
- * @param withChildren
- * whether the node has children.
- * @param visible
- * whether the tree node is visible.
- * @param expanded
- * whether the tree node is expanded
- *
- */
- public TreeNodeInfo(final T id, final int level,
- final boolean withChildren, final boolean visible,
- final boolean expanded) {
- super();
- this.id = id;
- this.level = level;
- this.withChildren = withChildren;
- this.visible = visible;
- this.expanded = expanded;
- }
-
- public T getId() {
- return id;
- }
-
- public boolean isWithChildren() {
- return withChildren;
- }
-
- public boolean isVisible() {
- return visible;
- }
-
- public boolean isExpanded() {
- return expanded;
- }
-
- public int getLevel() {
- return level;
- }
-
- @Override
- public String toString() {
- return "TreeNodeInfo [id=" + id + ", level=" + level
- + ", withChildren=" + withChildren + ", visible=" + visible
- + ", expanded=" + expanded + "]";
- }
-
-}
\ No newline at end of file
diff --git a/android-libraries/TreeViewList/src/pl/polidea/treeview/TreeStateManager.java b/android-libraries/TreeViewList/src/pl/polidea/treeview/TreeStateManager.java
deleted file mode 100644
index 781b70e587..0000000000
--- a/android-libraries/TreeViewList/src/pl/polidea/treeview/TreeStateManager.java
+++ /dev/null
@@ -1,193 +0,0 @@
-package pl.polidea.treeview;
-
-import java.io.Serializable;
-import java.util.List;
-
-import android.database.DataSetObserver;
-
-/**
- * Manages information about state of the tree. It only keeps information about
- * tree elements, not the elements themselves.
- *
- * @param
- * type of the identifier for nodes in the tree
- */
-public interface TreeStateManager extends Serializable {
-
- /**
- * Returns array of integers showing the location of the node in hierarchy.
- * It corresponds to heading numbering. {0,0,0} in 3 level node is the first
- * node {0,0,1} is second leaf (assuming that there are two leaves in first
- * subnode of the first node).
- *
- * @param id
- * id of the node
- * @return textual description of the hierarchy in tree for the node.
- */
- Integer[] getHierarchyDescription(T id);
-
- /**
- * Returns level of the node.
- *
- * @param id
- * id of the node
- * @return level in the tree
- */
- int getLevel(T id);
-
- /**
- * Returns information about the node.
- *
- * @param id
- * node id
- * @return node info
- */
- TreeNodeInfo getNodeInfo(T id);
-
- /**
- * Returns children of the node.
- *
- * @param id
- * id of the node or null if asking for top nodes
- * @return children of the node
- */
- List getChildren(T id);
-
- /**
- * Returns parent of the node.
- *
- * @param id
- * id of the node
- * @return parent id or null if no parent
- */
- T getParent(T id);
-
- /**
- * Adds the node before child or at the beginning.
- *
- * @param parent
- * id of the parent node. If null - adds at the top level
- * @param newChild
- * new child to add if null - adds at the beginning.
- * @param beforeChild
- * child before which to add the new child
- */
- void addBeforeChild(T parent, T newChild, T beforeChild);
-
- /**
- * Adds the node after child or at the end.
- *
- * @param parent
- * id of the parent node. If null - adds at the top level.
- * @param newChild
- * new child to add. If null - adds at the end.
- * @param afterChild
- * child after which to add the new child
- */
- void addAfterChild(T parent, T newChild, T afterChild);
-
- /**
- * Removes the node and all children from the tree.
- *
- * @param id
- * id of the node to remove or null if all nodes are to be
- * removed.
- */
- void removeNodeRecursively(T id);
-
- /**
- * Expands all children of the node.
- *
- * @param id
- * node which children should be expanded. cannot be null (top
- * nodes are always expanded!).
- */
- void expandDirectChildren(T id);
-
- /**
- * Expands everything below the node specified. Might be null - then expands
- * all.
- *
- * @param id
- * node which children should be expanded or null if all nodes
- * are to be expanded.
- */
- void expandEverythingBelow(T id);
-
- /**
- * Collapse children.
- *
- * @param id
- * id collapses everything below node specified. If null,
- * collapses everything but top-level nodes.
- */
- void collapseChildren(T id);
-
- /**
- * Returns next sibling of the node (or null if no further sibling).
- *
- * @param id
- * node id
- * @return the sibling (or null if no next)
- */
- T getNextSibling(T id);
-
- /**
- * Returns previous sibling of the node (or null if no previous sibling).
- *
- * @param id
- * node id
- * @return the sibling (or null if no previous)
- */
- T getPreviousSibling(T id);
-
- /**
- * Checks if given node is already in tree.
- *
- * @param id
- * id of the node
- * @return true if node is already in tree.
- */
- boolean isInTree(T id);
-
- /**
- * Count visible elements.
- *
- * @return number of currently visible elements.
- */
- int getVisibleCount();
-
- /**
- * Returns visible node list.
- *
- * @return return the list of all visible nodes in the right sequence
- */
- List getVisibleList();
-
- /**
- * Registers observers with the manager.
- *
- * @param observer
- * observer
- */
- void registerDataSetObserver(final DataSetObserver observer);
-
- /**
- * Unregisters observers with the manager.
- *
- * @param observer
- * observer
- */
- void unregisterDataSetObserver(final DataSetObserver observer);
-
- /**
- * Cleans tree stored in manager. After this operation the tree is empty.
- *
- */
- void clear();
-
- /**
- * Refreshes views connected to the manager.
- */
- void refresh();
-}
diff --git a/android-libraries/TreeViewList/src/pl/polidea/treeview/TreeViewList.java b/android-libraries/TreeViewList/src/pl/polidea/treeview/TreeViewList.java
deleted file mode 100644
index fb48ab5c9b..0000000000
--- a/android-libraries/TreeViewList/src/pl/polidea/treeview/TreeViewList.java
+++ /dev/null
@@ -1,198 +0,0 @@
-package pl.polidea.treeview;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ListAdapter;
-import android.widget.ListView;
-
-/**
- * Tree view, expandable multi-level.
- *
- *
- */
-public class TreeViewList extends ListView {
- private static final int DEFAULT_COLLAPSED_RESOURCE = R.drawable.collapsed;
- private static final int DEFAULT_EXPANDED_RESOURCE = R.drawable.expanded;
- private static final int DEFAULT_INDENT = 0;
- private static final int DEFAULT_GRAVITY = Gravity.LEFT
- | Gravity.CENTER_VERTICAL;
- private Drawable expandedDrawable;
- private Drawable collapsedDrawable;
- private Drawable rowBackgroundDrawable;
- private Drawable indicatorBackgroundDrawable;
- private int indentWidth = 0;
- private int indicatorGravity = 0;
- private AbstractTreeViewAdapter< ? > treeAdapter;
- private boolean collapsible;
- private boolean handleTrackballPress;
-
- public TreeViewList(final Context context, final AttributeSet attrs) {
- this(context, attrs, R.style.treeViewListStyle);
- }
-
- public TreeViewList(final Context context) {
- this(context, null);
- }
-
- public TreeViewList(final Context context, final AttributeSet attrs,
- final int defStyle) {
- super(context, attrs, defStyle);
- parseAttributes(context, attrs);
- }
-
- private void parseAttributes(final Context context, final AttributeSet attrs) {
- final TypedArray a = context.obtainStyledAttributes(attrs,
- R.styleable.TreeViewList);
- expandedDrawable = a.getDrawable(R.styleable.TreeViewList_src_expanded);
- if (expandedDrawable == null) {
- expandedDrawable = context.getResources().getDrawable(
- DEFAULT_EXPANDED_RESOURCE);
- }
- collapsedDrawable = a
- .getDrawable(R.styleable.TreeViewList_src_collapsed);
- if (collapsedDrawable == null) {
- collapsedDrawable = context.getResources().getDrawable(
- DEFAULT_COLLAPSED_RESOURCE);
- }
- indentWidth = a.getDimensionPixelSize(
- R.styleable.TreeViewList_indent_width, DEFAULT_INDENT);
- indicatorGravity = a.getInteger(
- R.styleable.TreeViewList_indicator_gravity, DEFAULT_GRAVITY);
- indicatorBackgroundDrawable = a
- .getDrawable(R.styleable.TreeViewList_indicator_background);
- rowBackgroundDrawable = a
- .getDrawable(R.styleable.TreeViewList_row_background);
- collapsible = a.getBoolean(R.styleable.TreeViewList_collapsible, true);
- handleTrackballPress = a.getBoolean(
- R.styleable.TreeViewList_handle_trackball_press, true);
- }
-
- @Override
- public void setAdapter(final ListAdapter adapter) {
- if (!(adapter instanceof AbstractTreeViewAdapter)) {
- throw new TreeConfigurationException(
- "The adapter is not of TreeViewAdapter type");
- }
- treeAdapter = (AbstractTreeViewAdapter< ? >) adapter;
- syncAdapter();
- super.setAdapter(treeAdapter);
- }
-
- private void syncAdapter() {
- treeAdapter.setCollapsedDrawable(collapsedDrawable);
- treeAdapter.setExpandedDrawable(expandedDrawable);
- treeAdapter.setIndicatorGravity(indicatorGravity);
- treeAdapter.setIndentWidth(indentWidth);
- treeAdapter.setIndicatorBackgroundDrawable(indicatorBackgroundDrawable);
- treeAdapter.setRowBackgroundDrawable(rowBackgroundDrawable);
- treeAdapter.setCollapsible(collapsible);
- if (handleTrackballPress) {
- setOnItemClickListener(new OnItemClickListener() {
- @Override
- public void onItemClick(final AdapterView< ? > parent,
- final View view, final int position, final long id) {
- treeAdapter.handleItemClick(view, view.getTag());
- }
- });
- } else {
- setOnClickListener(null);
- }
-
- }
-
- public void setExpandedDrawable(final Drawable expandedDrawable) {
- this.expandedDrawable = expandedDrawable;
- syncAdapter();
- treeAdapter.refresh();
- }
-
- public void setCollapsedDrawable(final Drawable collapsedDrawable) {
- this.collapsedDrawable = collapsedDrawable;
- syncAdapter();
- treeAdapter.refresh();
- }
-
- public void setRowBackgroundDrawable(final Drawable rowBackgroundDrawable) {
- this.rowBackgroundDrawable = rowBackgroundDrawable;
- syncAdapter();
- treeAdapter.refresh();
- }
-
- public void setIndicatorBackgroundDrawable(
- final Drawable indicatorBackgroundDrawable) {
- this.indicatorBackgroundDrawable = indicatorBackgroundDrawable;
- syncAdapter();
- treeAdapter.refresh();
- }
-
- public void setIndentWidth(final int indentWidth) {
- this.indentWidth = indentWidth;
- syncAdapter();
- treeAdapter.refresh();
- }
-
- public void setIndicatorGravity(final int indicatorGravity) {
- this.indicatorGravity = indicatorGravity;
- syncAdapter();
- treeAdapter.refresh();
- }
-
- public void setCollapsible(final boolean collapsible) {
- this.collapsible = collapsible;
- syncAdapter();
- treeAdapter.refresh();
- }
-
- public void setHandleTrackballPress(final boolean handleTrackballPress) {
- this.handleTrackballPress = handleTrackballPress;
- syncAdapter();
- treeAdapter.refresh();
- }
-
- public Drawable getExpandedDrawable() {
- return expandedDrawable;
- }
-
- public Drawable getCollapsedDrawable() {
- return collapsedDrawable;
- }
-
- public Drawable getRowBackgroundDrawable() {
- return rowBackgroundDrawable;
- }
-
- public Drawable getIndicatorBackgroundDrawable() {
- return indicatorBackgroundDrawable;
- }
-
- public int getIndentWidth() {
- return indentWidth;
- }
-
- public int getIndicatorGravity() {
- return indicatorGravity;
- }
-
- public boolean isCollapsible() {
- return collapsible;
- }
-
- public boolean isHandleTrackballPress() {
- return handleTrackballPress;
- }
-
-}
diff --git a/android-libraries/TreeViewList/src/pl/polidea/treeview/overview.html b/android-libraries/TreeViewList/src/pl/polidea/treeview/overview.html
deleted file mode 100644
index bdd09ce9f7..0000000000
--- a/android-libraries/TreeViewList/src/pl/polidea/treeview/overview.html
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-This is a small utility that provides quite configurable tree view list.
-It is based on standard android list view. It separates out different
-aspects of the tree: there is a separate list view, tree adapter, tree
-state manager and tree state builder.
-
-
-
Tree view provides the frame to display the view.
-
Adapter allows to create visual representation of each tree
- node.
-
State manager provides storage for tree state (connections
- between parents and children, collapsed/expanded state). It provides
- all the low-level tree manipulation methods.
-
Tree builder allows to build tree easily providing higher
- level methods. The tree can be build either from prepared sequentially
- prepared list of nodes (node id, level) or using (parent/child
- relationships).
-
For now only in-memory state manager is provided, but Tree State
- Manger interface is done in the way that database tree manager even for
- large trees is potentially supported.
-
-
-
\ No newline at end of file
diff --git a/android-libraries/TreeViewList/src/pl/polidea/treeview/package-info.java b/android-libraries/TreeViewList/src/pl/polidea/treeview/package-info.java
deleted file mode 100644
index a622e091bc..0000000000
--- a/android-libraries/TreeViewList/src/pl/polidea/treeview/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Provides expandable Tree View implementation.
- */
-package pl.polidea.treeview;
\ No newline at end of file
diff --git a/android-libraries/achartengine/.classpath b/android-libraries/achartengine/.classpath
deleted file mode 100644
index a4f1e40546..0000000000
--- a/android-libraries/achartengine/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/android-libraries/achartengine/.project b/android-libraries/achartengine/.project
deleted file mode 100644
index fb1c7567ae..0000000000
--- a/android-libraries/achartengine/.project
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
- achartengine
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
diff --git a/android-libraries/achartengine/AndroidManifest.xml b/android-libraries/achartengine/AndroidManifest.xml
deleted file mode 100644
index 083e05fcfd..0000000000
--- a/android-libraries/achartengine/AndroidManifest.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/android-libraries/achartengine/extra/LICENSE-2.0.txt b/android-libraries/achartengine/extra/LICENSE-2.0.txt
deleted file mode 100644
index d645695673..0000000000
--- a/android-libraries/achartengine/extra/LICENSE-2.0.txt
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- 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.
diff --git a/android-libraries/achartengine/project.properties b/android-libraries/achartengine/project.properties
deleted file mode 100644
index 337e8f37df..0000000000
--- a/android-libraries/achartengine/project.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-7
-android.library=true
diff --git a/android-libraries/achartengine/src/org/achartengine/ChartFactory.java b/android-libraries/achartengine/src/org/achartengine/ChartFactory.java
deleted file mode 100644
index 301f1a8fab..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/ChartFactory.java
+++ /dev/null
@@ -1,708 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine;
-
-import org.achartengine.chart.BarChart;
-import org.achartengine.chart.BarChart.Type;
-import org.achartengine.chart.BubbleChart;
-import org.achartengine.chart.CombinedXYChart;
-import org.achartengine.chart.CubicLineChart;
-import org.achartengine.chart.DialChart;
-import org.achartengine.chart.DoughnutChart;
-import org.achartengine.chart.LineChart;
-import org.achartengine.chart.PieChart;
-import org.achartengine.chart.RangeBarChart;
-import org.achartengine.chart.ScatterChart;
-import org.achartengine.chart.TimeChart;
-import org.achartengine.chart.XYChart;
-import org.achartengine.model.CategorySeries;
-import org.achartengine.model.MultipleCategorySeries;
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.renderer.DefaultRenderer;
-import org.achartengine.renderer.DialRenderer;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-
-import android.content.Context;
-import android.content.Intent;
-
-/**
- * Utility methods for creating chart views or intents.
- */
-public class ChartFactory {
- /** The key for the chart data. */
- public static final String CHART = "chart";
-
- /** The key for the chart graphical activity title. */
- public static final String TITLE = "title";
-
- private ChartFactory() {
- // empty for now
- }
-
- /**
- * Creates a line chart view.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @return a line chart graphical view
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final GraphicalView getLineChartView(Context context,
- XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) {
- checkParameters(dataset, renderer);
- XYChart chart = new LineChart(dataset, renderer);
- return new GraphicalView(context, chart);
- }
-
- /**
- * Creates a cubic line chart view.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @return a line chart graphical view
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final GraphicalView getCubeLineChartView(Context context,
- XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, float smoothness) {
- checkParameters(dataset, renderer);
- XYChart chart = new CubicLineChart(dataset, renderer, smoothness);
- return new GraphicalView(context, chart);
- }
-
- /**
- * Creates a scatter chart view.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @return a scatter chart graphical view
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final GraphicalView getScatterChartView(Context context,
- XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) {
- checkParameters(dataset, renderer);
- XYChart chart = new ScatterChart(dataset, renderer);
- return new GraphicalView(context, chart);
- }
-
- /**
- * Creates a bubble chart view.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @return a scatter chart graphical view
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final GraphicalView getBubbleChartView(Context context,
- XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) {
- checkParameters(dataset, renderer);
- XYChart chart = new BubbleChart(dataset, renderer);
- return new GraphicalView(context, chart);
- }
-
- /**
- * Creates a time chart view.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @param format the date format pattern to be used for displaying the X axis
- * date labels. If null, a default appropriate format will be used.
- * @return a time chart graphical view
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final GraphicalView getTimeChartView(Context context,
- XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, String format) {
- checkParameters(dataset, renderer);
- TimeChart chart = new TimeChart(dataset, renderer);
- chart.setDateFormat(format);
- return new GraphicalView(context, chart);
- }
-
- /**
- * Creates a bar chart view.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @param type the bar chart type
- * @return a bar chart graphical view
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final GraphicalView getBarChartView(Context context,
- XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type) {
- checkParameters(dataset, renderer);
- XYChart chart = new BarChart(dataset, renderer, type);
- return new GraphicalView(context, chart);
- }
-
- /**
- * Creates a range bar chart view.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @param type the range bar chart type
- * @return a bar chart graphical view
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final GraphicalView getRangeBarChartView(Context context,
- XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type) {
- checkParameters(dataset, renderer);
- XYChart chart = new RangeBarChart(dataset, renderer, type);
- return new GraphicalView(context, chart);
- }
-
- /**
- * Creates a combined XY chart view.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @param types the chart types (cannot be null)
- * @return a combined XY chart graphical view
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if a dataset number of items is different than the number of
- * series renderers or number of chart types
- */
- public static final GraphicalView getCombinedXYChartView(Context context,
- XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, String[] types) {
- if (dataset == null || renderer == null || types == null
- || dataset.getSeriesCount() != types.length) {
- throw new IllegalArgumentException(
- "Dataset, renderer and types should be not null and the datasets series count should be equal to the types length");
- }
- checkParameters(dataset, renderer);
- CombinedXYChart chart = new CombinedXYChart(dataset, renderer, types);
- return new GraphicalView(context, chart);
- }
-
- /**
- * Creates a pie chart intent that can be used to start the graphical view
- * activity.
- *
- * @param context the context
- * @param dataset the category series dataset (cannot be null)
- * @param renderer the series renderer (cannot be null)
- * @return a pie chart view
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset number of items is different than the number of
- * series renderers
- */
- public static final GraphicalView getPieChartView(Context context, CategorySeries dataset,
- DefaultRenderer renderer) {
- checkParameters(dataset, renderer);
- PieChart chart = new PieChart(dataset, renderer);
- return new GraphicalView(context, chart);
- }
-
- /**
- * Creates a dial chart intent that can be used to start the graphical view
- * activity.
- *
- * @param context the context
- * @param dataset the category series dataset (cannot be null)
- * @param renderer the dial renderer (cannot be null)
- * @return a pie chart view
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset number of items is different than the number of
- * series renderers
- */
- public static final GraphicalView getDialChartView(Context context, CategorySeries dataset,
- DialRenderer renderer) {
- checkParameters(dataset, renderer);
- DialChart chart = new DialChart(dataset, renderer);
- return new GraphicalView(context, chart);
- }
-
- /**
- * Creates a doughnut chart intent that can be used to start the graphical
- * view activity.
- *
- * @param context the context
- * @param dataset the multiple category series dataset (cannot be null)
- * @param renderer the series renderer (cannot be null)
- * @return a pie chart view
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset number of items is different than the number of
- * series renderers
- */
- public static final GraphicalView getDoughnutChartView(Context context,
- MultipleCategorySeries dataset, DefaultRenderer renderer) {
- checkParameters(dataset, renderer);
- DoughnutChart chart = new DoughnutChart(dataset, renderer);
- return new GraphicalView(context, chart);
- }
-
- /**
- *
- * Creates a line chart intent that can be used to start the graphical view
- * activity.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @return a line chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final Intent getLineChartIntent(Context context, XYMultipleSeriesDataset dataset,
- XYMultipleSeriesRenderer renderer) {
- return getLineChartIntent(context, dataset, renderer, "");
- }
-
- /**
- *
- * Creates a cubic line chart intent that can be used to start the graphical
- * view activity.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @return a line chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final Intent getCubicLineChartIntent(Context context,
- XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, float smoothness) {
- return getCubicLineChartIntent(context, dataset, renderer, smoothness, "");
- }
-
- /**
- * Creates a scatter chart intent that can be used to start the graphical view
- * activity.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @return a scatter chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final Intent getScatterChartIntent(Context context,
- XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) {
- return getScatterChartIntent(context, dataset, renderer, "");
- }
-
- /**
- * Creates a bubble chart intent that can be used to start the graphical view
- * activity.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @return a scatter chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final Intent getBubbleChartIntent(Context context, XYMultipleSeriesDataset dataset,
- XYMultipleSeriesRenderer renderer) {
- return getBubbleChartIntent(context, dataset, renderer, "");
- }
-
- /**
- * Creates a time chart intent that can be used to start the graphical view
- * activity.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @param format the date format pattern to be used for displaying the X axis
- * date labels. If null, a default appropriate format will be used.
- * @return a time chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final Intent getTimeChartIntent(Context context, XYMultipleSeriesDataset dataset,
- XYMultipleSeriesRenderer renderer, String format) {
- return getTimeChartIntent(context, dataset, renderer, format, "");
- }
-
- /**
- * Creates a bar chart intent that can be used to start the graphical view
- * activity.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @param type the bar chart type
- * @return a bar chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final Intent getBarChartIntent(Context context, XYMultipleSeriesDataset dataset,
- XYMultipleSeriesRenderer renderer, Type type) {
- return getBarChartIntent(context, dataset, renderer, type, "");
- }
-
- /**
- * Creates a line chart intent that can be used to start the graphical view
- * activity.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @param activityTitle the graphical chart activity title. If this is null,
- * then the title bar will be hidden. If a blank title is passed in,
- * then the title bar will be the default. Pass in any other string
- * to set a custom title.
- * @return a line chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final Intent getLineChartIntent(Context context, XYMultipleSeriesDataset dataset,
- XYMultipleSeriesRenderer renderer, String activityTitle) {
- checkParameters(dataset, renderer);
- Intent intent = new Intent(context, GraphicalActivity.class);
- XYChart chart = new LineChart(dataset, renderer);
- intent.putExtra(CHART, chart);
- intent.putExtra(TITLE, activityTitle);
- return intent;
- }
-
- /**
- * Creates a line chart intent that can be used to start the graphical view
- * activity.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @param activityTitle the graphical chart activity title. If this is null,
- * then the title bar will be hidden. If a blank title is passed in,
- * then the title bar will be the default. Pass in any other string
- * to set a custom title.
- * @return a line chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final Intent getCubicLineChartIntent(Context context,
- XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, float smoothness,
- String activityTitle) {
- checkParameters(dataset, renderer);
- Intent intent = new Intent(context, GraphicalActivity.class);
- XYChart chart = new CubicLineChart(dataset, renderer, smoothness);
- intent.putExtra(CHART, chart);
- intent.putExtra(TITLE, activityTitle);
- return intent;
- }
-
- /**
- * Creates a scatter chart intent that can be used to start the graphical view
- * activity.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @param activityTitle the graphical chart activity title
- * @return a scatter chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final Intent getScatterChartIntent(Context context,
- XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, String activityTitle) {
- checkParameters(dataset, renderer);
- Intent intent = new Intent(context, GraphicalActivity.class);
- XYChart chart = new ScatterChart(dataset, renderer);
- intent.putExtra(CHART, chart);
- intent.putExtra(TITLE, activityTitle);
- return intent;
- }
-
- /**
- * Creates a bubble chart intent that can be used to start the graphical view
- * activity.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @param activityTitle the graphical chart activity title
- * @return a scatter chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final Intent getBubbleChartIntent(Context context, XYMultipleSeriesDataset dataset,
- XYMultipleSeriesRenderer renderer, String activityTitle) {
- checkParameters(dataset, renderer);
- Intent intent = new Intent(context, GraphicalActivity.class);
- XYChart chart = new BubbleChart(dataset, renderer);
- intent.putExtra(CHART, chart);
- intent.putExtra(TITLE, activityTitle);
- return intent;
- }
-
- /**
- * Creates a time chart intent that can be used to start the graphical view
- * activity.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @param format the date format pattern to be used for displaying the X axis
- * date labels. If null, a default appropriate format will be used
- * @param activityTitle the graphical chart activity title
- * @return a time chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final Intent getTimeChartIntent(Context context, XYMultipleSeriesDataset dataset,
- XYMultipleSeriesRenderer renderer, String format, String activityTitle) {
- checkParameters(dataset, renderer);
- Intent intent = new Intent(context, GraphicalActivity.class);
- TimeChart chart = new TimeChart(dataset, renderer);
- chart.setDateFormat(format);
- intent.putExtra(CHART, chart);
- intent.putExtra(TITLE, activityTitle);
- return intent;
- }
-
- /**
- * Creates a bar chart intent that can be used to start the graphical view
- * activity.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @param type the bar chart type
- * @param activityTitle the graphical chart activity title
- * @return a bar chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final Intent getBarChartIntent(Context context, XYMultipleSeriesDataset dataset,
- XYMultipleSeriesRenderer renderer, Type type, String activityTitle) {
- checkParameters(dataset, renderer);
- Intent intent = new Intent(context, GraphicalActivity.class);
- BarChart chart = new BarChart(dataset, renderer, type);
- intent.putExtra(CHART, chart);
- intent.putExtra(TITLE, activityTitle);
- return intent;
- }
-
- /**
- * Creates a range bar chart intent that can be used to start the graphical
- * view activity.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @param type the range bar chart type
- * @param activityTitle the graphical chart activity title
- * @return a range bar chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- public static final Intent getRangeBarChartIntent(Context context,
- XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type,
- String activityTitle) {
- checkParameters(dataset, renderer);
- Intent intent = new Intent(context, GraphicalActivity.class);
- RangeBarChart chart = new RangeBarChart(dataset, renderer, type);
- intent.putExtra(CHART, chart);
- intent.putExtra(TITLE, activityTitle);
- return intent;
- }
-
- /**
- * Creates a combined XY chart intent that can be used to start the graphical
- * view activity.
- *
- * @param context the context
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @param types the chart types (cannot be null)
- * @param activityTitle the graphical chart activity title
- * @return a combined XY chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if a dataset number of items is different than the number of
- * series renderers or number of chart types
- */
- public static final Intent getCombinedXYChartIntent(Context context,
- XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, String[] types,
- String activityTitle) {
- if (dataset == null || renderer == null || types == null
- || dataset.getSeriesCount() != types.length) {
- throw new IllegalArgumentException(
- "Datasets, renderers and types should be not null and the datasets series count should be equal to the types length");
- }
- checkParameters(dataset, renderer);
- Intent intent = new Intent(context, GraphicalActivity.class);
- CombinedXYChart chart = new CombinedXYChart(dataset, renderer, types);
- intent.putExtra(CHART, chart);
- intent.putExtra(TITLE, activityTitle);
- return intent;
- }
-
- /**
- * Creates a pie chart intent that can be used to start the graphical view
- * activity.
- *
- * @param context the context
- * @param dataset the category series dataset (cannot be null)
- * @param renderer the series renderer (cannot be null)
- * @param activityTitle the graphical chart activity title
- * @return a pie chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset number of items is different than the number of
- * series renderers
- */
- public static final Intent getPieChartIntent(Context context, CategorySeries dataset,
- DefaultRenderer renderer, String activityTitle) {
- checkParameters(dataset, renderer);
- Intent intent = new Intent(context, GraphicalActivity.class);
- PieChart chart = new PieChart(dataset, renderer);
- intent.putExtra(CHART, chart);
- intent.putExtra(TITLE, activityTitle);
- return intent;
- }
-
- /**
- * Creates a doughnut chart intent that can be used to start the graphical
- * view activity.
- *
- * @param context the context
- * @param dataset the multiple category series dataset (cannot be null)
- * @param renderer the series renderer (cannot be null)
- * @param activityTitle the graphical chart activity title
- * @return a pie chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset number of items is different than the number of
- * series renderers
- */
- public static final Intent getDoughnutChartIntent(Context context,
- MultipleCategorySeries dataset, DefaultRenderer renderer, String activityTitle) {
- checkParameters(dataset, renderer);
- Intent intent = new Intent(context, GraphicalActivity.class);
- DoughnutChart chart = new DoughnutChart(dataset, renderer);
- intent.putExtra(CHART, chart);
- intent.putExtra(TITLE, activityTitle);
- return intent;
- }
-
- /**
- * Creates a dial chart intent that can be used to start the graphical view
- * activity.
- *
- * @param context the context
- * @param dataset the category series dataset (cannot be null)
- * @param renderer the dial renderer (cannot be null)
- * @param activityTitle the graphical chart activity title
- * @return a dial chart intent
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset number of items is different than the number of
- * series renderers
- */
- public static final Intent getDialChartIntent(Context context, CategorySeries dataset,
- DialRenderer renderer, String activityTitle) {
- checkParameters(dataset, renderer);
- Intent intent = new Intent(context, GraphicalActivity.class);
- DialChart chart = new DialChart(dataset, renderer);
- intent.putExtra(CHART, chart);
- intent.putExtra(TITLE, activityTitle);
- return intent;
- }
-
- /**
- * Checks the validity of the dataset and renderer parameters.
- *
- * @param dataset the multiple series dataset (cannot be null)
- * @param renderer the multiple series renderer (cannot be null)
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset and the renderer don't include the same number of
- * series
- */
- private static void checkParameters(XYMultipleSeriesDataset dataset,
- XYMultipleSeriesRenderer renderer) {
- if (dataset == null || renderer == null
- || dataset.getSeriesCount() != renderer.getSeriesRendererCount()) {
- throw new IllegalArgumentException(
- "Dataset and renderer should be not null and should have the same number of series");
- }
- }
-
- /**
- * Checks the validity of the dataset and renderer parameters.
- *
- * @param dataset the category series dataset (cannot be null)
- * @param renderer the series renderer (cannot be null)
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset number of items is different than the number of
- * series renderers
- */
- private static void checkParameters(CategorySeries dataset, DefaultRenderer renderer) {
- if (dataset == null || renderer == null
- || dataset.getItemCount() != renderer.getSeriesRendererCount()) {
- throw new IllegalArgumentException(
- "Dataset and renderer should be not null and the dataset number of items should be equal to the number of series renderers");
- }
- }
-
- /**
- * Checks the validity of the dataset and renderer parameters.
- *
- * @param dataset the category series dataset (cannot be null)
- * @param renderer the series renderer (cannot be null)
- * @throws IllegalArgumentException if dataset is null or renderer is null or
- * if the dataset number of items is different than the number of
- * series renderers
- */
- private static void checkParameters(MultipleCategorySeries dataset, DefaultRenderer renderer) {
- if (dataset == null || renderer == null
- || !checkMultipleSeriesItems(dataset, renderer.getSeriesRendererCount())) {
- throw new IllegalArgumentException(
- "Titles and values should be not null and the dataset number of items should be equal to the number of series renderers");
- }
- }
-
- private static boolean checkMultipleSeriesItems(MultipleCategorySeries dataset, int value) {
- int count = dataset.getCategoriesCount();
- boolean equal = true;
- for (int k = 0; k < count && equal; k++) {
- equal = dataset.getValues(k).length == dataset.getTitles(k).length;
- }
- return equal;
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/GraphicalActivity.java b/android-libraries/achartengine/src/org/achartengine/GraphicalActivity.java
deleted file mode 100644
index 56c190aef0..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/GraphicalActivity.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine;
-
-import org.achartengine.chart.AbstractChart;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.Window;
-
-/**
- * An activity that encapsulates a graphical view of the chart.
- */
-public class GraphicalActivity extends Activity {
- /** The encapsulated graphical view. */
- private GraphicalView mView;
- /** The chart to be drawn. */
- private AbstractChart mChart;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Bundle extras = getIntent().getExtras();
- mChart = (AbstractChart) extras.getSerializable(ChartFactory.CHART);
- mView = new GraphicalView(this, mChart);
- String title = extras.getString(ChartFactory.TITLE);
- if (title == null) {
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- } else if (title.length() > 0) {
- setTitle(title);
- }
- setContentView(mView);
- }
-
-}
\ No newline at end of file
diff --git a/android-libraries/achartengine/src/org/achartengine/GraphicalView.java b/android-libraries/achartengine/src/org/achartengine/GraphicalView.java
deleted file mode 100644
index e9aebff534..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/GraphicalView.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine;
-
-import org.achartengine.chart.AbstractChart;
-import org.achartengine.chart.RoundChart;
-import org.achartengine.chart.XYChart;
-import org.achartengine.model.Point;
-import org.achartengine.model.SeriesSelection;
-import org.achartengine.renderer.DefaultRenderer;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-import org.achartengine.tools.FitZoom;
-import org.achartengine.tools.PanListener;
-import org.achartengine.tools.Zoom;
-import org.achartengine.tools.ZoomListener;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Rect;
-import android.graphics.RectF;
-import android.os.Build;
-import android.os.Handler;
-import android.view.MotionEvent;
-import android.view.View;
-
-/**
- * The view that encapsulates the graphical chart.
- */
-public class GraphicalView extends View {
- /** The chart to be drawn. */
- private AbstractChart mChart;
- /** The chart renderer. */
- private DefaultRenderer mRenderer;
- /** The view bounds. */
- private Rect mRect = new Rect();
- /** The user interface thread handler. */
- private Handler mHandler;
- /** The zoom buttons rectangle. */
- private RectF mZoomR = new RectF();
- /** The zoom in icon. */
- private Bitmap zoomInImage;
- /** The zoom out icon. */
- private Bitmap zoomOutImage;
- /** The fit zoom icon. */
- private Bitmap fitZoomImage;
- /** The zoom area size. */
- private int zoomSize = 50;
- /** The zoom buttons background color. */
- private static final int ZOOM_BUTTONS_COLOR = Color.argb(175, 150, 150, 150);
- /** The zoom in tool. */
- private Zoom mZoomIn;
- /** The zoom out tool. */
- private Zoom mZoomOut;
- /** The fit zoom tool. */
- private FitZoom mFitZoom;
- /** The paint to be used when drawing the chart. */
- private Paint mPaint = new Paint();
- /** The touch handler. */
- private ITouchHandler mTouchHandler;
- /** The old x coordinate. */
- private float oldX;
- /** The old y coordinate. */
- private float oldY;
-
- /**
- * Creates a new graphical view.
- *
- * @param context the context
- * @param chart the chart to be drawn
- */
- public GraphicalView(Context context, AbstractChart chart) {
- super(context);
- mChart = chart;
- mHandler = new Handler();
- if (mChart instanceof XYChart) {
- mRenderer = ((XYChart) mChart).getRenderer();
- } else {
- mRenderer = ((RoundChart) mChart).getRenderer();
- }
- if (mRenderer.isZoomButtonsVisible()) {
- zoomInImage = BitmapFactory.decodeStream(GraphicalView.class
- .getResourceAsStream("image/zoom_in.png"));
- zoomOutImage = BitmapFactory.decodeStream(GraphicalView.class
- .getResourceAsStream("image/zoom_out.png"));
- fitZoomImage = BitmapFactory.decodeStream(GraphicalView.class
- .getResourceAsStream("image/zoom-1.png"));
- }
-
- if (mRenderer instanceof XYMultipleSeriesRenderer
- && ((XYMultipleSeriesRenderer) mRenderer).getMarginsColor() == XYMultipleSeriesRenderer.NO_COLOR) {
- ((XYMultipleSeriesRenderer) mRenderer).setMarginsColor(mPaint.getColor());
- }
- if (mRenderer.isZoomEnabled() && mRenderer.isZoomButtonsVisible()
- || mRenderer.isExternalZoomEnabled()) {
- mZoomIn = new Zoom(mChart, true, mRenderer.getZoomRate());
- mZoomOut = new Zoom(mChart, false, mRenderer.getZoomRate());
- mFitZoom = new FitZoom(mChart);
- }
- int version = 7;
- try {
- version = Integer.valueOf(Build.VERSION.SDK);
- } catch (Exception e) {
- // do nothing
- }
- if (version < 7) {
- mTouchHandler = new TouchHandlerOld(this, mChart);
- } else {
- mTouchHandler = new TouchHandler(this, mChart);
- }
- }
-
- /**
- * Returns the current series selection object.
- *
- * @return the series selection
- */
- public SeriesSelection getCurrentSeriesAndPoint() {
- return mChart.getSeriesAndPointForScreenCoordinate(new Point(oldX, oldY));
- }
-
- /**
- * Transforms the currently selected screen point to a real point.
- *
- * @param scale the scale
- * @return the currently selected real point
- */
- public double[] toRealPoint(int scale) {
- if (mChart instanceof XYChart) {
- XYChart chart = (XYChart) mChart;
- return chart.toRealPoint(oldX, oldY, scale);
- }
- return null;
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
- canvas.getClipBounds(mRect);
- int top = mRect.top;
- int left = mRect.left;
- int width = mRect.width();
- int height = mRect.height();
- if (mRenderer.isInScroll()) {
- top = 0;
- left = 0;
- width = getMeasuredWidth();
- height = getMeasuredHeight();
- }
- mChart.draw(canvas, left, top, width, height, mPaint);
- if (mRenderer != null && mRenderer.isZoomEnabled() && mRenderer.isZoomButtonsVisible()) {
- mPaint.setColor(ZOOM_BUTTONS_COLOR);
- zoomSize = Math.max(zoomSize, Math.min(width, height) / 7);
- mZoomR.set(left + width - zoomSize * 3, top + height - zoomSize * 0.775f, left + width, top
- + height);
- canvas.drawRoundRect(mZoomR, zoomSize / 3, zoomSize / 3, mPaint);
- float buttonY = top + height - zoomSize * 0.625f;
- canvas.drawBitmap(zoomInImage, left + width - zoomSize * 2.75f, buttonY, null);
- canvas.drawBitmap(zoomOutImage, left + width - zoomSize * 1.75f, buttonY, null);
- canvas.drawBitmap(fitZoomImage, left + width - zoomSize * 0.75f, buttonY, null);
- }
- }
-
- /**
- * Sets the zoom rate.
- *
- * @param rate the zoom rate
- */
- public void setZoomRate(float rate) {
- if (mZoomIn != null && mZoomOut != null) {
- mZoomIn.setZoomRate(rate);
- mZoomOut.setZoomRate(rate);
- }
- }
-
- /**
- * Do a chart zoom in.
- */
- public void zoomIn() {
- if (mZoomIn != null) {
- mZoomIn.apply(Zoom.ZOOM_AXIS_XY);
- repaint();
- }
- }
-
- /**
- * Do a chart zoom out.
- */
- public void zoomOut() {
- if (mZoomOut != null) {
- mZoomOut.apply(Zoom.ZOOM_AXIS_XY);
- repaint();
- }
- }
-
-
-
- /**
- * Do a chart zoom reset / fit zoom.
- */
- public void zoomReset() {
- if (mFitZoom != null) {
- mFitZoom.apply();
- mZoomIn.notifyZoomResetListeners();
- repaint();
- }
- }
-
- /**
- * Adds a new zoom listener.
- *
- * @param listener zoom listener
- */
- public void addZoomListener(ZoomListener listener, boolean onButtons, boolean onPinch) {
- if (onButtons) {
- if (mZoomIn != null) {
- mZoomIn.addZoomListener(listener);
- mZoomOut.addZoomListener(listener);
- }
- if (onPinch) {
- mTouchHandler.addZoomListener(listener);
- }
- }
- }
-
- /**
- * Removes a zoom listener.
- *
- * @param listener zoom listener
- */
- public synchronized void removeZoomListener(ZoomListener listener) {
- if (mZoomIn != null) {
- mZoomIn.removeZoomListener(listener);
- mZoomOut.removeZoomListener(listener);
- }
- mTouchHandler.removeZoomListener(listener);
- }
-
- /**
- * Adds a new pan listener.
- *
- * @param listener pan listener
- */
- public void addPanListener(PanListener listener) {
- mTouchHandler.addPanListener(listener);
- }
-
- /**
- * Removes a pan listener.
- *
- * @param listener pan listener
- */
- public void removePanListener(PanListener listener) {
- mTouchHandler.removePanListener(listener);
- }
-
- protected RectF getZoomRectangle() {
- return mZoomR;
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (event.getAction() == MotionEvent.ACTION_DOWN) {
- // save the x and y so they can be used in the click and long press
- // listeners
- oldX = event.getX();
- oldY = event.getY();
- }
- if (mRenderer != null && (mRenderer.isPanEnabled() || mRenderer.isZoomEnabled())) {
- if (mTouchHandler.handleTouch(event)) {
- return true;
- }
- }
- return super.onTouchEvent(event);
- }
-
- /**
- * Schedule a view content repaint.
- */
- public void repaint() {
- mHandler.post(new Runnable() {
- public void run() {
- invalidate();
- }
- });
- }
-
- /**
- * Schedule a view content repaint, in the specified rectangle area.
- *
- * @param left the left position of the area to be repainted
- * @param top the top position of the area to be repainted
- * @param right the right position of the area to be repainted
- * @param bottom the bottom position of the area to be repainted
- */
- public void repaint(final int left, final int top, final int right, final int bottom) {
- mHandler.post(new Runnable() {
- public void run() {
- invalidate(left, top, right, bottom);
- }
- });
- }
-
- /**
- * Saves the content of the graphical view to a bitmap.
- *
- * @return the bitmap
- */
- public Bitmap toBitmap() {
- setDrawingCacheEnabled(false);
- if (!isDrawingCacheEnabled()) {
- setDrawingCacheEnabled(true);
- }
- if (mRenderer.isApplyBackgroundColor()) {
- setDrawingCacheBackgroundColor(mRenderer.getBackgroundColor());
- }
- setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
- return getDrawingCache(true);
- }
-
-}
\ No newline at end of file
diff --git a/android-libraries/achartengine/src/org/achartengine/ITouchHandler.java b/android-libraries/achartengine/src/org/achartengine/ITouchHandler.java
deleted file mode 100644
index 4debe96493..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/ITouchHandler.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine;
-
-import org.achartengine.tools.PanListener;
-import org.achartengine.tools.ZoomListener;
-
-import android.view.MotionEvent;
-
-/**
- * The interface to be implemented by the touch handlers.
- */
-public interface ITouchHandler {
- /**
- * Handles the touch event.
- *
- * @param event the touch event
- * @return true if the event was handled
- */
- boolean handleTouch(MotionEvent event);
-
- /**
- * Adds a new zoom listener.
- *
- * @param listener zoom listener
- */
- void addZoomListener(ZoomListener listener);
-
- /**
- * Removes a zoom listener.
- *
- * @param listener zoom listener
- */
- void removeZoomListener(ZoomListener listener);
-
- /**
- * Adds a new pan listener.
- *
- * @param listener pan listener
- */
- void addPanListener(PanListener listener);
-
- /**
- * Removes a pan listener.
- *
- * @param listener pan listener
- */
- void removePanListener(PanListener listener);
-
-}
\ No newline at end of file
diff --git a/android-libraries/achartengine/src/org/achartengine/TouchHandler.java b/android-libraries/achartengine/src/org/achartengine/TouchHandler.java
deleted file mode 100644
index a06d05d635..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/TouchHandler.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine;
-
-import org.achartengine.chart.AbstractChart;
-import org.achartengine.chart.RoundChart;
-import org.achartengine.chart.XYChart;
-import org.achartengine.renderer.DefaultRenderer;
-import org.achartengine.tools.Pan;
-import org.achartengine.tools.PanListener;
-import org.achartengine.tools.Zoom;
-import org.achartengine.tools.ZoomListener;
-
-import android.graphics.RectF;
-import android.view.MotionEvent;
-
-/**
- * The main handler of the touch events.
- */
-public class TouchHandler implements ITouchHandler {
- /** The chart renderer. */
- private DefaultRenderer mRenderer;
- /** The old x coordinate. */
- private float oldX;
- /** The old y coordinate. */
- private float oldY;
- /** The old x2 coordinate. */
- private float oldX2;
- /** The old y2 coordinate. */
- private float oldY2;
- /** The zoom buttons rectangle. */
- private RectF zoomR = new RectF();
- /** The pan tool. */
- private Pan mPan;
- /** The zoom for the pinch gesture. */
- private Zoom mPinchZoom;
- /** The graphical view. */
- private GraphicalView graphicalView;
-
- /**
- * Creates a new graphical view.
- *
- * @param view the graphical view
- * @param chart the chart to be drawn
- */
- public TouchHandler(GraphicalView view, AbstractChart chart) {
- graphicalView = view;
- zoomR = graphicalView.getZoomRectangle();
- if (chart instanceof XYChart) {
- mRenderer = ((XYChart) chart).getRenderer();
- } else {
- mRenderer = ((RoundChart) chart).getRenderer();
- }
- if (mRenderer.isPanEnabled()) {
- mPan = new Pan(chart);
- }
- if (mRenderer.isZoomEnabled()) {
- mPinchZoom = new Zoom(chart, true, 1);
- }
- }
-
- /**
- * Handles the touch event.
- *
- * @param event the touch event
- */
- public boolean handleTouch(MotionEvent event) {
- int action = event.getAction();
- if (mRenderer != null && action == MotionEvent.ACTION_MOVE) {
- if (oldX >= 0 || oldY >= 0) {
- float newX = event.getX(0);
- float newY = event.getY(0);
- if (event.getPointerCount() > 1 && (oldX2 >= 0 || oldY2 >= 0) && mRenderer.isZoomEnabled()) {
- float newX2 = event.getX(1);
- float newY2 = event.getY(1);
- float newDeltaX = Math.abs(newX - newX2);
- float newDeltaY = Math.abs(newY - newY2);
- float oldDeltaX = Math.abs(oldX - oldX2);
- float oldDeltaY = Math.abs(oldY - oldY2);
- float zoomRate = 1;
-
- float tan1 = Math.abs(newY - oldY) / Math.abs(newX - oldX);
- float tan2 = Math.abs(newY2 - oldY2) / Math.abs(newX2 - oldX2);
- if ( tan1 <= 0.577 && tan2 <= 0.577) {
- // horizontal pinch zoom, |deltaY| / |deltaX| is [0 ~ 0.577], 0.577 is the approximate value of tan(Pi/6)
- zoomRate = newDeltaX / oldDeltaX;
- if (zoomRate > 0.909 && zoomRate < 1.1) {
- mPinchZoom.setZoomRate(zoomRate);
- mPinchZoom.apply(Zoom.ZOOM_AXIS_X);
- }
- } else if ( tan1 >= 1.732 && tan2 >= 1.732 ) {
- // pinch zoom vertically, |deltaY| / |deltaX| is [1.732 ~ infinity], 1.732 is the approximate value of tan(Pi/3)
- zoomRate = newDeltaY / oldDeltaY;
- if (zoomRate > 0.909 && zoomRate < 1.1) {
- mPinchZoom.setZoomRate(zoomRate);
- mPinchZoom.apply(Zoom.ZOOM_AXIS_Y);
- }
- } else if ( (tan1 > 0.577 && tan1 < 1.732) && (tan2 > 0.577 && tan2 < 1.732) ){
- // pinch zoom diagonally
- if (Math.abs(newX - oldX) >= Math.abs(newY - oldY)) {
- zoomRate = newDeltaX / oldDeltaX;
- } else {
- zoomRate = newDeltaY / oldDeltaY;
- }
- if (zoomRate > 0.909 && zoomRate < 1.1) {
- mPinchZoom.setZoomRate(zoomRate);
- mPinchZoom.apply(Zoom.ZOOM_AXIS_XY);
- }
- }
- oldX2 = newX2;
- oldY2 = newY2;
- } else if (mRenderer.isPanEnabled()) {
- mPan.apply(oldX, oldY, newX, newY);
- oldX2 = 0;
- oldY2 = 0;
- }
- oldX = newX;
- oldY = newY;
- graphicalView.repaint();
- return true;
- }
- } else if (action == MotionEvent.ACTION_DOWN) {
- oldX = event.getX(0);
- oldY = event.getY(0);
- if (mRenderer != null && mRenderer.isZoomEnabled() && zoomR.contains(oldX, oldY)) {
- if (oldX < zoomR.left + zoomR.width() / 3) {
- graphicalView.zoomIn();
- } else if (oldX < zoomR.left + zoomR.width() * 2 / 3) {
- graphicalView.zoomOut();
- } else {
- graphicalView.zoomReset();
- }
- return true;
- }
- } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) {
- oldX = 0;
- oldY = 0;
- oldX2 = 0;
- oldY2 = 0;
- if (action == MotionEvent.ACTION_POINTER_UP) {
- oldX = -1;
- oldY = -1;
- }
- }
- return !mRenderer.isClickEnabled();
- }
-
- /**
- * Adds a new zoom listener.
- *
- * @param listener zoom listener
- */
- public void addZoomListener(ZoomListener listener) {
- if (mPinchZoom != null) {
- mPinchZoom.addZoomListener(listener);
- }
- }
-
- /**
- * Removes a zoom listener.
- *
- * @param listener zoom listener
- */
- public void removeZoomListener(ZoomListener listener) {
- if (mPinchZoom != null) {
- mPinchZoom.removeZoomListener(listener);
- }
- }
-
- /**
- * Adds a new pan listener.
- *
- * @param listener pan listener
- */
- public void addPanListener(PanListener listener) {
- if (mPan != null) {
- mPan.addPanListener(listener);
- }
- }
-
- /**
- * Removes a pan listener.
- *
- * @param listener pan listener
- */
- public void removePanListener(PanListener listener) {
- if (mPan != null) {
- mPan.removePanListener(listener);
- }
- }
-}
\ No newline at end of file
diff --git a/android-libraries/achartengine/src/org/achartengine/TouchHandlerOld.java b/android-libraries/achartengine/src/org/achartengine/TouchHandlerOld.java
deleted file mode 100644
index 38b4f227b4..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/TouchHandlerOld.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine;
-
-import org.achartengine.chart.AbstractChart;
-import org.achartengine.chart.RoundChart;
-import org.achartengine.chart.XYChart;
-import org.achartengine.renderer.DefaultRenderer;
-import org.achartengine.tools.Pan;
-import org.achartengine.tools.PanListener;
-import org.achartengine.tools.ZoomListener;
-
-import android.graphics.RectF;
-import android.view.MotionEvent;
-
-/**
- * A handler implementation for touch events for older platforms.
- */
-public class TouchHandlerOld implements ITouchHandler {
- /** The chart renderer. */
- private DefaultRenderer mRenderer;
- /** The old x coordinate. */
- private float oldX;
- /** The old y coordinate. */
- private float oldY;
- /** The zoom buttons rectangle. */
- private RectF zoomR = new RectF();
- /** The pan tool. */
- private Pan mPan;
- /** The graphical view. */
- private GraphicalView graphicalView;
-
- /**
- * Creates an implementation of the old version of the touch handler.
- *
- * @param view the graphical view
- * @param chart the chart to be drawn
- */
- public TouchHandlerOld(GraphicalView view, AbstractChart chart) {
- graphicalView = view;
- zoomR = graphicalView.getZoomRectangle();
- if (chart instanceof XYChart) {
- mRenderer = ((XYChart) chart).getRenderer();
- } else {
- mRenderer = ((RoundChart) chart).getRenderer();
- }
- if (mRenderer.isPanEnabled()) {
- mPan = new Pan(chart);
- }
- }
-
- public boolean handleTouch(MotionEvent event) {
- int action = event.getAction();
- if (mRenderer != null && action == MotionEvent.ACTION_MOVE) {
- if (oldX >= 0 || oldY >= 0) {
- float newX = event.getX();
- float newY = event.getY();
- if (mRenderer.isPanEnabled()) {
- mPan.apply(oldX, oldY, newX, newY);
- }
- oldX = newX;
- oldY = newY;
- graphicalView.repaint();
- return true;
- }
- } else if (action == MotionEvent.ACTION_DOWN) {
- oldX = event.getX();
- oldY = event.getY();
- if (mRenderer != null && mRenderer.isZoomEnabled() && zoomR.contains(oldX, oldY)) {
- if (oldX < zoomR.left + zoomR.width() / 3) {
- graphicalView.zoomIn();
- } else if (oldX < zoomR.left + zoomR.width() * 2 / 3) {
- graphicalView.zoomOut();
- } else {
- graphicalView.zoomReset();
- }
- return true;
- }
- } else if (action == MotionEvent.ACTION_UP) {
- oldX = 0;
- oldY = 0;
- }
- return !mRenderer.isClickEnabled();
- }
-
- /**
- * Adds a new zoom listener.
- *
- * @param listener zoom listener
- */
- public void addZoomListener(ZoomListener listener) {
- }
-
- /**
- * Removes a zoom listener.
- *
- * @param listener zoom listener
- */
- public void removeZoomListener(ZoomListener listener) {
- }
-
- /**
- * Adds a new pan listener.
- *
- * @param listener pan listener
- */
- public void addPanListener(PanListener listener) {
- if (mPan != null) {
- mPan.addPanListener(listener);
- }
- }
-
- /**
- * Removes a pan listener.
- *
- * @param listener pan listener
- */
- public void removePanListener(PanListener listener) {
- if (mPan != null) {
- mPan.removePanListener(listener);
- }
- }
-
-}
\ No newline at end of file
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/AbstractChart.java b/android-libraries/achartengine/src/org/achartengine/chart/AbstractChart.java
deleted file mode 100644
index f99a5c2a85..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/AbstractChart.java
+++ /dev/null
@@ -1,475 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import java.io.Serializable;
-import java.util.List;
-
-import org.achartengine.model.Point;
-import org.achartengine.model.SeriesSelection;
-import org.achartengine.renderer.DefaultRenderer;
-import org.achartengine.renderer.SimpleSeriesRenderer;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-import org.achartengine.renderer.XYMultipleSeriesRenderer.Orientation;
-import org.achartengine.util.MathHelper;
-
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Paint.Align;
-import android.graphics.Paint.Style;
-import android.graphics.Path;
-import android.graphics.Rect;
-import android.graphics.RectF;
-
-/**
- * An abstract class to be implemented by the chart rendering classes.
- */
-public abstract class AbstractChart implements Serializable {
- /**
- * The graphical representation of the chart.
- *
- * @param canvas the canvas to paint to
- * @param x the top left x value of the view to draw to
- * @param y the top left y value of the view to draw to
- * @param width the width of the view to draw to
- * @param height the height of the view to draw to
- * @param paint the paint
- */
- public abstract void draw(Canvas canvas, int x, int y, int width, int height, Paint paint);
-
- /**
- * Draws the chart background.
- *
- * @param renderer the chart renderer
- * @param canvas the canvas to paint to
- * @param x the top left x value of the view to draw to
- * @param y the top left y value of the view to draw to
- * @param width the width of the view to draw to
- * @param height the height of the view to draw to
- * @param paint the paint used for drawing
- * @param newColor if a new color is to be used
- * @param color the color to be used
- */
- protected void drawBackground(DefaultRenderer renderer, Canvas canvas, int x, int y, int width,
- int height, Paint paint, boolean newColor, int color) {
- if (renderer.isApplyBackgroundColor() || newColor) {
- if (newColor) {
- paint.setColor(color);
- } else {
- paint.setColor(renderer.getBackgroundColor());
- }
- paint.setStyle(Style.FILL);
- canvas.drawRect(x, y, x + width, y + height, paint);
- }
- }
-
- /**
- * Draws the chart legend.
- *
- * @param canvas the canvas to paint to
- * @param renderer the series renderer
- * @param titles the titles to go to the legend
- * @param left the left X value of the area to draw to
- * @param right the right X value of the area to draw to
- * @param y the y value of the area to draw to
- * @param width the width of the area to draw to
- * @param height the height of the area to draw to
- * @param legendSize the legend size
- * @param paint the paint to be used for drawing
- * @param calculate if only calculating the legend size
- *
- * @return the legend height
- */
- protected int drawLegend(Canvas canvas, DefaultRenderer renderer, String[] titles, int left,
- int right, int y, int width, int height, int legendSize, Paint paint, boolean calculate) {
- float size = 32;
- if (renderer.isShowLegend()) {
- float currentX = left;
- float currentY = y + height - legendSize + size;
- paint.setTextAlign(Align.LEFT);
- paint.setTextSize(renderer.getLegendTextSize());
- int sLength = Math.min(titles.length, renderer.getSeriesRendererCount());
- for (int i = 0; i < sLength; i++) {
- final float lineSize = getLegendShapeWidth(i);
- String text = titles[i];
- if (titles.length == renderer.getSeriesRendererCount()) {
- paint.setColor(renderer.getSeriesRendererAt(i).getColor());
- } else {
- paint.setColor(Color.LTGRAY);
- }
- float[] widths = new float[text.length()];
- paint.getTextWidths(text, widths);
- float sum = 0;
- for (float value : widths) {
- sum += value;
- }
- float extraSize = lineSize + 10 + sum;
- float currentWidth = currentX + extraSize;
-
- if (i > 0 && getExceed(currentWidth, renderer, right, width)) {
- currentX = left;
- currentY += renderer.getLegendTextSize();
- size += renderer.getLegendTextSize();
- currentWidth = currentX + extraSize;
- }
- if (getExceed(currentWidth, renderer, right, width)) {
- float maxWidth = right - currentX - lineSize - 10;
- if (isVertical(renderer)) {
- maxWidth = width - currentX - lineSize - 10;
- }
- int nr = paint.breakText(text, true, maxWidth, widths);
- text = text.substring(0, nr) + "...";
- }
- if (!calculate) {
- drawLegendShape(canvas, renderer.getSeriesRendererAt(i), currentX, currentY, i, paint);
- drawString(canvas, text, currentX + lineSize + 5, currentY + 5, paint);
- }
- currentX += extraSize;
- }
- }
- return Math.round(size + renderer.getLegendTextSize());
- }
-
- /**
- * Draw a multiple lines string.
- *
- * @param canvas the canvas to paint to
- * @param text the text to be painted
- * @param x the x value of the area to draw to
- * @param y the y value of the area to draw to
- * @param paint the paint to be used for drawing
- */
- protected void drawString(Canvas canvas, String text, float x, float y, Paint paint) {
- String[] lines = text.split("\n");
- Rect rect = new Rect();
- int yOff = 0;
- for (int i = 0; i < lines.length; ++i) {
- canvas.drawText(lines[i], x, y + yOff, paint);
- paint.getTextBounds(lines[i], 0, lines[i].length(), rect);
- yOff = yOff + rect.height() + 5; // space between lines is 5
- }
- }
-
- /**
- * Calculates if the current width exceeds the total width.
- *
- * @param currentWidth the current width
- * @param renderer the renderer
- * @param right the right side pixel value
- * @param width the total width
- * @return if the current width exceeds the total width
- */
- protected boolean getExceed(float currentWidth, DefaultRenderer renderer, int right, int width) {
- boolean exceed = currentWidth > right;
- if (isVertical(renderer)) {
- exceed = currentWidth > width;
- }
- return exceed;
- }
-
- /**
- * Checks if the current chart is rendered as vertical.
- *
- * @param renderer the renderer
- * @return if the chart is rendered as a vertical one
- */
- public boolean isVertical(DefaultRenderer renderer) {
- return renderer instanceof XYMultipleSeriesRenderer
- && ((XYMultipleSeriesRenderer) renderer).getOrientation() == Orientation.VERTICAL;
- }
-
- /**
- * Makes sure the fraction digit is not displayed, if not needed.
- *
- * @param label the input label value
- * @return the label without the useless fraction digit
- */
- protected String getLabel(double label) {
- String text = "";
- if (label == Math.round(label)) {
- text = Math.round(label) + "";
- } else {
- text = label + "";
- }
- return text;
- }
-
- private static float[] calculateDrawPoints(float p1x, float p1y, float p2x, float p2y,
- int screenHeight, int screenWidth) {
- float drawP1x;
- float drawP1y;
- float drawP2x;
- float drawP2y;
-
- if (p1y > screenHeight) {
- // Intersection with the top of the screen
- float m = (p2y - p1y) / (p2x - p1x);
- drawP1x = (screenHeight - p1y + m * p1x) / m;
- drawP1y = screenHeight;
-
- if (drawP1x < 0) {
- // If Intersection is left of the screen we calculate the intersection
- // with the left border
- drawP1x = 0;
- drawP1y = p1y - m * p1x;
- } else if (drawP1x > screenWidth) {
- // If Intersection is right of the screen we calculate the intersection
- // with the right border
- drawP1x = screenWidth;
- drawP1y = m * screenWidth + p1y - m * p1x;
- }
- } else if (p1y < 0) {
- float m = (p2y - p1y) / (p2x - p1x);
- drawP1x = (-p1y + m * p1x) / m;
- drawP1y = 0;
- if (drawP1x < 0) {
- drawP1x = 0;
- drawP1y = p1y - m * p1x;
- } else if (drawP1x > screenWidth) {
- drawP1x = screenWidth;
- drawP1y = m * screenWidth + p1y - m * p1x;
- }
- } else {
- // If the point is in the screen use it
- drawP1x = p1x;
- drawP1y = p1y;
- }
-
- if (p2y > screenHeight) {
- float m = (p2y - p1y) / (p2x - p1x);
- drawP2x = (screenHeight - p1y + m * p1x) / m;
- drawP2y = screenHeight;
- if (drawP2x < 0) {
- drawP2x = 0;
- drawP2y = p1y - m * p1x;
- } else if (drawP2x > screenWidth) {
- drawP2x = screenWidth;
- drawP2y = m * screenWidth + p1y - m * p1x;
- }
- } else if (p2y < 0) {
- float m = (p2y - p1y) / (p2x - p1x);
- drawP2x = (-p1y + m * p1x) / m;
- drawP2y = 0;
- if (drawP2x < 0) {
- drawP2x = 0;
- drawP2y = p1y - m * p1x;
- } else if (drawP2x > screenWidth) {
- drawP2x = screenWidth;
- drawP2y = m * screenWidth + p1y - m * p1x;
- }
- } else {
- // If the point is in the screen use it
- drawP2x = p2x;
- drawP2y = p2y;
- }
-
- return new float[] { drawP1x, drawP1y, drawP2x, drawP2y };
- }
-
- /**
- * The graphical representation of a path.
- *
- * @param canvas the canvas to paint to
- * @param points the points that are contained in the path to paint
- * @param paint the paint to be used for painting
- * @param circular if the path ends with the start point
- */
- protected void drawPath(Canvas canvas, float[] points, Paint paint, boolean circular) {
- Path path = new Path();
- int height = canvas.getHeight();
- int width = canvas.getWidth();
-
- float[] tempDrawPoints;
- if (points.length < 4) {
- return;
- }
- tempDrawPoints = calculateDrawPoints(points[0], points[1], points[2], points[3], height, width);
- path.moveTo(tempDrawPoints[0], tempDrawPoints[1]);
- path.lineTo(tempDrawPoints[2], tempDrawPoints[3]);
-
- for (int i = 4; i < points.length; i += 2) {
- if ((points[i - 1] < 0 && points[i + 1] < 0)
- || (points[i - 1] > height && points[i + 1] > height)) {
- continue;
- }
- tempDrawPoints = calculateDrawPoints(points[i - 2], points[i - 1], points[i], points[i + 1],
- height, width);
- if (!circular) {
- path.moveTo(tempDrawPoints[0], tempDrawPoints[1]);
- }
- path.lineTo(tempDrawPoints[2], tempDrawPoints[3]);
- }
- if (circular) {
- path.lineTo(points[0], points[1]);
- }
- canvas.drawPath(path, paint);
- }
-
- /**
- * Returns the legend shape width.
- *
- * @param seriesIndex the series index
- * @return the legend shape width
- */
- public abstract int getLegendShapeWidth(int seriesIndex);
-
- /**
- * The graphical representation of the legend shape.
- *
- * @param canvas the canvas to paint to
- * @param renderer the series renderer
- * @param x the x value of the point the shape should be drawn at
- * @param y the y value of the point the shape should be drawn at
- * @param seriesIndex the series index
- * @param paint the paint to be used for drawing
- */
- public abstract void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x,
- float y, int seriesIndex, Paint paint);
-
- /**
- * Calculates the best text to fit into the available space.
- *
- * @param text the entire text
- * @param width the width to fit the text into
- * @param paint the paint
- * @return the text to fit into the space
- */
- private String getFitText(String text, float width, Paint paint) {
- String newText = text;
- int length = text.length();
- int diff = 0;
- while (paint.measureText(newText) > width && diff < length) {
- diff++;
- newText = text.substring(0, length - diff) + "...";
- }
- if (diff == length) {
- newText = "...";
- }
- return newText;
- }
-
- /**
- * Calculates the current legend size.
- *
- * @param renderer the renderer
- * @param defaultHeight the default height
- * @param extraHeight the added extra height
- * @return the legend size
- */
- protected int getLegendSize(DefaultRenderer renderer, int defaultHeight, float extraHeight) {
- int legendSize = renderer.getLegendHeight();
- if (renderer.isShowLegend() && legendSize == 0) {
- legendSize = defaultHeight;
- }
- if (!renderer.isShowLegend() && renderer.isShowLabels()) {
- legendSize = (int) (renderer.getLabelsTextSize() * 4 / 3 + extraHeight);
- }
- return legendSize;
- }
-
- /**
- * Draws a text label.
- *
- * @param canvas the canvas
- * @param labelText the label text
- * @param renderer the renderer
- * @param prevLabelsBounds the previous rendered label bounds
- * @param centerX the round chart center on X axis
- * @param centerY the round chart center on Y axis
- * @param shortRadius the short radius for the round chart
- * @param longRadius the long radius for the round chart
- * @param currentAngle the current angle
- * @param angle the label extra angle
- * @param left the left side
- * @param right the right side
- * @param color the label color
- * @param paint the paint
- * @param line if a line to the label should be drawn
- */
- protected void drawLabel(Canvas canvas, String labelText, DefaultRenderer renderer,
- List prevLabelsBounds, int centerX, int centerY, float shortRadius, float longRadius,
- float currentAngle, float angle, int left, int right, int color, Paint paint, boolean line) {
- if (renderer.isShowLabels()) {
- paint.setColor(color);
- double rAngle = Math.toRadians(90 - (currentAngle + angle / 2));
- double sinValue = Math.sin(rAngle);
- double cosValue = Math.cos(rAngle);
- int x1 = Math.round(centerX + (float) (shortRadius * sinValue));
- int y1 = Math.round(centerY + (float) (shortRadius * cosValue));
- int x2 = Math.round(centerX + (float) (longRadius * sinValue));
- int y2 = Math.round(centerY + (float) (longRadius * cosValue));
-
- float size = renderer.getLabelsTextSize();
- float extra = Math.max(size / 2, 10);
- paint.setTextAlign(Align.LEFT);
- if (x1 > x2) {
- extra = -extra;
- paint.setTextAlign(Align.RIGHT);
- }
- float xLabel = x2 + extra;
- float yLabel = y2;
- float width = right - xLabel;
- if (x1 > x2) {
- width = xLabel - left;
- }
- labelText = getFitText(labelText, width, paint);
- float widthLabel = paint.measureText(labelText);
- boolean okBounds = false;
- while (!okBounds && line) {
- boolean intersects = false;
- int length = prevLabelsBounds.size();
- for (int j = 0; j < length && !intersects; j++) {
- RectF prevLabelBounds = prevLabelsBounds.get(j);
- if (prevLabelBounds.intersects(xLabel, yLabel, xLabel + widthLabel, yLabel + size)) {
- intersects = true;
- yLabel = Math.max(yLabel, prevLabelBounds.bottom);
- }
- }
- okBounds = !intersects;
- }
-
- if (line) {
- y2 = (int) (yLabel - size / 2);
- canvas.drawLine(x1, y1, x2, y2, paint);
- canvas.drawLine(x2, y2, x2 + extra, y2, paint);
- } else {
- paint.setTextAlign(Align.CENTER);
- }
- canvas.drawText(labelText, xLabel, yLabel, paint);
- if (line) {
- prevLabelsBounds.add(new RectF(xLabel, yLabel, xLabel + widthLabel, yLabel + size));
- }
- }
- }
-
- public boolean isNullValue(double value) {
- return Double.isNaN(value) || Double.isInfinite(value) || value == MathHelper.NULL_VALUE;
- }
-
- /**
- * Given screen coordinates, returns the series and point indexes of a chart
- * element. If there is no chart element (line, point, bar, etc) at those
- * coordinates, null is returned.
- *
- * @param screenPoint
- * @return the series and point indexes
- */
- public SeriesSelection getSeriesAndPointForScreenCoordinate(Point screenPoint) {
- return null;
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/BarChart.java b/android-libraries/achartengine/src/org/achartengine/chart/BarChart.java
deleted file mode 100644
index d5d0fb235d..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/BarChart.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.model.XYSeries;
-import org.achartengine.renderer.SimpleSeriesRenderer;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Paint.Style;
-import android.graphics.RectF;
-import android.graphics.drawable.GradientDrawable;
-import android.graphics.drawable.GradientDrawable.Orientation;
-
-/**
- * The bar chart rendering class.
- */
-public class BarChart extends XYChart {
- /** The constant to identify this chart type. */
- public static final String TYPE = "Bar";
- /** The legend shape width. */
- private static final int SHAPE_WIDTH = 12;
- /** The chart type. */
- protected Type mType = Type.DEFAULT;
-
- /**
- * The bar chart type enum.
- */
- public enum Type {
- DEFAULT, STACKED;
- }
-
- BarChart() {
- }
-
- BarChart(Type type) {
- mType = type;
- }
-
- /**
- * Builds a new bar chart instance.
- *
- * @param dataset the multiple series dataset
- * @param renderer the multiple series renderer
- * @param type the bar chart type
- */
- public BarChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type) {
- super(dataset, renderer);
- mType = type;
- }
-
- @Override
- protected ClickableArea[] clickableAreasForPoints(float[] points, double[] values,
- float yAxisValue, int seriesIndex, int startIndex) {
- int seriesNr = mDataset.getSeriesCount();
- int length = points.length;
- ClickableArea[] ret = new ClickableArea[length / 2];
- float halfDiffX = getHalfDiffX(points, length, seriesNr);
- for (int i = 0; i < length; i += 2) {
- float x = points[i];
- float y = points[i + 1];
- if (mType == Type.STACKED) {
- ret[i / 2] = new ClickableArea(new RectF(x - halfDiffX, y, x + halfDiffX, yAxisValue),
- values[i], values[i + 1]);
- } else {
- float startX = x - seriesNr * halfDiffX + seriesIndex * 2 * halfDiffX;
- ret[i / 2] = new ClickableArea(new RectF(startX, y, startX + 2 * halfDiffX, yAxisValue),
- values[i], values[i + 1]);
- }
- }
- return ret;
- }
-
- /**
- * The graphical representation of a series.
- *
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param points the array of points to be used for drawing the series
- * @param seriesRenderer the series renderer
- * @param yAxisValue the minimum value of the y axis
- * @param seriesIndex the index of the series currently being drawn
- * @param startIndex the start index of the rendering points
- */
- public void drawSeries(Canvas canvas, Paint paint, float[] points,
- SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex) {
- int seriesNr = mDataset.getSeriesCount();
- int length = points.length;
- paint.setColor(seriesRenderer.getColor());
- paint.setStyle(Style.FILL);
- float halfDiffX = getHalfDiffX(points, length, seriesNr);
- for (int i = 0; i < length; i += 2) {
- float x = points[i];
- float y = points[i + 1];
- drawBar(canvas, x, yAxisValue, x, y, halfDiffX, seriesNr, seriesIndex, paint);
- }
- paint.setColor(seriesRenderer.getColor());
- }
-
- /**
- * Draws a bar.
- *
- * @param canvas the canvas
- * @param xMin the X axis minimum
- * @param yMin the Y axis minimum
- * @param xMax the X axis maximum
- * @param yMax the Y axis maximum
- * @param halfDiffX half the size of a bar
- * @param seriesNr the total number of series
- * @param seriesIndex the current series index
- * @param paint the paint
- */
- protected void drawBar(Canvas canvas, float xMin, float yMin, float xMax, float yMax,
- float halfDiffX, int seriesNr, int seriesIndex, Paint paint) {
- int scale = mDataset.getSeriesAt(seriesIndex).getScaleNumber();
- if (mType == Type.STACKED) {
- drawBar(canvas, xMin - halfDiffX, yMax, xMax + halfDiffX, yMin, scale, seriesIndex, paint);
- } else {
- float startX = xMin - seriesNr * halfDiffX + seriesIndex * 2 * halfDiffX;
- drawBar(canvas, startX, yMax, startX + 2 * halfDiffX, yMin, scale, seriesIndex, paint);
- }
- }
-
- /**
- * Draws a bar.
- *
- * @param canvas the canvas
- * @param xMin the X axis minimum
- * @param yMin the Y axis minimum
- * @param xMax the X axis maximum
- * @param yMax the Y axis maximum
- * @param scale the scale index
- * @param seriesIndex the current series index
- * @param paint the paint
- */
- private void drawBar(Canvas canvas, float xMin, float yMin, float xMax, float yMax, int scale,
- int seriesIndex, Paint paint) {
- SimpleSeriesRenderer renderer = mRenderer.getSeriesRendererAt(seriesIndex);
- if (renderer.isGradientEnabled()) {
- float minY = (float) toScreenPoint(new double[] { 0, renderer.getGradientStopValue() }, scale)[1];
- float maxY = (float) toScreenPoint(new double[] { 0, renderer.getGradientStartValue() },
- scale)[1];
- float gradientMinY = Math.max(minY, Math.min(yMin, yMax));
- float gradientMaxY = Math.min(maxY, Math.max(yMin, yMax));
- int gradientMinColor = renderer.getGradientStopColor();
- int gradientMaxColor = renderer.getGradientStartColor();
- int gradientStartColor = gradientMaxColor;
- int gradientStopColor = gradientMinColor;
-
- if (yMin < minY) {
- paint.setColor(gradientMinColor);
- canvas.drawRect(Math.round(xMin), Math.round(yMin), Math.round(xMax),
- Math.round(gradientMinY), paint);
- } else {
- gradientStopColor = getGradientPartialColor(gradientMinColor, gradientMaxColor,
- (maxY - gradientMinY) / (maxY - minY));
- }
- if (yMax > maxY) {
- paint.setColor(gradientMaxColor);
- canvas.drawRect(Math.round(xMin), Math.round(gradientMaxY), Math.round(xMax),
- Math.round(yMax), paint);
- } else {
- gradientStartColor = getGradientPartialColor(gradientMaxColor, gradientMinColor,
- (gradientMaxY - minY) / (maxY - minY));
- }
- GradientDrawable gradient = new GradientDrawable(Orientation.BOTTOM_TOP, new int[] {
- gradientStartColor, gradientStopColor });
- gradient.setBounds(Math.round(xMin), Math.round(gradientMinY), Math.round(xMax),
- Math.round(gradientMaxY));
- gradient.draw(canvas);
- } else {
- if (Math.abs(yMin - yMax) < 1) {
- if (yMin < yMax) {
- yMax = yMin + 1;
- } else {
- yMax = yMin - 1;
- }
- }
- canvas
- .drawRect(Math.round(xMin), Math.round(yMin), Math.round(xMax), Math.round(yMax), paint);
- }
- }
-
- private int getGradientPartialColor(int minColor, int maxColor, float fraction) {
- int alpha = Math.round(fraction * Color.alpha(minColor) + (1 - fraction)
- * Color.alpha(maxColor));
- int r = Math.round(fraction * Color.red(minColor) + (1 - fraction) * Color.red(maxColor));
- int g = Math.round(fraction * Color.green(minColor) + (1 - fraction) * Color.green(maxColor));
- int b = Math.round(fraction * Color.blue(minColor) + (1 - fraction) * Color.blue((maxColor)));
- return Color.argb(alpha, r, g, b);
- }
-
- /**
- * The graphical representation of the series values as text.
- *
- * @param canvas the canvas to paint to
- * @param series the series to be painted
- * @param renderer the series renderer
- * @param paint the paint to be used for drawing
- * @param points the array of points to be used for drawing the series
- * @param seriesIndex the index of the series currently being drawn
- * @param startIndex the start index of the rendering points
- */
- protected void drawChartValuesText(Canvas canvas, XYSeries series, SimpleSeriesRenderer renderer,
- Paint paint, float[] points, int seriesIndex, int startIndex) {
- int seriesNr = mDataset.getSeriesCount();
- float halfDiffX = getHalfDiffX(points, points.length, seriesNr);
- for (int i = 0; i < points.length; i += 2) {
- int index = startIndex + i / 2;
- double value = series.getY(index);
- if (!isNullValue(value)) {
- float x = points[i];
- if (mType == Type.DEFAULT) {
- x += seriesIndex * 2 * halfDiffX - (seriesNr - 1.5f) * halfDiffX;
- }
- if (value >= 0) {
- drawText(canvas, getLabel(value), x, points[i + 1] - renderer.getChartValuesSpacing(),
- paint, 0);
- } else {
- drawText(canvas, getLabel(value), x, points[i + 1] + renderer.getChartValuesTextSize()
- + renderer.getChartValuesSpacing() - 3, paint, 0);
- }
- }
- }
- }
-
- /**
- * Returns the legend shape width.
- *
- * @param seriesIndex the series index
- * @return the legend shape width
- */
- public int getLegendShapeWidth(int seriesIndex) {
- return SHAPE_WIDTH;
- }
-
- /**
- * The graphical representation of the legend shape.
- *
- * @param canvas the canvas to paint to
- * @param renderer the series renderer
- * @param x the x value of the point the shape should be drawn at
- * @param y the y value of the point the shape should be drawn at
- * @param seriesIndex the series index
- * @param paint the paint to be used for drawing
- */
- public void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y,
- int seriesIndex, Paint paint) {
- float halfShapeWidth = SHAPE_WIDTH / 2;
- canvas.drawRect(x, y - halfShapeWidth, x + SHAPE_WIDTH, y + halfShapeWidth, paint);
- }
-
- /**
- * Calculates and returns the half-distance in the graphical representation of
- * 2 consecutive points.
- *
- * @param points the points
- * @param length the points length
- * @param seriesNr the series number
- * @return the calculated half-distance value
- */
- protected float getHalfDiffX(float[] points, int length, int seriesNr) {
- int div = length;
- if (length > 2) {
- div = length - 2;
- }
- float halfDiffX = (points[length - 2] - points[0]) / div;
- if (halfDiffX == 0) {
- halfDiffX = 10;
- }
-
- if (mType != Type.STACKED) {
- halfDiffX /= seriesNr;
- }
- return (float) (halfDiffX / (getCoeficient() * (1 + mRenderer.getBarSpacing())));
- }
-
- /**
- * Returns the value of a constant used to calculate the half-distance.
- *
- * @return the constant value
- */
- protected float getCoeficient() {
- return 1f;
- }
-
- /**
- * Returns if the chart should display the null values.
- *
- * @return if null values should be rendered
- */
- protected boolean isRenderNullValues() {
- return true;
- }
-
- /**
- * Returns the default axis minimum.
- *
- * @return the default axis minimum
- */
- public double getDefaultMinimum() {
- return 0;
- }
-
- /**
- * Returns the chart type identifier.
- *
- * @return the chart type
- */
- public String getChartType() {
- return TYPE;
- }
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/BubbleChart.java b/android-libraries/achartengine/src/org/achartengine/chart/BubbleChart.java
deleted file mode 100644
index f3125713b2..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/BubbleChart.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.model.XYValueSeries;
-import org.achartengine.renderer.SimpleSeriesRenderer;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-import org.achartengine.renderer.XYSeriesRenderer;
-
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Paint.Style;
-import android.graphics.RectF;
-
-/**
- * The bubble chart rendering class.
- */
-public class BubbleChart extends XYChart {
- /** The constant to identify this chart type. */
- public static final String TYPE = "Bubble";
- /** The legend shape width. */
- private static final int SHAPE_WIDTH = 10;
- /** The minimum bubble size. */
- private static final int MIN_BUBBLE_SIZE = 2;
- /** The maximum bubble size. */
- private static final int MAX_BUBBLE_SIZE = 20;
-
- BubbleChart() {
- }
-
- /**
- * Builds a new bubble chart instance.
- *
- * @param dataset the multiple series dataset
- * @param renderer the multiple series renderer
- */
- public BubbleChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) {
- super(dataset, renderer);
- }
-
- /**
- * The graphical representation of a series.
- *
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param points the array of points to be used for drawing the series
- * @param seriesRenderer the series renderer
- * @param yAxisValue the minimum value of the y axis
- * @param seriesIndex the index of the series currently being drawn
- * @param startIndex the start index of the rendering points
- */
- public void drawSeries(Canvas canvas, Paint paint, float[] points,
- SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex) {
- XYSeriesRenderer renderer = (XYSeriesRenderer) seriesRenderer;
- paint.setColor(renderer.getColor());
- paint.setStyle(Style.FILL);
- int length = points.length;
- XYValueSeries series = (XYValueSeries) mDataset.getSeriesAt(seriesIndex);
- double max = series.getMaxValue();
- double coef = MAX_BUBBLE_SIZE / max;
- for (int i = 0; i < length; i += 2) {
- double size = series.getValue(startIndex + i / 2) * coef + MIN_BUBBLE_SIZE;
- drawCircle(canvas, paint, points[i], points[i + 1], (float) size);
- }
- }
-
- @Override
- protected ClickableArea[] clickableAreasForPoints(float[] points, double[] values,
- float yAxisValue, int seriesIndex, int startIndex) {
- int length = points.length;
- XYValueSeries series = (XYValueSeries) mDataset.getSeriesAt(seriesIndex);
- double max = series.getMaxValue();
- double coef = MAX_BUBBLE_SIZE / max;
- ClickableArea[] ret = new ClickableArea[length / 2];
- for (int i = 0; i < length; i += 2) {
- double size = series.getValue(startIndex + i / 2) * coef + MIN_BUBBLE_SIZE;
- ret[i / 2] = new ClickableArea(new RectF(points[i] - (float) size, points[i + 1]
- - (float) size, points[i] + (float) size, points[i + 1] + (float) size), values[i],
- values[i + 1]);
- }
- return ret;
- }
-
- /**
- * Returns the legend shape width.
- *
- * @param seriesIndex the series index
- * @return the legend shape width
- */
- public int getLegendShapeWidth(int seriesIndex) {
- return SHAPE_WIDTH;
- }
-
- /**
- * The graphical representation of the legend shape.
- *
- * @param canvas the canvas to paint to
- * @param renderer the series renderer
- * @param x the x value of the point the shape should be drawn at
- * @param y the y value of the point the shape should be drawn at
- * @param seriesIndex the series index
- * @param paint the paint to be used for drawing
- */
- public void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y,
- int seriesIndex, Paint paint) {
- paint.setStyle(Style.FILL);
- drawCircle(canvas, paint, x + SHAPE_WIDTH, y, 3);
- }
-
- /**
- * The graphical representation of a circle point shape.
- *
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param x the x value of the point the shape should be drawn at
- * @param y the y value of the point the shape should be drawn at
- * @param radius the bubble radius
- */
- private void drawCircle(Canvas canvas, Paint paint, float x, float y, float radius) {
- canvas.drawCircle(x, y, radius, paint);
- }
-
- /**
- * Returns the chart type identifier.
- *
- * @return the chart type
- */
- public String getChartType() {
- return TYPE;
- }
-
-}
\ No newline at end of file
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/ClickableArea.java b/android-libraries/achartengine/src/org/achartengine/chart/ClickableArea.java
deleted file mode 100644
index d2d306ca02..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/ClickableArea.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import android.graphics.RectF;
-
-public class ClickableArea {
- private RectF rect;
- private double x;
- private double y;
-
- public ClickableArea(RectF rect, double x, double y) {
- super();
- this.rect = rect;
- this.x = x;
- this.y = y;
- }
-
- public RectF getRect() {
- return rect;
- }
-
- public double getX() {
- return x;
- }
-
- public double getY() {
- return y;
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/CombinedXYChart.java b/android-libraries/achartengine/src/org/achartengine/chart/CombinedXYChart.java
deleted file mode 100644
index d684c3a2a1..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/CombinedXYChart.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import java.util.List;
-
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.model.XYSeries;
-import org.achartengine.renderer.SimpleSeriesRenderer;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-import org.achartengine.renderer.XYMultipleSeriesRenderer.Orientation;
-
-import android.graphics.Canvas;
-import android.graphics.Paint;
-
-/**
- * The combined XY chart rendering class.
- */
-public class CombinedXYChart extends XYChart {
- /** The embedded XY charts. */
- private XYChart[] mCharts;
- /** The supported charts for being combined. */
- private Class[] xyChartTypes = new Class[] { TimeChart.class, LineChart.class,
- CubicLineChart.class, BarChart.class, BubbleChart.class, ScatterChart.class,
- RangeBarChart.class, RangeStackedBarChart.class };
-
- /**
- * Builds a new combined XY chart instance.
- *
- * @param dataset the multiple series dataset
- * @param renderer the multiple series renderer
- * @param types the XY chart types
- */
- public CombinedXYChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer,
- String[] types) {
- super(dataset, renderer);
- int length = types.length;
- mCharts = new XYChart[length];
- for (int i = 0; i < length; i++) {
- try {
- mCharts[i] = getXYChart(types[i]);
- } catch (Exception e) {
- // ignore
- }
- if (mCharts[i] == null) {
- throw new IllegalArgumentException("Unknown chart type " + types[i]);
- } else {
- XYMultipleSeriesDataset newDataset = new XYMultipleSeriesDataset();
- newDataset.addSeries(dataset.getSeriesAt(i));
- XYMultipleSeriesRenderer newRenderer = new XYMultipleSeriesRenderer();
- // TODO: copy other parameters here
- newRenderer.setBarSpacing(renderer.getBarSpacing());
- newRenderer.setPointSize(renderer.getPointSize());
- int scale = dataset.getSeriesAt(i).getScaleNumber();
- if (renderer.isMinXSet(scale)) {
- newRenderer.setXAxisMin(renderer.getXAxisMin(scale));
- }
- if (renderer.isMaxXSet(scale)) {
- newRenderer.setXAxisMax(renderer.getXAxisMax(scale));
- }
- if (renderer.isMinYSet(scale)) {
- newRenderer.setYAxisMin(renderer.getYAxisMin(scale));
- }
- if (renderer.isMaxYSet(scale)) {
- newRenderer.setYAxisMax(renderer.getYAxisMax(scale));
- }
- newRenderer.addSeriesRenderer(renderer.getSeriesRendererAt(i));
- mCharts[i].setDatasetRenderer(newDataset, newRenderer);
- }
- }
- }
-
- /**
- * Returns a chart instance based on the provided type.
- *
- * @param type the chart type
- * @return an instance of a chart implementation
- * @throws IllegalAccessException
- * @throws InstantiationException
- */
- private XYChart getXYChart(String type) throws IllegalAccessException, InstantiationException {
- XYChart chart = null;
- int length = xyChartTypes.length;
- for (int i = 0; i < length && chart == null; i++) {
- XYChart newChart = (XYChart) xyChartTypes[i].newInstance();
- if (type.equals(newChart.getChartType())) {
- chart = newChart;
- }
- }
- return chart;
- }
-
- /**
- * The graphical representation of a series.
- *
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param points the array of points to be used for drawing the series
- * @param seriesRenderer the series renderer
- * @param yAxisValue the minimum value of the y axis
- * @param seriesIndex the index of the series currently being drawn
- * @param startIndex the start index of the rendering points
- */
- public void drawSeries(Canvas canvas, Paint paint, float[] points,
- SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex) {
- mCharts[seriesIndex].setScreenR(getScreenR());
- mCharts[seriesIndex].setCalcRange(getCalcRange(mDataset.getSeriesAt(seriesIndex)
- .getScaleNumber()), 0);
- mCharts[seriesIndex].drawSeries(canvas, paint, points, seriesRenderer, yAxisValue, 0,
- startIndex);
- }
-
- @Override
- protected ClickableArea[] clickableAreasForPoints(float[] points, double[] values,
- float yAxisValue, int seriesIndex, int startIndex) {
- return mCharts[seriesIndex].clickableAreasForPoints(points, values, yAxisValue, 0, startIndex);
- }
-
- @Override
- protected void drawSeries(XYSeries series, Canvas canvas, Paint paint, List pointsList,
- SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, Orientation or,
- int startIndex) {
- mCharts[seriesIndex].setScreenR(getScreenR());
- mCharts[seriesIndex].setCalcRange(getCalcRange(mDataset.getSeriesAt(seriesIndex)
- .getScaleNumber()), 0);
- mCharts[seriesIndex].drawSeries(series, canvas, paint, pointsList, seriesRenderer, yAxisValue,
- 0, or, startIndex);
- }
-
- /**
- * Returns the legend shape width.
- *
- * @param seriesIndex the series index
- * @return the legend shape width
- */
- public int getLegendShapeWidth(int seriesIndex) {
- return mCharts[seriesIndex].getLegendShapeWidth(0);
- }
-
- /**
- * The graphical representation of the legend shape.
- *
- * @param canvas the canvas to paint to
- * @param renderer the series renderer
- * @param x the x value of the point the shape should be drawn at
- * @param y the y value of the point the shape should be drawn at
- * @param seriesIndex the series index
- * @param paint the paint to be used for drawing
- */
- public void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y,
- int seriesIndex, Paint paint) {
- mCharts[seriesIndex].drawLegendShape(canvas, renderer, x, y, 0, paint);
- }
-
- /**
- * Returns the chart type identifier.
- *
- * @return the chart type
- */
- public String getChartType() {
- return "Combined";
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/CubicLineChart.java b/android-libraries/achartengine/src/org/achartengine/chart/CubicLineChart.java
deleted file mode 100644
index 2011318f54..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/CubicLineChart.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import org.achartengine.model.Point;
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Path;
-
-/**
- * The interpolated (cubic) line chart rendering class.
- */
-public class CubicLineChart extends LineChart {
- /** The chart type. */
- public static final String TYPE = "Cubic";
-
- private float firstMultiplier;
-
- private float secondMultiplier;
-
- private Point p1 = new Point();
-
- private Point p2 = new Point();
-
- private Point p3 = new Point();
-
- public CubicLineChart() {
- // default is to have first control point at about 33% of the distance,
- firstMultiplier = 0.33f;
- // and the next at 66% of the distance.
- secondMultiplier = 1 - firstMultiplier;
- }
-
- /**
- * Builds a cubic line chart.
- *
- * @param dataset the dataset
- * @param renderer the renderer
- * @param smoothness smoothness determines how smooth the curve should be,
- * range [0->0.5] super smooth, 0.5, means that it might not get
- * close to control points if you have random data // less smooth,
- * (close to 0) means that it will most likely touch all control //
- * points
- */
- public CubicLineChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer,
- float smoothness) {
- super(dataset, renderer);
- firstMultiplier = smoothness;
- secondMultiplier = 1 - firstMultiplier;
- }
-
- @Override
- protected void drawPath(Canvas canvas, float[] points, Paint paint, boolean circular) {
- Path p = new Path();
- float x = points[0];
- float y = points[1];
- p.moveTo(x, y);
-
- int length = points.length;
- if (circular) {
- length -= 4;
- }
-
- for (int i = 0; i < length; i += 2) {
- int nextIndex = i + 2 < length ? i + 2 : i;
- int nextNextIndex = i + 4 < length ? i + 4 : nextIndex;
- calc(points, p1, i, nextIndex, secondMultiplier);
- p2.setX(points[nextIndex]);
- p2.setY(points[nextIndex + 1]);
- calc(points, p3, nextIndex, nextNextIndex, firstMultiplier);
- // From last point, approaching x1/y1 and x2/y2 and ends up at x3/y3
- p.cubicTo(p1.getX(), p1.getY(), p2.getX(), p2.getY(), p3.getX(), p3.getY());
- }
- if (circular) {
- for (int i = length; i < length + 4; i += 2) {
- p.lineTo(points[i], points[i + 1]);
- }
- p.lineTo(points[0], points[1]);
- }
- canvas.drawPath(p, paint);
- }
-
- private void calc(float[] points, Point result, int index1, int index2, final float multiplier) {
- float p1x = points[index1];
- float p1y = points[index1 + 1];
- float p2x = points[index2];
- float p2y = points[index2 + 1];
-
- float diffX = p2x - p1x; // p2.x - p1.x;
- float diffY = p2y - p1y; // p2.y - p1.y;
- result.setX(p1x + (diffX * multiplier));
- result.setY(p1y + (diffY * multiplier));
- }
-
- /**
- * Returns the chart type identifier.
- *
- * @return the chart type
- */
- public String getChartType() {
- return TYPE;
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/DialChart.java b/android-libraries/achartengine/src/org/achartengine/chart/DialChart.java
deleted file mode 100644
index ebfcbbb1fb..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/DialChart.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import org.achartengine.model.CategorySeries;
-import org.achartengine.renderer.DefaultRenderer;
-import org.achartengine.renderer.DialRenderer;
-import org.achartengine.renderer.DialRenderer.Type;
-import org.achartengine.util.MathHelper;
-
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Paint.Align;
-import android.graphics.Paint.Style;
-
-/**
- * The dial chart rendering class.
- */
-public class DialChart extends RoundChart {
- /** The radius of the needle. */
- private static final int NEEDLE_RADIUS = 10;
- /** The series renderer. */
- private DialRenderer mRenderer;
-
- /**
- * Builds a new dial chart instance.
- *
- * @param dataset the series dataset
- * @param renderer the dial renderer
- */
- public DialChart(CategorySeries dataset, DialRenderer renderer) {
- super(dataset, renderer);
- mRenderer = renderer;
- }
-
- /**
- * The graphical representation of the dial chart.
- *
- * @param canvas the canvas to paint to
- * @param x the top left x value of the view to draw to
- * @param y the top left y value of the view to draw to
- * @param width the width of the view to draw to
- * @param height the height of the view to draw to
- * @param paint the paint
- */
- @Override
- public void draw(Canvas canvas, int x, int y, int width, int height, Paint paint) {
- paint.setAntiAlias(mRenderer.isAntialiasing());
- paint.setStyle(Style.FILL);
- paint.setTextSize(mRenderer.getLabelsTextSize());
- int legendSize = getLegendSize(mRenderer, height / 5, 0);
- int left = x;
- int top = y;
- int right = x + width;
-
- int sLength = mDataset.getItemCount();
- String[] titles = new String[sLength];
- for (int i = 0; i < sLength; i++) {
- titles[i] = mDataset.getCategory(i);
- }
-
- if (mRenderer.isFitLegend()) {
- legendSize = drawLegend(canvas, mRenderer, titles, left, right, y, width, height, legendSize,
- paint, true);
- }
- int bottom = y + height - legendSize;
- drawBackground(mRenderer, canvas, x, y, width, height, paint, false, DefaultRenderer.NO_COLOR);
-
- int mRadius = Math.min(Math.abs(right - left), Math.abs(bottom - top));
- int radius = (int) (mRadius * 0.35 * mRenderer.getScale());
- if (mCenterX == NO_VALUE) {
- mCenterX = (left + right) / 2;
- }
- if (mCenterY == NO_VALUE) {
- mCenterY = (bottom + top) / 2;
- }
- float shortRadius = radius * 0.9f;
- float longRadius = radius * 1.1f;
- double min = mRenderer.getMinValue();
- double max = mRenderer.getMaxValue();
- double angleMin = mRenderer.getAngleMin();
- double angleMax = mRenderer.getAngleMax();
- if (!mRenderer.isMinValueSet() || !mRenderer.isMaxValueSet()) {
- int count = mRenderer.getSeriesRendererCount();
- for (int i = 0; i < count; i++) {
- double value = mDataset.getValue(i);
- if (!mRenderer.isMinValueSet()) {
- min = Math.min(min, value);
- }
- if (!mRenderer.isMaxValueSet()) {
- max = Math.max(max, value);
- }
- }
- }
- if (min == max) {
- min = min * 0.5;
- max = max * 1.5;
- }
-
- paint.setColor(mRenderer.getLabelsColor());
- double minorTicks = mRenderer.getMinorTicksSpacing();
- double majorTicks = mRenderer.getMajorTicksSpacing();
- if (minorTicks == MathHelper.NULL_VALUE) {
- minorTicks = (max - min) / 30;
- }
- if (majorTicks == MathHelper.NULL_VALUE) {
- majorTicks = (max - min) / 10;
- }
- drawTicks(canvas, min, max, angleMin, angleMax, mCenterX, mCenterY, longRadius, radius,
- minorTicks, paint, false);
- drawTicks(canvas, min, max, angleMin, angleMax, mCenterX, mCenterY, longRadius, shortRadius,
- majorTicks, paint, true);
-
- int count = mRenderer.getSeriesRendererCount();
- for (int i = 0; i < count; i++) {
- double angle = getAngleForValue(mDataset.getValue(i), angleMin, angleMax, min, max);
- paint.setColor(mRenderer.getSeriesRendererAt(i).getColor());
- boolean type = mRenderer.getVisualTypeForIndex(i) == Type.ARROW;
- drawNeedle(canvas, angle, mCenterX, mCenterY, shortRadius, type, paint);
- }
- drawLegend(canvas, mRenderer, titles, left, right, y, width, height, legendSize, paint, false);
- drawTitle(canvas, x, y, width, paint);
- }
-
- /**
- * Returns the angle for a specific chart value.
- *
- * @param value the chart value
- * @param minAngle the minimum chart angle value
- * @param maxAngle the maximum chart angle value
- * @param min the minimum chart value
- * @param max the maximum chart value
- * @return the angle
- */
- private double getAngleForValue(double value, double minAngle, double maxAngle, double min,
- double max) {
- double angleDiff = maxAngle - minAngle;
- double diff = max - min;
- return Math.toRadians(minAngle + (value - min) * angleDiff / diff);
- }
-
- /**
- * Draws the chart tick lines.
- *
- * @param canvas the canvas
- * @param min the minimum chart value
- * @param max the maximum chart value
- * @param minAngle the minimum chart angle value
- * @param maxAngle the maximum chart angle value
- * @param centerX the center x value
- * @param centerY the center y value
- * @param longRadius the long radius
- * @param shortRadius the short radius
- * @param ticks the tick spacing
- * @param paint the paint settings
- * @param labels paint the labels
- * @return the angle
- */
- private void drawTicks(Canvas canvas, double min, double max, double minAngle, double maxAngle,
- int centerX, int centerY, double longRadius, double shortRadius, double ticks, Paint paint,
- boolean labels) {
- for (double i = min; i <= max; i += ticks) {
- double angle = getAngleForValue(i, minAngle, maxAngle, min, max);
- double sinValue = Math.sin(angle);
- double cosValue = Math.cos(angle);
- int x1 = Math.round(centerX + (float) (shortRadius * sinValue));
- int y1 = Math.round(centerY + (float) (shortRadius * cosValue));
- int x2 = Math.round(centerX + (float) (longRadius * sinValue));
- int y2 = Math.round(centerY + (float) (longRadius * cosValue));
- canvas.drawLine(x1, y1, x2, y2, paint);
- if (labels) {
- paint.setTextAlign(Align.LEFT);
- if (x1 <= x2) {
- paint.setTextAlign(Align.RIGHT);
- }
- String text = i + "";
- if (Math.round(i) == (long) i) {
- text = (long) i + "";
- }
- canvas.drawText(text, x1, y1, paint);
- }
- }
- }
-
- /**
- * Returns the angle for a specific chart value.
- *
- * @param canvas the canvas
- * @param angle the needle angle value
- * @param centerX the center x value
- * @param centerY the center y value
- * @param radius the radius
- * @param arrow if a needle or an arrow to be painted
- * @param paint the paint settings
- * @return the angle
- */
- private void drawNeedle(Canvas canvas, double angle, int centerX, int centerY, double radius,
- boolean arrow, Paint paint) {
- double diff = Math.toRadians(90);
- int needleSinValue = (int) (NEEDLE_RADIUS * Math.sin(angle - diff));
- int needleCosValue = (int) (NEEDLE_RADIUS * Math.cos(angle - diff));
- int needleX = (int) (radius * Math.sin(angle));
- int needleY = (int) (radius * Math.cos(angle));
- int needleCenterX = centerX + needleX;
- int needleCenterY = centerY + needleY;
- float[] points;
- if (arrow) {
- int arrowBaseX = centerX + (int) (radius * 0.85 * Math.sin(angle));
- int arrowBaseY = centerY + (int) (radius * 0.85 * Math.cos(angle));
- points = new float[] { arrowBaseX - needleSinValue, arrowBaseY - needleCosValue,
- needleCenterX, needleCenterY, arrowBaseX + needleSinValue, arrowBaseY + needleCosValue };
- float width = paint.getStrokeWidth();
- paint.setStrokeWidth(5);
- canvas.drawLine(centerX, centerY, needleCenterX, needleCenterY, paint);
- paint.setStrokeWidth(width);
- } else {
- points = new float[] { centerX - needleSinValue, centerY - needleCosValue, needleCenterX,
- needleCenterY, centerX + needleSinValue, centerY + needleCosValue };
- }
- drawPath(canvas, points, paint, true);
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/DoughnutChart.java b/android-libraries/achartengine/src/org/achartengine/chart/DoughnutChart.java
deleted file mode 100644
index ad67b07692..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/DoughnutChart.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.achartengine.model.MultipleCategorySeries;
-import org.achartengine.renderer.DefaultRenderer;
-import org.achartengine.renderer.SimpleSeriesRenderer;
-
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Paint.Style;
-import android.graphics.RectF;
-
-/**
- * The doughnut chart rendering class.
- */
-public class DoughnutChart extends RoundChart {
- /** The series dataset. */
- private MultipleCategorySeries mDataset;
- /** A step variable to control the size of the legend shape. */
- private int mStep;
-
- /**
- * Builds a new doughnut chart instance.
- *
- * @param dataset the series dataset
- * @param renderer the series renderer
- */
- public DoughnutChart(MultipleCategorySeries dataset, DefaultRenderer renderer) {
- super(null, renderer);
- mDataset = dataset;
- }
-
- /**
- * The graphical representation of the doughnut chart.
- *
- * @param canvas the canvas to paint to
- * @param x the top left x value of the view to draw to
- * @param y the top left y value of the view to draw to
- * @param width the width of the view to draw to
- * @param height the height of the view to draw to
- * @param paint the paint
- */
- @Override
- public void draw(Canvas canvas, int x, int y, int width, int height, Paint paint) {
- paint.setAntiAlias(mRenderer.isAntialiasing());
- paint.setStyle(Style.FILL);
- paint.setTextSize(mRenderer.getLabelsTextSize());
- int legendSize = getLegendSize(mRenderer, height / 5, 0);
- int left = x;
- int top = y;
- int right = x + width;
- int cLength = mDataset.getCategoriesCount();
- String[] categories = new String[cLength];
- for (int category = 0; category < cLength; category++) {
- categories[category] = mDataset.getCategory(category);
- }
- if (mRenderer.isFitLegend()) {
- legendSize = drawLegend(canvas, mRenderer, categories, left, right, y, width, height,
- legendSize, paint, true);
- }
-
- int bottom = y + height - legendSize;
- drawBackground(mRenderer, canvas, x, y, width, height, paint, false, DefaultRenderer.NO_COLOR);
- mStep = SHAPE_WIDTH * 3 / 4;
-
- int mRadius = Math.min(Math.abs(right - left), Math.abs(bottom - top));
- double rCoef = 0.35 * mRenderer.getScale();
- double decCoef = 0.2 / cLength;
- int radius = (int) (mRadius * rCoef);
- if (mCenterX == NO_VALUE) {
- mCenterX = (left + right) / 2;
- }
- if (mCenterY == NO_VALUE) {
- mCenterY = (bottom + top) / 2;
- }
- float shortRadius = radius * 0.9f;
- float longRadius = radius * 1.1f;
- List prevLabelsBounds = new ArrayList();
- for (int category = 0; category < cLength; category++) {
- int sLength = mDataset.getItemCount(category);
- double total = 0;
- String[] titles = new String[sLength];
- for (int i = 0; i < sLength; i++) {
- total += mDataset.getValues(category)[i];
- titles[i] = mDataset.getTitles(category)[i];
- }
- float currentAngle = mRenderer.getStartAngle();
- RectF oval = new RectF(mCenterX - radius, mCenterY - radius, mCenterX + radius, mCenterY
- + radius);
- for (int i = 0; i < sLength; i++) {
- paint.setColor(mRenderer.getSeriesRendererAt(i).getColor());
- float value = (float) mDataset.getValues(category)[i];
- float angle = (float) (value / total * 360);
- canvas.drawArc(oval, currentAngle, angle, true, paint);
- drawLabel(canvas, mDataset.getTitles(category)[i], mRenderer, prevLabelsBounds, mCenterX,
- mCenterY, shortRadius, longRadius, currentAngle, angle, left, right,
- mRenderer.getLabelsColor(), paint, true);
- currentAngle += angle;
- }
- radius -= (int) mRadius * decCoef;
- shortRadius -= mRadius * decCoef - 2;
- if (mRenderer.getBackgroundColor() != 0) {
- paint.setColor(mRenderer.getBackgroundColor());
- } else {
- paint.setColor(Color.WHITE);
- }
- paint.setStyle(Style.FILL);
- oval = new RectF(mCenterX - radius, mCenterY - radius, mCenterX + radius, mCenterY + radius);
- canvas.drawArc(oval, 0, 360, true, paint);
- radius -= 1;
- }
- prevLabelsBounds.clear();
- drawLegend(canvas, mRenderer, categories, left, right, y, width, height, legendSize, paint,
- false);
- drawTitle(canvas, x, y, width, paint);
- }
-
- /**
- * Returns the legend shape width.
- *
- * @param seriesIndex the series index
- * @return the legend shape width
- */
- public int getLegendShapeWidth(int seriesIndex) {
- return SHAPE_WIDTH;
- }
-
- /**
- * The graphical representation of the legend shape.
- *
- * @param canvas the canvas to paint to
- * @param renderer the series renderer
- * @param x the x value of the point the shape should be drawn at
- * @param y the y value of the point the shape should be drawn at
- * @param seriesIndex the series index
- * @param paint the paint to be used for drawing
- */
- public void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y,
- int seriesIndex, Paint paint) {
- mStep--;
- canvas.drawCircle(x + SHAPE_WIDTH - mStep, y, mStep, paint);
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/LineChart.java b/android-libraries/achartengine/src/org/achartengine/chart/LineChart.java
deleted file mode 100644
index 2c45898638..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/LineChart.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.renderer.SimpleSeriesRenderer;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-import org.achartengine.renderer.XYSeriesRenderer;
-
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Paint.Style;
-import android.graphics.RectF;
-
-/**
- * The line chart rendering class.
- */
-public class LineChart extends XYChart {
- /** The constant to identify this chart type. */
- public static final String TYPE = "Line";
- /** The legend shape width. */
- private static final int SHAPE_WIDTH = 30;
- /** The scatter chart to be used to draw the data points. */
- private ScatterChart pointsChart;
-
- LineChart() {
- }
-
- /**
- * Builds a new line chart instance.
- *
- * @param dataset the multiple series dataset
- * @param renderer the multiple series renderer
- */
- public LineChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) {
- super(dataset, renderer);
- pointsChart = new ScatterChart(dataset, renderer);
- }
-
- /**
- * Sets the series and the renderer.
- *
- * @param dataset the series dataset
- * @param renderer the series renderer
- */
- protected void setDatasetRenderer(XYMultipleSeriesDataset dataset,
- XYMultipleSeriesRenderer renderer) {
- super.setDatasetRenderer(dataset, renderer);
- pointsChart = new ScatterChart(dataset, renderer);
- }
-
- /**
- * The graphical representation of a series.
- *
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param points the array of points to be used for drawing the series
- * @param seriesRenderer the series renderer
- * @param yAxisValue the minimum value of the y axis
- * @param seriesIndex the index of the series currently being drawn
- * @param startIndex the start index of the rendering points
- */
- public void drawSeries(Canvas canvas, Paint paint, float[] points,
- SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex) {
- int length = points.length;
- XYSeriesRenderer renderer = (XYSeriesRenderer) seriesRenderer;
- float lineWidth = paint.getStrokeWidth();
- paint.setStrokeWidth(renderer.getLineWidth());
- if (renderer.isFillBelowLine()) {
- paint.setColor(renderer.getFillBelowLineColor());
- int pLength = points.length;
- float[] fillPoints = new float[pLength + 4];
- System.arraycopy(points, 0, fillPoints, 0, length);
- fillPoints[0] = points[0] + 1;
- fillPoints[length] = fillPoints[length - 2];
- fillPoints[length + 1] = yAxisValue;
- fillPoints[length + 2] = fillPoints[0];
- fillPoints[length + 3] = fillPoints[length + 1];
- for (int i = 0; i < length + 4; i += 2) {
- if (fillPoints[i + 1] < 0) {
- fillPoints[i + 1] = 0;
- }
- }
- paint.setStyle(Style.FILL);
- drawPath(canvas, fillPoints, paint, true);
- }
- paint.setColor(seriesRenderer.getColor());
- paint.setStyle(Style.STROKE);
- drawPath(canvas, points, paint, false);
- paint.setStrokeWidth(lineWidth);
- }
-
- @Override
- protected ClickableArea[] clickableAreasForPoints(float[] points, double[] values,
- float yAxisValue, int seriesIndex, int startIndex) {
- int length = points.length;
- ClickableArea[] ret = new ClickableArea[length / 2];
- for (int i = 0; i < length; i += 2) {
- int selectableBuffer = mRenderer.getSelectableBuffer();
- ret[i / 2] = new ClickableArea(new RectF(points[i] - selectableBuffer, points[i + 1]
- - selectableBuffer, points[i] + selectableBuffer, points[i + 1] + selectableBuffer),
- values[i], values[i + 1]);
- }
- return ret;
- }
-
- /**
- * Returns the legend shape width.
- *
- * @param seriesIndex the series index
- * @return the legend shape width
- */
- public int getLegendShapeWidth(int seriesIndex) {
- return SHAPE_WIDTH;
- }
-
- /**
- * The graphical representation of the legend shape.
- *
- * @param canvas the canvas to paint to
- * @param renderer the series renderer
- * @param x the x value of the point the shape should be drawn at
- * @param y the y value of the point the shape should be drawn at
- * @param seriesIndex the series index
- * @param paint the paint to be used for drawing
- */
- public void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y,
- int seriesIndex, Paint paint) {
- canvas.drawLine(x, y, x + SHAPE_WIDTH, y, paint);
- if (isRenderPoints(renderer)) {
- pointsChart.drawLegendShape(canvas, renderer, x + 5, y, seriesIndex, paint);
- }
- }
-
- /**
- * Returns if the chart should display the points as a certain shape.
- *
- * @param renderer the series renderer
- */
- public boolean isRenderPoints(SimpleSeriesRenderer renderer) {
- return ((XYSeriesRenderer) renderer).getPointStyle() != PointStyle.POINT;
- }
-
- /**
- * Returns the scatter chart to be used for drawing the data points.
- *
- * @return the data points scatter chart
- */
- public ScatterChart getPointsChart() {
- return pointsChart;
- }
-
- /**
- * Returns the chart type identifier.
- *
- * @return the chart type
- */
- public String getChartType() {
- return TYPE;
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/PieChart.java b/android-libraries/achartengine/src/org/achartengine/chart/PieChart.java
deleted file mode 100644
index d656a95eba..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/PieChart.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.achartengine.model.CategorySeries;
-import org.achartengine.model.Point;
-import org.achartengine.model.SeriesSelection;
-import org.achartengine.renderer.DefaultRenderer;
-
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Paint.Style;
-import android.graphics.RectF;
-
-/**
- * The pie chart rendering class.
- */
-public class PieChart extends RoundChart {
- /** Handles returning values when tapping on PieChart. */
- private PieMapper mPieMapper;
-
- /**
- * Builds a new pie chart instance.
- *
- * @param dataset the series dataset
- * @param renderer the series renderer
- */
- public PieChart(CategorySeries dataset, DefaultRenderer renderer) {
- super(dataset, renderer);
- mPieMapper = new PieMapper();
- }
-
- /**
- * The graphical representation of the pie chart.
- *
- * @param canvas the canvas to paint to
- * @param x the top left x value of the view to draw to
- * @param y the top left y value of the view to draw to
- * @param width the width of the view to draw to
- * @param height the height of the view to draw to
- * @param paint the paint
- */
- @Override
- public void draw(Canvas canvas, int x, int y, int width, int height, Paint paint) {
- paint.setAntiAlias(mRenderer.isAntialiasing());
- paint.setStyle(Style.FILL);
- paint.setTextSize(mRenderer.getLabelsTextSize());
- int legendSize = getLegendSize(mRenderer, height / 5, 0);
- int left = x;
- int top = y;
- int right = x + width;
- int sLength = mDataset.getItemCount();
- double total = 0;
- String[] titles = new String[sLength];
- for (int i = 0; i < sLength; i++) {
- total += mDataset.getValue(i);
- titles[i] = mDataset.getCategory(i);
- }
- if (mRenderer.isFitLegend()) {
- legendSize = drawLegend(canvas, mRenderer, titles, left, right, y, width, height, legendSize,
- paint, true);
- }
- int bottom = y + height - legendSize;
- drawBackground(mRenderer, canvas, x, y, width, height, paint, false, DefaultRenderer.NO_COLOR);
-
- float currentAngle = mRenderer.getStartAngle();
- int mRadius = Math.min(Math.abs(right - left), Math.abs(bottom - top));
- int radius = (int) (mRadius * 0.35 * mRenderer.getScale());
-
- if (mCenterX == NO_VALUE) {
- mCenterX = (left + right) / 2;
- }
- if (mCenterY == NO_VALUE) {
- mCenterY = (bottom + top) / 2;
- }
-
- // Hook in clip detection after center has been calculated
- mPieMapper.setDimensions(radius, mCenterX, mCenterY);
- boolean loadPieCfg = !mPieMapper.areAllSegmentPresent(sLength);
- if (loadPieCfg) {
- mPieMapper.clearPieSegments();
- }
-
- float shortRadius = radius * 0.9f;
- float longRadius = radius * 1.1f;
-
- RectF oval = new RectF(mCenterX - radius, mCenterY - radius, mCenterX + radius, mCenterY
- + radius);
- List prevLabelsBounds = new ArrayList();
-
- for (int i = 0; i < sLength; i++) {
- paint.setColor(mRenderer.getSeriesRendererAt(i).getColor());
- float value = (float) mDataset.getValue(i);
- float angle = (float) (value / total * 360);
- canvas.drawArc(oval, currentAngle, angle, true, paint);
- drawLabel(canvas, mDataset.getCategory(i), mRenderer, prevLabelsBounds, mCenterX, mCenterY,
- shortRadius, longRadius, currentAngle, angle, left, right, mRenderer.getLabelsColor(),
- paint, true);
- if (mRenderer.isDisplayValues()) {
- drawLabel(canvas, getLabel(mDataset.getValue(i)), mRenderer, prevLabelsBounds, mCenterX,
- mCenterY, shortRadius / 2, longRadius / 2, currentAngle, angle, left, right,
- mRenderer.getLabelsColor(), paint, false);
- }
-
- // Save details for getSeries functionality
- if (loadPieCfg) {
- mPieMapper.addPieSegment(i, value, currentAngle, angle);
- }
- currentAngle += angle;
- }
- prevLabelsBounds.clear();
- drawLegend(canvas, mRenderer, titles, left, right, y, width, height, legendSize, paint, false);
- drawTitle(canvas, x, y, width, paint);
- }
-
- public SeriesSelection getSeriesAndPointForScreenCoordinate(Point screenPoint) {
- return mPieMapper.getSeriesAndPointForScreenCoordinate(screenPoint);
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/PieMapper.java b/android-libraries/achartengine/src/org/achartengine/chart/PieMapper.java
deleted file mode 100644
index 6e4b71504e..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/PieMapper.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.achartengine.model.Point;
-import org.achartengine.model.SeriesSelection;
-
-/**
- * PieChart Segment Selection Management.
- */
-public class PieMapper implements Serializable {
-
- private List mPieSegmentList = new ArrayList();
-
- private int mPieChartRadius;
-
- private int mCenterX, mCenterY;
-
- /**
- * Set PieChart location on screen.
- *
- * @param pieRadius
- * @param centerX
- * @param centerY
- */
- public void setDimensions(int pieRadius, int centerX, int centerY) {
- mPieChartRadius = pieRadius;
- mCenterX = centerX;
- mCenterY = centerY;
- }
-
- /**
- * If we have all PieChart Config then there is no point in reloading it
- *
- * @param datasetSize
- * @return true if cfg for each segment is present
- */
- public boolean areAllSegmentPresent(int datasetSize) {
- return mPieSegmentList.size() == datasetSize;
- }
-
- /**
- * Add configuration for a PieChart Segment
- *
- * @param dataIndex
- * @param value
- * @param startAngle
- * @param angle
- */
- public void addPieSegment(int dataIndex, float value, float startAngle, float angle) {
- mPieSegmentList.add(new PieSegment(dataIndex, value, startAngle, angle));
- }
-
- /**
- * Clears the pie segments list.
- */
- public void clearPieSegments() {
- mPieSegmentList.clear();
- }
-
- /**
- * Fetches angle relative to pie chart center point where 3 O'Clock is 0 and
- * 12 O'Clock is 270degrees
- *
- * @param screenPoint
- * @return angle in degress from 0-360.
- */
- public double getAngle(Point screenPoint) {
- double dx = screenPoint.getX() - mCenterX;
- // Minus to correct for coord re-mapping
- double dy = -(screenPoint.getY() - mCenterY);
-
- double inRads = Math.atan2(dy, dx);
-
- // We need to map to coord system when 0 degree is at 3 O'clock, 270 at 12
- // O'clock
- if (inRads < 0)
- inRads = Math.abs(inRads);
- else
- inRads = 2 * Math.PI - inRads;
-
- return Math.toDegrees(inRads);
- }
-
- /**
- * Checks if Point falls within PieChart
- *
- * @param screenPoint
- * @return true if in PieChart
- */
- public boolean isOnPieChart(Point screenPoint) {
- // Using a bit of Pythagoras
- // inside circle if (x-center_x)**2 + (y-center_y)**2 <= radius**2:
-
- double sqValue = (Math.pow(mCenterX - screenPoint.getX(), 2) + Math.pow(
- mCenterY - screenPoint.getY(), 2));
-
- double radiusSquared = mPieChartRadius * mPieChartRadius;
- boolean isOnPieChart = sqValue <= radiusSquared;
- return isOnPieChart;
- }
-
- /**
- * Fetches the SeriesSelection for the PieSegment selected.
- *
- * @param screenPoint - the user tap location
- * @return null if screen point is not in PieChart or its config if it is
- */
- public SeriesSelection getSeriesAndPointForScreenCoordinate(Point screenPoint) {
- if (isOnPieChart(screenPoint)) {
- double angleFromPieCenter = getAngle(screenPoint);
-
- for (PieSegment pieSeg : mPieSegmentList) {
- if (pieSeg.isInSegment(angleFromPieCenter)) {
- return new SeriesSelection(0, pieSeg.getDataIndex(), pieSeg.getValue(),
- pieSeg.getValue());
- }
- }
- }
- return null;
- }
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/PieSegment.java b/android-libraries/achartengine/src/org/achartengine/chart/PieSegment.java
deleted file mode 100644
index 0fb0a2e48d..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/PieSegment.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import java.io.Serializable;
-
-/**
- * Holds An PieChart Segment
- */
-public class PieSegment implements Serializable {
- private float mStartAngle;
-
- private float mEndAngle;
-
- private int mDataIndex;
-
- private float mValue;
-
- public PieSegment(int dataIndex, float value, float startAngle, float angle) {
- mStartAngle = startAngle;
- mEndAngle = angle + startAngle;
- mDataIndex = dataIndex;
- mValue = value;
- }
-
- /**
- * Checks if angle falls in segment.
- *
- * @param angle
- * @return true if in segment, false otherwise.
- */
- public boolean isInSegment(double angle) {
- return angle >= mStartAngle && angle <= mEndAngle;
- }
-
- protected float getStartAngle() {
- return mStartAngle;
- }
-
- protected float getEndAngle() {
- return mEndAngle;
- }
-
- protected int getDataIndex() {
- return mDataIndex;
- }
-
- protected float getValue() {
- return mValue;
- }
-
- public String toString() {
- return "mDataIndex=" + mDataIndex + ",mValue=" + mValue + ",mStartAngle=" + mStartAngle
- + ",mEndAngle=" + mEndAngle;
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/PointStyle.java b/android-libraries/achartengine/src/org/achartengine/chart/PointStyle.java
deleted file mode 100644
index 29a2311a9a..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/PointStyle.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-/**
- * The chart point style enumerator.
- */
-public enum PointStyle {
- X("x"), CIRCLE("circle"), TRIANGLE("triangle"), SQUARE("square"), DIAMOND("diamond"), POINT(
- "point");
-
- /** The point shape name. */
- private String mName;
-
- /**
- * The point style enum constructor.
- *
- * @param name the name
- */
- private PointStyle(String name) {
- mName = name;
- }
-
- /**
- * Returns the point shape name.
- *
- * @return the point shape name
- */
- public String getName() {
- return mName;
- }
-
- /**
- * Returns the point shape name.
- *
- * @return the point shape name
- */
- public String toString() {
- return getName();
- }
-
- /**
- * Return the point shape that has the provided symbol.
- *
- * @param name the point style name
- * @return the point shape
- */
- public static PointStyle getPointStyleForName(String name) {
- PointStyle pointStyle = null;
- PointStyle[] styles = values();
- int length = styles.length;
- for (int i = 0; i < length && pointStyle == null; i++) {
- if (styles[i].mName.equals(name)) {
- pointStyle = styles[i];
- }
- }
- return pointStyle;
- }
-
- /**
- * Returns the point shape index based on the given name.
- *
- * @return the point shape index
- */
- public static int getIndexForName(String name) {
- int index = -1;
- PointStyle[] styles = values();
- int length = styles.length;
- for (int i = 0; i < length && index < 0; i++) {
- if (styles[i].mName.equals(name)) {
- index = i;
- }
- }
- return Math.max(0, index);
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/RangeBarChart.java b/android-libraries/achartengine/src/org/achartengine/chart/RangeBarChart.java
deleted file mode 100644
index 105f509a4e..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/RangeBarChart.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.model.XYSeries;
-import org.achartengine.renderer.SimpleSeriesRenderer;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Paint.Style;
-
-/**
- * The range bar chart rendering class.
- */
-public class RangeBarChart extends BarChart {
- /** The chart type. */
- public static final String TYPE = "RangeBar";
-
- RangeBarChart() {
- }
-
- RangeBarChart(Type type) {
- super(type);
- }
-
- /**
- * Builds a new range bar chart instance.
- *
- * @param dataset the multiple series dataset
- * @param renderer the multiple series renderer
- * @param type the range bar chart type
- */
- public RangeBarChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type) {
- super(dataset, renderer, type);
- }
-
- /**
- * The graphical representation of a series.
- *
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param points the array of points to be used for drawing the series
- * @param seriesRenderer the series renderer
- * @param yAxisValue the minimum value of the y axis
- * @param seriesIndex the index of the series currently being drawn
- * @param startIndex the start index of the rendering points
- */
- public void drawSeries(Canvas canvas, Paint paint, float[] points,
- SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex) {
- int seriesNr = mDataset.getSeriesCount();
- int length = points.length;
- paint.setColor(seriesRenderer.getColor());
- paint.setStyle(Style.FILL);
- float halfDiffX = getHalfDiffX(points, length, seriesNr);
- int start = 0;
- if (startIndex > 0) {
- start = 2;
- }
- for (int i = start; i < length; i += 4) {
- if (points.length > i + 3) {
- float xMin = points[i];
- float yMin = points[i + 1];
- // xMin = xMax
- float xMax = points[i + 2];
- float yMax = points[i + 3];
- drawBar(canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint);
- }
- }
- paint.setColor(seriesRenderer.getColor());
- }
-
- /**
- * The graphical representation of the series values as text.
- *
- * @param canvas the canvas to paint to
- * @param series the series to be painted
- * @param renderer the series renderer
- * @param paint the paint to be used for drawing
- * @param points the array of points to be used for drawing the series
- * @param seriesIndex the index of the series currently being drawn
- * @param startIndex the start index of the rendering points
- */
- protected void drawChartValuesText(Canvas canvas, XYSeries series, SimpleSeriesRenderer renderer,
- Paint paint, float[] points, int seriesIndex, int startIndex) {
- int seriesNr = mDataset.getSeriesCount();
- float halfDiffX = getHalfDiffX(points, points.length, seriesNr);
- int start = 0;
- if (startIndex > 0) {
- start = 2;
- }
- for (int i = start; i < points.length; i += 4) {
- int index = startIndex + i / 2;
- float x = points[i];
- if (mType == Type.DEFAULT) {
- x += seriesIndex * 2 * halfDiffX - (seriesNr - 1.5f) * halfDiffX;
- }
-
- if (!isNullValue(series.getY(index + 1)) && points.length > i + 3) {
- // draw the maximum value
- drawText(canvas, getLabel(series.getY(index + 1)), x,
- points[i + 3] - renderer.getChartValuesSpacing(), paint, 0);
- }
- if (!isNullValue(series.getY(index)) && points.length > i + 1) {
- // draw the minimum value
- drawText(canvas, getLabel(series.getY(index)), x,
- points[i + 1] + renderer.getChartValuesTextSize() + renderer.getChartValuesSpacing()
- - 3, paint, 0);
- }
- }
- }
-
- /**
- * Returns the value of a constant used to calculate the half-distance.
- *
- * @return the constant value
- */
- protected float getCoeficient() {
- return 0.5f;
- }
-
- /**
- * Returns the chart type identifier.
- *
- * @return the chart type
- */
- public String getChartType() {
- return TYPE;
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/RangeStackedBarChart.java b/android-libraries/achartengine/src/org/achartengine/chart/RangeStackedBarChart.java
deleted file mode 100644
index 4da4f00688..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/RangeStackedBarChart.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-public class RangeStackedBarChart extends RangeBarChart {
- /** The chart type. */
- public static final String TYPE = "RangeStackedBar";
-
- RangeStackedBarChart() {
- super(Type.STACKED);
- }
-
- public String getChartType() {
- return TYPE;
- }
-}
\ No newline at end of file
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/RoundChart.java b/android-libraries/achartengine/src/org/achartengine/chart/RoundChart.java
deleted file mode 100644
index 1a2121d440..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/RoundChart.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import org.achartengine.model.CategorySeries;
-import org.achartengine.renderer.DefaultRenderer;
-import org.achartengine.renderer.SimpleSeriesRenderer;
-
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Paint.Align;
-
-/**
- * An abstract class to be extended by round like chart rendering classes.
- */
-public abstract class RoundChart extends AbstractChart {
- /** The legend shape width. */
- protected static final int SHAPE_WIDTH = 10;
- /** The series dataset. */
- protected CategorySeries mDataset;
- /** The series renderer. */
- protected DefaultRenderer mRenderer;
- /** A no value constant. */
- protected static final int NO_VALUE = Integer.MAX_VALUE;
- /** The chart center X axis. */
- protected int mCenterX = NO_VALUE;
- /** The chart center y axis. */
- protected int mCenterY = NO_VALUE;
-
- /**
- * Round chart.
- *
- * @param dataset the series dataset
- * @param renderer the series renderer
- */
- public RoundChart(CategorySeries dataset, DefaultRenderer renderer) {
- mDataset = dataset;
- mRenderer = renderer;
- }
-
- /**
- * The graphical representation of the round chart title.
- *
- * @param canvas the canvas to paint to
- * @param x the top left x value of the view to draw to
- * @param y the top left y value of the view to draw to
- * @param width the width of the view to draw to
- * @param paint the paint
- */
- public void drawTitle(Canvas canvas, int x, int y, int width, Paint paint) {
- if (mRenderer.isShowLabels()) {
- paint.setColor(mRenderer.getLabelsColor());
- paint.setTextAlign(Align.CENTER);
- paint.setTextSize(mRenderer.getChartTitleTextSize());
- drawString(canvas, mRenderer.getChartTitle(), x + width / 2,
- y + mRenderer.getChartTitleTextSize(), paint);
- }
- }
-
- /**
- * Returns the legend shape width.
- *
- * @param seriesIndex the series index
- * @return the legend shape width
- */
- public int getLegendShapeWidth(int seriesIndex) {
- return SHAPE_WIDTH;
- }
-
- /**
- * The graphical representation of the legend shape.
- *
- * @param canvas the canvas to paint to
- * @param renderer the series renderer
- * @param x the x value of the point the shape should be drawn at
- * @param y the y value of the point the shape should be drawn at
- * @param seriesIndex the series index
- * @param paint the paint to be used for drawing
- */
- public void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y,
- int seriesIndex, Paint paint) {
- canvas.drawRect(x, y - SHAPE_WIDTH / 2, x + SHAPE_WIDTH, y + SHAPE_WIDTH / 2, paint);
- }
-
- /**
- * Returns the renderer.
- *
- * @return the renderer
- */
- public DefaultRenderer getRenderer() {
- return mRenderer;
- }
-
- /**
- * Returns the center on X axis.
- *
- * @return the center on X axis
- */
- public int getCenterX() {
- return mCenterX;
- }
-
- /**
- * Returns the center on Y axis.
- *
- * @return the center on Y axis
- */
- public int getCenterY() {
- return mCenterY;
- }
-
- /**
- * Sets a new center on X axis.
- *
- * @param centerX center on X axis
- */
- public void setCenterX(int centerX) {
- mCenterX = centerX;
- }
-
- /**
- * Sets a new center on Y axis.
- *
- * @param centerY center on Y axis
- */
- public void setCenterY(int centerY) {
- mCenterY = centerY;
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/ScatterChart.java b/android-libraries/achartengine/src/org/achartengine/chart/ScatterChart.java
deleted file mode 100644
index 1d3b2a184a..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/ScatterChart.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.renderer.SimpleSeriesRenderer;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-import org.achartengine.renderer.XYSeriesRenderer;
-
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Paint.Style;
-import android.graphics.RectF;
-
-/**
- * The scatter chart rendering class.
- */
-public class ScatterChart extends XYChart {
- /** The constant to identify this chart type. */
- public static final String TYPE = "Scatter";
- /** The default point shape size. */
- private static final float SIZE = 3;
- /** The legend shape width. */
- private static final int SHAPE_WIDTH = 10;
- /** The point shape size. */
- private float size = SIZE;
-
- ScatterChart() {
- }
-
- /**
- * Builds a new scatter chart instance.
- *
- * @param dataset the multiple series dataset
- * @param renderer the multiple series renderer
- */
- public ScatterChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) {
- super(dataset, renderer);
- size = renderer.getPointSize();
- }
-
- // TODO: javadoc
- protected void setDatasetRenderer(XYMultipleSeriesDataset dataset,
- XYMultipleSeriesRenderer renderer) {
- super.setDatasetRenderer(dataset, renderer);
- size = renderer.getPointSize();
- }
-
- /**
- * The graphical representation of a series.
- *
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param points the array of points to be used for drawing the series
- * @param seriesRenderer the series renderer
- * @param yAxisValue the minimum value of the y axis
- * @param seriesIndex the index of the series currently being drawn
- * @param startIndex the start index of the rendering points
- */
- public void drawSeries(Canvas canvas, Paint paint, float[] points,
- SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex) {
- XYSeriesRenderer renderer = (XYSeriesRenderer) seriesRenderer;
- paint.setColor(renderer.getColor());
- if (renderer.isFillPoints()) {
- paint.setStyle(Style.FILL);
- } else {
- paint.setStyle(Style.STROKE);
- }
- int length = points.length;
- switch (renderer.getPointStyle()) {
- case X:
- for (int i = 0; i < length; i += 2) {
- drawX(canvas, paint, points[i], points[i + 1]);
- }
- break;
- case CIRCLE:
- for (int i = 0; i < length; i += 2) {
- drawCircle(canvas, paint, points[i], points[i + 1]);
- }
- break;
- case TRIANGLE:
- float[] path = new float[6];
- for (int i = 0; i < length; i += 2) {
- drawTriangle(canvas, paint, path, points[i], points[i + 1]);
- }
- break;
- case SQUARE:
- for (int i = 0; i < length; i += 2) {
- drawSquare(canvas, paint, points[i], points[i + 1]);
- }
- break;
- case DIAMOND:
- path = new float[8];
- for (int i = 0; i < length; i += 2) {
- drawDiamond(canvas, paint, path, points[i], points[i + 1]);
- }
- break;
- case POINT:
- canvas.drawPoints(points, paint);
- break;
- }
- }
-
- @Override
- protected ClickableArea[] clickableAreasForPoints(float[] points, double[] values,
- float yAxisValue, int seriesIndex, int startIndex) {
- int length = points.length;
- ClickableArea[] ret = new ClickableArea[length / 2];
- for (int i = 0; i < length; i += 2) {
- int selectableBuffer = mRenderer.getSelectableBuffer();
- ret[i / 2] = new ClickableArea(new RectF(points[i] - selectableBuffer, points[i + 1]
- - selectableBuffer, points[i] + selectableBuffer, points[i + 1] + selectableBuffer),
- values[i], values[i + 1]);
- }
- return ret;
- }
-
- /**
- * Returns the legend shape width.
- *
- * @param seriesIndex the series index
- * @return the legend shape width
- */
- public int getLegendShapeWidth(int seriesIndex) {
- return SHAPE_WIDTH;
- }
-
- /**
- * The graphical representation of the legend shape.
- *
- * @param canvas the canvas to paint to
- * @param renderer the series renderer
- * @param x the x value of the point the shape should be drawn at
- * @param y the y value of the point the shape should be drawn at
- * @param seriesIndex the series index
- * @param paint the paint to be used for drawing
- */
- public void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y,
- int seriesIndex, Paint paint) {
- if (((XYSeriesRenderer) renderer).isFillPoints()) {
- paint.setStyle(Style.FILL);
- } else {
- paint.setStyle(Style.STROKE);
- }
- switch (((XYSeriesRenderer) renderer).getPointStyle()) {
- case X:
- drawX(canvas, paint, x + SHAPE_WIDTH, y);
- break;
- case CIRCLE:
- drawCircle(canvas, paint, x + SHAPE_WIDTH, y);
- break;
- case TRIANGLE:
- drawTriangle(canvas, paint, new float[6], x + SHAPE_WIDTH, y);
- break;
- case SQUARE:
- drawSquare(canvas, paint, x + SHAPE_WIDTH, y);
- break;
- case DIAMOND:
- drawDiamond(canvas, paint, new float[8], x + SHAPE_WIDTH, y);
- break;
- case POINT:
- canvas.drawPoint(x + SHAPE_WIDTH, y, paint);
- break;
- }
- }
-
- /**
- * The graphical representation of an X point shape.
- *
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param x the x value of the point the shape should be drawn at
- * @param y the y value of the point the shape should be drawn at
- */
- private void drawX(Canvas canvas, Paint paint, float x, float y) {
- canvas.drawLine(x - size, y - size, x + size, y + size, paint);
- canvas.drawLine(x + size, y - size, x - size, y + size, paint);
- }
-
- /**
- * The graphical representation of a circle point shape.
- *
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param x the x value of the point the shape should be drawn at
- * @param y the y value of the point the shape should be drawn at
- */
- private void drawCircle(Canvas canvas, Paint paint, float x, float y) {
- canvas.drawCircle(x, y, size, paint);
- }
-
- /**
- * The graphical representation of a triangle point shape.
- *
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param path the triangle path
- * @param x the x value of the point the shape should be drawn at
- * @param y the y value of the point the shape should be drawn at
- */
- private void drawTriangle(Canvas canvas, Paint paint, float[] path, float x, float y) {
- path[0] = x;
- path[1] = y - size - size / 2;
- path[2] = x - size;
- path[3] = y + size;
- path[4] = x + size;
- path[5] = path[3];
- drawPath(canvas, path, paint, true);
- }
-
- /**
- * The graphical representation of a square point shape.
- *
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param x the x value of the point the shape should be drawn at
- * @param y the y value of the point the shape should be drawn at
- */
- private void drawSquare(Canvas canvas, Paint paint, float x, float y) {
- canvas.drawRect(x - size, y - size, x + size, y + size, paint);
- }
-
- /**
- * The graphical representation of a diamond point shape.
- *
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param path the diamond path
- * @param x the x value of the point the shape should be drawn at
- * @param y the y value of the point the shape should be drawn at
- */
- private void drawDiamond(Canvas canvas, Paint paint, float[] path, float x, float y) {
- path[0] = x;
- path[1] = y - size;
- path[2] = x - size;
- path[3] = y;
- path[4] = x;
- path[5] = y + size;
- path[6] = x + size;
- path[7] = y;
- drawPath(canvas, path, paint, true);
- }
-
- /**
- * Returns the chart type identifier.
- *
- * @return the chart type
- */
- public String getChartType() {
- return TYPE;
- }
-
-}
\ No newline at end of file
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/TimeChart.java b/android-libraries/achartengine/src/org/achartengine/chart/TimeChart.java
deleted file mode 100644
index ba201de78b..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/TimeChart.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.model.XYSeries;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-
-import android.graphics.Canvas;
-import android.graphics.Paint;
-
-/**
- * The time chart rendering class.
- */
-public class TimeChart extends LineChart {
- /** The constant to identify this chart type. */
- public static final String TYPE = "Time";
- /** The number of milliseconds in a day. */
- public static final long DAY = 24 * 60 * 60 * 1000;
- /** The date format pattern to be used in formatting the X axis labels. */
- private String mDateFormat;
- /** The starting point for labels. */
- private Double mStartPoint;
-
- TimeChart() {
- }
-
- /**
- * Builds a new time chart instance.
- *
- * @param dataset the multiple series dataset
- * @param renderer the multiple series renderer
- */
- public TimeChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) {
- super(dataset, renderer);
- }
-
- /**
- * Returns the date format pattern to be used for formatting the X axis
- * labels.
- *
- * @return the date format pattern for the X axis labels
- */
- public String getDateFormat() {
- return mDateFormat;
- }
-
- /**
- * Sets the date format pattern to be used for formatting the X axis labels.
- *
- * @param format the date format pattern for the X axis labels. If null, an
- * appropriate default format will be used.
- */
- public void setDateFormat(String format) {
- mDateFormat = format;
- }
-
- /**
- * The graphical representation of the labels on the X axis.
- *
- * @param xLabels the X labels values
- * @param xTextLabelLocations the X text label locations
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param left the left value of the labels area
- * @param top the top value of the labels area
- * @param bottom the bottom value of the labels area
- * @param xPixelsPerUnit the amount of pixels per one unit in the chart labels
- * @param minX the minimum value on the X axis in the chart
- * @param maxX the maximum value on the X axis in the chart
- */
- @Override
- protected void drawXLabels(List xLabels, Double[] xTextLabelLocations, Canvas canvas,
- Paint paint, int left, int top, int bottom, double xPixelsPerUnit, double minX, double maxX) {
- int length = xLabels.size();
- if (length > 0) {
- boolean showLabels = mRenderer.isShowLabels();
- boolean showGridY = mRenderer.isShowGridY();
- DateFormat format = getDateFormat(xLabels.get(0), xLabels.get(length - 1));
- for (int i = 0; i < length; i++) {
- long label = Math.round(xLabels.get(i));
- float xLabel = (float) (left + xPixelsPerUnit * (label - minX));
- if (showLabels) {
- paint.setColor(mRenderer.getXLabelsColor());
- canvas
- .drawLine(xLabel, bottom, xLabel, bottom + mRenderer.getLabelsTextSize() / 3, paint);
- drawText(canvas, format.format(new Date(label)), xLabel,
- bottom + mRenderer.getLabelsTextSize() * 4 / 3, paint, mRenderer.getXLabelsAngle());
- }
- if (showGridY) {
- paint.setColor(mRenderer.getGridColor());
- canvas.drawLine(xLabel, bottom, xLabel, top, paint);
- }
- }
- }
- drawXTextLabels(xTextLabelLocations, canvas, paint, true, left, top, bottom, xPixelsPerUnit,
- minX, maxX);
- }
-
- /**
- * Returns the date format pattern to be used, based on the date range.
- *
- * @param start the start date in milliseconds
- * @param end the end date in milliseconds
- * @return the date format
- */
- private DateFormat getDateFormat(double start, double end) {
- if (mDateFormat != null) {
- SimpleDateFormat format = null;
- try {
- format = new SimpleDateFormat(mDateFormat);
- return format;
- } catch (Exception e) {
- // do nothing here
- }
- }
- DateFormat format = SimpleDateFormat.getDateInstance(SimpleDateFormat.MEDIUM);
- double diff = end - start;
- if (diff > DAY && diff < 5 * DAY) {
- format = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.SHORT);
- } else if (diff < DAY) {
- format = SimpleDateFormat.getTimeInstance(SimpleDateFormat.MEDIUM);
- }
- return format;
- }
-
- /**
- * Returns the chart type identifier.
- *
- * @return the chart type
- */
- public String getChartType() {
- return TYPE;
- }
-
- protected List getXLabels(double min, double max, int count) {
- final List result = new ArrayList();
- if (!mRenderer.isXRoundedLabels()) {
- if (mDataset.getSeriesCount() > 0) {
- XYSeries series = mDataset.getSeriesAt(0);
- int length = series.getItemCount();
- int intervalLength = 0;
- int startIndex = -1;
- for (int i = 0; i < length; i++) {
- double value = series.getX(i);
- if (min <= value && value <= max) {
- intervalLength++;
- if (startIndex < 0) {
- startIndex = i;
- }
- }
- }
- if (intervalLength < count) {
- for (int i = startIndex; i < startIndex + intervalLength; i++) {
- result.add(series.getX(i));
- }
- } else {
- float step = (float) intervalLength / count;
- int intervalCount = 0;
- for (int i = 0; i < length && intervalCount < count; i++) {
- double value = series.getX(Math.round(i * step));
- if (min <= value && value <= max) {
- result.add(value);
- intervalCount++;
- }
- }
- }
- return result;
- } else {
- return super.getXLabels(min, max, count);
- }
- }
- if (mStartPoint == null) {
- mStartPoint = min - (min % DAY) + DAY + new Date(Math.round(min)).getTimezoneOffset() * 60
- * 1000;
- }
- if (count > 25) {
- count = 25;
- }
-
-
- final double cycleMath = (max - min) / count;
- if (cycleMath <= 0) {
- return result;
- }
- double cycle = DAY;
-
- if (cycleMath <= DAY) {
- while (cycleMath < cycle / 2) {
- cycle = cycle / 2;
- }
- } else {
- while (cycleMath > cycle) {
- cycle = cycle * 2;
- }
- }
-
- double val = mStartPoint - Math.floor((mStartPoint - min) / cycle) * cycle;
- int i = 0;
- while (val < max && i++ <= count) {
- result.add(val);
- val += cycle;
- }
-
- return result;
- }
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/XYChart.java b/android-libraries/achartengine/src/org/achartengine/chart/XYChart.java
deleted file mode 100644
index 6b531d60b3..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/XYChart.java
+++ /dev/null
@@ -1,905 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.chart;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.SortedMap;
-
-import org.achartengine.model.Point;
-import org.achartengine.model.SeriesSelection;
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.model.XYSeries;
-import org.achartengine.renderer.BasicStroke;
-import org.achartengine.renderer.DefaultRenderer;
-import org.achartengine.renderer.SimpleSeriesRenderer;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-import org.achartengine.renderer.XYMultipleSeriesRenderer.Orientation;
-import org.achartengine.util.MathHelper;
-
-import android.graphics.Canvas;
-import android.graphics.DashPathEffect;
-import android.graphics.Paint;
-import android.graphics.Paint.Align;
-import android.graphics.Paint.Cap;
-import android.graphics.Paint.Join;
-import android.graphics.Paint.Style;
-import android.graphics.PathEffect;
-import android.graphics.Rect;
-import android.graphics.RectF;
-import android.graphics.Typeface;
-
-/**
- * The XY chart rendering class.
- */
-public abstract class XYChart extends AbstractChart {
- /** The multiple series dataset. */
- protected XYMultipleSeriesDataset mDataset;
- /** The multiple series renderer. */
- protected XYMultipleSeriesRenderer mRenderer;
- /** The current scale value. */
- private float mScale;
- /** The current translate value. */
- private float mTranslate;
- /** The canvas center point. */
- private Point mCenter;
- /** The visible chart area, in screen coordinates. */
- private Rect mScreenR;
- /** The calculated range. */
- private final Map mCalcRange = new HashMap();
-
- /**
- * The clickable areas for all points. The array index is the series index,
- * and the RectF list index is the point index in that series.
- */
- private Map> clickableAreas = new HashMap>();
-
- protected XYChart() {
- }
-
- /**
- * Builds a new XY chart instance.
- *
- * @param dataset the multiple series dataset
- * @param renderer the multiple series renderer
- */
- public XYChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) {
- mDataset = dataset;
- mRenderer = renderer;
- }
-
- // TODO: javadoc
- protected void setDatasetRenderer(XYMultipleSeriesDataset dataset,
- XYMultipleSeriesRenderer renderer) {
- mDataset = dataset;
- mRenderer = renderer;
- }
-
- /**
- * The graphical representation of the XY chart.
- *
- * @param canvas the canvas to paint to
- * @param x the top left x value of the view to draw to
- * @param y the top left y value of the view to draw to
- * @param width the width of the view to draw to
- * @param height the height of the view to draw to
- * @param paint the paint
- */
- public void draw(Canvas canvas, int x, int y, int width, int height, Paint paint) {
- paint.setAntiAlias(mRenderer.isAntialiasing());
- int legendSize = getLegendSize(mRenderer, height / 5, mRenderer.getAxisTitleTextSize());
- int[] margins = mRenderer.getMargins();
- int left = x + margins[1];
- int top = y + margins[0];
- int right = x + width - margins[3];
- int sLength = mDataset.getSeriesCount();
- String[] titles = new String[sLength];
- for (int i = 0; i < sLength; i++) {
- titles[i] = mDataset.getSeriesAt(i).getTitle();
- }
- if (mRenderer.isFitLegend() && mRenderer.isShowLegend()) {
- legendSize = drawLegend(canvas, mRenderer, titles, left, right, y, width, height, legendSize,
- paint, true);
- }
- int bottom = y + height - margins[2] - legendSize;
- if (mScreenR == null) {
- mScreenR = new Rect();
- }
- mScreenR.set(left, top, right, bottom);
- drawBackground(mRenderer, canvas, x, y, width, height, paint, false, DefaultRenderer.NO_COLOR);
-
- if (paint.getTypeface() == null
- || !paint.getTypeface().toString().equals(mRenderer.getTextTypefaceName())
- || paint.getTypeface().getStyle() != mRenderer.getTextTypefaceStyle()) {
- paint.setTypeface(Typeface.create(mRenderer.getTextTypefaceName(),
- mRenderer.getTextTypefaceStyle()));
- }
- Orientation or = mRenderer.getOrientation();
- if (or == Orientation.VERTICAL) {
- right -= legendSize;
- bottom += legendSize - 20;
- }
- int angle = or.getAngle();
- boolean rotate = angle == 90;
- mScale = (float) (height) / width;
- mTranslate = Math.abs(width - height) / 2;
- if (mScale < 1) {
- mTranslate *= -1;
- }
- mCenter = new Point((x + width) / 2, (y + height) / 2);
- if (rotate) {
- transform(canvas, angle, false);
- }
-
- int maxScaleNumber = -Integer.MAX_VALUE;
- for (int i = 0; i < sLength; i++) {
- maxScaleNumber = Math.max(maxScaleNumber, mDataset.getSeriesAt(i).getScaleNumber());
- }
- maxScaleNumber++;
- if (maxScaleNumber < 0) {
- return;
- }
- double[] minX = new double[maxScaleNumber];
- double[] maxX = new double[maxScaleNumber];
- double[] minY = new double[maxScaleNumber];
- double[] maxY = new double[maxScaleNumber];
- boolean[] isMinXSet = new boolean[maxScaleNumber];
- boolean[] isMaxXSet = new boolean[maxScaleNumber];
- boolean[] isMinYSet = new boolean[maxScaleNumber];
- boolean[] isMaxYSet = new boolean[maxScaleNumber];
-
- for (int i = 0; i < maxScaleNumber; i++) {
- minX[i] = mRenderer.getXAxisMin(i);
- maxX[i] = mRenderer.getXAxisMax(i);
- minY[i] = mRenderer.getYAxisMin(i);
- maxY[i] = mRenderer.getYAxisMax(i);
- isMinXSet[i] = mRenderer.isMinXSet(i);
- isMaxXSet[i] = mRenderer.isMaxXSet(i);
- isMinYSet[i] = mRenderer.isMinYSet(i);
- isMaxYSet[i] = mRenderer.isMaxYSet(i);
- if (mCalcRange.get(i) == null) {
- mCalcRange.put(i, new double[4]);
- }
- }
- double[] xPixelsPerUnit = new double[maxScaleNumber];
- double[] yPixelsPerUnit = new double[maxScaleNumber];
- for (int i = 0; i < sLength; i++) {
- XYSeries series = mDataset.getSeriesAt(i);
- int scale = series.getScaleNumber();
- if (series.getItemCount() == 0) {
- continue;
- }
- if (!isMinXSet[scale]) {
- double minimumX = series.getMinX();
- minX[scale] = Math.min(minX[scale], minimumX);
- mCalcRange.get(scale)[0] = minX[scale];
- }
- if (!isMaxXSet[scale]) {
- double maximumX = series.getMaxX();
- maxX[scale] = Math.max(maxX[scale], maximumX);
- mCalcRange.get(scale)[1] = maxX[scale];
- }
- if (!isMinYSet[scale]) {
- double minimumY = series.getMinY();
- minY[scale] = Math.min(minY[scale], (float) minimumY);
- mCalcRange.get(scale)[2] = minY[scale];
- }
- if (!isMaxYSet[scale]) {
- double maximumY = series.getMaxY();
- maxY[scale] = Math.max(maxY[scale], (float) maximumY);
- mCalcRange.get(scale)[3] = maxY[scale];
- }
- }
- for (int i = 0; i < maxScaleNumber; i++) {
- if (maxX[i] - minX[i] != 0) {
- xPixelsPerUnit[i] = (right - left) / (maxX[i] - minX[i]);
- }
- if (maxY[i] - minY[i] != 0) {
- yPixelsPerUnit[i] = (float) ((bottom - top) / (maxY[i] - minY[i]));
- }
- }
-
- boolean hasValues = false;
- // use a linked list for these reasons:
- // 1) Avoid a large contiguous memory allocation
- // 2) We don't need random seeking, only sequential reading/writing, so
- // linked list makes sense
- clickableAreas = new HashMap>();
- for (int i = 0; i < sLength; i++) {
- XYSeries series = mDataset.getSeriesAt(i);
- int scale = series.getScaleNumber();
- if (series.getItemCount() == 0) {
- continue;
- }
-
- hasValues = true;
- SimpleSeriesRenderer seriesRenderer = mRenderer.getSeriesRendererAt(i);
-
- // int originalValuesLength = series.getItemCount();
- // int valuesLength = originalValuesLength;
- // int length = valuesLength * 2;
-
- List points = new ArrayList();
- List values = new ArrayList();
- float yAxisValue = Math.min(bottom, (float) (bottom + yPixelsPerUnit[scale] * minY[scale]));
- LinkedList clickableArea = new LinkedList();
-
- clickableAreas.put(i, clickableArea);
-
- SortedMap range = series.getRange(minX[scale], maxX[scale], 1);
- int startIndex = -1;
-
- for (Entry value : range.entrySet()) {
-
- double xValue = value.getKey();
- double yValue = value.getValue();
- if (startIndex < 0) {
- startIndex = series.getIndexForKey(xValue);
- }
-
- // points.add((float) (left + xPixelsPerUnit[scale]
- // * (value.getKey().floatValue() - minX[scale])));
- // points.add((float) (bottom - yPixelsPerUnit[scale]
- // * (value.getValue().floatValue() - minY[scale])));
- values.add(value.getKey());
- values.add(value.getValue());
-
- if (!isNullValue(yValue)) {
- points.add((float) (left + xPixelsPerUnit[scale] * (xValue - minX[scale])));
- points.add((float) (bottom - yPixelsPerUnit[scale] * (yValue - minY[scale])));
- } else if (isRenderNullValues()) {
- points.add((float) (left + xPixelsPerUnit[scale] * (xValue - minX[scale])));
- points.add((float) (bottom - yPixelsPerUnit[scale] * (-minY[scale])));
- } else {
- if (points.size() > 0) {
- drawSeries(series, canvas, paint, points, seriesRenderer, yAxisValue, i, or, startIndex);
- ClickableArea[] clickableAreasForSubSeries = clickableAreasForPoints(
- MathHelper.getFloats(points), MathHelper.getDoubles(values), yAxisValue, i,
- startIndex);
- clickableArea.addAll(Arrays.asList(clickableAreasForSubSeries));
- points.clear();
- values.clear();
- }
- clickableArea.add(null);
- }
- }
-
- if (points.size() > 0) {
- drawSeries(series, canvas, paint, points, seriesRenderer, yAxisValue, i, or, startIndex);
- ClickableArea[] clickableAreasForSubSeries = clickableAreasForPoints(
- MathHelper.getFloats(points), MathHelper.getDoubles(values), yAxisValue, i, startIndex);
- clickableArea.addAll(Arrays.asList(clickableAreasForSubSeries));
- }
- }
-
- // draw stuff over the margins such as data doesn't render on these areas
- drawBackground(mRenderer, canvas, x, bottom, width, height - bottom, paint, true,
- mRenderer.getMarginsColor());
- drawBackground(mRenderer, canvas, x, y, width, margins[0], paint, true,
- mRenderer.getMarginsColor());
- if (or == Orientation.HORIZONTAL) {
- drawBackground(mRenderer, canvas, x, y, left - x, height - y, paint, true,
- mRenderer.getMarginsColor());
- drawBackground(mRenderer, canvas, right, y, margins[3], height - y, paint, true,
- mRenderer.getMarginsColor());
- } else if (or == Orientation.VERTICAL) {
- drawBackground(mRenderer, canvas, right, y, width - right, height - y, paint, true,
- mRenderer.getMarginsColor());
- drawBackground(mRenderer, canvas, x, y, left - x, height - y, paint, true,
- mRenderer.getMarginsColor());
- }
-
- boolean showLabels = mRenderer.isShowLabels() && hasValues;
- boolean showGridX = mRenderer.isShowGridX();
- boolean showCustomTextGrid = mRenderer.isShowCustomTextGrid();
- if (showLabels || showGridX) {
- List xLabels = getValidLabels(getXLabels(minX[0], maxX[0], mRenderer.getXLabels()));
- Map> allYLabels = getYLabels(minY, maxY, maxScaleNumber);
-
- int xLabelsLeft = left;
- if (showLabels) {
- paint.setColor(mRenderer.getXLabelsColor());
- paint.setTextSize(mRenderer.getLabelsTextSize());
- paint.setTextAlign(mRenderer.getXLabelsAlign());
- if (mRenderer.getXLabelsAlign() == Align.LEFT) {
- xLabelsLeft += mRenderer.getLabelsTextSize() / 4;
- }
- }
- drawXLabels(xLabels, mRenderer.getXTextLabelLocations(), canvas, paint, xLabelsLeft, top,
- bottom, xPixelsPerUnit[0], minX[0], maxX[0]);
- drawYLabels(allYLabels, canvas, paint, maxScaleNumber, left, right, bottom, yPixelsPerUnit,
- minY);
-
- if (showLabels) {
- paint.setColor(mRenderer.getLabelsColor());
- for (int i = 0; i < maxScaleNumber; i++) {
- Align axisAlign = mRenderer.getYAxisAlign(i);
- Double[] yTextLabelLocations = mRenderer.getYTextLabelLocations(i);
- for (Double location : yTextLabelLocations) {
- if (minY[i] <= location && location <= maxY[i]) {
- float yLabel = (float) (bottom - yPixelsPerUnit[i]
- * (location.doubleValue() - minY[i]));
- String label = mRenderer.getYTextLabel(location, i);
- paint.setColor(mRenderer.getYLabelsColor(i));
- paint.setTextAlign(mRenderer.getYLabelsAlign(i));
- if (or == Orientation.HORIZONTAL) {
- if (axisAlign == Align.LEFT) {
- canvas.drawLine(left + getLabelLinePos(axisAlign), yLabel, left, yLabel, paint);
- drawText(canvas, label, left, yLabel - 2, paint, mRenderer.getYLabelsAngle());
- } else {
- canvas.drawLine(right, yLabel, right + getLabelLinePos(axisAlign), yLabel, paint);
- drawText(canvas, label, right, yLabel - 2, paint, mRenderer.getYLabelsAngle());
- }
-
- if (showCustomTextGrid) {
- paint.setColor(mRenderer.getGridColor());
- canvas.drawLine(left, yLabel, right, yLabel, paint);
- }
- } else {
- canvas.drawLine(right - getLabelLinePos(axisAlign), yLabel, right, yLabel, paint);
- drawText(canvas, label, right + 10, yLabel - 2, paint, mRenderer.getYLabelsAngle());
- if (showCustomTextGrid) {
- paint.setColor(mRenderer.getGridColor());
- canvas.drawLine(right, yLabel, left, yLabel, paint);
- }
- }
- }
- }
- }
- }
-
- if (showLabels) {
- paint.setColor(mRenderer.getLabelsColor());
- float size = mRenderer.getAxisTitleTextSize();
- paint.setTextSize(size);
- paint.setTextAlign(Align.CENTER);
- if (or == Orientation.HORIZONTAL) {
- drawText(canvas, mRenderer.getXTitle(), x + width / 2,
- bottom + mRenderer.getLabelsTextSize() * 4 / 3 + size, paint, 0);
- for (int i = 0; i < maxScaleNumber; i++) {
- Align axisAlign = mRenderer.getYAxisAlign(i);
- if (axisAlign == Align.LEFT) {
- drawText(canvas, mRenderer.getYTitle(i), x + size, y + height / 2, paint, -90);
- } else {
- drawText(canvas, mRenderer.getYTitle(i), x + width, y + height / 2, paint, -90);
- }
- }
- paint.setTextSize(mRenderer.getChartTitleTextSize());
- drawText(canvas, mRenderer.getChartTitle(), x + width / 2,
- y + mRenderer.getChartTitleTextSize(), paint, 0);
- } else if (or == Orientation.VERTICAL) {
- drawText(canvas, mRenderer.getXTitle(), x + width / 2, y + height - size, paint, -90);
- drawText(canvas, mRenderer.getYTitle(), right + 20, y + height / 2, paint, 0);
- paint.setTextSize(mRenderer.getChartTitleTextSize());
- drawText(canvas, mRenderer.getChartTitle(), x + size, top + height / 2, paint, 0);
- }
- }
- }
- if (or == Orientation.HORIZONTAL) {
- drawLegend(canvas, mRenderer, titles, left, right, y, width, height, legendSize, paint, false);
- } else if (or == Orientation.VERTICAL) {
- transform(canvas, angle, true);
- drawLegend(canvas, mRenderer, titles, left, right, y, width, height, legendSize, paint, false);
- transform(canvas, angle, false);
- }
- if (mRenderer.isShowAxes()) {
- paint.setColor(mRenderer.getAxesColor());
- canvas.drawLine(left, bottom, right, bottom, paint);
- boolean rightAxis = false;
- for (int i = 0; i < maxScaleNumber && !rightAxis; i++) {
- rightAxis = mRenderer.getYAxisAlign(i) == Align.RIGHT;
- }
- if (or == Orientation.HORIZONTAL) {
- canvas.drawLine(left, top, left, bottom, paint);
- if (rightAxis) {
- canvas.drawLine(right, top, right, bottom, paint);
- }
- } else if (or == Orientation.VERTICAL) {
- canvas.drawLine(right, top, right, bottom, paint);
- }
- }
- if (rotate) {
- transform(canvas, angle, true);
- }
- }
-
- protected List getXLabels(double min, double max, int count) {
- return MathHelper.getLabels(min, max, count);
- }
-
- protected Map> getYLabels(double[] minY, double[] maxY, int maxScaleNumber) {
- Map> allYLabels = new HashMap>();
- for (int i = 0; i < maxScaleNumber; i++) {
- allYLabels.put(i,
- getValidLabels(MathHelper.getLabels(minY[i], maxY[i], mRenderer.getYLabels())));
- }
- return allYLabels;
- }
-
- protected Rect getScreenR() {
- return mScreenR;
- }
-
- protected void setScreenR(Rect screenR) {
- mScreenR = screenR;
- }
-
- private List getValidLabels(List labels) {
- List result = new ArrayList(labels);
- for (Double label : labels) {
- if (label.isNaN()) {
- result.remove(label);
- }
- }
- return result;
- }
-
- /**
- * Draws the series.
- *
- * @param series the series
- * @param canvas the canvas
- * @param paint the paint object
- * @param pointsList the points to be rendered
- * @param seriesRenderer the series renderer
- * @param yAxisValue the y axis value in pixels
- * @param seriesIndex the series index
- * @param or the orientation
- * @param startIndex the start index of the rendering points
- */
- protected void drawSeries(XYSeries series, Canvas canvas, Paint paint, List pointsList,
- SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, Orientation or,
- int startIndex) {
- BasicStroke stroke = seriesRenderer.getStroke();
- Cap cap = paint.getStrokeCap();
- Join join = paint.getStrokeJoin();
- float miter = paint.getStrokeMiter();
- PathEffect pathEffect = paint.getPathEffect();
- Style style = paint.getStyle();
- if (stroke != null) {
- PathEffect effect = null;
- if (stroke.getIntervals() != null) {
- effect = new DashPathEffect(stroke.getIntervals(), stroke.getPhase());
- }
- setStroke(stroke.getCap(), stroke.getJoin(), stroke.getMiter(), Style.FILL_AND_STROKE,
- effect, paint);
- }
- float[] points = MathHelper.getFloats(pointsList);
- drawSeries(canvas, paint, points, seriesRenderer, yAxisValue, seriesIndex, startIndex);
- if (isRenderPoints(seriesRenderer)) {
- ScatterChart pointsChart = getPointsChart();
- if (pointsChart != null) {
- pointsChart.drawSeries(canvas, paint, points, seriesRenderer, yAxisValue, seriesIndex,
- startIndex);
- }
- }
- paint.setTextSize(seriesRenderer.getChartValuesTextSize());
- if (or == Orientation.HORIZONTAL) {
- paint.setTextAlign(Align.CENTER);
- } else {
- paint.setTextAlign(Align.LEFT);
- }
- if (seriesRenderer.isDisplayChartValues()) {
- paint.setTextAlign(seriesRenderer.getChartValuesTextAlign());
- drawChartValuesText(canvas, series, seriesRenderer, paint, points, seriesIndex, startIndex);
- }
- if (stroke != null) {
- setStroke(cap, join, miter, style, pathEffect, paint);
- }
- }
-
- private void setStroke(Cap cap, Join join, float miter, Style style, PathEffect pathEffect,
- Paint paint) {
- paint.setStrokeCap(cap);
- paint.setStrokeJoin(join);
- paint.setStrokeMiter(miter);
- paint.setPathEffect(pathEffect);
- paint.setStyle(style);
- }
-
- /**
- * The graphical representation of the series values as text.
- *
- * @param canvas the canvas to paint to
- * @param series the series to be painted
- * @param renderer the series renderer
- * @param paint the paint to be used for drawing
- * @param points the array of points to be used for drawing the series
- * @param seriesIndex the index of the series currently being drawn
- * @param startIndex the start index of the rendering points
- */
- protected void drawChartValuesText(Canvas canvas, XYSeries series, SimpleSeriesRenderer renderer,
- Paint paint, float[] points, int seriesIndex, int startIndex) {
- if (points.length > 1) { // there are more than one point
- // record the first point's position
- float previousPointX = points[0];
- float previousPointY = points[1];
- for (int k = 0; k < points.length; k += 2) {
- if (k == 2) { // decide whether to display first two points' values or not
- if (Math.abs(points[2]- points[0]) > 100 || Math.abs(points[3] - points[1]) > 100) {
- // first point
- drawText(canvas, getLabel(series.getY(startIndex)), points[0], points[1]
- - renderer.getChartValuesSpacing(), paint, 0);
- // second point
- drawText(canvas, getLabel(series.getY(startIndex + 1)), points[2], points[3]
- - renderer.getChartValuesSpacing(), paint, 0);
-
- previousPointX = points[2];
- previousPointY = points[3];
- }
- } else if (k > 2) {
- // compare current point's position with the previous point's, if they are not too close, display
- if (Math.abs(points[k]- previousPointX) > 100 || Math.abs(points[k+1] - previousPointY) > 100) {
- drawText(canvas, getLabel(series.getY(startIndex + k / 2)), points[k], points[k + 1]
- - renderer.getChartValuesSpacing(), paint, 0);
- previousPointX = points[k];
- previousPointY = points[k+1];
- }
- }
- }
- } else { // if only one point, display it
- for (int k = 0; k < points.length; k += 2) {
- drawText(canvas, getLabel(series.getY(startIndex + k / 2)), points[k], points[k + 1]
- - renderer.getChartValuesSpacing(), paint, 0);
- }
- }
- }
-
- /**
- * The graphical representation of a text, to handle both HORIZONTAL and
- * VERTICAL orientations and extra rotation angles.
- *
- * @param canvas the canvas to paint to
- * @param text the text to be rendered
- * @param x the X axis location of the text
- * @param y the Y axis location of the text
- * @param paint the paint to be used for drawing
- * @param extraAngle the text angle
- */
- protected void drawText(Canvas canvas, String text, float x, float y, Paint paint,
- float extraAngle) {
- float angle = -mRenderer.getOrientation().getAngle() + extraAngle;
- if (angle != 0) {
- // canvas.scale(1 / mScale, mScale);
- canvas.rotate(angle, x, y);
- }
- drawString(canvas, text, x, y, paint);
- if (angle != 0) {
- canvas.rotate(-angle, x, y);
- // canvas.scale(mScale, 1 / mScale);
- }
- }
-
- /**
- * Transform the canvas such as it can handle both HORIZONTAL and VERTICAL
- * orientations.
- *
- * @param canvas the canvas to paint to
- * @param angle the angle of rotation
- * @param inverse if the inverse transform needs to be applied
- */
- private void transform(Canvas canvas, float angle, boolean inverse) {
- if (inverse) {
- canvas.scale(1 / mScale, mScale);
- canvas.translate(mTranslate, -mTranslate);
- canvas.rotate(-angle, mCenter.getX(), mCenter.getY());
- } else {
- canvas.rotate(angle, mCenter.getX(), mCenter.getY());
- canvas.translate(-mTranslate, mTranslate);
- canvas.scale(mScale, 1 / mScale);
- }
- }
-
- /**
- * The graphical representation of the labels on the X axis.
- *
- * @param xLabels the X labels values
- * @param xTextLabelLocations the X text label locations
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param left the left value of the labels area
- * @param top the top value of the labels area
- * @param bottom the bottom value of the labels area
- * @param xPixelsPerUnit the amount of pixels per one unit in the chart labels
- * @param minX the minimum value on the X axis in the chart
- * @param maxX the maximum value on the X axis in the chart
- */
- protected void drawXLabels(List xLabels, Double[] xTextLabelLocations, Canvas canvas,
- Paint paint, int left, int top, int bottom, double xPixelsPerUnit, double minX, double maxX) {
- int length = xLabels.size();
- boolean showLabels = mRenderer.isShowLabels();
- boolean showGridY = mRenderer.isShowGridY();
- for (int i = 0; i < length; i++) {
- double label = xLabels.get(i);
- float xLabel = (float) (left + xPixelsPerUnit * (label - minX));
- if (showLabels) {
- paint.setColor(mRenderer.getXLabelsColor());
- canvas.drawLine(xLabel, bottom, xLabel, bottom + mRenderer.getLabelsTextSize() / 3, paint);
- drawText(canvas, getLabel(label), xLabel, bottom + mRenderer.getLabelsTextSize() * 4 / 3,
- paint, mRenderer.getXLabelsAngle());
- }
- if (showGridY) {
- paint.setColor(mRenderer.getGridColor());
- canvas.drawLine(xLabel, bottom, xLabel, top, paint);
- }
- }
- drawXTextLabels(xTextLabelLocations, canvas, paint, showLabels, left, top, bottom,
- xPixelsPerUnit, minX, maxX);
- }
-
- /**
- * The graphical representation of the labels on the X axis.
- *
- * @param allYLabels the Y labels values
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param maxScaleNumber the maximum scale number
- * @param left the left value of the labels area
- * @param right the right value of the labels area
- * @param bottom the bottom value of the labels area
- * @param yPixelsPerUnit the amount of pixels per one unit in the chart labels
- * @param minY the minimum value on the Y axis in the chart
- */
- protected void drawYLabels(Map> allYLabels, Canvas canvas, Paint paint,
- int maxScaleNumber, int left, int right, int bottom, double[] yPixelsPerUnit, double[] minY) {
- Orientation or = mRenderer.getOrientation();
- boolean showGridX = mRenderer.isShowGridX();
- boolean showLabels = mRenderer.isShowLabels();
- for (int i = 0; i < maxScaleNumber; i++) {
- paint.setTextAlign(mRenderer.getYLabelsAlign(i));
- List yLabels = allYLabels.get(i);
- int length = yLabels.size();
- for (int j = 0; j < length; j++) {
- double label = yLabels.get(j);
- Align axisAlign = mRenderer.getYAxisAlign(i);
- boolean textLabel = mRenderer.getYTextLabel(label, i) != null;
- float yLabel = (float) (bottom - yPixelsPerUnit[i] * (label - minY[i]));
- if (or == Orientation.HORIZONTAL) {
- if (showLabels && !textLabel) {
- paint.setColor(mRenderer.getYLabelsColor(i));
- if (axisAlign == Align.LEFT) {
- canvas.drawLine(left + getLabelLinePos(axisAlign), yLabel, left, yLabel, paint);
- drawText(canvas, getLabel(label), left, yLabel - 2, paint,
- mRenderer.getYLabelsAngle());
- } else {
- canvas.drawLine(right, yLabel, right + getLabelLinePos(axisAlign), yLabel, paint);
- drawText(canvas, getLabel(label), right, yLabel - 2, paint,
- mRenderer.getYLabelsAngle());
- }
- }
- if (showGridX) {
- paint.setColor(mRenderer.getGridColor());
- canvas.drawLine(left, yLabel, right, yLabel, paint);
- }
- } else if (or == Orientation.VERTICAL) {
- if (showLabels && !textLabel) {
- paint.setColor(mRenderer.getYLabelsColor(i));
- canvas.drawLine(right - getLabelLinePos(axisAlign), yLabel, right, yLabel, paint);
- drawText(canvas, getLabel(label), right + 10, yLabel - 2, paint,
- mRenderer.getYLabelsAngle());
- }
- if (showGridX) {
- paint.setColor(mRenderer.getGridColor());
- canvas.drawLine(right, yLabel, left, yLabel, paint);
- }
- }
- }
- }
- }
-
- /**
- * The graphical representation of the text labels on the X axis.
- *
- * @param xTextLabelLocations the X text label locations
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param left the left value of the labels area
- * @param top the top value of the labels area
- * @param bottom the bottom value of the labels area
- * @param xPixelsPerUnit the amount of pixels per one unit in the chart labels
- * @param minX the minimum value on the X axis in the chart
- * @param maxX the maximum value on the X axis in the chart
- */
- protected void drawXTextLabels(Double[] xTextLabelLocations, Canvas canvas, Paint paint,
- boolean showLabels, int left, int top, int bottom, double xPixelsPerUnit, double minX,
- double maxX) {
- boolean showCustomTextGrid = mRenderer.isShowCustomTextGrid();
- if (showLabels) {
- paint.setColor(mRenderer.getXLabelsColor());
- for (Double location : xTextLabelLocations) {
- if (minX <= location && location <= maxX) {
- float xLabel = (float) (left + xPixelsPerUnit * (location.doubleValue() - minX));
- paint.setColor(mRenderer.getXLabelsColor());
- canvas
- .drawLine(xLabel, bottom, xLabel, bottom + mRenderer.getLabelsTextSize() / 3, paint);
- drawText(canvas, mRenderer.getXTextLabel(location), xLabel,
- bottom + mRenderer.getLabelsTextSize() * 4 / 3, paint, mRenderer.getXLabelsAngle());
- if (showCustomTextGrid) {
- paint.setColor(mRenderer.getGridColor());
- canvas.drawLine(xLabel, bottom, xLabel, top, paint);
- }
- }
- }
- }
- }
-
- // TODO: docs
- public XYMultipleSeriesRenderer getRenderer() {
- return mRenderer;
- }
-
- public XYMultipleSeriesDataset getDataset() {
- return mDataset;
- }
-
- public double[] getCalcRange(int scale) {
- return mCalcRange.get(scale);
- }
-
- public void setCalcRange(double[] range, int scale) {
- mCalcRange.put(scale, range);
- }
-
- public double[] toRealPoint(float screenX, float screenY) {
- return toRealPoint(screenX, screenY, 0);
- }
-
- public double[] toScreenPoint(double[] realPoint) {
- return toScreenPoint(realPoint, 0);
- }
-
- private int getLabelLinePos(Align align) {
- int pos = 4;
- if (align == Align.LEFT) {
- pos = -pos;
- }
- return pos;
- }
-
- /**
- * Transforms a screen point to a real coordinates point.
- *
- * @param screenX the screen x axis value
- * @param screenY the screen y axis value
- * @return the real coordinates point
- */
- public double[] toRealPoint(float screenX, float screenY, int scale) {
- double realMinX = mRenderer.getXAxisMin(scale);
- double realMaxX = mRenderer.getXAxisMax(scale);
- double realMinY = mRenderer.getYAxisMin(scale);
- double realMaxY = mRenderer.getYAxisMax(scale);
- return new double[] {
- (screenX - mScreenR.left) * (realMaxX - realMinX) / mScreenR.width() + realMinX,
- (mScreenR.top + mScreenR.height() - screenY) * (realMaxY - realMinY) / mScreenR.height()
- + realMinY };
- }
-
- public double[] toScreenPoint(double[] realPoint, int scale) {
- double realMinX = mRenderer.getXAxisMin(scale);
- double realMaxX = mRenderer.getXAxisMax(scale);
- double realMinY = mRenderer.getYAxisMin(scale);
- double realMaxY = mRenderer.getYAxisMax(scale);
- if (!mRenderer.isMinXSet(scale) || !mRenderer.isMaxXSet(scale) || !mRenderer.isMinXSet(scale)
- || !mRenderer.isMaxYSet(scale)) {
- double[] calcRange = getCalcRange(scale);
- realMinX = calcRange[0];
- realMaxX = calcRange[1];
- realMinY = calcRange[2];
- realMaxY = calcRange[3];
- }
- return new double[] {
- (realPoint[0] - realMinX) * mScreenR.width() / (realMaxX - realMinX) + mScreenR.left,
- (realMaxY - realPoint[1]) * mScreenR.height() / (realMaxY - realMinY) + mScreenR.top };
- }
-
- public SeriesSelection getSeriesAndPointForScreenCoordinate(final Point screenPoint) {
- if (clickableAreas != null)
- for (int seriesIndex = clickableAreas.size() - 1; seriesIndex >= 0; seriesIndex--) {
- // series 0 is drawn first. Then series 1 is drawn on top, and series 2
- // on top of that.
- // we want to know what the user clicked on, so traverse them in the
- // order they appear on the screen.
- int pointIndex = 0;
- if (clickableAreas.get(seriesIndex) != null) {
- RectF rectangle;
- for (ClickableArea area : clickableAreas.get(seriesIndex)) {
- rectangle = area.getRect();
- if (rectangle != null && rectangle.contains(screenPoint.getX(), screenPoint.getY())) {
- return new SeriesSelection(seriesIndex, pointIndex, area.getX(), area.getY());
- }
- pointIndex++;
- }
- }
- }
- return super.getSeriesAndPointForScreenCoordinate(screenPoint);
- }
-
- /**
- * The graphical representation of a series.
- *
- * @param canvas the canvas to paint to
- * @param paint the paint to be used for drawing
- * @param points the array of points to be used for drawing the series
- * @param seriesRenderer the series renderer
- * @param yAxisValue the minimum value of the y axis
- * @param seriesIndex the index of the series currently being drawn
- * @param startIndex the start index of the rendering points
- */
- public abstract void drawSeries(Canvas canvas, Paint paint, float[] points,
- SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex);
-
- /**
- * Returns the clickable areas for all passed points
- *
- * @param points the array of points
- * @param values the array of values of each point
- * @param yAxisValue the minimum value of the y axis
- * @param seriesIndex the index of the series to which the points belong
- * @return an array of rectangles with the clickable area
- * @param startIndex the start index of the rendering points
- */
- protected abstract ClickableArea[] clickableAreasForPoints(float[] points, double[] values,
- float yAxisValue, int seriesIndex, int startIndex);
-
- /**
- * Returns if the chart should display the null values.
- *
- * @return if null values should be rendered
- */
- protected boolean isRenderNullValues() {
- return false;
- }
-
- /**
- * Returns if the chart should display the points as a certain shape.
- *
- * @param renderer the series renderer
- */
- public boolean isRenderPoints(SimpleSeriesRenderer renderer) {
- return false;
- }
-
- /**
- * Returns the default axis minimum.
- *
- * @return the default axis minimum
- */
- public double getDefaultMinimum() {
- return MathHelper.NULL_VALUE;
- }
-
- /**
- * Returns the scatter chart to be used for drawing the data points.
- *
- * @return the data points scatter chart
- */
- public ScatterChart getPointsChart() {
- return null;
- }
-
- /**
- * Returns the chart type identifier.
- *
- * @return the chart type
- */
- public abstract String getChartType();
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/package.html b/android-libraries/achartengine/src/org/achartengine/chart/package.html
deleted file mode 100644
index 2c5fbec195..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/chart/package.html
+++ /dev/null
@@ -1,6 +0,0 @@
-
-AChartEngine
-
-Provides the classes that handle the actual rendering / drawing of the charts, based on the provided model and renderer.
-
-
\ No newline at end of file
diff --git a/android-libraries/achartengine/src/org/achartengine/image/zoom-1.png b/android-libraries/achartengine/src/org/achartengine/image/zoom-1.png
deleted file mode 100644
index 8265f27840..0000000000
Binary files a/android-libraries/achartengine/src/org/achartengine/image/zoom-1.png and /dev/null differ
diff --git a/android-libraries/achartengine/src/org/achartengine/image/zoom_in.png b/android-libraries/achartengine/src/org/achartengine/image/zoom_in.png
deleted file mode 100644
index 1ac4864d4a..0000000000
Binary files a/android-libraries/achartengine/src/org/achartengine/image/zoom_in.png and /dev/null differ
diff --git a/android-libraries/achartengine/src/org/achartengine/image/zoom_out.png b/android-libraries/achartengine/src/org/achartengine/image/zoom_out.png
deleted file mode 100644
index d67a87de53..0000000000
Binary files a/android-libraries/achartengine/src/org/achartengine/image/zoom_out.png and /dev/null differ
diff --git a/android-libraries/achartengine/src/org/achartengine/model/CategorySeries.java b/android-libraries/achartengine/src/org/achartengine/model/CategorySeries.java
deleted file mode 100644
index ae31c7dda1..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/model/CategorySeries.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.model;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A series for the category charts like the pie ones.
- */
-public class CategorySeries implements Serializable {
- /** The series title. */
- private String mTitle;
- /** The series categories. */
- private List mCategories = new ArrayList();
- /** The series values. */
- private List mValues = new ArrayList();
-
- /**
- * Builds a new category series.
- *
- * @param title the series title
- */
- public CategorySeries(String title) {
- mTitle = title;
- }
-
- /**
- * Returns the series title.
- *
- * @return the series title
- */
- public String getTitle() {
- return mTitle;
- }
-
- /**
- * Adds a new value to the series
- *
- * @param value the new value
- */
- public synchronized void add(double value) {
- add(mCategories.size() + "", value);
- }
-
- /**
- * Adds a new value to the series.
- *
- * @param category the category
- * @param value the new value
- */
- public synchronized void add(String category, double value) {
- mCategories.add(category);
- mValues.add(value);
- }
-
- /**
- * Replaces the value at the specific index in the series.
- *
- * @param index the index in the series
- * @param category the category
- * @param value the new value
- */
- public synchronized void set(int index, String category, double value) {
- mCategories.set(index, category);
- mValues.set(index, value);
- }
-
- /**
- * Removes an existing value from the series.
- *
- * @param index the index in the series of the value to remove
- */
- public synchronized void remove(int index) {
- mCategories.remove(index);
- mValues.remove(index);
- }
-
- /**
- * Removes all the existing values from the series.
- */
- public synchronized void clear() {
- mCategories.clear();
- mValues.clear();
- }
-
- /**
- * Returns the value at the specified index.
- *
- * @param index the index
- * @return the value at the index
- */
- public synchronized double getValue(int index) {
- return mValues.get(index);
- }
-
- /**
- * Returns the category name at the specified index.
- *
- * @param index the index
- * @return the category name at the index
- */
- public synchronized String getCategory(int index) {
- return mCategories.get(index);
- }
-
- /**
- * Returns the series item count.
- *
- * @return the series item count
- */
- public synchronized int getItemCount() {
- return mCategories.size();
- }
-
- /**
- * Transforms the category series to an XY series.
- *
- * @return the XY series
- */
- public XYSeries toXYSeries() {
- XYSeries xySeries = new XYSeries(mTitle);
- int k = 0;
- for (double value : mValues) {
- xySeries.add(++k, value);
- }
- return xySeries;
- }
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/model/MultipleCategorySeries.java b/android-libraries/achartengine/src/org/achartengine/model/MultipleCategorySeries.java
deleted file mode 100644
index 992db4c173..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/model/MultipleCategorySeries.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.model;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A series for the multiple category charts like the doughnut.
- */
-public class MultipleCategorySeries implements Serializable {
- /** The series title. */
- private String mTitle;
- /** The series local keys. */
- private List mCategories = new ArrayList();
- /** The series name. */
- private List mTitles = new ArrayList();
- /** The series values. */
- private List mValues = new ArrayList();
-
- /**
- * Builds a new category series.
- *
- * @param title the series title
- */
- public MultipleCategorySeries(String title) {
- mTitle = title;
- }
-
- /**
- * Adds a new value to the series
- *
- * @param titles the titles to be used as labels
- * @param values the new value
- */
- public void add(String[] titles, double[] values) {
- add(mCategories.size() + "", titles, values);
- }
-
- /**
- * Adds a new value to the series.
- *
- * @param category the category name
- * @param titles the titles to be used as labels
- * @param values the new value
- */
- public void add(String category, String[] titles, double[] values) {
- mCategories.add(category);
- mTitles.add(titles);
- mValues.add(values);
- }
-
- /**
- * Removes an existing value from the series.
- *
- * @param index the index in the series of the value to remove
- */
- public void remove(int index) {
- mCategories.remove(index);
- mTitles.remove(index);
- mValues.remove(index);
- }
-
- /**
- * Removes all the existing values from the series.
- */
- public void clear() {
- mCategories.clear();
- mTitles.clear();
- mValues.clear();
- }
-
- /**
- * Returns the values at the specified index.
- *
- * @param index the index
- * @return the value at the index
- */
- public double[] getValues(int index) {
- return mValues.get(index);
- }
-
- /**
- * Returns the category name at the specified index.
- *
- * @param index the index
- * @return the category name at the index
- */
- public String getCategory(int index) {
- return mCategories.get(index);
- }
-
- /**
- * Returns the categories count.
- *
- * @return the categories count
- */
- public int getCategoriesCount() {
- return mCategories.size();
- }
-
- /**
- * Returns the series item count.
- *
- * @param index the index
- * @return the series item count
- */
- public int getItemCount(int index) {
- return mValues.get(index).length;
- }
-
- /**
- * Returns the series titles.
- *
- * @param index the index
- * @return the series titles
- */
- public String[] getTitles(int index) {
- return mTitles.get(index);
- }
-
- /**
- * Transforms the category series to an XY series.
- *
- * @return the XY series
- */
- public XYSeries toXYSeries() {
- XYSeries xySeries = new XYSeries(mTitle);
- return xySeries;
- }
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/model/Point.java b/android-libraries/achartengine/src/org/achartengine/model/Point.java
deleted file mode 100644
index 4d2767cf8b..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/model/Point.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.model;
-
-import java.io.Serializable;
-
-/**
- * A class to encapsulate the definition of a point.
- */
-public final class Point implements Serializable {
- /** The X axis coordinate value. */
- private float mX;
- /** The Y axis coordinate value. */
- private float mY;
-
- public Point() {
- }
-
- public Point(float x, float y) {
- mX = x;
- mY = y;
- }
-
- public float getX() {
- return mX;
- }
-
- public float getY() {
- return mY;
- }
-
- public void setX(float x) {
- mX = x;
- }
-
- public void setY(float y) {
- mY = y;
- }
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/model/RangeCategorySeries.java b/android-libraries/achartengine/src/org/achartengine/model/RangeCategorySeries.java
deleted file mode 100644
index c004fa1069..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/model/RangeCategorySeries.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.model;
-
-import java.util.ArrayList;
-import java.util.List;
-/**
- * A series for the range category charts like the range bar.
- */
-public class RangeCategorySeries extends CategorySeries {
- /** The series values. */
- private List mMaxValues = new ArrayList();
- /**
- * Builds a new category series.
- *
- * @param title the series title
- */
- public RangeCategorySeries(String title) {
- super(title);
- }
- /**
- * Adds new values to the series
- *
- * @param minValue the new minimum value
- * @param maxValue the new maximum value
- */
- public synchronized void add(double minValue, double maxValue) {
- super.add(minValue);
- mMaxValues.add(maxValue);
- }
-
- /**
- * Adds new values to the series.
- *
- * @param category the category
- * @param minValue the new minimum value
- * @param maxValue the new maximum value
- */
- public synchronized void add(String category, double minValue, double maxValue) {
- super.add(category, minValue);
- mMaxValues.add(maxValue);
- }
-
- /**
- * Removes existing values from the series.
- *
- * @param index the index in the series of the values to remove
- */
- public synchronized void remove(int index) {
- super.remove(index);
- mMaxValues.remove(index);
- }
-
- /**
- * Removes all the existing values from the series.
- */
- public synchronized void clear() {
- super.clear();
- mMaxValues.clear();
- }
-
- /**
- * Returns the minimum value at the specified index.
- *
- * @param index the index
- * @return the minimum value at the index
- */
- public double getMinimumValue(int index) {
- return getValue(index);
- }
-
- /**
- * Returns the maximum value at the specified index.
- *
- * @param index the index
- * @return the maximum value at the index
- */
- public double getMaximumValue(int index) {
- return mMaxValues.get(index);
- }
-
- /**
- * Transforms the range category series to an XY series.
- *
- * @return the XY series
- */
- public XYSeries toXYSeries() {
- XYSeries xySeries = new XYSeries(getTitle());
- int length = getItemCount();
- for (int k = 0; k < length; k++) {
- xySeries.add(k + 1, getMinimumValue(k));
- // the new fast XYSeries implementation doesn't allow 2 values at the same X,
- // so I had to do a hack until I find a better solution
- xySeries.add(k + 1.000001, getMaximumValue(k));
- }
- return xySeries;
- }
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/model/SeriesSelection.java b/android-libraries/achartengine/src/org/achartengine/model/SeriesSelection.java
deleted file mode 100644
index 4319c742bb..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/model/SeriesSelection.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.model;
-
-public class SeriesSelection {
- private int mSeriesIndex;
-
- private int mPointIndex;
-
- private double mXValue;
-
- private double mValue;
-
- public SeriesSelection(int seriesIndex, int pointIndex, double xValue, double value) {
- mSeriesIndex = seriesIndex;
- mPointIndex = pointIndex;
- mXValue = xValue;
- mValue = value;
- }
-
- public int getSeriesIndex() {
- return mSeriesIndex;
- }
-
- public int getPointIndex() {
- return mPointIndex;
- }
-
- public double getXValue() {
- return mXValue;
- }
-
- public double getValue() {
- return mValue;
- }
-}
\ No newline at end of file
diff --git a/android-libraries/achartengine/src/org/achartengine/model/TimeSeries.java b/android-libraries/achartengine/src/org/achartengine/model/TimeSeries.java
deleted file mode 100644
index 6b9a18e5cb..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/model/TimeSeries.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.model;
-
-import java.util.Date;
-
-/**
- * A series for the date / time charts.
- */
-public class TimeSeries extends XYSeries {
-
- /**
- * Builds a new date / time series.
- *
- * @param title the series title
- */
- public TimeSeries(String title) {
- super(title);
- }
-
- /**
- * Adds a new value to the series.
- *
- * @param x the date / time value for the X axis
- * @param y the value for the Y axis
- */
- public synchronized void add(Date x, double y) {
- super.add(x.getTime(), y);
- }
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/model/XYMultipleSeriesDataset.java b/android-libraries/achartengine/src/org/achartengine/model/XYMultipleSeriesDataset.java
deleted file mode 100644
index 6ac6a6defa..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/model/XYMultipleSeriesDataset.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.model;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A series that includes 0 to many XYSeries.
- */
-public class XYMultipleSeriesDataset implements Serializable {
- /** The included series. */
- private List mSeries = new ArrayList();
-
- /**
- * Adds a new XY series to the list.
- *
- * @param series the XY series to ass
- */
- public synchronized void addSeries(XYSeries series) {
- mSeries.add(series);
- }
-
- /**
- * Adds a new XY series to the list.
- *
- * @param index the index in the series list
- * @param series the XY series to ass
- */
- public synchronized void addSeries(int index, XYSeries series) {
- mSeries.add(index, series);
- }
-
- /**
- * Removes the XY series from the list.
- *
- * @param index the index in the series list of the series to remove
- */
- public synchronized void removeSeries(int index) {
- mSeries.remove(index);
- }
-
- /**
- * Removes the XY series from the list.
- *
- * @param series the XY series to be removed
- */
- public synchronized void removeSeries(XYSeries series) {
- mSeries.remove(series);
- }
-
- /**
- * Returns the XY series at the specified index.
- *
- * @param index the index
- * @return the XY series at the index
- */
- public synchronized XYSeries getSeriesAt(int index) {
- return mSeries.get(index);
- }
-
- /**
- * Returns the XY series count.
- *
- * @return the XY series count
- */
- public synchronized int getSeriesCount() {
- return mSeries.size();
- }
-
- /**
- * Returns an array of the XY series.
- *
- * @return the XY series array
- */
- public synchronized XYSeries[] getSeries() {
- return mSeries.toArray(new XYSeries[0]);
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/model/XYSeries.java b/android-libraries/achartengine/src/org/achartengine/model/XYSeries.java
deleted file mode 100644
index 56063b77e4..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/model/XYSeries.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.model;
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.SortedMap;
-
-import org.achartengine.util.IndexXYMap;
-import org.achartengine.util.MathHelper;
-import org.achartengine.util.XYEntry;
-
-/**
- * An XY series encapsulates values for XY charts like line, time, area,
- * scatter... charts.
- */
-public class XYSeries implements Serializable {
- /** The series title. */
- private String mTitle;
- /** A map to contain values for X and Y axes and index for each bundle */
- private final IndexXYMap mXY = new IndexXYMap();
- /** The minimum value for the X axis. */
- private double mMinX = MathHelper.NULL_VALUE;
- /** The maximum value for the X axis. */
- private double mMaxX = -MathHelper.NULL_VALUE;
- /** The minimum value for the Y axis. */
- private double mMinY = MathHelper.NULL_VALUE;
- /** The maximum value for the Y axis. */
- private double mMaxY = -MathHelper.NULL_VALUE;
- /** The scale number for this series. */
- private final int mScaleNumber;
-
- /**
- * Builds a new XY series.
- *
- * @param title the series title.
- */
- public XYSeries(String title) {
- this(title, 0);
- }
-
- /**
- * Builds a new XY series.
- *
- * @param title the series title.
- * @param scaleNumber the series scale number
- */
- public XYSeries(String title, int scaleNumber) {
- mTitle = title;
- mScaleNumber = scaleNumber;
- initRange();
- }
-
- public int getScaleNumber() {
- return mScaleNumber;
- }
-
- /**
- * Initializes the range for both axes.
- */
- private void initRange() {
- mMinX = MathHelper.NULL_VALUE;
- mMaxX = -MathHelper.NULL_VALUE;
- mMinY = MathHelper.NULL_VALUE;
- mMaxY = -MathHelper.NULL_VALUE;
- int length = getItemCount();
- for (int k = 0; k < length; k++) {
- double x = getX(k);
- double y = getY(k);
- updateRange(x, y);
- }
- }
-
- /**
- * Updates the range on both axes.
- *
- * @param x the new x value
- * @param y the new y value
- */
- private void updateRange(double x, double y) {
- mMinX = Math.min(mMinX, x);
- mMaxX = Math.max(mMaxX, x);
- mMinY = Math.min(mMinY, y);
- mMaxY = Math.max(mMaxY, y);
- }
-
- /**
- * Returns the series title.
- *
- * @return the series title
- */
- public String getTitle() {
- return mTitle;
- }
-
- /**
- * Sets the series title.
- *
- * @param title the series title
- */
- public void setTitle(String title) {
- mTitle = title;
- }
-
- /**
- * Adds a new value to the series.
- *
- * @param x the value for the X axis
- * @param y the value for the Y axis
- */
- public synchronized void add(double x, double y) {
- mXY.put(x, y);
- updateRange(x, y);
- }
-
- /**
- * Removes an existing value from the series.
- *
- * @param index the index in the series of the value to remove
- */
- public synchronized void remove(int index) {
- XYEntry removedEntry = mXY.removeByIndex(index);
- double removedX = removedEntry.getKey();
- double removedY = removedEntry.getValue();
- if (removedX == mMinX || removedX == mMaxX || removedY == mMinY || removedY == mMaxY) {
- initRange();
- }
- }
-
- /**
- * Removes all the existing values from the series.
- */
- public synchronized void clear() {
- mXY.clear();
- initRange();
- }
-
- /**
- * Returns the X axis value at the specified index.
- *
- * @param index the index
- * @return the X value
- */
- public synchronized double getX(int index) {
- return mXY.getXByIndex(index);
- }
-
- /**
- * Returns the Y axis value at the specified index.
- *
- * @param index the index
- * @return the Y value
- */
- public synchronized double getY(int index) {
- return mXY.getYByIndex(index);
- }
-
- /**
- * Returns submap of x and y values according to the given start and end
- *
- * @param start start x value
- * @param stop stop x value
- * @return a submap of x and y values
- */
- public synchronized SortedMap getRange(double start, double stop,
- int beforeAfterPoints) {
- // we need to add one point before the start and one point after the end (if
- // there are any)
- // to ensure that line doesn't end before the end of the screen
-
- // this would be simply: start = mXY.lowerKey(start) but NavigableMap is
- // available since API 9
- SortedMap headMap = mXY.headMap(start);
- if (!headMap.isEmpty()) {
- start = headMap.lastKey();
- }
-
- // this would be simply: end = mXY.higherKey(end) but NavigableMap is
- // available since API 9
- // so we have to do this hack in order to support older versions
- SortedMap tailMap = mXY.tailMap(stop);
- if (!tailMap.isEmpty()) {
- Iterator tailIterator = tailMap.keySet().iterator();
- Double next = tailIterator.next();
- if (tailIterator.hasNext()) {
- stop = tailIterator.next();
- } else {
- stop += next;
- }
- }
- return mXY.subMap(start, stop);
- }
-
- public int getIndexForKey(double key) {
- return mXY.getIndexForKey(key);
- }
-
- /**
- * Returns the series item count.
- *
- * @return the series item count
- */
- public synchronized int getItemCount() {
- return mXY.size();
- }
-
- /**
- * Returns the minimum value on the X axis.
- *
- * @return the X axis minimum value
- */
- public double getMinX() {
- return mMinX;
- }
-
- /**
- * Returns the minimum value on the Y axis.
- *
- * @return the Y axis minimum value
- */
- public double getMinY() {
- return mMinY;
- }
-
- /**
- * Returns the maximum value on the X axis.
- *
- * @return the X axis maximum value
- */
- public double getMaxX() {
- return mMaxX;
- }
-
- /**
- * Returns the maximum value on the Y axis.
- *
- * @return the Y axis maximum value
- */
- public double getMaxY() {
- return mMaxY;
- }
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/model/XYValueSeries.java b/android-libraries/achartengine/src/org/achartengine/model/XYValueSeries.java
deleted file mode 100644
index 81aff28b87..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/model/XYValueSeries.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.achartengine.util.MathHelper;
-
-/**
- * An extension of the XY series which adds a third dimension. It is used for XY
- * charts like bubble.
- */
-public class XYValueSeries extends XYSeries {
- /** A list to contain the series values. */
- private List mValue = new ArrayList();
- /** The minimum value. */
- private double mMinValue = MathHelper.NULL_VALUE;
- /** The maximum value. */
- private double mMaxValue = -MathHelper.NULL_VALUE;
-
- /**
- * Builds a new XY value series.
- *
- * @param title the series title.
- */
- public XYValueSeries(String title) {
- super(title);
- }
-
- /**
- * Adds a new value to the series.
- *
- * @param x the value for the X axis
- * @param y the value for the Y axis
- * @param value the value
- */
- public synchronized void add(double x, double y, double value) {
- super.add(x, y);
- mValue.add(value);
- updateRange(value);
- }
-
- /**
- * Initializes the values range.
- */
- private void initRange() {
- mMinValue = MathHelper.NULL_VALUE;
- mMaxValue = MathHelper.NULL_VALUE;
- int length = getItemCount();
- for (int k = 0; k < length; k++) {
- updateRange(getValue(k));
- }
- }
-
- /**
- * Updates the values range.
- *
- * @param value the new value
- */
- private void updateRange(double value) {
- mMinValue = Math.min(mMinValue, value);
- mMaxValue = Math.max(mMaxValue, value);
- }
-
- /**
- * Adds a new value to the series.
- *
- * @param x the value for the X axis
- * @param y the value for the Y axis
- */
- public synchronized void add(double x, double y) {
- add(x, y, 0d);
- }
-
- /**
- * Removes an existing value from the series.
- *
- * @param index the index in the series of the value to remove
- */
- public synchronized void remove(int index) {
- super.remove(index);
- double removedValue = mValue.remove(index);
- if (removedValue == mMinValue || removedValue == mMaxValue) {
- initRange();
- }
- }
-
- /**
- * Removes all the values from the series.
- */
- public synchronized void clear() {
- super.clear();
- mValue.clear();
- initRange();
- }
-
- /**
- * Returns the value at the specified index.
- *
- * @param index the index
- * @return the value
- */
- public synchronized double getValue(int index) {
- return mValue.get(index);
- }
-
- /**
- * Returns the minimum value.
- *
- * @return the minimum value
- */
- public double getMinValue() {
- return mMinValue;
- }
-
- /**
- * Returns the maximum value.
- *
- * @return the maximum value
- */
- public double getMaxValue() {
- return mMaxValue;
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/model/package.html b/android-libraries/achartengine/src/org/achartengine/model/package.html
deleted file mode 100644
index 6135d29c79..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/model/package.html
+++ /dev/null
@@ -1,6 +0,0 @@
-
-AChartEngine
-
-Provides the classes that handle the data values (data model) to be used by displaying the charts.
-
-
\ No newline at end of file
diff --git a/android-libraries/achartengine/src/org/achartengine/package.html b/android-libraries/achartengine/src/org/achartengine/package.html
deleted file mode 100644
index b26cf259eb..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/package.html
+++ /dev/null
@@ -1,6 +0,0 @@
-
-AChartEngine
-
-The main classes, including the ChartFactory, GraphicalActivity and GraphicalView.
-
-
\ No newline at end of file
diff --git a/android-libraries/achartengine/src/org/achartengine/renderer/BasicStroke.java b/android-libraries/achartengine/src/org/achartengine/renderer/BasicStroke.java
deleted file mode 100644
index 3ac93d54ee..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/renderer/BasicStroke.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.renderer;
-
-import java.io.Serializable;
-
-import android.graphics.Paint.Cap;
-import android.graphics.Paint.Join;
-
-/**
- * A descriptor for the stroke style.
- */
-public class BasicStroke implements Serializable {
- /** The solid line style. */
- public static final BasicStroke SOLID = new BasicStroke(Cap.BUTT, Join.MITER, 4, null, 0);
- /** The dashed line style. */
- public static final BasicStroke DASHED = new BasicStroke(Cap.ROUND, Join.BEVEL, 10, new float[] {
- 10, 10 }, 1);
- /** The dot line style. */
- public static final BasicStroke DOTTED = new BasicStroke(Cap.ROUND, Join.BEVEL, 5, new float[] {
- 2, 10 }, 1);
- /** The stroke cap. */
- private Cap mCap;
- /** The stroke join. */
- private Join mJoin;
- /** The stroke miter. */
- private float mMiter;
- /** The path effect intervals. */
- private float[] mIntervals;
- /** The path effect phase. */
- private float mPhase;
-
- /**
- * Build a new basic stroke style.
- *
- * @param cap the stroke cap
- * @param join the stroke join
- * @param miter the stroke miter
- * @param intervals the path effect intervals
- * @param phase the path effect phase
- */
- public BasicStroke(Cap cap, Join join, float miter, float[] intervals, float phase) {
- mCap = cap;
- mJoin = join;
- mMiter = miter;
- mIntervals = intervals;
- }
-
- /**
- * Returns the stroke cap.
- *
- * @return the stroke cap
- */
- public Cap getCap() {
- return mCap;
- }
-
- /**
- * Returns the stroke join.
- *
- * @return the stroke join
- */
- public Join getJoin() {
- return mJoin;
- }
-
- /**
- * Returns the stroke miter.
- *
- * @return the stroke miter
- */
- public float getMiter() {
- return mMiter;
- }
-
- /**
- * Returns the path effect intervals.
- *
- * @return the path effect intervals
- */
- public float[] getIntervals() {
- return mIntervals;
- }
-
- /**
- * Returns the path effect phase.
- *
- * @return the path effect phase
- */
- public float getPhase() {
- return mPhase;
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/renderer/DefaultRenderer.java b/android-libraries/achartengine/src/org/achartengine/renderer/DefaultRenderer.java
deleted file mode 100644
index 4dbb25497a..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/renderer/DefaultRenderer.java
+++ /dev/null
@@ -1,750 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.renderer;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import android.graphics.Color;
-import android.graphics.Typeface;
-
-/**
- * An abstract renderer to be extended by the multiple series classes.
- */
-public class DefaultRenderer implements Serializable {
- /** The chart title. */
- private String mChartTitle = "";
- /** The chart title text size. */
- private float mChartTitleTextSize = 15;
- /** A no color constant. */
- public static final int NO_COLOR = 0;
- /** The default background color. */
- public static final int BACKGROUND_COLOR = Color.BLACK;
- /** The default color for text. */
- public static final int TEXT_COLOR = Color.LTGRAY;
- /** A text font for regular text, like the chart labels. */
- private static final Typeface REGULAR_TEXT_FONT = Typeface
- .create(Typeface.SERIF, Typeface.NORMAL);
- /** The typeface name for the texts. */
- private String mTextTypefaceName = REGULAR_TEXT_FONT.toString();
- /** The typeface style for the texts. */
- private int mTextTypefaceStyle = Typeface.NORMAL;
- /** The chart background color. */
- private int mBackgroundColor;
- /** If the background color is applied. */
- private boolean mApplyBackgroundColor;
- /** If the axes are visible. */
- private boolean mShowAxes = true;
- /** The axes color. */
- private int mAxesColor = TEXT_COLOR;
- /** If the labels are visible. */
- private boolean mShowLabels = true;
- /** The labels color. */
- private int mLabelsColor = TEXT_COLOR;
- /** The labels text size. */
- private float mLabelsTextSize = 10;
- /** If the legend is visible. */
- private boolean mShowLegend = true;
- /** The legend text size. */
- private float mLegendTextSize = 12;
- /** If the legend should size to fit. */
- private boolean mFitLegend = false;
- /** If the X axis grid should be displayed. */
- private boolean mShowGridX = false;
- /** If the Y axis grid should be displayed. */
- private boolean mShowGridY = false;
- /** If the custom text grid should be displayed. */
- private boolean mShowCustomTextGrid = false;
- /** The simple renderers that are included in this multiple series renderer. */
- private List mRenderers = new ArrayList();
- /** The antialiasing flag. */
- private boolean mAntialiasing = true;
- /** The legend height. */
- private int mLegendHeight = 0;
- /** The margins size. */
- private int[] mMargins = new int[] { 20, 30, 10, 20 };
- /** A value to be used for scaling the chart. */
- private float mScale = 1;
- /** A flag for enabling the pan. */
- private boolean mPanEnabled = true;
- /** A flag for enabling the zoom. */
- private boolean mZoomEnabled = true;
- /** A flag for enabling the visibility of the zoom buttons. */
- private boolean mZoomButtonsVisible = false;
- /** The zoom rate. */
- private float mZoomRate = 1.5f;
- /** A flag for enabling the external zoom. */
- private boolean mExternalZoomEnabled = false;
- /** The original chart scale. */
- private float mOriginalScale = mScale;
- /** A flag for enabling the click on elements. */
- private boolean mClickEnabled = false;
- /** The selectable radius around a clickable point. */
- private int selectableBuffer = 15;
- /** If the chart should display the values (available for pie chart). */
- private boolean mDisplayValues;
-
- /**
- * A flag to be set if the chart is inside a scroll and doesn't need to shrink
- * when not enough space.
- */
- private boolean mInScroll;
- /** The start angle for circular charts such as pie, doughnut, etc. */
- private float mStartAngle = 0;
-
- /**
- * Returns the chart title.
- *
- * @return the chart title
- */
- public String getChartTitle() {
- return mChartTitle;
- }
-
- /**
- * Sets the chart title.
- *
- * @param title the chart title
- */
- public void setChartTitle(String title) {
- mChartTitle = title;
- }
-
- /**
- * Returns the chart title text size.
- *
- * @return the chart title text size
- */
- public float getChartTitleTextSize() {
- return mChartTitleTextSize;
- }
-
- /**
- * Sets the chart title text size.
- *
- * @param textSize the chart title text size
- */
- public void setChartTitleTextSize(float textSize) {
- mChartTitleTextSize = textSize;
- }
-
- /**
- * Adds a simple renderer to the multiple renderer.
- *
- * @param renderer the renderer to be added
- */
- public void addSeriesRenderer(SimpleSeriesRenderer renderer) {
- mRenderers.add(renderer);
- }
-
- /**
- * Adds a simple renderer to the multiple renderer.
- *
- * @param index the index in the renderers list
- * @param renderer the renderer to be added
- */
- public void addSeriesRenderer(int index, SimpleSeriesRenderer renderer) {
- mRenderers.add(index, renderer);
- }
-
- /**
- * Removes a simple renderer from the multiple renderer.
- *
- * @param renderer the renderer to be removed
- */
- public void removeSeriesRenderer(SimpleSeriesRenderer renderer) {
- mRenderers.remove(renderer);
- }
-
- /**
- * Removes all renderers from the multiple renderer.
- */
- public void removeAllRenderers() {
- mRenderers.clear();
- }
-
- /**
- * Returns the simple renderer from the multiple renderer list.
- *
- * @param index the index in the simple renderers list
- * @return the simple renderer at the specified index
- */
- public SimpleSeriesRenderer getSeriesRendererAt(int index) {
- return mRenderers.get(index);
- }
-
- /**
- * Returns the simple renderers count in the multiple renderer list.
- *
- * @return the simple renderers count
- */
- public int getSeriesRendererCount() {
- return mRenderers.size();
- }
-
- /**
- * Returns an array of the simple renderers in the multiple renderer list.
- *
- * @return the simple renderers array
- */
- public SimpleSeriesRenderer[] getSeriesRenderers() {
- return mRenderers.toArray(new SimpleSeriesRenderer[0]);
- }
-
- /**
- * Returns the background color.
- *
- * @return the background color
- */
- public int getBackgroundColor() {
- return mBackgroundColor;
- }
-
- /**
- * Sets the background color.
- *
- * @param color the background color
- */
- public void setBackgroundColor(int color) {
- mBackgroundColor = color;
- }
-
- /**
- * Returns if the background color should be applied.
- *
- * @return the apply flag for the background color.
- */
- public boolean isApplyBackgroundColor() {
- return mApplyBackgroundColor;
- }
-
- /**
- * Sets if the background color should be applied.
- *
- * @param apply the apply flag for the background color
- */
- public void setApplyBackgroundColor(boolean apply) {
- mApplyBackgroundColor = apply;
- }
-
- /**
- * Returns the axes color.
- *
- * @return the axes color
- */
- public int getAxesColor() {
- return mAxesColor;
- }
-
- /**
- * Sets the axes color.
- *
- * @param color the axes color
- */
- public void setAxesColor(int color) {
- mAxesColor = color;
- }
-
- /**
- * Returns the labels color.
- *
- * @return the labels color
- */
- public int getLabelsColor() {
- return mLabelsColor;
- }
-
- /**
- * Sets the labels color.
- *
- * @param color the labels color
- */
- public void setLabelsColor(int color) {
- mLabelsColor = color;
- }
-
- /**
- * Returns the labels text size.
- *
- * @return the labels text size
- */
- public float getLabelsTextSize() {
- return mLabelsTextSize;
- }
-
- /**
- * Sets the labels text size.
- *
- * @param textSize the labels text size
- */
- public void setLabelsTextSize(float textSize) {
- mLabelsTextSize = textSize;
- }
-
- /**
- * Returns if the axes should be visible.
- *
- * @return the visibility flag for the axes
- */
- public boolean isShowAxes() {
- return mShowAxes;
- }
-
- /**
- * Sets if the axes should be visible.
- *
- * @param showAxes the visibility flag for the axes
- */
- public void setShowAxes(boolean showAxes) {
- mShowAxes = showAxes;
- }
-
- /**
- * Returns if the labels should be visible.
- *
- * @return the visibility flag for the labels
- */
- public boolean isShowLabels() {
- return mShowLabels;
- }
-
- /**
- * Sets if the labels should be visible.
- *
- * @param showLabels the visibility flag for the labels
- */
- public void setShowLabels(boolean showLabels) {
- mShowLabels = showLabels;
- }
-
- /**
- * Returns if the X axis grid should be visible.
- *
- * @return the visibility flag for the X axis grid
- */
- public boolean isShowGridX() {
- return mShowGridX;
- }
-
- /**
- * Returns if the Y axis grid should be visible.
- *
- * @return the visibility flag for the Y axis grid
- */
- public boolean isShowGridY() {
- return mShowGridY;
- }
-
- /**
- * Sets if the X axis grid should be visible.
- *
- * @param showGrid the visibility flag for the X axis grid
- */
- public void setShowGridX(boolean showGrid) {
- mShowGridX = showGrid;
- }
-
- /**
- * Sets if the Y axis grid should be visible.
- *
- * @param showGrid the visibility flag for the Y axis grid
- */
- public void setShowGridY(boolean showGrid) {
- mShowGridY = showGrid;
- }
-
- /**
- * Sets if the grid should be visible.
- *
- * @param showGrid the visibility flag for the grid
- */
- public void setShowGrid(boolean showGrid) {
- setShowGridX(showGrid);
- setShowGridY(showGrid);
- }
-
- /**
- * Returns if the grid should be visible for custom X or Y labels.
- *
- * @return the visibility flag for the custom text grid
- */
- public boolean isShowCustomTextGrid() {
- return mShowCustomTextGrid;
- }
-
- /**
- * Sets if the grid for custom X or Y labels should be visible.
- *
- * @param showGrid the visibility flag for the custom text grid
- */
- public void setShowCustomTextGrid(boolean showGrid) {
- mShowCustomTextGrid = showGrid;
- }
-
- /**
- * Returns if the legend should be visible.
- *
- * @return the visibility flag for the legend
- */
- public boolean isShowLegend() {
- return mShowLegend;
- }
-
- /**
- * Sets if the legend should be visible.
- *
- * @param showLegend the visibility flag for the legend
- */
- public void setShowLegend(boolean showLegend) {
- mShowLegend = showLegend;
- }
-
- /**
- * Returns if the legend should size to fit.
- *
- * @return the fit behavior
- */
- public boolean isFitLegend() {
- return mFitLegend;
- }
-
- /**
- * Sets if the legend should size to fit.
- *
- * @param fit the fit behavior
- */
- public void setFitLegend(boolean fit) {
- mFitLegend = fit;
- }
-
- /**
- * Returns the text typeface name.
- *
- * @return the text typeface name
- */
- public String getTextTypefaceName() {
- return mTextTypefaceName;
- }
-
- /**
- * Returns the text typeface style.
- *
- * @return the text typeface style
- */
- public int getTextTypefaceStyle() {
- return mTextTypefaceStyle;
- }
-
- /**
- * Returns the legend text size.
- *
- * @return the legend text size
- */
- public float getLegendTextSize() {
- return mLegendTextSize;
- }
-
- /**
- * Sets the legend text size.
- *
- * @param textSize the legend text size
- */
- public void setLegendTextSize(float textSize) {
- mLegendTextSize = textSize;
- }
-
- /**
- * Sets the text typeface name and style.
- *
- * @param typefaceName the text typeface name
- * @param style the text typeface style
- */
- public void setTextTypeface(String typefaceName, int style) {
- mTextTypefaceName = typefaceName;
- mTextTypefaceStyle = style;
- }
-
- /**
- * Returns the antialiasing flag value.
- *
- * @return the antialiasing value
- */
- public boolean isAntialiasing() {
- return mAntialiasing;
- }
-
- /**
- * Sets the antialiasing value.
- *
- * @param antialiasing the antialiasing
- */
- public void setAntialiasing(boolean antialiasing) {
- mAntialiasing = antialiasing;
- }
-
- /**
- * Returns the value to be used for scaling the chart.
- *
- * @return the scale value
- */
- public float getScale() {
- return mScale;
- }
-
- /**
- * Returns the original value to be used for scaling the chart.
- *
- * @return the original scale value
- */
- public float getOriginalScale() {
- return mOriginalScale;
- }
-
- /**
- * Sets the value to be used for scaling the chart. It works on some charts
- * like pie, doughnut, dial.
- *
- * @param scale the scale value
- */
- public void setScale(float scale) {
- mScale = scale;
- }
-
- /**
- * Returns the enabled state of the zoom.
- *
- * @return if zoom is enabled
- */
- public boolean isZoomEnabled() {
- return mZoomEnabled;
- }
-
- /**
- * Sets the enabled state of the zoom.
- *
- * @param enabled zoom enabled
- */
- public void setZoomEnabled(boolean enabled) {
- mZoomEnabled = enabled;
- }
-
- /**
- * Returns the visible state of the zoom buttons.
- *
- * @return if zoom buttons are visible
- */
- public boolean isZoomButtonsVisible() {
- return mZoomButtonsVisible;
- }
-
- /**
- * Sets the visible state of the zoom buttons.
- *
- * @param visible if the zoom buttons are visible
- */
- public void setZoomButtonsVisible(boolean visible) {
- mZoomButtonsVisible = visible;
- }
-
- /**
- * Returns the enabled state of the external (application implemented) zoom.
- *
- * @return if external zoom is enabled
- */
- public boolean isExternalZoomEnabled() {
- return mExternalZoomEnabled;
- }
-
- /**
- * Sets the enabled state of the external (application implemented) zoom.
- *
- * @param enabled external zoom enabled
- */
- public void setExternalZoomEnabled(boolean enabled) {
- mExternalZoomEnabled = enabled;
- }
-
- /**
- * Returns the zoom rate.
- *
- * @return the zoom rate
- */
- public float getZoomRate() {
- return mZoomRate;
- }
-
- /**
- * Returns the enabled state of the pan.
- *
- * @return if pan is enabled
- */
- public boolean isPanEnabled() {
- return mPanEnabled;
- }
-
- /**
- * Sets the enabled state of the pan.
- *
- * @param enabled pan enabled
- */
- public void setPanEnabled(boolean enabled) {
- mPanEnabled = enabled;
- }
-
- /**
- * Sets the zoom rate.
- *
- * @param rate the zoom rate
- */
- public void setZoomRate(float rate) {
- mZoomRate = rate;
- }
-
- /**
- * Returns the enabled state of the click.
- *
- * @return if click is enabled
- */
- public boolean isClickEnabled() {
- return mClickEnabled;
- }
-
- /**
- * Sets the enabled state of the click.
- *
- * @param enabled click enabled
- */
- public void setClickEnabled(boolean enabled) {
- mClickEnabled = enabled;
- }
-
- /**
- * Returns the selectable radius value around clickable points.
- *
- * @return the selectable radius
- */
- public int getSelectableBuffer() {
- return selectableBuffer;
- }
-
- /**
- * Sets the selectable radius value around clickable points.
- *
- * @param buffer the selectable radius
- */
- public void setSelectableBuffer(int buffer) {
- selectableBuffer = buffer;
- }
-
- /**
- * Returns the legend height.
- *
- * @return the legend height
- */
- public int getLegendHeight() {
- return mLegendHeight;
- }
-
- /**
- * Sets the legend height, in pixels.
- *
- * @param height the legend height
- */
- public void setLegendHeight(int height) {
- mLegendHeight = height;
- }
-
- /**
- * Returns the margin sizes. An array containing the margins in this order:
- * top, left, bottom, right
- *
- * @return the margin sizes
- */
- public int[] getMargins() {
- return mMargins;
- }
-
- /**
- * Sets the margins, in pixels.
- *
- * @param margins an array containing the margin size values, in this order:
- * top, left, bottom, right
- */
- public void setMargins(int[] margins) {
- mMargins = margins;
- }
-
- /**
- * Returns if the chart is inside a scroll view and doesn't need to shrink.
- *
- * @return if it is inside a scroll view
- */
- public boolean isInScroll() {
- return mInScroll;
- }
-
- /**
- * To be set if the chart is inside a scroll view and doesn't need to shrink
- * when not enough space.
- *
- * @param inScroll if it is inside a scroll view
- */
- public void setInScroll(boolean inScroll) {
- mInScroll = inScroll;
- }
-
- /**
- * Returns the start angle for circular charts such as pie, doughnut. An angle
- * of 0 degrees correspond to the geometric angle of 0 degrees (3 o'clock on a
- * watch.)
- *
- * @return the start angle in degrees
- */
- public float getStartAngle() {
- return mStartAngle;
- }
-
- /**
- * Sets the start angle for circular charts such as pie, doughnut, etc. An
- * angle of 0 degrees correspond to the geometric angle of 0 degrees (3
- * o'clock on a watch.)
- *
- * @param startAngle the start angle in degrees
- */
- public void setStartAngle(float startAngle) {
- mStartAngle = startAngle;
- }
-
- /**
- * Returns if the values should be displayed as text.
- *
- * @return if the values should be displayed as text
- */
- public boolean isDisplayValues() {
- return mDisplayValues;
- }
-
- /**
- * Sets if the values should be displayed as text (supported by pie chart).
- *
- * @param display if the values should be displayed as text
- */
- public void setDisplayValues(boolean display) {
- mDisplayValues = display;
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/renderer/DialRenderer.java b/android-libraries/achartengine/src/org/achartengine/renderer/DialRenderer.java
deleted file mode 100644
index 1ed84619d6..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/renderer/DialRenderer.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.renderer;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.achartengine.util.MathHelper;
-
-/**
- * Dial chart renderer.
- */
-public class DialRenderer extends DefaultRenderer {
- /** The start angle in the dial range. */
- private double mAngleMin = 330;
- /** The end angle in the dial range. */
- private double mAngleMax = 30;
- /** The start value in dial range. */
- private double mMinValue = MathHelper.NULL_VALUE;
- /** The end value in dial range. */
- private double mMaxValue = -MathHelper.NULL_VALUE;
- /** The spacing for the minor ticks. */
- private double mMinorTickSpacing = MathHelper.NULL_VALUE;
- /** The spacing for the major ticks. */
- private double mMajorTickSpacing = MathHelper.NULL_VALUE;
- /** An array of the renderers types (default is NEEDLE). */
- private List mVisualTypes = new ArrayList();
-
- public enum Type {
- NEEDLE, ARROW;
- }
-
- /**
- * Returns the start angle value of the dial.
- *
- * @return the angle start value
- */
- public double getAngleMin() {
- return mAngleMin;
- }
-
- /**
- * Sets the start angle value of the dial.
- *
- * @param min the dial angle start value
- */
- public void setAngleMin(double min) {
- mAngleMin = min;
- }
-
- /**
- * Returns the end angle value of the dial.
- *
- * @return the angle end value
- */
- public double getAngleMax() {
- return mAngleMax;
- }
-
- /**
- * Sets the end angle value of the dial.
- *
- * @param max the dial angle end value
- */
- public void setAngleMax(double max) {
- mAngleMax = max;
- }
-
- /**
- * Returns the start value to be rendered on the dial.
- *
- * @return the start value on dial
- */
- public double getMinValue() {
- return mMinValue;
- }
-
- /**
- * Sets the start value to be rendered on the dial.
- *
- * @param min the start value on the dial
- */
- public void setMinValue(double min) {
- mMinValue = min;
- }
-
- /**
- * Returns if the minimum dial value was set.
- *
- * @return the minimum dial value was set or not
- */
- public boolean isMinValueSet() {
- return mMinValue != MathHelper.NULL_VALUE;
- }
-
- /**
- * Returns the end value to be rendered on the dial.
- *
- * @return the end value on the dial
- */
- public double getMaxValue() {
- return mMaxValue;
- }
-
- /**
- * Sets the end value to be rendered on the dial.
- *
- * @param max the end value on the dial
- */
- public void setMaxValue(double max) {
- mMaxValue = max;
- }
-
- /**
- * Returns if the maximum dial value was set.
- *
- * @return the maximum dial was set or not
- */
- public boolean isMaxValueSet() {
- return mMaxValue != -MathHelper.NULL_VALUE;
- }
-
- /**
- * Returns the minor ticks spacing.
- *
- * @return the minor ticks spacing
- */
- public double getMinorTicksSpacing() {
- return mMinorTickSpacing;
- }
-
- /**
- * Sets the minor ticks spacing.
- *
- * @param spacing the minor ticks spacing
- */
- public void setMinorTicksSpacing(double spacing) {
- mMinorTickSpacing = spacing;
- }
-
- /**
- * Returns the major ticks spacing.
- *
- * @return the major ticks spacing
- */
- public double getMajorTicksSpacing() {
- return mMajorTickSpacing;
- }
-
- /**
- * Sets the major ticks spacing.
- *
- * @param spacing the major ticks spacing
- */
- public void setMajorTicksSpacing(double spacing) {
- mMajorTickSpacing = spacing;
- }
-
- /**
- * Returns the visual type at the specified index.
- *
- * @param index the index
- * @return the visual type
- */
- public Type getVisualTypeForIndex(int index) {
- if (index < mVisualTypes.size()) {
- return mVisualTypes.get(index);
- }
- return Type.NEEDLE;
- }
-
- /**
- * Sets the visual types.
- *
- * @param types the visual types
- */
- public void setVisualTypes(Type[] types) {
- mVisualTypes.clear();
- mVisualTypes.addAll(Arrays.asList(types));
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/renderer/SimpleSeriesRenderer.java b/android-libraries/achartengine/src/org/achartengine/renderer/SimpleSeriesRenderer.java
deleted file mode 100644
index 0763fc58ef..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/renderer/SimpleSeriesRenderer.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.renderer;
-
-import java.io.Serializable;
-
-import android.graphics.Color;
-import android.graphics.Paint.Align;
-
-/**
- * A simple series renderer.
- */
-public class SimpleSeriesRenderer implements Serializable {
- /** The series color. */
- private int mColor = Color.BLUE;
- /** If the values should be displayed above the chart points. */
- private boolean mDisplayChartValues;
- /** The chart values text size. */
- private float mChartValuesTextSize = 10;
- /** The chart values text alignment. */
- private Align mChartValuesTextAlign = Align.CENTER;
- /** The chart values spacing from the data point. */
- private float mChartValuesSpacing = 5f;
- /** The stroke style. */
- private BasicStroke mStroke;
- /** If gradient is enabled. */
- private boolean mGradientEnabled = false;
- /** The gradient start value. */
- private double mGradientStartValue;
- /** The gradient start color. */
- private int mGradientStartColor;
- /** The gradient stop value. */
- private double mGradientStopValue;
- /** The gradient stop color. */
- private int mGradientStopColor;
-
- /**
- * Returns the series color.
- *
- * @return the series color
- */
- public int getColor() {
- return mColor;
- }
-
- /**
- * Sets the series color.
- *
- * @param color the series color
- */
- public void setColor(int color) {
- mColor = color;
- }
-
- /**
- * Returns if the chart point values should be displayed as text.
- *
- * @return if the chart point values should be displayed as text
- */
- public boolean isDisplayChartValues() {
- return mDisplayChartValues;
- }
-
- /**
- * Sets if the chart point values should be displayed as text.
- *
- * @param display if the chart point values should be displayed as text
- */
- public void setDisplayChartValues(boolean display) {
- mDisplayChartValues = display;
- }
-
- /**
- * Returns the chart values text size.
- *
- * @return the chart values text size
- */
- public float getChartValuesTextSize() {
- return mChartValuesTextSize;
- }
-
- /**
- * Sets the chart values text size.
- *
- * @param textSize the chart values text size
- */
- public void setChartValuesTextSize(float textSize) {
- mChartValuesTextSize = textSize;
- }
-
- /**
- * Returns the chart values text align.
- *
- * @return the chart values text align
- */
- public Align getChartValuesTextAlign() {
- return mChartValuesTextAlign;
- }
-
- /**
- * Sets the chart values text align.
- *
- * @param align the chart values text align
- */
- public void setChartValuesTextAlign(Align align) {
- mChartValuesTextAlign = align;
- }
-
- /**
- * Returns the chart values spacing from the data point.
- *
- * @return the chart values spacing
- */
- public float getChartValuesSpacing() {
- return mChartValuesSpacing;
- }
-
- /**
- * Sets the chart values spacing from the data point.
- *
- * @param spacing the chart values spacing (in pixels) from the chart data
- * point
- */
- public void setChartValuesSpacing(float spacing) {
- mChartValuesSpacing = spacing;
- }
-
- /**
- * Returns the stroke style.
- *
- * @return the stroke style
- */
- public BasicStroke getStroke() {
- return mStroke;
- }
-
- /**
- * Sets the stroke style.
- *
- * @param stroke the stroke style
- */
- public void setStroke(BasicStroke stroke) {
- mStroke = stroke;
- }
-
- /**
- * Returns the gradient is enabled value.
- *
- * @return the gradient enabled
- */
- public boolean isGradientEnabled() {
- return mGradientEnabled;
- }
-
- /**
- * Sets the gradient enabled value.
- *
- * @param enabled the gradient enabled
- */
- public void setGradientEnabled(boolean enabled) {
- mGradientEnabled = enabled;
- }
-
- /**
- * Returns the gradient start value.
- *
- * @return the gradient start value
- */
- public double getGradientStartValue() {
- return mGradientStartValue;
- }
-
- /**
- * Returns the gradient start color.
- *
- * @return the gradient start color
- */
- public int getGradientStartColor() {
- return mGradientStartColor;
- }
-
- /**
- * Sets the gradient start value and color.
- *
- * @param start the gradient start value
- * @param color the gradient start color
- */
- public void setGradientStart(double start, int color) {
- mGradientStartValue = start;
- mGradientStartColor = color;
- }
-
- /**
- * Returns the gradient stop value.
- *
- * @return the gradient stop value
- */
- public double getGradientStopValue() {
- return mGradientStopValue;
- }
-
- /**
- * Returns the gradient stop color.
- *
- * @return the gradient stop color
- */
- public int getGradientStopColor() {
- return mGradientStopColor;
- }
-
- /**
- * Sets the gradient stop value and color.
- *
- * @param start the gradient stop value
- * @param color the gradient stop color
- */
- public void setGradientStop(double start, int color) {
- mGradientStopValue = start;
- mGradientStopColor = color;
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/renderer/XYMultipleSeriesRenderer.java b/android-libraries/achartengine/src/org/achartengine/renderer/XYMultipleSeriesRenderer.java
deleted file mode 100644
index 64b3421172..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/renderer/XYMultipleSeriesRenderer.java
+++ /dev/null
@@ -1,1101 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.renderer;
-
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.achartengine.util.MathHelper;
-
-import android.graphics.Color;
-import android.graphics.Paint.Align;
-
-/**
- * Multiple XY series renderer.
- */
-public class XYMultipleSeriesRenderer extends DefaultRenderer {
- /** The X axis title. */
- private String mXTitle = "";
- /** The Y axis title. */
- private String[] mYTitle;
- /** The axis title text size. */
- private float mAxisTitleTextSize = 12;
- /** The start value in the X axis range. */
- private double[] mMinX;
- /** The end value in the X axis range. */
- private double[] mMaxX;
- /** The start value in the Y axis range. */
- private double[] mMinY;
- /** The end value in the Y axis range. */
- private double[] mMaxY;
- /** The approximative number of labels on the x axis. */
- private int mXLabels = 5;
- /** The approximative number of labels on the y axis. */
- private int mYLabels = 5;
- /** The current orientation of the chart. */
- private Orientation mOrientation = Orientation.HORIZONTAL;
- /** The X axis text labels. */
- private Map mXTextLabels = new HashMap();
- /** The Y axis text labels. */
- private Map> mYTextLabels = new LinkedHashMap>();
- /** A flag for enabling or not the pan on the X axis. */
- private boolean mPanXEnabled = true;
- /** A flag for enabling or not the pan on the Y axis. */
- private boolean mPanYEnabled = true;
- /** A flag for enabling or not the zoom on the X axis. */
- private boolean mZoomXEnabled = true;
- /** A flag for enabling or not the zoom on the Y axis . */
- private boolean mZoomYEnabled = true;
- /** The spacing between bars, in bar charts. */
- private double mBarSpacing = 0;
- /** The margins colors. */
- private int mMarginsColor = NO_COLOR;
- /** The pan limits. */
- private double[] mPanLimits;
- /** The zoom limits. */
- private double[] mZoomLimits;
- /** The X axis labels rotation angle. */
- private float mXLabelsAngle;
- /** The Y axis labels rotation angle. */
- private float mYLabelsAngle;
- /** The initial axis range. */
- private Map initialRange = new LinkedHashMap();
- /** The point size for charts displaying points. */
- private float mPointSize = 3;
- /** The grid color. */
- private int mGridColor = Color.argb(75, 200, 200, 200);
- /** The number of scales. */
- private int scalesCount;
- /** The X axis labels alignment. */
- private Align xLabelsAlign = Align.CENTER;
- /** The Y axis labels alignment. */
- private Align[] yLabelsAlign;
- /** The Y axis alignment. */
- private Align[] yAxisAlign;
- /** The X axis labels color. */
- private int mXLabelsColor = TEXT_COLOR;
- /** The Y axis labels color. */
- private int[] mYLabelsColor = new int[] { TEXT_COLOR };
- /**
- * If X axis value selection algorithm to be used. Only used by the time
- * charts.
- */
- private boolean mXRoundedLabels = true;
-
- /**
- * An enum for the XY chart orientation of the X axis.
- */
- public enum Orientation {
- HORIZONTAL(0), VERTICAL(90);
- /** The rotate angle. */
- private int mAngle = 0;
-
- private Orientation(int angle) {
- mAngle = angle;
- }
-
- /**
- * Return the orientation rotate angle.
- *
- * @return the orientaion rotate angle
- */
- public int getAngle() {
- return mAngle;
- }
- }
-
- public XYMultipleSeriesRenderer() {
- this(1);
- }
-
- public XYMultipleSeriesRenderer(int scaleNumber) {
- scalesCount = scaleNumber;
- initAxesRange(scaleNumber);
- }
-
- public void initAxesRange(int scales) {
- mYTitle = new String[scales];
- yLabelsAlign = new Align[scales];
- yAxisAlign = new Align[scales];
- mYLabelsColor = new int[scales];
- mMinX = new double[scales];
- mMaxX = new double[scales];
- mMinY = new double[scales];
- mMaxY = new double[scales];
- for (int i = 0; i < scales; i++) {
- mYLabelsColor[i] = TEXT_COLOR;
- initAxesRangeForScale(i);
- }
- }
-
- public void initAxesRangeForScale(int i) {
- mMinX[i] = MathHelper.NULL_VALUE;
- mMaxX[i] = -MathHelper.NULL_VALUE;
- mMinY[i] = MathHelper.NULL_VALUE;
- mMaxY[i] = -MathHelper.NULL_VALUE;
- double[] range = new double[] { mMinX[i], mMaxX[i], mMinY[i], mMaxY[i] };
- initialRange.put(i, range);
- mYTitle[i] = "";
- mYTextLabels.put(i, new HashMap());
- yLabelsAlign[i] = Align.CENTER;
- yAxisAlign[i] = Align.LEFT;
- }
-
- /**
- * Returns the current orientation of the chart X axis.
- *
- * @return the chart orientation
- */
- public Orientation getOrientation() {
- return mOrientation;
- }
-
- /**
- * Sets the current orientation of the chart X axis.
- *
- * @param orientation the chart orientation
- */
- public void setOrientation(Orientation orientation) {
- mOrientation = orientation;
- }
-
- /**
- * Returns the title for the X axis.
- *
- * @return the X axis title
- */
- public String getXTitle() {
- return mXTitle;
- }
-
- /**
- * Sets the title for the X axis.
- *
- * @param title the X axis title
- */
- public void setXTitle(String title) {
- mXTitle = title;
- }
-
- /**
- * Returns the title for the Y axis.
- *
- * @return the Y axis title
- */
- public String getYTitle() {
- return getYTitle(0);
- }
-
- /**
- * Returns the title for the Y axis.
- *
- * @param scale the renderer scale
- * @return the Y axis title
- */
- public String getYTitle(int scale) {
- return mYTitle[scale];
- }
-
- /**
- * Sets the title for the Y axis.
- *
- * @param title the Y axis title
- */
- public void setYTitle(String title) {
- setYTitle(title, 0);
- }
-
- /**
- * Sets the title for the Y axis.
- *
- * @param title the Y axis title
- * @param scale the renderer scale
- */
- public void setYTitle(String title, int scale) {
- mYTitle[scale] = title;
- }
-
- /**
- * Returns the axis title text size.
- *
- * @return the axis title text size
- */
- public float getAxisTitleTextSize() {
- return mAxisTitleTextSize;
- }
-
- /**
- * Sets the axis title text size.
- *
- * @param textSize the chart axis text size
- */
- public void setAxisTitleTextSize(float textSize) {
- mAxisTitleTextSize = textSize;
- }
-
- /**
- * Returns the start value of the X axis range.
- *
- * @return the X axis range start value
- */
- public double getXAxisMin() {
- return getXAxisMin(0);
- }
-
- /**
- * Sets the start value of the X axis range.
- *
- * @param min the X axis range start value
- */
- public void setXAxisMin(double min) {
- setXAxisMin(min, 0);
- }
-
- /**
- * Returns if the minimum X value was set.
- *
- * @return the minX was set or not
- */
- public boolean isMinXSet() {
- return isMinXSet(0);
- }
-
- /**
- * Returns the end value of the X axis range.
- *
- * @return the X axis range end value
- */
- public double getXAxisMax() {
- return getXAxisMax(0);
- }
-
- /**
- * Sets the end value of the X axis range.
- *
- * @param max the X axis range end value
- */
- public void setXAxisMax(double max) {
- setXAxisMax(max, 0);
- }
-
- /**
- * Returns if the maximum X value was set.
- *
- * @return the maxX was set or not
- */
- public boolean isMaxXSet() {
- return isMaxXSet(0);
- }
-
- /**
- * Returns the start value of the Y axis range.
- *
- * @return the Y axis range end value
- */
- public double getYAxisMin() {
- return getYAxisMin(0);
- }
-
- /**
- * Sets the start value of the Y axis range.
- *
- * @param min the Y axis range start value
- */
- public void setYAxisMin(double min) {
- setYAxisMin(min, 0);
- }
-
- /**
- * Returns if the minimum Y value was set.
- *
- * @return the minY was set or not
- */
- public boolean isMinYSet() {
- return isMinYSet(0);
- }
-
- /**
- * Returns the end value of the Y axis range.
- *
- * @return the Y axis range end value
- */
- public double getYAxisMax() {
- return getYAxisMax(0);
- }
-
- /**
- * Sets the end value of the Y axis range.
- *
- * @param max the Y axis range end value
- */
- public void setYAxisMax(double max) {
- setYAxisMax(max, 0);
- }
-
- /**
- * Returns if the maximum Y value was set.
- *
- * @return the maxY was set or not
- */
- public boolean isMaxYSet() {
- return isMaxYSet(0);
- }
-
- /**
- * Returns the start value of the X axis range.
- *
- * @param scale the renderer scale
- * @return the X axis range start value
- */
- public double getXAxisMin(int scale) {
- return mMinX[scale];
- }
-
- /**
- * Sets the start value of the X axis range.
- *
- * @param min the X axis range start value
- * @param scale the renderer scale
- */
- public void setXAxisMin(double min, int scale) {
- if (!isMinXSet(scale)) {
- initialRange.get(scale)[0] = min;
- }
- mMinX[scale] = min;
- }
-
- /**
- * Returns if the minimum X value was set.
- *
- * @param scale the renderer scale
- * @return the minX was set or not
- */
- public boolean isMinXSet(int scale) {
- return mMinX[scale] != MathHelper.NULL_VALUE;
- }
-
- /**
- * Returns the end value of the X axis range.
- *
- * @param scale the renderer scale
- * @return the X axis range end value
- */
- public double getXAxisMax(int scale) {
- return mMaxX[scale];
- }
-
- /**
- * Sets the end value of the X axis range.
- *
- * @param max the X axis range end value
- * @param scale the renderer scale
- */
- public void setXAxisMax(double max, int scale) {
- if (!isMaxXSet(scale)) {
- initialRange.get(scale)[1] = max;
- }
- mMaxX[scale] = max;
- }
-
- /**
- * Returns if the maximum X value was set.
- *
- * @param scale the renderer scale
- * @return the maxX was set or not
- */
- public boolean isMaxXSet(int scale) {
- return mMaxX[scale] != -MathHelper.NULL_VALUE;
- }
-
- /**
- * Returns the start value of the Y axis range.
- *
- * @param scale the renderer scale
- * @return the Y axis range end value
- */
- public double getYAxisMin(int scale) {
- return mMinY[scale];
- }
-
- /**
- * Sets the start value of the Y axis range.
- *
- * @param min the Y axis range start value
- * @param scale the renderer scale
- */
- public void setYAxisMin(double min, int scale) {
- if (!isMinYSet(scale)) {
- initialRange.get(scale)[2] = min;
- }
- mMinY[scale] = min;
- }
-
- /**
- * Returns if the minimum Y value was set.
- *
- * @param scale the renderer scale
- * @return the minY was set or not
- */
- public boolean isMinYSet(int scale) {
- return mMinY[scale] != MathHelper.NULL_VALUE;
- }
-
- /**
- * Returns the end value of the Y axis range.
- *
- * @param scale the renderer scale
- * @return the Y axis range end value
- */
- public double getYAxisMax(int scale) {
- return mMaxY[scale];
- }
-
- /**
- * Sets the end value of the Y axis range.
- *
- * @param max the Y axis range end value
- * @param scale the renderer scale
- */
- public void setYAxisMax(double max, int scale) {
- if (!isMaxYSet(scale)) {
- initialRange.get(scale)[3] = max;
- }
- mMaxY[scale] = max;
- }
-
- /**
- * Returns if the maximum Y value was set.
- *
- * @param scale the renderer scale
- * @return the maxY was set or not
- */
- public boolean isMaxYSet(int scale) {
- return mMaxY[scale] != -MathHelper.NULL_VALUE;
- }
-
- /**
- * Returns the approximate number of labels for the X axis.
- *
- * @return the approximate number of labels for the X axis
- */
- public int getXLabels() {
- return mXLabels;
- }
-
- /**
- * Sets the approximate number of labels for the X axis.
- *
- * @param xLabels the approximate number of labels for the X axis
- */
- public void setXLabels(int xLabels) {
- mXLabels = xLabels;
- }
-
- /**
- * Adds a new text label for the specified X axis value.
- *
- * @param x the X axis value
- * @param text the text label
- * @deprecated use addXTextLabel instead
- */
- public void addTextLabel(double x, String text) {
- addXTextLabel(x, text);
- }
-
- /**
- * Adds a new text label for the specified X axis value.
- *
- * @param x the X axis value
- * @param text the text label
- */
- public void addXTextLabel(double x, String text) {
- mXTextLabels.put(x, text);
- }
-
- /**
- * Returns the X axis text label at the specified X axis value.
- *
- * @param x the X axis value
- * @return the X axis text label
- */
- public String getXTextLabel(Double x) {
- return mXTextLabels.get(x);
- }
-
- /**
- * Returns the X text label locations.
- *
- * @return the X text label locations
- */
- public Double[] getXTextLabelLocations() {
- return mXTextLabels.keySet().toArray(new Double[0]);
- }
-
- /**
- * Clears the existing text labels.
- *
- * @deprecated use clearXTextLabels instead
- */
- public void clearTextLabels() {
- clearXTextLabels();
- }
-
- /**
- * Clears the existing text labels on the X axis.
- */
- public void clearXTextLabels() {
- mXTextLabels.clear();
- }
-
- /**
- * If X axis labels should be rounded.
- *
- * @return if rounded time values to be used
- */
- public boolean isXRoundedLabels() {
- return mXRoundedLabels;
- }
-
- /**
- * Sets if X axis rounded time values to be used.
- *
- * @param rounded rounded values to be used
- */
- public void setXRoundedLabels(boolean rounded) {
- mXRoundedLabels = rounded;
- }
-
- /**
- * Adds a new text label for the specified Y axis value.
- *
- * @param y the Y axis value
- * @param text the text label
- */
- public void addYTextLabel(double y, String text) {
- addYTextLabel(y, text, 0);
- }
-
- /**
- * Adds a new text label for the specified Y axis value.
- *
- * @param y the Y axis value
- * @param text the text label
- * @param scale the renderer scale
- */
- public void addYTextLabel(double y, String text, int scale) {
- mYTextLabels.get(scale).put(y, text);
- }
-
- /**
- * Returns the Y axis text label at the specified Y axis value.
- *
- * @param y the Y axis value
- * @return the Y axis text label
- */
- public String getYTextLabel(Double y) {
- return getYTextLabel(y, 0);
- }
-
- /**
- * Returns the Y axis text label at the specified Y axis value.
- *
- * @param y the Y axis value
- * @param scale the renderer scale
- * @return the Y axis text label
- */
- public String getYTextLabel(Double y, int scale) {
- return mYTextLabels.get(scale).get(y);
- }
-
- /**
- * Returns the Y text label locations.
- *
- * @return the Y text label locations
- */
- public Double[] getYTextLabelLocations() {
- return getYTextLabelLocations(0);
- }
-
- /**
- * Returns the Y text label locations.
- *
- * @param scale the renderer scale
- * @return the Y text label locations
- */
- public Double[] getYTextLabelLocations(int scale) {
- return mYTextLabels.get(scale).keySet().toArray(new Double[0]);
- }
-
- /**
- * Clears the existing text labels on the Y axis.
- */
- public void clearYTextLabels() {
- clearYTextLabels(0);
- }
-
- /**
- * Clears the existing text labels on the Y axis.
- *
- * @param scale the renderer scale
- */
- public void clearYTextLabels(int scale) {
- mYTextLabels.get(scale).clear();
- }
-
- /**
- * Returns the approximate number of labels for the Y axis.
- *
- * @return the approximate number of labels for the Y axis
- */
- public int getYLabels() {
- return mYLabels;
- }
-
- /**
- * Sets the approximate number of labels for the Y axis.
- *
- * @param yLabels the approximate number of labels for the Y axis
- */
- public void setYLabels(int yLabels) {
- mYLabels = yLabels;
- }
-
- /**
- * Sets if the chart point values should be displayed as text.
- *
- * @param display if the chart point values should be displayed as text
- * @deprecated use SimpleSeriesRenderer.setDisplayChartValues() instead
- */
- public void setDisplayChartValues(boolean display) {
- SimpleSeriesRenderer[] renderers = getSeriesRenderers();
- for (SimpleSeriesRenderer renderer : renderers) {
- renderer.setDisplayChartValues(display);
- }
- }
-
- /**
- * Sets the chart values text size.
- *
- * @param textSize the chart values text size
- * @deprecated use SimpleSeriesRenderer.setChartValuesTextSize() instead
- */
- public void setChartValuesTextSize(float textSize) {
- SimpleSeriesRenderer[] renderers = getSeriesRenderers();
- for (SimpleSeriesRenderer renderer : renderers) {
- renderer.setChartValuesTextSize(textSize);
- }
- }
-
- /**
- * Returns the enabled state of the pan on at least one axis.
- *
- * @return if pan is enabled
- */
- public boolean isPanEnabled() {
- return isPanXEnabled() || isPanYEnabled();
- }
-
- /**
- * Returns the enabled state of the pan on X axis.
- *
- * @return if pan is enabled on X axis
- */
- public boolean isPanXEnabled() {
- return mPanXEnabled;
- }
-
- /**
- * Returns the enabled state of the pan on Y axis.
- *
- * @return if pan is enabled on Y axis
- */
- public boolean isPanYEnabled() {
- return mPanYEnabled;
- }
-
- /**
- * Sets the enabled state of the pan.
- *
- * @param enabledX pan enabled on X axis
- * @param enabledY pan enabled on Y axis
- */
- public void setPanEnabled(boolean enabledX, boolean enabledY) {
- mPanXEnabled = enabledX;
- mPanYEnabled = enabledY;
- }
-
- /**
- * Returns the enabled state of the zoom on at least one axis.
- *
- * @return if zoom is enabled
- */
- public boolean isZoomEnabled() {
- return isZoomXEnabled() || isZoomYEnabled();
- }
-
- /**
- * Returns the enabled state of the zoom on X axis.
- *
- * @return if zoom is enabled on X axis
- */
- public boolean isZoomXEnabled() {
- return mZoomXEnabled;
- }
-
- /**
- * Returns the enabled state of the zoom on Y axis.
- *
- * @return if zoom is enabled on Y axis
- */
- public boolean isZoomYEnabled() {
- return mZoomYEnabled;
- }
-
- /**
- * Sets the enabled state of the zoom.
- *
- * @param enabledX zoom enabled on X axis
- * @param enabledY zoom enabled on Y axis
- */
- public void setZoomEnabled(boolean enabledX, boolean enabledY) {
- mZoomXEnabled = enabledX;
- mZoomYEnabled = enabledY;
- }
-
- /**
- * Returns the spacing between bars, in bar charts.
- *
- * @return the spacing between bars
- * @deprecated use getBarSpacing instead
- */
- public double getBarsSpacing() {
- return getBarSpacing();
- }
-
- /**
- * Returns the spacing between bars, in bar charts.
- *
- * @return the spacing between bars
- */
- public double getBarSpacing() {
- return mBarSpacing;
- }
-
- /**
- * Sets the spacing between bars, in bar charts. Only available for bar
- * charts. This is a coefficient of the bar width. For instance, if you want
- * the spacing to be a half of the bar width, set this value to 0.5.
- *
- * @param spacing the spacing between bars coefficient
- */
- public void setBarSpacing(double spacing) {
- mBarSpacing = spacing;
- }
-
- /**
- * Returns the margins color.
- *
- * @return the margins color
- */
- public int getMarginsColor() {
- return mMarginsColor;
- }
-
- /**
- * Sets the color of the margins.
- *
- * @param color the margins color
- */
- public void setMarginsColor(int color) {
- mMarginsColor = color;
- }
-
- /**
- * Returns the grid color.
- *
- * @return the grid color
- */
- public int getGridColor() {
- return mGridColor;
- }
-
- /**
- * Sets the color of the grid.
- *
- * @param color the grid color
- */
- public void setGridColor(int color) {
- mGridColor = color;
- }
-
- /**
- * Returns the pan limits.
- *
- * @return the pan limits
- */
- public double[] getPanLimits() {
- return mPanLimits;
- }
-
- /**
- * Sets the pan limits as an array of 4 values. Setting it to null or a
- * different size array will disable the panning limitation. Values:
- * [panMinimumX, panMaximumX, panMinimumY, panMaximumY]
- *
- * @param panLimits the pan limits
- */
- public void setPanLimits(double[] panLimits) {
- mPanLimits = panLimits;
- }
-
- /**
- * Returns the zoom limits.
- *
- * @return the zoom limits
- */
- public double[] getZoomLimits() {
- return mZoomLimits;
- }
-
- /**
- * Sets the zoom limits as an array of 4 values. Setting it to null or a
- * different size array will disable the zooming limitation. Values:
- * [zoomMinimumX, zoomMaximumX, zoomMinimumY, zoomMaximumY]
- *
- * @param zoomLimits the zoom limits
- */
- public void setZoomLimits(double[] zoomLimits) {
- mZoomLimits = zoomLimits;
- }
-
- /**
- * Returns the rotation angle of labels for the X axis.
- *
- * @return the rotation angle of labels for the X axis
- */
- public float getXLabelsAngle() {
- return mXLabelsAngle;
- }
-
- /**
- * Sets the rotation angle (in degrees) of labels for the X axis.
- *
- * @param angle the rotation angle of labels for the X axis
- */
- public void setXLabelsAngle(float angle) {
- mXLabelsAngle = angle;
- }
-
- /**
- * Returns the rotation angle of labels for the Y axis.
- *
- * @return the approximate number of labels for the Y axis
- */
- public float getYLabelsAngle() {
- return mYLabelsAngle;
- }
-
- /**
- * Sets the rotation angle (in degrees) of labels for the Y axis.
- *
- * @param angle the rotation angle of labels for the Y axis
- */
- public void setYLabelsAngle(float angle) {
- mYLabelsAngle = angle;
- }
-
- /**
- * Returns the size of the points, for charts displaying points.
- *
- * @return the point size
- */
- public float getPointSize() {
- return mPointSize;
- }
-
- /**
- * Sets the size of the points, for charts displaying points.
- *
- * @param size the point size
- */
- public void setPointSize(float size) {
- mPointSize = size;
- }
-
- public void setRange(double[] range) {
- setRange(range, 0);
- }
-
- /**
- * Sets the axes range values.
- *
- * @param range an array having the values in this order: minX, maxX, minY,
- * maxY
- * @param scale the renderer scale
- */
- public void setRange(double[] range, int scale) {
- setXAxisMin(range[0], scale);
- setXAxisMax(range[1], scale);
- setYAxisMin(range[2], scale);
- setYAxisMax(range[3], scale);
- }
-
- public boolean isInitialRangeSet() {
- return isInitialRangeSet(0);
- }
-
- /**
- * Returns if the initial range is set.
- *
- * @param scale the renderer scale
- * @return the initial range was set or not
- */
- public boolean isInitialRangeSet(int scale) {
- return initialRange.get(scale) != null;
- }
-
- /**
- * Returns the initial range.
- *
- * @return the initial range
- */
- public double[] getInitialRange() {
- return getInitialRange(0);
- }
-
- /**
- * Returns the initial range.
- *
- * @param scale the renderer scale
- * @return the initial range
- */
- public double[] getInitialRange(int scale) {
- return initialRange.get(scale);
- }
-
- /**
- * Sets the axes initial range values. This will be used in the zoom fit tool.
- *
- * @param range an array having the values in this order: minX, maxX, minY,
- * maxY
- */
- public void setInitialRange(double[] range) {
- setInitialRange(range, 0);
- }
-
- /**
- * Sets the axes initial range values. This will be used in the zoom fit tool.
- *
- * @param range an array having the values in this order: minX, maxX, minY,
- * maxY
- * @param scale the renderer scale
- */
- public void setInitialRange(double[] range, int scale) {
- initialRange.put(scale, range);
- }
-
- /**
- * Returns the X axis labels color.
- *
- * @return the X axis labels color
- */
- public int getXLabelsColor() {
- return mXLabelsColor;
- }
-
- /**
- * Returns the Y axis labels color.
- *
- * @return the Y axis labels color
- */
- public int getYLabelsColor(int scale) {
- return mYLabelsColor[scale];
- }
-
- /**
- * Sets the X axis labels color.
- *
- * @param color the X axis labels color
- */
- public void setXLabelsColor(int color) {
- mXLabelsColor = color;
- }
-
- /**
- * Sets the Y axis labels color.
- *
- * @param scale the renderer scale
- * @param color the Y axis labels color
- */
- public void setYLabelsColor(int scale, int color) {
- mYLabelsColor[scale] = color;
- }
-
- /**
- * Returns the X axis labels alignment.
- *
- * @return X labels alignment
- */
- public Align getXLabelsAlign() {
- return xLabelsAlign;
- }
-
- /**
- * Sets the X axis labels alignment.
- *
- * @param align the X labels alignment
- */
- public void setXLabelsAlign(Align align) {
- xLabelsAlign = align;
- }
-
- /**
- * Returns the Y axis labels alignment.
- *
- * @param scale the renderer scale
- * @return Y labels alignment
- */
- public Align getYLabelsAlign(int scale) {
- return yLabelsAlign[scale];
- }
-
- public void setYLabelsAlign(Align align) {
- setYLabelsAlign(align, 0);
- }
-
- public Align getYAxisAlign(int scale) {
- return yAxisAlign[scale];
- }
-
- public void setYAxisAlign(Align align, int scale) {
- yAxisAlign[scale] = align;
- }
-
- /**
- * Sets the Y axis labels alignment.
- *
- * @param align the Y labels alignment
- */
- public void setYLabelsAlign(Align align, int scale) {
- yLabelsAlign[scale] = align;
- }
-
- public int getScalesCount() {
- return scalesCount;
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/renderer/XYSeriesRenderer.java b/android-libraries/achartengine/src/org/achartengine/renderer/XYSeriesRenderer.java
deleted file mode 100644
index 42e4808e2d..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/renderer/XYSeriesRenderer.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.renderer;
-
-import org.achartengine.chart.PointStyle;
-
-import android.graphics.Color;
-
-/**
- * A renderer for the XY type series.
- */
-public class XYSeriesRenderer extends SimpleSeriesRenderer {
- /** If the chart points should be filled. */
- private boolean mFillPoints = false;
- /** If the chart should be filled below its line. */
- private boolean mFillBelowLine = false;
- /** The fill below the chart line color. */
- private int mFillColor = Color.argb(125, 0, 0, 200);
- /** The point style. */
- private PointStyle mPointStyle = PointStyle.POINT;
- /** The chart line width. */
- private float mLineWidth = 1;
-
- /**
- * Returns if the chart should be filled below the line.
- *
- * @return the fill below line status
- */
- public boolean isFillBelowLine() {
- return mFillBelowLine;
- }
-
- /**
- * Sets if the line chart should be filled below its line. Filling below the
- * line transforms a line chart into an area chart.
- *
- * @param fill the fill below line flag value
- */
- public void setFillBelowLine(boolean fill) {
- mFillBelowLine = fill;
- }
-
- /**
- * Returns if the chart points should be filled.
- *
- * @return the points fill status
- */
- public boolean isFillPoints() {
- return mFillPoints;
- }
-
- /**
- * Sets if the chart points should be filled.
- *
- * @param fill the points fill flag value
- */
- public void setFillPoints(boolean fill) {
- mFillPoints = fill;
- }
-
- /**
- * Returns the fill below line color.
- *
- * @return the fill below line color
- */
- public int getFillBelowLineColor() {
- return mFillColor;
- }
-
- /**
- * Sets the fill below the line color.
- *
- * @param color the fill below line color
- */
- public void setFillBelowLineColor(int color) {
- mFillColor = color;
- }
-
- /**
- * Returns the point style.
- *
- * @return the point style
- */
- public PointStyle getPointStyle() {
- return mPointStyle;
- }
-
- /**
- * Sets the point style.
- *
- * @param style the point style
- */
- public void setPointStyle(PointStyle style) {
- mPointStyle = style;
- }
-
- /**
- * Returns the chart line width.
- *
- * @return the line width
- */
- public float getLineWidth() {
- return mLineWidth;
- }
-
- /**
- * Sets the chart line width.
- *
- * @param lineWidth the line width
- */
- public void setLineWidth(float lineWidth) {
- mLineWidth = lineWidth;
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/renderer/package.html b/android-libraries/achartengine/src/org/achartengine/renderer/package.html
deleted file mode 100644
index c9db0a454a..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/renderer/package.html
+++ /dev/null
@@ -1,6 +0,0 @@
-
-AChartEngine
-
-Provides renderer classes that keep the chart rendering / drawing styles.
-
-
\ No newline at end of file
diff --git a/android-libraries/achartengine/src/org/achartengine/tools/AbstractTool.java b/android-libraries/achartengine/src/org/achartengine/tools/AbstractTool.java
deleted file mode 100644
index 99841ed70e..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/tools/AbstractTool.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.tools;
-
-import org.achartengine.chart.AbstractChart;
-import org.achartengine.chart.XYChart;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-
-/**
- * Abstract class for being extended by graphical view tools.
- */
-public abstract class AbstractTool {
- /** The chart. */
- protected AbstractChart mChart;
- /** The renderer. */
- protected XYMultipleSeriesRenderer mRenderer;
-
- /**
- * Abstract tool constructor.
- *
- * @param chart the chart
- */
- public AbstractTool(AbstractChart chart) {
- mChart = chart;
- if (chart instanceof XYChart) {
- mRenderer = ((XYChart) chart).getRenderer();
- }
- }
-
- /**
- * Returns the current chart range.
- *
- * @param scale the scale
- * @return the chart range
- */
- public double[] getRange(int scale) {
- double minX = mRenderer.getXAxisMin(scale);
- double maxX = mRenderer.getXAxisMax(scale);
- double minY = mRenderer.getYAxisMin(scale);
- double maxY = mRenderer.getYAxisMax(scale);
- return new double[] { minX, maxX, minY, maxY };
- }
-
- /**
- * Sets the range to the calculated one, if not already set.
- *
- * @param range the range
- * @param scale the scale
- */
- public void checkRange(double[] range, int scale) {
- if (mChart instanceof XYChart) {
- double[] calcRange = ((XYChart) mChart).getCalcRange(scale);
- if (calcRange != null) {
- if (!mRenderer.isMinXSet(scale)) {
- range[0] = calcRange[0];
- mRenderer.setXAxisMin(range[0], scale);
- }
- if (!mRenderer.isMaxXSet(scale)) {
- range[1] = calcRange[1];
- mRenderer.setXAxisMax(range[1], scale);
- }
- if (!mRenderer.isMinYSet(scale)) {
- range[2] = calcRange[2];
- mRenderer.setYAxisMin(range[2], scale);
- }
- if (!mRenderer.isMaxYSet(scale)) {
- range[3] = calcRange[3];
- mRenderer.setYAxisMax(range[3], scale);
- }
- }
- }
- }
-
- /**
- * Sets a new range on the X axis.
- *
- * @param min the minimum value
- * @param max the maximum value
- * @param scale the scale
- */
- protected void setXRange(double min, double max, int scale) {
- mRenderer.setXAxisMin(min, scale);
- mRenderer.setXAxisMax(max, scale);
- }
-
- /**
- * Sets a new range on the Y axis.
- *
- * @param min the minimum value
- * @param max the maximum value
- * @param scale the scale
- */
- protected void setYRange(double min, double max, int scale) {
- mRenderer.setYAxisMin(min, scale);
- mRenderer.setYAxisMax(max, scale);
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/tools/FitZoom.java b/android-libraries/achartengine/src/org/achartengine/tools/FitZoom.java
deleted file mode 100644
index 92f67b8400..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/tools/FitZoom.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.tools;
-
-import org.achartengine.chart.AbstractChart;
-import org.achartengine.chart.RoundChart;
-import org.achartengine.chart.XYChart;
-import org.achartengine.model.XYSeries;
-import org.achartengine.renderer.DefaultRenderer;
-import org.achartengine.util.MathHelper;
-
-public class FitZoom extends AbstractTool {
- /**
- * Builds an instance of the fit zoom tool.
- *
- * @param chart the XY chart
- */
- public FitZoom(AbstractChart chart) {
- super(chart);
- }
-
- /**
- * Apply the tool.
- */
- public void apply() {
- if (mChart instanceof XYChart) {
- if (((XYChart) mChart).getDataset() == null) {
- return;
- }
- int scales = mRenderer.getScalesCount();
- if (mRenderer.isInitialRangeSet()) {
- for (int i = 0; i < scales; i++) {
- if (mRenderer.isInitialRangeSet(i)) {
- mRenderer.setRange(mRenderer.getInitialRange(i), i);
- }
- }
- } else {
- XYSeries[] series = ((XYChart) mChart).getDataset().getSeries();
- double[] range = null;
- int length = series.length;
- if (length > 0) {
- for (int i = 0; i < scales; i++) {
- range = new double[] { MathHelper.NULL_VALUE, -MathHelper.NULL_VALUE,
- MathHelper.NULL_VALUE, -MathHelper.NULL_VALUE };
- for (int j = 0; j < length; j++) {
- if (i == series[j].getScaleNumber()) {
- range[0] = Math.min(range[0], series[j].getMinX());
- range[1] = Math.max(range[1], series[j].getMaxX());
- range[2] = Math.min(range[2], series[j].getMinY());
- range[3] = Math.max(range[3], series[j].getMaxY());
- }
- }
- double marginX = Math.abs(range[1] - range[0]) / 40;
- double marginY = Math.abs(range[3] - range[2]) / 40;
- mRenderer.setRange(new double[] { range[0] - marginX, range[1] + marginX,
- range[2] - marginY, range[3] + marginY }, i);
- }
- }
- }
- } else {
- DefaultRenderer renderer = ((RoundChart) mChart).getRenderer();
- renderer.setScale(renderer.getOriginalScale());
- }
- }
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/tools/Pan.java b/android-libraries/achartengine/src/org/achartengine/tools/Pan.java
deleted file mode 100644
index 2d4ea28e35..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/tools/Pan.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.tools;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.achartengine.chart.AbstractChart;
-import org.achartengine.chart.RoundChart;
-import org.achartengine.chart.XYChart;
-
-/**
- * The pan tool.
- */
-public class Pan extends AbstractTool {
- /** The pan listeners. */
- private List mPanListeners = new ArrayList();
- /** Pan limits reached on the X axis. */
- private boolean limitsReachedX = false;
- /** Pan limits reached on the X axis. */
- private boolean limitsReachedY = false;
-
- /**
- * Builds and instance of the pan tool.
- *
- * @param chart the XY chart
- */
- public Pan(AbstractChart chart) {
- super(chart);
- }
-
- /**
- * Apply the tool.
- *
- * @param oldX the previous location on X axis
- * @param oldY the previous location on Y axis
- * @param newX the current location on X axis
- * @param newY the current location on the Y axis
- */
- public void apply(float oldX, float oldY, float newX, float newY) {
- boolean notLimitedUp = true;
- boolean notLimitedBottom = true;
- boolean notLimitedLeft = true;
- boolean notLimitedRight = true;
- if (mChart instanceof XYChart) {
- int scales = mRenderer.getScalesCount();
- double[] limits = mRenderer.getPanLimits();
- boolean limited = limits != null && limits.length == 4;
- XYChart chart = (XYChart) mChart;
- for (int i = 0; i < scales; i++) {
- double[] range = getRange(i);
- double[] calcRange = chart.getCalcRange(i);
- if (limitsReachedX
- && limitsReachedY
- && (range[0] == range[1] && calcRange[0] == calcRange[1] || range[2] == range[3]
- && calcRange[2] == calcRange[3])) {
- return;
- }
- checkRange(range, i);
-
- double[] realPoint = chart.toRealPoint(oldX, oldY, i);
- double[] realPoint2 = chart.toRealPoint(newX, newY, i);
- double deltaX = realPoint[0] - realPoint2[0];
- double deltaY = realPoint[1] - realPoint2[1];
- double ratio = getAxisRatio(range);
- if (chart.isVertical(mRenderer)) {
- double newDeltaX = -deltaY * ratio;
- double newDeltaY = deltaX / ratio;
- deltaX = newDeltaX;
- deltaY = newDeltaY;
- }
- if (mRenderer.isPanXEnabled()) {
- if (limits != null) {
- if (notLimitedLeft) {
- notLimitedLeft = limits[0] <= range[0] + deltaX;
- }
- if (notLimitedRight) {
- notLimitedRight = limits[1] >= range[1] + deltaX;
- }
- }
- if (!limited || (notLimitedLeft && notLimitedRight)) {
- setXRange(range[0] + deltaX, range[1] + deltaX, i);
- limitsReachedX = false;
- } else {
- limitsReachedX = true;
- }
- }
- if (mRenderer.isPanYEnabled()) {
- if (limits != null) {
- if (notLimitedBottom) {
- notLimitedBottom = limits[2] <= range[2] + deltaY;
- }
- if (notLimitedUp) {
- notLimitedUp = limits[3] >= range[3] + deltaY;
- }
- }
- if (!limited || (notLimitedBottom && notLimitedUp)) {
- setYRange(range[2] + deltaY, range[3] + deltaY, i);
- limitsReachedY = false;
- } else {
- limitsReachedY = true;
- }
- }
- }
- } else {
- RoundChart chart = (RoundChart) mChart;
- chart.setCenterX(chart.getCenterX() + (int) (newX - oldX));
- chart.setCenterY(chart.getCenterY() + (int) (newY - oldY));
- }
- notifyPanListeners();
- }
-
- /**
- * Return the X / Y axis range ratio.
- *
- * @param range the axis range
- * @return the ratio
- */
- private double getAxisRatio(double[] range) {
- return Math.abs(range[1] - range[0]) / Math.abs(range[3] - range[2]);
- }
-
- /**
- * Notify the pan listeners about a pan.
- */
- private synchronized void notifyPanListeners() {
- for (PanListener listener : mPanListeners) {
- listener.panApplied();
- }
- }
-
- /**
- * Adds a new pan listener.
- *
- * @param listener pan listener
- */
- public synchronized void addPanListener(PanListener listener) {
- mPanListeners.add(listener);
- }
-
- /**
- * Removes a pan listener.
- *
- * @param listener pan listener
- */
- public synchronized void removePanListener(PanListener listener) {
- mPanListeners.add(listener);
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/tools/PanListener.java b/android-libraries/achartengine/src/org/achartengine/tools/PanListener.java
deleted file mode 100644
index d3d136c000..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/tools/PanListener.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.tools;
-
-/**
- * A pan listener.
- */
-public interface PanListener {
-
- /**
- * Called when a pan change is triggered.
- */
- void panApplied();
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/tools/Zoom.java b/android-libraries/achartengine/src/org/achartengine/tools/Zoom.java
deleted file mode 100644
index 0abee92c87..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/tools/Zoom.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.tools;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.achartengine.chart.AbstractChart;
-import org.achartengine.chart.RoundChart;
-import org.achartengine.chart.XYChart;
-import org.achartengine.renderer.DefaultRenderer;
-
-/**
- * The zoom tool.
- */
-public class Zoom extends AbstractTool {
- /** A flag to be used to know if this is a zoom in or out. */
- private boolean mZoomIn;
- /** The zoom rate. */
- private float mZoomRate;
- /** The zoom listeners. */
- private List mZoomListeners = new ArrayList();
- /** Zoom limits reached on the X axis. */
- private boolean limitsReachedX = false;
- /** Zoom limits reached on the Y axis. */
- private boolean limitsReachedY = false;
-
- /** Zoom on X axis and Y axis */
- public static final int ZOOM_AXIS_XY = 0;
- /** Zoom on X axis independently */
- public static final int ZOOM_AXIS_X = 1;
- /** Zoom on Y axis independently */
- public static final int ZOOM_AXIS_Y = 2;
-
-
- /**
- * Builds the zoom tool.
- *
- * @param chart the chart
- * @param in zoom in or out
- * @param rate the zoom rate
- */
- public Zoom(AbstractChart chart, boolean in, float rate) {
- super(chart);
- mZoomIn = in;
- setZoomRate(rate);
- }
-
- /**
- * Sets the zoom rate.
- *
- * @param rate
- */
- public void setZoomRate(float rate) {
- mZoomRate = rate;
- }
-
- /**
- * Apply the zoom.
- */
- public void apply(int zoom_axis) {
- if (mChart instanceof XYChart) {
- int scales = mRenderer.getScalesCount();
- for (int i = 0; i < scales; i++) {
- double[] range = getRange(i);
- checkRange(range, i);
- double[] limits = mRenderer.getZoomLimits();
-
- double centerX = (range[0] + range[1]) / 2;
- double centerY = (range[2] + range[3]) / 2;
- double newWidth = range[1] - range[0];
- double newHeight = range[3] - range[2];
- double newXMin = centerX - newWidth / 2;
- double newXMax = centerX + newWidth / 2;
- double newYMin = centerY - newHeight / 2;
- double newYMax = centerY + newHeight / 2;
-
- // if already reached last zoom, then it will always set to reached
- if (i == 0) {
- limitsReachedX = limits != null && (newXMin <= limits[0] || newXMax >= limits[1]);
- limitsReachedY = limits != null && (newYMin <= limits[2] || newYMax >= limits[3]);
- }
-
- if (mZoomIn) {
- if (mRenderer.isZoomXEnabled() && // zoom in on X axis
- (zoom_axis == ZOOM_AXIS_X || zoom_axis == ZOOM_AXIS_XY)) {
- if (limitsReachedX && mZoomRate < 1) {
- // ignore pinch zoom out once reached X limit
- } else {
- newWidth /= mZoomRate;
- }
- }
-
- if (mRenderer.isZoomYEnabled() && // zoom in on Y axis
- (zoom_axis == ZOOM_AXIS_Y || zoom_axis == ZOOM_AXIS_XY)) {
- if (limitsReachedY && mZoomRate < 1) {
- } else {
- newHeight /= mZoomRate;
- }
- }
- } else {
- if (mRenderer.isZoomXEnabled() && !limitsReachedX && // zoom out on X axis
- (zoom_axis == ZOOM_AXIS_X || zoom_axis == ZOOM_AXIS_XY)) {
- newWidth *= mZoomRate;
- }
-
- if (mRenderer.isZoomYEnabled() && !limitsReachedY && // zoom out on Y axis
- (zoom_axis == ZOOM_AXIS_Y || zoom_axis == ZOOM_AXIS_XY)) {
- newHeight *= mZoomRate;
- }
- }
-
- if (mRenderer.isZoomXEnabled() &&
- (zoom_axis == ZOOM_AXIS_X || zoom_axis == ZOOM_AXIS_XY)) {
- newXMin = centerX - newWidth / 2;
- newXMax = centerX + newWidth / 2;
- setXRange(newXMin, newXMax, i);
- }
- if (mRenderer.isZoomYEnabled() &&
- (zoom_axis == ZOOM_AXIS_Y || zoom_axis == ZOOM_AXIS_XY)) {
- newYMin = centerY - newHeight / 2;
- newYMax = centerY + newHeight / 2;
- setYRange(newYMin, newYMax, i);
- }
- }
- } else {
- DefaultRenderer renderer = ((RoundChart) mChart).getRenderer();
- if (mZoomIn) {
- renderer.setScale(renderer.getScale() * mZoomRate);
- } else {
- renderer.setScale(renderer.getScale() / mZoomRate);
- }
- }
- notifyZoomListeners(new ZoomEvent(mZoomIn, mZoomRate));
- }
-
-
- /**
- * Notify the zoom listeners about a zoom change.
- *
- * @param e the zoom event
- */
- private synchronized void notifyZoomListeners(ZoomEvent e) {
- for (ZoomListener listener : mZoomListeners) {
- listener.zoomApplied(e);
- }
- }
-
- /**
- * Notify the zoom listeners about a zoom reset.
- */
- public synchronized void notifyZoomResetListeners() {
- for (ZoomListener listener : mZoomListeners) {
- listener.zoomReset();
- }
- }
-
- /**
- * Adds a new zoom listener.
- *
- * @param listener zoom listener
- */
- public synchronized void addZoomListener(ZoomListener listener) {
- mZoomListeners.add(listener);
- }
-
- /**
- * Removes a zoom listener.
- *
- * @param listener zoom listener
- */
- public synchronized void removeZoomListener(ZoomListener listener) {
- mZoomListeners.add(listener);
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/tools/ZoomEvent.java b/android-libraries/achartengine/src/org/achartengine/tools/ZoomEvent.java
deleted file mode 100644
index bd8fb686f7..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/tools/ZoomEvent.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.tools;
-
-
-/**
- * A zoom event.
- */
-public class ZoomEvent {
- /** A flag to be used to know if this is a zoom in or out. */
- private boolean mZoomIn;
- /** The zoom rate. */
- private float mZoomRate;
-
- /**
- * Builds the zoom tool.
- *
- * @param in zoom in or out
- * @param rate the zoom rate
- */
- public ZoomEvent(boolean in, float rate) {
- mZoomIn = in;
- mZoomRate = rate;
- }
-
- /**
- * Returns the zoom type.
- *
- * @return true if zoom in, false otherwise
- */
- public boolean isZoomIn() {
- return mZoomIn;
- }
-
- /**
- * Returns the zoom rate.
- *
- * @return the zoom rate
- */
- public float getZoomRate() {
- return mZoomRate;
- }
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/tools/ZoomListener.java b/android-libraries/achartengine/src/org/achartengine/tools/ZoomListener.java
deleted file mode 100644
index 4827483ea3..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/tools/ZoomListener.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.tools;
-
-/**
- * A zoom listener.
- */
-public interface ZoomListener {
-
- /**
- * Called when a zoom change is triggered.
- * @param e the zoom event
- */
- void zoomApplied(ZoomEvent e);
-
- /**
- * Called when a zoom reset is done.
- */
- void zoomReset();
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/util/IndexXYMap.java b/android-libraries/achartengine/src/org/achartengine/util/IndexXYMap.java
deleted file mode 100644
index f957262229..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/util/IndexXYMap.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.util;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.TreeMap;
-
-/**
- * This class requires sorted x values
- */
-public class IndexXYMap extends TreeMap {
- private final List indexList = new ArrayList();
-
- private double maxXDifference = 0;
-
- public IndexXYMap() {
- super();
- }
-
- public V put(K key, V value) {
- indexList.add(key);
- updateMaxXDifference();
- return super.put(key, value);
- }
-
- private void updateMaxXDifference() {
- if (indexList.size() < 2) {
- maxXDifference = 0;
- return;
- }
-
- if (Math.abs((Double) indexList.get(indexList.size() - 1)
- - (Double) indexList.get(indexList.size() - 2)) > maxXDifference)
- maxXDifference = Math.abs((Double) indexList.get(indexList.size() - 1)
- - (Double) indexList.get(indexList.size() - 2));
- }
-
- public double getMaxXDifference() {
- return maxXDifference;
- }
-
- public void clear() {
- updateMaxXDifference();
- super.clear();
- indexList.clear();
- }
-
- /**
- * Returns X-value according to the given index
- *
- * @param index
- * @return the X value
- */
- public K getXByIndex(int index) {
- return indexList.get(index);
- }
-
- /**
- * Returns Y-value according to the given index
- *
- * @param index
- * @return the Y value
- */
- public V getYByIndex(int index) {
- K key = indexList.get(index);
- return this.get(key);
- }
-
- /**
- * Returns XY-entry according to the given index
- *
- * @param index
- * @return the X and Y values
- */
- public XYEntry getByIndex(int index) {
- K key = indexList.get(index);
- return new XYEntry(key, this.get(key));
- }
-
- /**
- * Removes entry from map by index
- *
- * @param index
- */
- public XYEntry removeByIndex(int index) {
- K key = indexList.remove(index);
- return new XYEntry(key, this.remove(key));
- }
-
- public int getIndexForKey(K key) {
- return Collections.binarySearch(indexList, key, null);
- }
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/util/MathHelper.java b/android-libraries/achartengine/src/org/achartengine/util/MathHelper.java
deleted file mode 100644
index f5b893bf75..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/util/MathHelper.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.util;
-
-import java.text.NumberFormat;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Utility class for math operations.
- */
-public class MathHelper {
- /** A value that is used a null value. */
- public static final double NULL_VALUE = Double.MAX_VALUE;
- /**
- * A number formatter to be used to make sure we have a maximum number of
- * fraction digits in the labels.
- */
- private static final NumberFormat FORMAT = NumberFormat.getNumberInstance();
-
- private MathHelper() {
- // empty constructor
- }
-
- /**
- * Calculate the minimum and maximum values out of a list of doubles.
- *
- * @param values the input values
- * @return an array with the minimum and maximum values
- */
- public static double[] minmax(List values) {
- if (values.size() == 0) {
- return new double[2];
- }
- double min = values.get(0);
- double max = min;
- int length = values.size();
- for (int i = 1; i < length; i++) {
- double value = values.get(i);
- min = Math.min(min, value);
- max = Math.max(max, value);
- }
- return new double[] { min, max };
- }
-
- /**
- * Computes a reasonable set of labels for a data interval and number of
- * labels.
- *
- * @param start start value
- * @param end final value
- * @param approxNumLabels desired number of labels
- * @return collection containing {start value, end value, increment}
- */
- public static List getLabels(final double start, final double end,
- final int approxNumLabels) {
- FORMAT.setMaximumFractionDigits(5);
- List labels = new ArrayList();
- double[] labelParams = computeLabels(start, end, approxNumLabels);
- // when the start > end the inc will be negative so it will still work
- int numLabels = 1 + (int) ((labelParams[1] - labelParams[0]) / labelParams[2]);
- // we want the range to be inclusive but we don't want to blow up when
- // looping for the case where the min and max are the same. So we loop
- // on
- // numLabels not on the values.
- for (int i = 0; i < numLabels; i++) {
- double z = labelParams[0] + i * labelParams[2];
- try {
- // this way, we avoid a label value like 0.4000000000000000001 instead
- // of 0.4
- z = FORMAT.parse(FORMAT.format(z)).doubleValue();
- } catch (ParseException e) {
- // do nothing here
- }
- labels.add(z);
- }
- return labels;
- }
-
- /**
- * Computes a reasonable number of labels for a data range.
- *
- * @param start start value
- * @param end final value
- * @param approxNumLabels desired number of labels
- * @return double[] array containing {start value, end value, increment}
- */
- private static double[] computeLabels(final double start, final double end,
- final int approxNumLabels) {
- if (Math.abs(start - end) < 0.0000001f) {
- return new double[] { start, start, 0 };
- }
- double s = start;
- double e = end;
- boolean switched = false;
- if (s > e) {
- switched = true;
- double tmp = s;
- s = e;
- e = tmp;
- }
- double xStep = roundUp(Math.abs(s - e) / approxNumLabels);
- // Compute x starting point so it is a multiple of xStep.
- double xStart = xStep * Math.ceil(s / xStep);
- double xEnd = xStep * Math.floor(e / xStep);
- if (switched) {
- return new double[] { xEnd, xStart, -1.0 * xStep };
- }
- return new double[] { xStart, xEnd, xStep };
- }
-
- /**
- * Given a number, round up to the nearest power of ten times 1, 2, or 5. The
- * argument must be strictly positive.
- */
- private static double roundUp(final double val) {
- int exponent = (int) Math.floor(Math.log10(val));
- double rval = val * Math.pow(10, -exponent);
- if (rval > 5.0) {
- rval = 10.0;
- } else if (rval > 2.0) {
- rval = 5.0;
- } else if (rval > 1.0) {
- rval = 2.0;
- }
- rval *= Math.pow(10, exponent);
- return rval;
- }
-
- /**
- * Transforms a list of Float values into an array of float.
- *
- * @param values the list of Float
- * @return the array of floats
- */
- public static float[] getFloats(List values) {
- int length = values.size();
- float[] result = new float[length];
- for (int i = 0; i < length; i++) {
- result[i] = values.get(i).floatValue();
- }
- return result;
- }
-
- /**
- * Transforms a list of Double values into an array of double.
- *
- * @param values the list of Double
- * @return the array of doubles
- */
- public static double[] getDoubles(List values) {
- int length = values.size();
- double[] result = new double[length];
- for (int i = 0; i < length; i++) {
- result[i] = values.get(i).doubleValue();
- }
- return result;
- }
-
-}
diff --git a/android-libraries/achartengine/src/org/achartengine/util/XYEntry.java b/android-libraries/achartengine/src/org/achartengine/util/XYEntry.java
deleted file mode 100644
index 53761a4d1a..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/util/XYEntry.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
- *
- * 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 org.achartengine.util;
-
-import java.util.Map.Entry;
-
-/**
- * A map entry value encapsulating an XY point.
- */
-public class XYEntry implements Entry {
- private final K key;
-
- private V value;
-
- public XYEntry(K key, V value) {
- this.key = key;
- this.value = value;
- }
-
- public K getKey() {
- return key;
- }
-
- public V getValue() {
- return value;
- }
-
- public V setValue(V object) {
- this.value = object;
- return this.value;
- }
-}
\ No newline at end of file
diff --git a/android-libraries/achartengine/src/org/achartengine/util/package.html b/android-libraries/achartengine/src/org/achartengine/util/package.html
deleted file mode 100644
index da92e91330..0000000000
--- a/android-libraries/achartengine/src/org/achartengine/util/package.html
+++ /dev/null
@@ -1,6 +0,0 @@
-
-AChartEngine
-
-Utility classes that provide helper methods used by most of the other packages.
-
-
\ No newline at end of file
diff --git a/android/.classpath b/android/.classpath
deleted file mode 100644
index 07677d89fa..0000000000
--- a/android/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/android/.project b/android/.project
deleted file mode 100644
index 94894b517c..0000000000
--- a/android/.project
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
- OpenRocket-android
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
-
- core
- 2
- WORKSPACE_LOC/OpenRocket/src
-
-
- core-resources
- 2
- WORKSPACE_LOC/OpenRocket/resources
-
-
-
diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml
deleted file mode 100644
index 76922cdcaa..0000000000
--- a/android/AndroidManifest.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/libs/android-support-v4.jar b/android/libs/android-support-v4.jar
deleted file mode 100644
index 1fbeba0932..0000000000
Binary files a/android/libs/android-support-v4.jar and /dev/null differ
diff --git a/android/lint.xml b/android/lint.xml
deleted file mode 100644
index ee0eead5bb..0000000000
--- a/android/lint.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/android/proguard.cfg b/android/proguard.cfg
deleted file mode 100644
index b1cdf17b5b..0000000000
--- a/android/proguard.cfg
+++ /dev/null
@@ -1,40 +0,0 @@
--optimizationpasses 5
--dontusemixedcaseclassnames
--dontskipnonpubliclibraryclasses
--dontpreverify
--verbose
--optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-
--keep public class * extends android.app.Activity
--keep public class * extends android.app.Application
--keep public class * extends android.app.Service
--keep public class * extends android.content.BroadcastReceiver
--keep public class * extends android.content.ContentProvider
--keep public class * extends android.app.backup.BackupAgentHelper
--keep public class * extends android.preference.Preference
--keep public class com.android.vending.licensing.ILicensingService
-
--keepclasseswithmembernames class * {
- native ;
-}
-
--keepclasseswithmembers class * {
- public (android.content.Context, android.util.AttributeSet);
-}
-
--keepclasseswithmembers class * {
- public (android.content.Context, android.util.AttributeSet, int);
-}
-
--keepclassmembers class * extends android.app.Activity {
- public void *(android.view.View);
-}
-
--keepclassmembers enum * {
- public static **[] values();
- public static ** valueOf(java.lang.String);
-}
-
--keep class * implements android.os.Parcelable {
- public static final android.os.Parcelable$Creator *;
-}
diff --git a/android/project.properties b/android/project.properties
deleted file mode 100644
index 8202ea55fd..0000000000
--- a/android/project.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-15
-android.library.reference.1=../ActionBarSherlock
-android.library.reference.2=../TreeViewList
-android.library.reference.3=../achartengine
diff --git a/android/res/drawable-hdpi/arrow_down_float.png b/android/res/drawable-hdpi/arrow_down_float.png
deleted file mode 100644
index 2466c8f672..0000000000
Binary files a/android/res/drawable-hdpi/arrow_down_float.png and /dev/null differ
diff --git a/android/res/drawable-hdpi/arrow_up_float.png b/android/res/drawable-hdpi/arrow_up_float.png
deleted file mode 100644
index d1301c3bdd..0000000000
Binary files a/android/res/drawable-hdpi/arrow_up_float.png and /dev/null differ
diff --git a/android/res/drawable-hdpi/ic_menu_add.png b/android/res/drawable-hdpi/ic_menu_add.png
deleted file mode 100644
index 444e8a5ee8..0000000000
Binary files a/android/res/drawable-hdpi/ic_menu_add.png and /dev/null differ
diff --git a/android/res/drawable-hdpi/ic_menu_archive.png b/android/res/drawable-hdpi/ic_menu_archive.png
deleted file mode 100644
index e2d9bc1a3c..0000000000
Binary files a/android/res/drawable-hdpi/ic_menu_archive.png and /dev/null differ
diff --git a/android/res/drawable-hdpi/ic_menu_download.png b/android/res/drawable-hdpi/ic_menu_download.png
deleted file mode 100644
index 628028c7ad..0000000000
Binary files a/android/res/drawable-hdpi/ic_menu_download.png and /dev/null differ
diff --git a/android/res/drawable-hdpi/ic_menu_info_details.png b/android/res/drawable-hdpi/ic_menu_info_details.png
deleted file mode 100644
index 6a7a1e94a7..0000000000
Binary files a/android/res/drawable-hdpi/ic_menu_info_details.png and /dev/null differ
diff --git a/android/res/drawable-hdpi/ic_menu_preferences.png b/android/res/drawable-hdpi/ic_menu_preferences.png
deleted file mode 100644
index 5321f82852..0000000000
Binary files a/android/res/drawable-hdpi/ic_menu_preferences.png and /dev/null differ
diff --git a/android/res/drawable-hdpi/ic_menu_save.png b/android/res/drawable-hdpi/ic_menu_save.png
deleted file mode 100644
index 36fc7f4ddf..0000000000
Binary files a/android/res/drawable-hdpi/ic_menu_save.png and /dev/null differ
diff --git a/android/res/drawable-hdpi/or_launcher.png b/android/res/drawable-hdpi/or_launcher.png
deleted file mode 100644
index 22c526f315..0000000000
Binary files a/android/res/drawable-hdpi/or_launcher.png and /dev/null differ
diff --git a/android/res/drawable-ldpi/arrow_down_float.png b/android/res/drawable-ldpi/arrow_down_float.png
deleted file mode 100644
index c41340da46..0000000000
Binary files a/android/res/drawable-ldpi/arrow_down_float.png and /dev/null differ
diff --git a/android/res/drawable-ldpi/arrow_up_float.png b/android/res/drawable-ldpi/arrow_up_float.png
deleted file mode 100644
index 8b60f12160..0000000000
Binary files a/android/res/drawable-ldpi/arrow_up_float.png and /dev/null differ
diff --git a/android/res/drawable-ldpi/ic_menu_add.png b/android/res/drawable-ldpi/ic_menu_add.png
deleted file mode 100644
index 89620af8c0..0000000000
Binary files a/android/res/drawable-ldpi/ic_menu_add.png and /dev/null differ
diff --git a/android/res/drawable-ldpi/ic_menu_archive.png b/android/res/drawable-ldpi/ic_menu_archive.png
deleted file mode 100644
index 719ecd8582..0000000000
Binary files a/android/res/drawable-ldpi/ic_menu_archive.png and /dev/null differ
diff --git a/android/res/drawable-ldpi/ic_menu_info_details.png b/android/res/drawable-ldpi/ic_menu_info_details.png
deleted file mode 100644
index 55c57d5c54..0000000000
Binary files a/android/res/drawable-ldpi/ic_menu_info_details.png and /dev/null differ
diff --git a/android/res/drawable-ldpi/ic_menu_preferences.png b/android/res/drawable-ldpi/ic_menu_preferences.png
deleted file mode 100644
index efc2f3e459..0000000000
Binary files a/android/res/drawable-ldpi/ic_menu_preferences.png and /dev/null differ
diff --git a/android/res/drawable-ldpi/ic_menu_save.png b/android/res/drawable-ldpi/ic_menu_save.png
deleted file mode 100644
index ac053b41d9..0000000000
Binary files a/android/res/drawable-ldpi/ic_menu_save.png and /dev/null differ
diff --git a/android/res/drawable-ldpi/or_launcher.png b/android/res/drawable-ldpi/or_launcher.png
deleted file mode 100644
index 5f7a0b2ae0..0000000000
Binary files a/android/res/drawable-ldpi/or_launcher.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/arrow_down_float.png b/android/res/drawable-mdpi/arrow_down_float.png
deleted file mode 100644
index dd825234ca..0000000000
Binary files a/android/res/drawable-mdpi/arrow_down_float.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/arrow_up_float.png b/android/res/drawable-mdpi/arrow_up_float.png
deleted file mode 100644
index 9bc3d1c26e..0000000000
Binary files a/android/res/drawable-mdpi/arrow_up_float.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/ic_directory.png b/android/res/drawable-mdpi/ic_directory.png
deleted file mode 100644
index a4599e37a0..0000000000
Binary files a/android/res/drawable-mdpi/ic_directory.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/ic_menu_add.png b/android/res/drawable-mdpi/ic_menu_add.png
deleted file mode 100644
index 361c7c460e..0000000000
Binary files a/android/res/drawable-mdpi/ic_menu_add.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/ic_menu_archive.png b/android/res/drawable-mdpi/ic_menu_archive.png
deleted file mode 100644
index 49ac569dc2..0000000000
Binary files a/android/res/drawable-mdpi/ic_menu_archive.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/ic_menu_info_details.png b/android/res/drawable-mdpi/ic_menu_info_details.png
deleted file mode 100644
index 18b15b5add..0000000000
Binary files a/android/res/drawable-mdpi/ic_menu_info_details.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/ic_menu_preferences.png b/android/res/drawable-mdpi/ic_menu_preferences.png
deleted file mode 100644
index ccc50e66ee..0000000000
Binary files a/android/res/drawable-mdpi/ic_menu_preferences.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/ic_menu_save.png b/android/res/drawable-mdpi/ic_menu_save.png
deleted file mode 100644
index 5f6686448d..0000000000
Binary files a/android/res/drawable-mdpi/ic_menu_save.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/ic_motorbrowser.png b/android/res/drawable-mdpi/ic_motorbrowser.png
deleted file mode 100644
index c7dcd53633..0000000000
Binary files a/android/res/drawable-mdpi/ic_motorbrowser.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/ic_star_select.png b/android/res/drawable-mdpi/ic_star_select.png
deleted file mode 100644
index 4c479314f3..0000000000
Binary files a/android/res/drawable-mdpi/ic_star_select.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/ic_star_unselected.png b/android/res/drawable-mdpi/ic_star_unselected.png
deleted file mode 100644
index 98203a7398..0000000000
Binary files a/android/res/drawable-mdpi/ic_star_unselected.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/or_launcher.png b/android/res/drawable-mdpi/or_launcher.png
deleted file mode 100644
index 36a91549da..0000000000
Binary files a/android/res/drawable-mdpi/or_launcher.png and /dev/null differ
diff --git a/android/res/drawable-xhdpi/ic_menu_add.png b/android/res/drawable-xhdpi/ic_menu_add.png
deleted file mode 100644
index 7d498a96e2..0000000000
Binary files a/android/res/drawable-xhdpi/ic_menu_add.png and /dev/null differ
diff --git a/android/res/drawable-xhdpi/ic_menu_archive.png b/android/res/drawable-xhdpi/ic_menu_archive.png
deleted file mode 100644
index b1be9d5b98..0000000000
Binary files a/android/res/drawable-xhdpi/ic_menu_archive.png and /dev/null differ
diff --git a/android/res/drawable-xhdpi/ic_menu_download.png b/android/res/drawable-xhdpi/ic_menu_download.png
deleted file mode 100644
index fdbb334ef4..0000000000
Binary files a/android/res/drawable-xhdpi/ic_menu_download.png and /dev/null differ
diff --git a/android/res/drawable-xhdpi/ic_menu_info_details.png b/android/res/drawable-xhdpi/ic_menu_info_details.png
deleted file mode 100644
index 24ea543733..0000000000
Binary files a/android/res/drawable-xhdpi/ic_menu_info_details.png and /dev/null differ
diff --git a/android/res/drawable-xhdpi/ic_menu_preferences.png b/android/res/drawable-xhdpi/ic_menu_preferences.png
deleted file mode 100644
index 02cfbad0b0..0000000000
Binary files a/android/res/drawable-xhdpi/ic_menu_preferences.png and /dev/null differ
diff --git a/android/res/drawable-xhdpi/ic_menu_save.png b/android/res/drawable-xhdpi/ic_menu_save.png
deleted file mode 100644
index 62a66d87a5..0000000000
Binary files a/android/res/drawable-xhdpi/ic_menu_save.png and /dev/null differ
diff --git a/android/res/drawable-xhdpi/or_launcher.png b/android/res/drawable-xhdpi/or_launcher.png
deleted file mode 100644
index f13148d214..0000000000
Binary files a/android/res/drawable-xhdpi/or_launcher.png and /dev/null differ
diff --git a/android/res/drawable/filebrowser_home.xml b/android/res/drawable/filebrowser_home.xml
deleted file mode 100644
index 1ca0fef6d5..0000000000
--- a/android/res/drawable/filebrowser_home.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/openrocket.png b/android/res/drawable/openrocket.png
deleted file mode 100644
index ca28bf5bb5..0000000000
Binary files a/android/res/drawable/openrocket.png and /dev/null differ
diff --git a/android/res/drawable/rocketglobe.png b/android/res/drawable/rocketglobe.png
deleted file mode 100644
index 6deb572b86..0000000000
Binary files a/android/res/drawable/rocketglobe.png and /dev/null differ
diff --git a/android/res/drawable/sf_donate.png b/android/res/drawable/sf_donate.png
deleted file mode 100644
index 7f5a52c597..0000000000
Binary files a/android/res/drawable/sf_donate.png and /dev/null differ
diff --git a/android/res/drawable/simulation_state.xml b/android/res/drawable/simulation_state.xml
deleted file mode 100644
index 28e5923410..0000000000
--- a/android/res/drawable/simulation_state.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/simulation_state_green.xml b/android/res/drawable/simulation_state_green.xml
deleted file mode 100644
index 4ccef1898d..0000000000
--- a/android/res/drawable/simulation_state_green.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/simulation_state_red.xml b/android/res/drawable/simulation_state_red.xml
deleted file mode 100644
index 37c5b523fb..0000000000
--- a/android/res/drawable/simulation_state_red.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/simulation_state_yellow.xml b/android/res/drawable/simulation_state_yellow.xml
deleted file mode 100644
index 1d25847849..0000000000
--- a/android/res/drawable/simulation_state_yellow.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/starfield.png b/android/res/drawable/starfield.png
deleted file mode 100644
index 6ce43c533b..0000000000
Binary files a/android/res/drawable/starfield.png and /dev/null differ
diff --git a/android/res/layout-land/main.xml b/android/res/layout-land/main.xml
deleted file mode 100644
index 693bf737c0..0000000000
--- a/android/res/layout-land/main.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout-land/simulation_event_item.xml b/android/res/layout-land/simulation_event_item.xml
deleted file mode 100644
index 726be69811..0000000000
--- a/android/res/layout-land/simulation_event_item.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout-large-land/motorbrowser.xml b/android/res/layout-large-land/motorbrowser.xml
deleted file mode 100644
index 25a2a83606..0000000000
--- a/android/res/layout-large-land/motorbrowser.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout-large-land/openrocketviewer.xml b/android/res/layout-large-land/openrocketviewer.xml
deleted file mode 100644
index 648162451a..0000000000
--- a/android/res/layout-large-land/openrocketviewer.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout-xlarge-port/motorbrowser.xml b/android/res/layout-xlarge-port/motorbrowser.xml
deleted file mode 100644
index a1cab77f49..0000000000
--- a/android/res/layout-xlarge-port/motorbrowser.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout-xlarge-port/openrocketviewer.xml b/android/res/layout-xlarge-port/openrocketviewer.xml
deleted file mode 100644
index f0b7ac936c..0000000000
--- a/android/res/layout-xlarge-port/openrocketviewer.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/component_list_item.xml b/android/res/layout/component_list_item.xml
deleted file mode 100644
index 7b12fc2d38..0000000000
--- a/android/res/layout/component_list_item.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/filebrowser_list_item.xml b/android/res/layout/filebrowser_list_item.xml
deleted file mode 100644
index 0cee268fc9..0000000000
--- a/android/res/layout/filebrowser_list_item.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/main.xml b/android/res/layout/main.xml
deleted file mode 100644
index 0ef5c289f8..0000000000
--- a/android/res/layout/main.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/motor_config_delay_dialog.xml b/android/res/layout/motor_config_delay_dialog.xml
deleted file mode 100644
index 8df8882a77..0000000000
--- a/android/res/layout/motor_config_delay_dialog.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/motor_config_item.xml b/android/res/layout/motor_config_item.xml
deleted file mode 100644
index 46b07a2755..0000000000
--- a/android/res/layout/motor_config_item.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/motor_detail_form.xml b/android/res/layout/motor_detail_form.xml
deleted file mode 100644
index ee035fa3e4..0000000000
--- a/android/res/layout/motor_detail_form.xml
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/motor_list_child.xml b/android/res/layout/motor_list_child.xml
deleted file mode 100644
index 453f4b25ab..0000000000
--- a/android/res/layout/motor_list_child.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/motor_list_dialog.xml b/android/res/layout/motor_list_dialog.xml
deleted file mode 100644
index ff18b983f8..0000000000
--- a/android/res/layout/motor_list_dialog.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/motor_list_group.xml b/android/res/layout/motor_list_group.xml
deleted file mode 100644
index a0dbd24d83..0000000000
--- a/android/res/layout/motor_list_group.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/motorbrowser.xml b/android/res/layout/motorbrowser.xml
deleted file mode 100644
index 8024bef445..0000000000
--- a/android/res/layout/motorbrowser.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/openrocketviewer.xml b/android/res/layout/openrocketviewer.xml
deleted file mode 100644
index 105284ef47..0000000000
--- a/android/res/layout/openrocketviewer.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/rocket_component.xml b/android/res/layout/rocket_component.xml
deleted file mode 100644
index 40c3ba2cd2..0000000000
--- a/android/res/layout/rocket_component.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
diff --git a/android/res/layout/rocket_configurations.xml b/android/res/layout/rocket_configurations.xml
deleted file mode 100644
index 001c52012d..0000000000
--- a/android/res/layout/rocket_configurations.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/rocket_overview.xml b/android/res/layout/rocket_overview.xml
deleted file mode 100644
index 6a881a49d5..0000000000
--- a/android/res/layout/rocket_overview.xml
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/rocket_simulations.xml b/android/res/layout/rocket_simulations.xml
deleted file mode 100644
index e856d1e971..0000000000
--- a/android/res/layout/rocket_simulations.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/simplefilebrowser.xml b/android/res/layout/simplefilebrowser.xml
deleted file mode 100644
index 7fad576b2d..0000000000
--- a/android/res/layout/simplefilebrowser.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/simulation_condition_dialog.xml b/android/res/layout/simulation_condition_dialog.xml
deleted file mode 100644
index 2edd052c7a..0000000000
--- a/android/res/layout/simulation_condition_dialog.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/simulation_event_dialog.xml b/android/res/layout/simulation_event_dialog.xml
deleted file mode 100644
index d92b42f76c..0000000000
--- a/android/res/layout/simulation_event_dialog.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/android/res/layout/simulation_event_item.xml b/android/res/layout/simulation_event_item.xml
deleted file mode 100644
index e50a2c266f..0000000000
--- a/android/res/layout/simulation_event_item.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/simulation_graph_activity.xml b/android/res/layout/simulation_graph_activity.xml
deleted file mode 100644
index 0b1fbc61b7..0000000000
--- a/android/res/layout/simulation_graph_activity.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/simulation_list_item.xml b/android/res/layout/simulation_list_item.xml
deleted file mode 100644
index 4d349188b7..0000000000
--- a/android/res/layout/simulation_list_item.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/simulation_plot_config_dialog.xml b/android/res/layout/simulation_plot_config_dialog.xml
deleted file mode 100644
index d3af9014d7..0000000000
--- a/android/res/layout/simulation_plot_config_dialog.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/layout/simulation_plot_config_event_list_item.xml b/android/res/layout/simulation_plot_config_event_list_item.xml
deleted file mode 100644
index 19eb9f2b20..0000000000
--- a/android/res/layout/simulation_plot_config_event_list_item.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
diff --git a/android/res/layout/tcqueryform.xml b/android/res/layout/tcqueryform.xml
deleted file mode 100644
index d739334aeb..0000000000
--- a/android/res/layout/tcqueryform.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/menu/main_menu.xml b/android/res/menu/main_menu.xml
deleted file mode 100644
index 51fc89f9e9..0000000000
--- a/android/res/menu/main_menu.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
\ No newline at end of file
diff --git a/android/res/menu/motor_browser_option_menu.xml b/android/res/menu/motor_browser_option_menu.xml
deleted file mode 100644
index 36308523e8..0000000000
--- a/android/res/menu/motor_browser_option_menu.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
\ No newline at end of file
diff --git a/android/res/menu/rocket_viewer_configurations_option_menu.xml b/android/res/menu/rocket_viewer_configurations_option_menu.xml
deleted file mode 100644
index 0464e59ab7..0000000000
--- a/android/res/menu/rocket_viewer_configurations_option_menu.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
\ No newline at end of file
diff --git a/android/res/menu/rocket_viewer_option_menu.xml b/android/res/menu/rocket_viewer_option_menu.xml
deleted file mode 100644
index eaf7bc22a2..0000000000
--- a/android/res/menu/rocket_viewer_option_menu.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
\ No newline at end of file
diff --git a/android/res/menu/rocket_viewer_simulation_option_menu.xml b/android/res/menu/rocket_viewer_simulation_option_menu.xml
deleted file mode 100644
index 0464e59ab7..0000000000
--- a/android/res/menu/rocket_viewer_simulation_option_menu.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
\ No newline at end of file
diff --git a/android/res/menu/simulation_option_menu.xml b/android/res/menu/simulation_option_menu.xml
deleted file mode 100644
index 0f8aa934fa..0000000000
--- a/android/res/menu/simulation_option_menu.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
\ No newline at end of file
diff --git a/android/res/values-fr/strings.xml b/android/res/values-fr/strings.xml
deleted file mode 100644
index c09dee135c..0000000000
--- a/android/res/values-fr/strings.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
-
- OpenRocket
- version 12.09
- Charger
- Sauvegarder
- Ajouter
- Liste de moteur
- Télécharger
- A propos
- Préférences
- Changer le tracé
- Voir les événements
- Sélectionner les Séries et Evénements
- Tracer
- Sauvegarder le fichierâ…
- Charger le fichierâ…
- Voulez vous sauvegarder les changements dans le modèle courant?
- Non
- Oui
- Sauvegarde automatique de la fusée
- Erreur en chargeant le fichier
-
-
- Boitier
- Diamètre
- Impulsion
- Fabriquant
-
-
- Soumettre
- Choisir la Configuration
- Séries 1
- Séries 2
-
- Sauvegarde auto de la fusée
- Sauvegarde automatique du document fusée après avoir fait les simulations
-
- Motor Browser Grouping
- Set the grouping in Motor Browser
-
- Motor Browser
-
- Utiliser le gestionnaire de fichiers interne
- Vérification pour Utiliser le gestionnaire de fichiers interne à la place d\'un gestionnaire de fichiers externe
-
- Montrer seulement les fichiers ORK avec le gestionnaire de fichiers interne
- Check to show only .ork files in internal file browser
-
-
- Millimètres
- Centimètres
- Mètres
- Pouces
- Pieds
-
-
- Grammes
- Kilogrammes
- Onces
- Livres
-
-
- Mètres/Seconde
- Kilomètres/Heure
- Pied/Seconde
- Miles/Heure
-
-
- Mètres
- Kilomètres
- Pieds
- Yards
- Miles
- Miles Nautiques
-
- CG
- Concepteur
- Longueur
- Masse à vide
- Nombre d\'étages
- Poids au décollage
- CP
- Marge de stabilité
- Ouvrir le fichier ork
- Voir les moteurs
- Fabriquant
- Nom commun
- Retards
- Info boitier
- Class de l\'impulsion
- Diamètre
- Longueur
- Choisir les Moteurs
- Vitesse du vent
- Longueur de la rampe
- Angle de la rampe
- Direction de la rampe
- Choisir le moteur
- Retard
- Effacer
- Lancer
-
-
diff --git a/android/res/values-v11/styles.xml b/android/res/values-v11/styles.xml
deleted file mode 100644
index 535b5345ac..0000000000
--- a/android/res/values-v11/styles.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/values/pref_strings.xml b/android/res/values/pref_strings.xml
deleted file mode 100644
index 5f3284ac4c..0000000000
--- a/android/res/values/pref_strings.xml
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
- PreferenceMotorBrowserGroupingOption
- PreferenceUseInternalFileBrowserOpion
- PreferenceFileBrowserBaseDirectory
- PreferenceShowOnlyOrkFiles
- PreferenceAutoSaveOption
-
-
- 0
- 1
- 2
- 3
-
-
- PreferenceUnitLengthOption
-
-
- mm
- cm
- m
- in
- ft
-
-
- PreferenceUnitMassOption
-
-
- g
- kg
- oz
- lb
-
-
- PreferenceUnitVelocityOption
-
-
- m/s
- km/h
- ft/s
- mph
-
-
- PreferenceUnitDistanceOption
-
-
- m
- km
- ft
- yd
- mi
- nmi
-
-
-
- AeroTech
- Alpha Hybrids
- Animal Motor Works
- Apogee Components
- Cesaroni Technology
- Contrail Rockets
- Ellis Mountain
- Estes Industries
- Gorilla Rocket Motors
- Hypertek
- Kosdon by AeroTech
- Kosdon TRM
- Loki Research
- Propulsion Polymers
- Public Missiles, Ltd.
- Quest Aerospace
- R.A.T.T. Works
- Roadrunner Rocketry
- Rocketvision Flight-Star
- Sky Ripper Systems
- West Coast Hybrids
-
-
-
- A
- B
- C
- D
- E
- F
- G
- H
- I
- J
- K
- L
- M
- N
- O
-
-
-
- 6
- 10.5
- 13
- 18
- 20
- 24
- 29
- 32
- 38
- 54
- 64
- 69
- 75
- 76
- 81
- 98
- 152
- 161
-
-
-
\ No newline at end of file
diff --git a/android/res/values/simulation_states.xml b/android/res/values/simulation_states.xml
deleted file mode 100644
index 836f7b4190..0000000000
--- a/android/res/values/simulation_states.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml
deleted file mode 100644
index c0d4d49fd7..0000000000
--- a/android/res/values/strings.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-
-
-
- OpenRocket
- version 12.09
- Cancel
- OK
- Dismiss
- Load
- Save
- Add
- Motor List
- Download
- About
- Preferences
- Missing Motors
- The following motors are missing:
- Would you like to download them from Thrustcurve?
- Change Plot
- View Events
- Select Series And Events
- Delete Motor Configuration
-
- Plot
- Saving file…
- Loading file…
- Would you like to save the changes to the current model?
- No
- Yes
- Automatically saving rocket
- Error Loading File
-
-
- Case
- Diameter
- Impulse
- Manufacturer
-
-
- Submit
- Download from Thrustcurve.org
- Select Configuration
- Series 1
- Series 2
-
- Autosave Rocket
- Automatically save the rocket document after simulations
-
- Motor Browser Grouping
- Set the grouping in Motor Browser
-
- Motor Browser
-
- Use Internal File Browser
- Check to use built in file browser instead of external file browser
-
- Show only ORK files in Internal File Browser
- Check to show only .ork files in internal file browser
-
-
- Millimeters
- Centimeters
- Meters
- Inches
- Feet
-
-
- Grams
- Kilograms
- Ounces
- Pounds
-
-
- Meters/Second
- Kilometers/Hour
- Feet/Second
- Miles/Hour
-
-
- Meters
- Kilometers
- Feet
- Yards
- Miles
- Nautical Miles
-
- CG
- Designer
- Length
- Empty Mass
- Stage Count
- Lift off weight
- CP
- Stability margin
- Open ork file
- View motors
- Manufacturer
- Common Name
- Delays
- Case Info
- Impulse Class
- Diameter
- Length
- Select Motors
- Wind speed
- Launch Rod Length
- Launch Rod Angle
- Launch Rod Direction
- Select Motor
- Delay
- Delete
- Run
- Edit
-
-
\ No newline at end of file
diff --git a/android/res/values/styles.xml b/android/res/values/styles.xml
deleted file mode 100644
index edb9e721ff..0000000000
--- a/android/res/values/styles.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/xml/preferences.xml b/android/res/xml/preferences.xml
deleted file mode 100644
index ff39a61f38..0000000000
--- a/android/res/xml/preferences.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-
-
- android:key="preferences"
- android:title="Pref Title"
- android:summary="pref summary"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/src/build.properties b/android/src/build.properties
deleted file mode 100644
index b892c09780..0000000000
--- a/android/src/build.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-build.version=12.03-droid-DEV
-build.source=source
diff --git a/android/src/net/sf/openrocket/android/AboutDialogFragment.java b/android/src/net/sf/openrocket/android/AboutDialogFragment.java
deleted file mode 100644
index 5f5813a6be..0000000000
--- a/android/src/net/sf/openrocket/android/AboutDialogFragment.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package net.sf.openrocket.android;
-
-import android.app.AlertDialog;
-import android.os.Bundle;
-import android.support.v4.app.DialogFragment;
-import android.text.Html;
-import android.text.method.LinkMovementMethod;
-import android.widget.TextView;
-
-public class AboutDialogFragment extends DialogFragment {
-
- public static AboutDialogFragment newInstance() {
- AboutDialogFragment frag = new AboutDialogFragment();
- return frag;
- }
-
- @Override
- public AlertDialog onCreateDialog(Bundle savedInstanceState) {
-
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- // .setIcon(android.R.drawable.alert_dialog_icon)
- builder.setTitle("About OpenRocket");
- StringBuilder sb = new StringBuilder();
- sb.append("
Copyright 2007-2012 Sampo Niskanen and others
");
- sb.append("
Android port by Kevin Ruland
");
- sb.append("");
- sb.append("
Licensed under GPLv3 or later. ");
- sb.append("Full source available on SourceForge
");
- sb.append("
The android port contains third party software:
");
- sb.append("
AChartEngine - Apache License 2.0
");
- sb.append("
Android Open Source Project - Apache License 2.0
");
- sb.append("
Android tree-view-list - 2-clause BSD licensed
");
- String s = sb.toString();
- builder.setMessage(Html.fromHtml(s));
- builder.setCancelable(true);
- return builder.create();
- }
-
- @Override
- public void onStart() {
- super.onStart();
- ((TextView) this.getDialog().findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
- }
-
-
-}
diff --git a/android/src/net/sf/openrocket/android/ActivityHelpers.java b/android/src/net/sf/openrocket/android/ActivityHelpers.java
deleted file mode 100644
index 02e920e4c2..0000000000
--- a/android/src/net/sf/openrocket/android/ActivityHelpers.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package net.sf.openrocket.android;
-
-import net.sf.openrocket.android.motor.MotorBrowserActivity;
-import net.sf.openrocket.android.thrustcurve.TCQueryActivity;
-import android.app.Activity;
-import android.content.Intent;
-import android.net.Uri;
-import android.support.v4.app.FragmentActivity;
-
-public abstract class ActivityHelpers {
-
- public static void goHome( Activity parent ) {
- Intent i = new Intent(parent, Main.class);
- i.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP + Intent.FLAG_ACTIVITY_NEW_TASK );
- parent.startActivity(i);
- }
-
- public static void browseMotors( Activity parent ) {
- Intent i = new Intent(parent, MotorBrowserActivity.class);
- parent.startActivity(i);
- }
-
- public static void startPreferences( Activity parent ) {
- Intent intent = new Intent(parent, PreferencesActivity.class);
- parent.startActivity(intent);
- }
-
- public static void downloadFromThrustcurve( Activity parent, int requestCode ) {
- Intent i = new Intent(parent, TCQueryActivity.class);
- parent.startActivityForResult(i, requestCode);
- }
-
- public static void donate( Activity parent ) {
- String url = "http://sourceforge.net/donate/index.php?group_id=260357";
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData( Uri.parse(url) );
- parent.startActivity(intent);
- }
-
- public static void showAbout( FragmentActivity parent ) {
- AboutDialogFragment frag = AboutDialogFragment.newInstance();
- frag.show(parent.getSupportFragmentManager(), "about");
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/Application.java b/android/src/net/sf/openrocket/android/Application.java
deleted file mode 100644
index 9661f400dd..0000000000
--- a/android/src/net/sf/openrocket/android/Application.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package net.sf.openrocket.android;
-
-import java.util.Locale;
-
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.database.ComponentPresetDatabase;
-import net.sf.openrocket.l10n.DebugTranslator;
-import net.sf.openrocket.l10n.ResourceBundleTranslator;
-import net.sf.openrocket.l10n.Translator;
-import android.content.pm.ApplicationInfo;
-import android.preference.PreferenceManager;
-
-public class Application extends android.app.Application {
-
- // Big B boolean so I can synchronize on it.
- private static Boolean initialized = false;
-
- public void initialize() {
- synchronized (initialized) {
- if ( initialized == true ) {
- return;
- }
-
- // Android does not have a default sax parser set. This needs to be defined first.
- System.setProperty("org.xml.sax.driver","org.xmlpull.v1.sax2.Driver");
-
- net.sf.openrocket.startup.Application.setLogger( new AndroidLogWrapper.LogHelper() );
-
- net.sf.openrocket.startup.Application.setPreferences( new PreferencesAdapter() );
-
- net.sf.openrocket.startup.Application.setComponentPresetDao( new ComponentPresetDatabase(){
- @Override
- protected void load() {
- // We don't need components
- }
- } );
-
- MotorDatabaseAdapter db = new MotorDatabaseAdapter(this);
-
- net.sf.openrocket.startup.Application.setMotorSetDatabase(db);
-
- Translator t;
- t = new ResourceBundleTranslator("l10n.messages");
- if (Locale.getDefault().getLanguage().equals("xx")) {
- t = new DebugTranslator(t);
- }
-
- net.sf.openrocket.startup.Application.setBaseTranslator(t);
-
- initialized = true;
- }
- }
-
- public Application() {
- }
-
- /* (non-Javadoc)
- * @see android.app.Application#onCreate()
- */
- @Override
- public void onCreate() {
- super.onCreate();
- initialize();
- boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
- AndroidLogWrapper.setLogEnabled(isDebuggable);
- PreferencesActivity.initializePreferences(this, PreferenceManager.getDefaultSharedPreferences(this));
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/CurrentRocket.java b/android/src/net/sf/openrocket/android/CurrentRocket.java
deleted file mode 100644
index 3644606395..0000000000
--- a/android/src/net/sf/openrocket/android/CurrentRocket.java
+++ /dev/null
@@ -1,154 +0,0 @@
-package net.sf.openrocket.android;
-
-import static net.sf.openrocket.android.events.Events.*;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
-import net.sf.openrocket.aerodynamics.WarningSet;
-import net.sf.openrocket.document.OpenRocketDocument;
-import net.sf.openrocket.document.Simulation;
-import net.sf.openrocket.document.StorageOptions;
-import net.sf.openrocket.file.openrocket.OpenRocketSaver;
-import net.sf.openrocket.rocketcomponent.Rocket;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.support.v4.content.LocalBroadcastManager;
-
-public class CurrentRocket {
-
- private Uri fileUri;
-
- private OpenRocketDocument rocketDocument;
- private WarningSet warnings;
-
- private boolean isModified = false;
- private Set runningSims = new HashSet();
-
- /**
- * @return the rocketDocument
- */
- public OpenRocketDocument getRocketDocument() {
- return rocketDocument;
- }
-
- private void notifySimsChanged( Context context ) {
- Intent msg = new Intent(MESSAGE_ACTION);
- msg.putExtra(TYPE, SIMS_CHANGED);
-
- LocalBroadcastManager.getInstance(context).sendBroadcast(msg);
- }
-
- private void notifySimComplete( Context context ) {
- Intent msg = new Intent(MESSAGE_ACTION);
- msg.putExtra(TYPE, SIM_COMPLETE);
-
- LocalBroadcastManager.getInstance(context).sendBroadcast(msg);
- }
-
- private void notifyMotorConfigChanged( Context context ) {
- Intent msg = new Intent(MESSAGE_ACTION);
- msg.putExtra(TYPE, CONFIGS_CHANGED);
-
- LocalBroadcastManager.getInstance(context).sendBroadcast(msg);
- }
-
- public synchronized void lockSimulation( Context context, int simulationId ) {
- runningSims.add(simulationId);
- // TODO - someday we might want to know about this:
- // notifySimsChanged( context );
- }
-
- public synchronized void unlockSimulation( Context context, int simulationId ) {
- this.isModified = true;
- runningSims.remove(simulationId);
- notifySimComplete(context);
- }
-
- public synchronized Set lockedSimulations() {
- return new HashSet(runningSims);
- }
-
- public synchronized void addNewSimulation( Context context ) {
- isModified = true;
- Rocket rocket = rocketDocument.getRocket();
- Simulation newSim = new Simulation(rocket);
- newSim.setName(rocketDocument.getNextSimulationName());
- rocketDocument.addSimulation(newSim);
- notifySimsChanged(context);
- }
-
- public synchronized void deleteSimulation( Context context, int simulationPos ) {
- isModified = true;
- rocketDocument.removeSimulation( simulationPos );
- notifySimsChanged(context);
- }
-
- public synchronized String addNewMotorConfig( Context context ) {
- isModified = true;
- String configId = rocketDocument.getRocket().newMotorConfigurationID();
- notifyMotorConfigChanged(context);
- return configId;
- }
-
- public synchronized void deleteMotorConfig( Context context, String config ) {
- rocketDocument.getRocket().removeMotorConfigurationID(config);
- notifyMotorConfigChanged(context);
- }
-
- /**
- * @param rocketDocument the rocketDocument to set
- */
- public void setRocketDocument(OpenRocketDocument rocketDocument) {
- this.rocketDocument = rocketDocument;
- synchronized ( this ) {
- isModified = false;
- }
- }
-
- public WarningSet getWarnings() {
- return warnings;
- }
-
- public void setWarnings(WarningSet warnings) {
- this.warnings = warnings;
- }
-
- public Uri getFileUri() {
- return fileUri;
- }
-
- public void setFileUri(Uri fileUri) {
- this.fileUri = fileUri;
- }
-
- public boolean isModified() {
- return this.isModified;
- }
-
- public boolean canSave() {
- return this.isModified && this.runningSims.isEmpty();
- }
-
- public void saveOpenRocketDocument() throws IOException {
-
- // Translate the fileUri if it happens to be a .rkt file.
-
- String filename = fileUri.getPath();
-
- if ( ! filename.endsWith(".ork") ) {
- filename = filename.concat(".ork");
- }
-
- OpenRocketSaver saver = new OpenRocketSaver();
- StorageOptions options = new StorageOptions();
- options.setCompressionEnabled(true);
- options.setSimulationTimeSkip(StorageOptions.SIMULATION_DATA_ALL);
- saver.save(new File(filename),rocketDocument,options);
- isModified = false;
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/CurrentRocketHolder.java b/android/src/net/sf/openrocket/android/CurrentRocketHolder.java
deleted file mode 100644
index 566a2dbe29..0000000000
--- a/android/src/net/sf/openrocket/android/CurrentRocketHolder.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package net.sf.openrocket.android;
-
-
-public abstract class CurrentRocketHolder {
-
- private static CurrentRocket currentRocket = new CurrentRocket();
-
- public static CurrentRocket getCurrentRocket() {
- return currentRocket;
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/Main.java b/android/src/net/sf/openrocket/android/Main.java
deleted file mode 100644
index 7b6eb48e3e..0000000000
--- a/android/src/net/sf/openrocket/android/Main.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package net.sf.openrocket.android;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.rocket.OpenRocketLoaderActivity;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.Button;
-
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-public class Main extends OpenRocketLoaderActivity {
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.main);
- ((Button) findViewById(R.id.main_open)).setOnClickListener(
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Main.this.pickOrkFiles();
- }
- });
- ((Button) findViewById(R.id.main_browse)).setOnClickListener(
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- ActivityHelpers.browseMotors(Main.this);
- }
- });
- ((Button) findViewById(R.id.main_donate)).setOnClickListener(
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- ActivityHelpers.donate(Main.this);
- }
- });
- }
-
- @Override
- protected void onPostResume() {
- super.onPostResume();
- // Rocket already loaded.
- if ( !isLoading() && CurrentRocketHolder.getCurrentRocket().getRocketDocument() != null ) {
- moveOnToViewer();
- }
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getSupportMenuInflater();
- inflater.inflate(R.menu.main_menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch( item.getItemId() ) {
- case R.id.main_menu_preferences:
- ActivityHelpers.startPreferences(this);
- return true;
- case R.id.menu_about:
- ActivityHelpers.showAbout(this);
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/MotorDatabaseAdapter.java b/android/src/net/sf/openrocket/android/MotorDatabaseAdapter.java
deleted file mode 100644
index cb027d2b8a..0000000000
--- a/android/src/net/sf/openrocket/android/MotorDatabaseAdapter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package net.sf.openrocket.android;
-
-import java.util.Collections;
-import java.util.List;
-
-import net.sf.openrocket.android.db.DbAdapter;
-import net.sf.openrocket.android.motor.ExtendedThrustCurveMotor;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.database.MotorDatabase;
-import net.sf.openrocket.motor.Motor;
-import net.sf.openrocket.motor.Motor.Type;
-import android.content.Context;
-
-public class MotorDatabaseAdapter implements MotorDatabase {
-
- private DbAdapter mDbHelper;
-
- public MotorDatabaseAdapter( Context ctx ) {
- mDbHelper = new DbAdapter(ctx);
- mDbHelper.open();
- }
-
- @Override
- public List extends Motor> findMotors(Type type, String manufacturer,
- String designation, double diameter, double length) {
-
- AndroidLogWrapper.d(MotorDatabaseAdapter.class,"find motor: type="+ String.valueOf(type));
- AndroidLogWrapper.d(MotorDatabaseAdapter.class,"find motor: manu="+ manufacturer);
- AndroidLogWrapper.d(MotorDatabaseAdapter.class,"find motor: designation="+ designation);
- AndroidLogWrapper.d(MotorDatabaseAdapter.class,"find motor: diameter=" +diameter);
- AndroidLogWrapper.d(MotorDatabaseAdapter.class,"find motor: length="+ length);
-
- try {
- ExtendedThrustCurveMotor m = mDbHelper.getMotorDao().fetchMotor(manufacturer, designation);
- if ( m != null ) {
- return Collections.singletonList(m);
- }
- } catch ( Exception ex ) {
-
- }
- return Collections.emptyList();
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/PreferencesActivity.java b/android/src/net/sf/openrocket/android/PreferencesActivity.java
deleted file mode 100644
index c6e6eee327..0000000000
--- a/android/src/net/sf/openrocket/android/PreferencesActivity.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package net.sf.openrocket.android;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.unit.UnitGroup;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.preference.Preference;
-import android.preference.PreferenceManager;
-
-import com.actionbarsherlock.app.SherlockPreferenceActivity;
-
-public class PreferencesActivity extends SherlockPreferenceActivity
-{
-
-
- @Override
- protected void onCreate( Bundle savedInstanceState ) {
- super.onCreate( savedInstanceState );
- addPreferencesFromResource(R.xml.preferences);
-
- PreferenceManager prefManager = getPreferenceManager();
- {
- String key = getApplication().getResources().getString(R.string.PreferenceUnitLengthOption);
- Preference pref = prefManager.findPreference(key);
- new UnitPreferenceListener(pref, UnitGroup.UNITS_LENGTH, "Current value ");
-
- }
- {
- String key = getApplication().getResources().getString(R.string.PreferenceUnitMassOption);
- Preference pref = prefManager.findPreference(key);
- new UnitPreferenceListener(pref, UnitGroup.UNITS_MASS, "Current value ");
-
- }
- {
- String key = getApplication().getResources().getString(R.string.PreferenceUnitVelocityOption);
- Preference pref = prefManager.findPreference(key);
- new UnitPreferenceListener(pref, UnitGroup.UNITS_VELOCITY, "Current value ");
-
- }
- {
- String key = getApplication().getResources().getString(R.string.PreferenceUnitDistanceOption);
- Preference pref = prefManager.findPreference(key);
- new UnitPreferenceListener(pref, UnitGroup.UNITS_DISTANCE, "Current value ");
-
- }
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- }
-
- /**
- * This method is to be called from Application setup to pull the saved preference
- * values into the various datastructures used in OpenRocket.
- * This method is located in this class because it is probably best to have as much
- * of the code in the same place as possible.
- * @param sharedPreferences
- */
- public static void initializePreferences( android.app.Application app, SharedPreferences sharedPreferences ) {
-
- String unitLength = app.getResources().getString(R.string.PreferenceUnitLengthOption);
- String len = sharedPreferences.getString(unitLength, "cm");
- UnitGroup.UNITS_LENGTH.setDefaultUnit( len );
-
- AndroidLogWrapper.d(PreferencesActivity.class, "Chaning mass");
- String unitMass = app.getResources().getString(R.string.PreferenceUnitMassOption);
- String mass = sharedPreferences.getString(unitMass, "g");
- UnitGroup.UNITS_MASS.setDefaultUnit( mass );
-
- String unitVelocity = app.getResources().getString(R.string.PreferenceUnitVelocityOption);
- String velocity = sharedPreferences.getString(unitVelocity, "m/s");
- UnitGroup.UNITS_VELOCITY.setDefaultUnit( velocity );
-
- String unitDistance = app.getResources().getString(R.string.PreferenceUnitDistanceOption);
- String distance = sharedPreferences.getString(unitDistance, "m");
- UnitGroup.UNITS_DISTANCE.setDefaultUnit( distance );
-
- }
-
- private class UnitPreferenceListener implements Preference.OnPreferenceChangeListener {
-
- private UnitGroup matchedGroup;
- private String message;
- private Preference pref;
-
- private UnitPreferenceListener( Preference pref, UnitGroup unit, String message) {
- this.pref = pref;
- this.matchedGroup = unit;
- this.message = message;
- pref.setSummary(message + unit.getDefaultUnit().getUnit());
- // todo figure out how to setSummary - need to get initial value.
- pref.setOnPreferenceChangeListener(this);
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- matchedGroup.setDefaultUnit((String)newValue);
- preference.setSummary(message + newValue);
- return true;
- }
-
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/PreferencesAdapter.java b/android/src/net/sf/openrocket/android/PreferencesAdapter.java
deleted file mode 100644
index e4d68a7a54..0000000000
--- a/android/src/net/sf/openrocket/android/PreferencesAdapter.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package net.sf.openrocket.android;
-
-import java.util.Collections;
-import java.util.Set;
-
-import net.sf.openrocket.material.Material;
-import net.sf.openrocket.preset.ComponentPreset;
-import net.sf.openrocket.preset.ComponentPreset.Type;
-
-public class PreferencesAdapter extends net.sf.openrocket.startup.Preferences {
-
- @Override
- public boolean getBoolean(String key, boolean defaultValue) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public void putBoolean(String key, boolean value) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public int getInt(String key, int defaultValue) {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public void putInt(String key, int value) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public double getDouble(String key, double defaultValue) {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public void putDouble(String key, double value) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public String getString(String key, String defaultValue) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void putString(String key, String value) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public String getString(String directory, String key, String defaultValue) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void putString(String directory, String key, String value) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see net.sf.openrocket.startup.Preferences#addUserMaterial(net.sf.openrocket.material.Material)
- */
- @Override
- public void addUserMaterial(Material m) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see net.sf.openrocket.startup.Preferences#getUserMaterials()
- */
- @Override
- public Set getUserMaterials() {
- return Collections.emptySet();
- }
-
- /* (non-Javadoc)
- * @see net.sf.openrocket.startup.Preferences#removeUserMaterial(net.sf.openrocket.material.Material)
- */
- @Override
- public void removeUserMaterial(Material m) {
- }
-
- @Override
- public void setComponentFavorite(ComponentPreset preset, Type type, boolean favorite) {
- }
-
- @Override
- public Set getComponentFavorites(Type type) {
- return Collections.emptySet();
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/db/ConversionUtils.java b/android/src/net/sf/openrocket/android/db/ConversionUtils.java
deleted file mode 100644
index a1f5bee945..0000000000
--- a/android/src/net/sf/openrocket/android/db/ConversionUtils.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package net.sf.openrocket.android.db;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.openrocket.motor.Motor;
-import net.sf.openrocket.util.Coordinate;
-
-public abstract class ConversionUtils {
-
- static double[] stringToDelays( String value ) {
- if (value == null || "".equals(value) ) {
- return new double[0];
- }
- String[] parts = value.split(",");
- double[] values = new double[parts.length];
- for( int i =0; i delaysToStringList( double[] delays ) {
- ArrayList list = new ArrayList( delays.length );
- for( double d: delays ) {
- if ( d == Motor.PLUGGED ) {
- list.add("P");
- } else {
- list.add(String.valueOf(Math.round(d)));
- }
- }
- return list;
- }
-
- public static double stringToDelay( String s ) {
- if ( "P".equals(s) ) {
- return Motor.PLUGGED;
- }
- return Long.parseLong(s);
- }
-
- static double[] deserializeArrayOfDouble( byte[] bytes ) throws Exception {
- double[] data = null;
- if (bytes != null ) {
- ObjectInputStream is = new ObjectInputStream( new ByteArrayInputStream(bytes));
- data = (double[]) is.readObject();
- }
- return data;
- }
-
- static byte[] serializeArrayOfDouble( double[] data ) throws Exception {
-
- byte[] serObj = null;
- if ( data != null ) {
- ByteArrayOutputStream b = new ByteArrayOutputStream();
- ObjectOutputStream os = new ObjectOutputStream(b);
- os.writeObject(data);
- os.close();
- serObj = b.toByteArray();
- }
- return serObj;
- }
-
- static Coordinate[] deserializeArrayOfCoordinate( byte[] bytes ) throws Exception {
- Coordinate[] data = null;
- if (bytes != null ) {
- ObjectInputStream is = new ObjectInputStream( new ByteArrayInputStream(bytes));
- data = (Coordinate[]) is.readObject();
- }
- return data;
- }
-
- static byte[] serializeArrayOfCoordinate( Coordinate[] data ) throws Exception {
-
- byte[] serObj = null;
- if ( data != null ) {
- ByteArrayOutputStream b = new ByteArrayOutputStream();
- ObjectOutputStream os = new ObjectOutputStream(b);
- os.writeObject(data);
- os.close();
- serObj = b.toByteArray();
- }
- return serObj;
- }
-
-
-}
\ No newline at end of file
diff --git a/android/src/net/sf/openrocket/android/db/DbAdapter.java b/android/src/net/sf/openrocket/android/db/DbAdapter.java
deleted file mode 100644
index 0b601d9a5e..0000000000
--- a/android/src/net/sf/openrocket/android/db/DbAdapter.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package net.sf.openrocket.android.db;
-
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import android.content.Context;
-import android.database.SQLException;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-
-public class DbAdapter {
-
- private static final String TAG = "DbAdapter";
- private DatabaseHelper mDbHelper;
- private SQLiteDatabase mDb;
-
- private static final String DATABASE_NAME = "openrocket";
- private static final int DATABASE_VERSION = 3;
-
- private final Context mCtx;
-
- private MotorDao motorDao;
-
- public MotorDao getMotorDao() {
- return motorDao;
- }
-
- private class DatabaseHelper extends SQLiteOpenHelper {
- DatabaseHelper(Context context) {
- super(context, DATABASE_NAME, null, DATABASE_VERSION);
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- executeSQL( db, MotorDao.create());
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- AndroidLogWrapper.w(DbAdapter.class, "Upgrading database from version " + oldVersion + " to "
- + newVersion + ", which will destroy all old data");
- executeSQL(db, MotorDao.update(oldVersion, newVersion));
- }
-
- private void executeSQL( SQLiteDatabase db, String[] sqls ) {
- for(String s: sqls ) {
- db.execSQL(s);
- }
- }
-
- }
-
- /**
- * Constructor - takes the context to allow the database to be
- * opened/created
- *
- * @param ctx the Context within which to work
- */
- public DbAdapter(Context ctx) {
- this.mCtx = ctx;
- }
-
- /**
- * Open the database. If it cannot be opened, try to create a new
- * instance of the database. If it cannot be created, throw an exception to
- * signal the failure
- *
- * @return this (self reference, allowing this to be chained in an
- * initialization call)
- * @throws SQLException if the database could be neither opened or created
- */
- public DbAdapter open() throws SQLException {
- mDbHelper = new DatabaseHelper(mCtx);
- mDb = mDbHelper.getWritableDatabase();
- motorDao = new MotorDao(mDb);
- return this;
- }
-
- public void close() {
- mDbHelper.close();
- }
-
-}
\ No newline at end of file
diff --git a/android/src/net/sf/openrocket/android/db/MotorDao.java b/android/src/net/sf/openrocket/android/db/MotorDao.java
deleted file mode 100644
index 8c865437c8..0000000000
--- a/android/src/net/sf/openrocket/android/db/MotorDao.java
+++ /dev/null
@@ -1,280 +0,0 @@
-package net.sf.openrocket.android.db;
-
-import net.sf.openrocket.android.motor.ExtendedThrustCurveMotor;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.android.util.AndroidLogWrapper.LogHelper;
-import net.sf.openrocket.motor.Manufacturer;
-import net.sf.openrocket.motor.Motor;
-import net.sf.openrocket.motor.ThrustCurveMotor;
-import net.sf.openrocket.util.Coordinate;
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-
-public class MotorDao {
-
- private SQLiteDatabase mDb;
-
- private final static String DATABASE_TABLE = "motor";
- private final static String DROP_TABLE = "DROP TABLE IF EXISTS " + DATABASE_TABLE;
- private final static String CREATE_TABLE =
- "create table " + DATABASE_TABLE + " ( " +
- "_id integer primary key, " +
- "unique_name text unique, " +
- "digest string, " +
- "designation text, " +
- "delays text, " +
- "diameter number, " +
- "tot_impulse_ns number, " +
- "avg_thrust_n number, " +
- "max_thrust_n number, " +
- "burn_time_s number, " +
- "length number," +
- "prop_mass_g number," +
- "tot_mass_g number," +
- "case_info text," +
- "manufacturer text," +
- "type text," +
- "impulse_class text," +
- "thrust_data blob," +
- "time_data blob," +
- "cg_data blob" +
- ");";
-
- MotorDao(SQLiteDatabase mDb) {
- this.mDb = mDb;
- }
-
- static String[] create() {
- return new String[] { CREATE_TABLE };
- }
-
- static String[] update(int oldVer, int newVer) {
- return new String[] { DROP_TABLE, CREATE_TABLE };
- }
-
- public final static String ID = "_id";
- public final static String UNIQUE_NAME = "unique_name";
- public final static String DIGEST = "digest";
- public final static String DESIGNATION = "designation";
- public final static String DELAYS = "delays";
- public final static String DIAMETER = "diameter";
- public final static String TOTAL_IMPULSE = "tot_impulse_ns";
- public final static String AVG_THRUST = "avg_thrust_n";
- public final static String MAX_THRUST = "max_thrust_n";
- public final static String BURN_TIME = "burn_time_s";
- public final static String LENGTH = "length";
- public final static String CASE_INFO = "case_info";
- public final static String MANUFACTURER = "manufacturer";
- public final static String TYPE = "type";
- public final static String IMPULSE_CLASS = "impulse_class";
- public final static String THRUST_DATA = "thrust_data";
- public final static String TIME_DATA = "time_data";
- public final static String CG_DATA = "cg_data";
-
- private final static String[] ALL_COLS = new String[] {
- ID,
- DIGEST,
- DESIGNATION,
- DELAYS,
- DIAMETER,
- TOTAL_IMPULSE,
- AVG_THRUST,
- MAX_THRUST,
- BURN_TIME,
- LENGTH,
- CASE_INFO,
- TYPE,
- IMPULSE_CLASS,
- MANUFACTURER,
- THRUST_DATA,
- TIME_DATA,
- CG_DATA
- };
-
- public long insertOrUpdateMotor(ExtendedThrustCurveMotor mi) throws Exception {
- ContentValues initialValues = new ContentValues();
- initialValues.put(ID, mi.getId());
- initialValues.put(UNIQUE_NAME, mi.getManufacturer() + mi.getDesignation());
- initialValues.put(DIGEST, mi.getDigest());
- initialValues.put(DESIGNATION, mi.getDesignation());
- initialValues.put(DELAYS, ConversionUtils.delaysToString(mi.getStandardDelays()));
- initialValues.put(DIAMETER, mi.getDiameter());
- initialValues.put(TOTAL_IMPULSE, mi.getTotalImpulseEstimate());
- initialValues.put(AVG_THRUST, mi.getAverageThrustEstimate());
- initialValues.put(MAX_THRUST, mi.getMaxThrustEstimate());
- initialValues.put(BURN_TIME, mi.getBurnTimeEstimate());
- initialValues.put(LENGTH, mi.getLength());
- initialValues.put(CASE_INFO, mi.getCaseInfo());
- initialValues.put(TYPE, mi.getMotorType().name());
- initialValues.put(IMPULSE_CLASS, mi.getImpulseClass());
- initialValues.put(MANUFACTURER, mi.getManufacturer().getSimpleName());
- initialValues.put(THRUST_DATA, ConversionUtils.serializeArrayOfDouble(mi.getThrustPoints()));
- initialValues.put(TIME_DATA, ConversionUtils.serializeArrayOfDouble(mi.getTimePoints()));
- initialValues.put(CG_DATA, ConversionUtils.serializeArrayOfCoordinate(mi.getCGPoints()));
-
- AndroidLogWrapper.d(MotorDao.class, "insertOrUpdate Motor");
- long rv = mDb.insertWithOnConflict(DATABASE_TABLE, null, initialValues, SQLiteDatabase.CONFLICT_REPLACE);
- return rv;
- }
-
- /**
- * Delete the motor and burn data with the given rowId
- *
- * @param name name of motor to delete
- * @return true if deleted, false otherwise
- */
- public boolean deleteMotor(Long id) {
-
- boolean rv = mDb.delete(DATABASE_TABLE, ID + "=" + id, null) > 0;
- return rv;
- }
-
- /**
- *
- * @param groupCol
- * @param groupVal
- * @return
- */
- public Cursor fetchAllInGroups(String groupCol, String groupVal) {
- return mDb.query(DATABASE_TABLE,
- /* columns */ALL_COLS,
- /* selection */groupCol + "=?",
- /* selection args*/new String[] { groupVal },
- /* groupby */null,
- /* having*/null,
- /* orderby*/TOTAL_IMPULSE);
-
- }
-
- /**
- * Fetch the groups based on groupCol
- * @param groupCol
- * @return
- */
- public Cursor fetchGroups(String groupCol) {
- return mDb.query(true, DATABASE_TABLE,
- /* columns */new String[] {
- groupCol
- },
- /* selection */null,
- /* selection args*/null,
- /* groupby */null,
- /* having*/null,
- /* orderby*/groupCol,
- /* limit*/null);
-
- }
-
- /**
- * Return a Cursor over the list of all motors
- *
- * @return Cursor over all notes
- */
- public Cursor fetchAllMotors() {
-
- return mDb.query(DATABASE_TABLE,
- /* columns */ALL_COLS,
- /* selection */null,
- /* selection args*/null,
- /* groupby */null,
- /* having*/null,
- /* orderby*/null);
- }
-
- private ExtendedThrustCurveMotor hydrateMotor(Cursor mCursor) throws Exception {
- ExtendedThrustCurveMotor mi;
- {
- String digest = mCursor.getString(mCursor.getColumnIndex(DIGEST));
- String designation = mCursor.getString(mCursor.getColumnIndex(DESIGNATION));
- String delayString = mCursor.getString(mCursor.getColumnIndex(DELAYS));
- double[] delays = ConversionUtils.stringToDelays(delayString);
- double diameter = mCursor.getDouble(mCursor.getColumnIndex(DIAMETER));
- double totImpulse = mCursor.getDouble(mCursor.getColumnIndex(TOTAL_IMPULSE));
- double avgImpulse = mCursor.getDouble(mCursor.getColumnIndex(AVG_THRUST));
- double maxThrust = mCursor.getDouble(mCursor.getColumnIndex(MAX_THRUST));
- double length = mCursor.getDouble(mCursor.getColumnIndex(LENGTH));
- Motor.Type type;
- try {
- type = Enum.valueOf(Motor.Type.class, mCursor.getString(mCursor.getColumnIndex(TYPE)));
- } catch (IllegalArgumentException e) {
- type = Motor.Type.UNKNOWN;
- }
- Manufacturer manufacturer = Manufacturer.getManufacturer(mCursor.getString(mCursor.getColumnIndex(MANUFACTURER)));
- double[] thrustData = ConversionUtils.deserializeArrayOfDouble(mCursor.getBlob(mCursor.getColumnIndex(THRUST_DATA)));
- double[] timeData = ConversionUtils.deserializeArrayOfDouble(mCursor.getBlob(mCursor.getColumnIndex(TIME_DATA)));
- Coordinate[] cgData = ConversionUtils.deserializeArrayOfCoordinate(mCursor.getBlob(mCursor.getColumnIndex(CG_DATA)));
-
- ThrustCurveMotor tcm = new ThrustCurveMotor(manufacturer,
- designation,
- "",
- type,
- delays,
- diameter,
- length,
- timeData,
- thrustData,
- cgData,
- digest
- );
- mi = new ExtendedThrustCurveMotor(tcm);
-
- mi.setId(mCursor.getLong(mCursor.getColumnIndex(ID)));
- mi.setCaseInfo(mCursor.getString(mCursor.getColumnIndex(CASE_INFO)));
- mi.setImpulseClass(mCursor.getString(mCursor.getColumnIndex(IMPULSE_CLASS)));
-
- }
- return mi;
-
- }
-
- public ExtendedThrustCurveMotor fetchMotor(Long id) throws Exception {
- Cursor mCursor = mDb.query(DATABASE_TABLE,
- /* columns */ALL_COLS,
- /* selection */ID + "=" + id,
- /* selection args*/null,
- /* groupby */null,
- /* having*/null,
- /* orderby*/null);
- if (mCursor == null) {
- return null;
- }
- try {
- if (mCursor.getCount() == 0) {
- return null;
- }
- mCursor.moveToFirst();
- return hydrateMotor(mCursor);
- } finally {
- mCursor.close();
- }
-
- }
-
- public ExtendedThrustCurveMotor fetchMotor(String manufacturerShortName, String designation) throws Exception {
- Cursor mCursor = mDb.query(DATABASE_TABLE,
- /* columns */ALL_COLS,
- /* selection */MANUFACTURER + "='" + manufacturerShortName + "' and " + DESIGNATION + "='" + designation + "'",
- /* selection args*/null,
- /* groupby */null,
- /* having*/null,
- /* orderby*/null);
- if (mCursor == null) {
- return null;
- }
- try {
- if (mCursor.getCount() == 0) {
- return null;
- }
- mCursor.moveToFirst();
- return hydrateMotor(mCursor);
- } catch( Exception ex ) {
- LogHelper.getInstance().debug("whoa!", ex);
- throw ex;
- } finally {
- mCursor.close();
- }
-
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/events/ChangeEventBroadcastReceiver.java b/android/src/net/sf/openrocket/android/events/ChangeEventBroadcastReceiver.java
deleted file mode 100644
index 69da6251dc..0000000000
--- a/android/src/net/sf/openrocket/android/events/ChangeEventBroadcastReceiver.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package net.sf.openrocket.android.events;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.support.v4.content.LocalBroadcastManager;
-
-public abstract class ChangeEventBroadcastReceiver extends BroadcastReceiver {
-
- public void register( Context context ) {
- LocalBroadcastManager.getInstance(context).registerReceiver( this,
- new IntentFilter(Events.MESSAGE_ACTION) );
- }
-
- public void unregister( Context context ) {
- LocalBroadcastManager.getInstance(context).unregisterReceiver(this);
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
-
- int type = intent.getIntExtra(Events.TYPE, -1);
- switch( type ) {
- case Events.CONFIGS_CHANGED:
- doMotorConfigsChanged();
- doSimsChanged();
- break;
- case Events.SIMS_CHANGED:
- doSimsChanged();
- break;
- case Events.SIM_COMPLETE:
- doSimComplete();
- break;
- }
- }
-
- protected abstract void doSimComplete();
-
- protected abstract void doSimsChanged();
-
- protected abstract void doMotorConfigsChanged();
-
-}
diff --git a/android/src/net/sf/openrocket/android/events/Events.java b/android/src/net/sf/openrocket/android/events/Events.java
deleted file mode 100644
index 75114d96c8..0000000000
--- a/android/src/net/sf/openrocket/android/events/Events.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package net.sf.openrocket.android.events;
-
-public abstract class Events {
-
- public final static int SIMS_CHANGED=0;
- public final static int SIM_COMPLETE=1;
- public final static int CONFIGS_CHANGED=2;
-
- public final static String MESSAGE_ACTION = "net.sf.openrocket.Message";
-
- public final static String TYPE = "type";
-
-
-}
diff --git a/android/src/net/sf/openrocket/android/filebrowser/AlphanumComparator.java b/android/src/net/sf/openrocket/android/filebrowser/AlphanumComparator.java
deleted file mode 100644
index 1bc762ca89..0000000000
--- a/android/src/net/sf/openrocket/android/filebrowser/AlphanumComparator.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * The Alphanum Algorithm is an improved sorting algorithm for strings
- * containing numbers. Instead of sorting numbers in ASCII order like
- * a standard sort, this algorithm sorts numbers in numeric order.
- *
- * The Alphanum Algorithm is discussed at http://www.DaveKoelle.com
- *
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-/*
- * Subsequently this code had been hacked up to make it genericized and support
- * folding upper/lower case.
- */
-package net.sf.openrocket.android.filebrowser;
-
-import java.text.Collator;
-import java.util.Comparator;
-
-/**
- * This is an updated version with enhancements made by Daniel Migowski,
- * Andre Bogus, and David Koelle
- *
- * To convert to use Templates (Java 1.5+):
- * - Change "implements Comparator" to "implements Comparator"
- * - Change "compare(Object o1, Object o2)" to "compare(String s1, String s2)"
- * - Remove the type checking and casting in compare().
- *
- * To use this class:
- * Use the static "sort" method from the java.util.Collections class:
- * Collections.sort(your list, new AlphanumComparator());
- */
-public class AlphanumComparator implements Comparator
-{
-
- private static final Collator sorter = Collator.getInstance();
- static {
- sorter.setStrength(Collator.TERTIARY);
- sorter.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
- }
-
- private final boolean isDigit(char ch)
- {
- return ch >= 48 && ch <= 57;
- }
-
- /** Length of string is passed in for improved efficiency (only need to calculate it once) **/
- private final String getChunk(String s, int slength, int marker)
- {
- StringBuilder chunk = new StringBuilder();
- char c = s.charAt(marker);
- chunk.append(c);
- marker++;
- if (isDigit(c))
- {
- while (marker < slength)
- {
- c = s.charAt(marker);
- if (!isDigit(c))
- break;
- chunk.append(c);
- marker++;
- }
- } else
- {
- while (marker < slength)
- {
- c = s.charAt(marker);
- if (isDigit(c))
- break;
- chunk.append(c);
- marker++;
- }
- }
- return chunk.toString();
- }
-
- public int compare(String s1, String s2)
- {
-
- int thisMarker = 0;
- int thatMarker = 0;
- int s1Length = s1.length();
- int s2Length = s2.length();
-
- while (thisMarker < s1Length && thatMarker < s2Length)
- {
- String thisChunk = getChunk(s1, s1Length, thisMarker);
- thisMarker += thisChunk.length();
-
- String thatChunk = getChunk(s2, s2Length, thatMarker);
- thatMarker += thatChunk.length();
-
- // If both chunks contain numeric characters, sort them numerically
- int result = 0;
- if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0)))
- {
- // Simple chunk comparison by length.
- int thisChunkLength = thisChunk.length();
- result = thisChunkLength - thatChunk.length();
- // If equal, the first different number counts
- if (result == 0)
- {
- for (int i = 0; i < thisChunkLength; i++)
- {
- result = thisChunk.charAt(i) - thatChunk.charAt(i);
- if (result != 0)
- {
- return result;
- }
- }
- }
- } else
- {
- result = sorter.compare(thisChunk, thatChunk);
- }
-
- if (result != 0)
- return result;
- }
-
- return s1Length - s2Length;
- }
-}
diff --git a/android/src/net/sf/openrocket/android/filebrowser/SimpleFileBrowser.java b/android/src/net/sf/openrocket/android/filebrowser/SimpleFileBrowser.java
deleted file mode 100644
index 1ca68f65c3..0000000000
--- a/android/src/net/sf/openrocket/android/filebrowser/SimpleFileBrowser.java
+++ /dev/null
@@ -1,288 +0,0 @@
-package net.sf.openrocket.android.filebrowser;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-
-import net.sf.openrocket.R;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.res.Resources;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Environment;
-import android.preference.PreferenceManager;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import com.actionbarsherlock.app.SherlockListActivity;
-
-public class SimpleFileBrowser extends SherlockListActivity {
-
- private List path = null;
- private final static File root = new File("/");
-
- private File previousDirectory = root;
-
- private String baseDirPrefKey;
- private String baseDirName;
-
- private boolean showOnlyOrkFiles;
-
- private static final OrkFileFilter filter = new OrkFileFilter();
- private static final Comparator sorter = new AlphanumComparator();
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.simplefilebrowser);
-
- Resources resources = this.getResources();
- baseDirPrefKey = resources.getString(R.string.PreferenceFileBrowserBaseDirectory);
- SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
-
- String showOnlyOrkFilesKey = resources.getString(R.string.PreferenceShowOnlyOrkFiles);
- showOnlyOrkFiles = pref.getBoolean(showOnlyOrkFilesKey, false);
-
- baseDirName = pref.getString(baseDirPrefKey, Environment.getExternalStorageDirectory().getAbsolutePath() );
- getDir( new File(baseDirName) );
- }
-
- private static class OrkFileFilter implements FileFilter {
-
- /* (non-Javadoc)
- * @see java.io.FileFilter#accept(java.io.File)
- */
- @Override
- public boolean accept(File arg0) {
- if ( arg0.isDirectory() ) {
- return true;
- }
- return isOrk(arg0);
- }
-
- public boolean isOrk(File arg0) {
- if ( arg0.getName().endsWith(".ork") ) {
- return true;
- }
- return false;
- }
- }
-
- private static class FileComparator implements Comparator {
-
- /* (non-Javadoc)
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
- @Override
- public int compare(File arg0, File arg1) {
- // Directories come before files, otherwise alpha.
- if ( arg0.isDirectory() ) {
- if ( ! arg1.isDirectory() ) {
- return -1;
- }
- return sorter.compare(arg0.getName(), arg1.getName());
- }
-
- // arg0 is not a directory.
- if ( arg1.isDirectory() ) {
- return 1;
- }
-
- return sorter.compare(arg0.getName(), arg1.getName());
- }
-
- }
-
- private void getDir(final File dirPath) {
-
- // A little sanity check. It could be possible the directory saved in the preference
- // is no longer mounted, is not a directory (any more), or cannot be read.
- // if any of these are the case, we display a little dialog, then revert to the
- // previousDirectory.
- if ( !dirPath.exists() || !dirPath.isDirectory() || !dirPath.canRead() ) {
-
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle("Unable to open directory " + dirPath.getAbsolutePath() );
- builder.setCancelable(true);
- builder.setOnCancelListener( new Dialog.OnCancelListener() {
-
- @Override
- public void onCancel(DialogInterface arg0) {
- if ( root.getAbsolutePath().equals(dirPath.getAbsolutePath()) ) {
- SimpleFileBrowser.this.finish();
- } else {
- SimpleFileBrowser.this.getDir( previousDirectory );
- }
- }
-
- });
- builder.show();
- return;
- }
-
- previousDirectory = dirPath;
-
- setTitle(dirPath.getAbsolutePath());
- path = new ArrayList();
-
- File[] files = dirPath.listFiles((showOnlyOrkFiles) ? filter : null );
-
- boolean hasUp = false;
- if ( !dirPath.getAbsolutePath().equals("/")) {
- path.add(root);
- path.add( dirPath.getParentFile() );
- hasUp = true;
- }
-
- Arrays.sort(files, new FileComparator() );
- for( File file : files ) {
- path.add(file);
- }
-
- DirectoryList fileList = new DirectoryList(hasUp, path);
- setListAdapter(fileList);
-
- }
-
- @Override
- protected void onListItemClick(ListView l, View v, int position, long id) {
- final File file = path.get(position);
- if (file.isDirectory()) {
- if (file.canRead())
- getDir(file);
- else {
- new AlertDialog.Builder(this).setIcon(R.drawable.or_launcher)
- .setTitle("[" + file.getName() + "] folder can't be read!")
- .setPositiveButton("OK",
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- // TODO Auto-generated method stub
- }
- }).show();
- }
- }
- else
- {
- Intent resultData = new Intent(Intent.ACTION_VIEW);
- resultData.setData( Uri.fromFile(file) );
- setResult(RESULT_OK,resultData);
- finish();
- }
- }
-
- private class DirectoryList extends BaseAdapter {
-
- List listing;
- boolean hasUp;
-
- DirectoryList( boolean hasUp ,List listing ) {
- this.listing = listing;
- this.hasUp = hasUp;
- }
-
- @Override
- public int getCount() {
- return listing.size();
- }
-
- @Override
- public Object getItem(int arg0) {
- return listing.get(arg0);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- if ( convertView == null ) {
- convertView = getLayoutInflater().inflate(R.layout.filebrowser_list_item, parent, false);
- }
-
- File file = (File) getItem(position);
-
- // Set the name of the field.
- {
- String fileName = file.getName();
- if ( hasUp ) {
- if (position == 0 ) {
- fileName = root.getAbsolutePath();
- } else if (position == 1) {
- fileName = "..";
- }
- }
-
- ((TextView) convertView.findViewById(R.id.filebrowser_list_item_name)).setText(fileName);
- }
-
- // Set the "type icon" directory, ork file, or none.
- {
- ImageView v = (ImageView) (convertView.findViewById(R.id.filebrowser_list_item_typeicon));
- if ( file.isDirectory() ) {
- v.setVisibility(View.VISIBLE);
- v.setImageResource(R.drawable.ic_directory);
- } else if ( filter.isOrk( file ) ) {
- v.setVisibility(View.VISIBLE);
- v.setImageResource(R.drawable.or_launcher);
- } else {
- v.setVisibility(View.INVISIBLE);
- }
- }
-
- // Set the "favorite directory" thing.
- {
- ImageView v = (ImageView) (convertView.findViewById(R.id.filebrowser_list_item_homeicon));
- if ( file.isDirectory() && hasUp && position > 1 ) {
- v.setVisibility(View.VISIBLE);
- if ( baseDirName.equals( file.getAbsolutePath() ) ) {
- v.setSelected(true);
- } else {
- v.setSelected(false);
- v.setClickable(true);
- v.setOnClickListener( new ChangeBaseDirectory(file.getAbsolutePath()));
- }
- } else {
- v.setVisibility(View.INVISIBLE);
- v.setClickable(false);
- }
- }
- return convertView;
- }
- }
-
- private class ChangeBaseDirectory implements View.OnClickListener {
-
- private final String dirname;
-
- ChangeBaseDirectory ( String dirname ) {
- this.dirname = dirname;
- }
-
- @Override
- public void onClick(View v) {
- if ( v.isSelected() == false ) {
- SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(SimpleFileBrowser.this);
- baseDirName = dirname;
- pref.edit().putString(baseDirPrefKey, dirname).commit();
- ((BaseAdapter)SimpleFileBrowser.this.getListAdapter()).notifyDataSetChanged();
- }
- }
-
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/motor/BurnPlotActivity.java b/android/src/net/sf/openrocket/android/motor/BurnPlotActivity.java
deleted file mode 100644
index 03aa88f336..0000000000
--- a/android/src/net/sf/openrocket/android/motor/BurnPlotActivity.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package net.sf.openrocket.android.motor;
-
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.v4.app.FragmentActivity;
-
-public class BurnPlotActivity extends FragmentActivity {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- AndroidLogWrapper.d(BurnPlotActivity.class,"onCreate Bundle = "+ String.valueOf(savedInstanceState));
-
- Intent i = getIntent();
- long motorId = i.getLongExtra("Motor",-1);
-
- BurnPlotFragment burnPlot = BurnPlotFragment.newInstance(motorId);
- getSupportFragmentManager().beginTransaction().replace(android.R.id.content, burnPlot).commit();
-
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/motor/BurnPlotFragment.java b/android/src/net/sf/openrocket/android/motor/BurnPlotFragment.java
deleted file mode 100644
index eff07756a6..0000000000
--- a/android/src/net/sf/openrocket/android/motor/BurnPlotFragment.java
+++ /dev/null
@@ -1,158 +0,0 @@
-package net.sf.openrocket.android.motor;
-
-import net.sf.openrocket.android.db.DbAdapter;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-
-import org.achartengine.GraphicalView;
-import org.achartengine.chart.LineChart;
-import org.achartengine.chart.PointStyle;
-import org.achartengine.chart.XYChart;
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.model.XYSeries;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-import org.achartengine.renderer.XYSeriesRenderer;
-
-import android.graphics.Color;
-import android.graphics.Paint.Align;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-public class BurnPlotFragment extends Fragment {
-
- private ExtendedThrustCurveMotor motor;
- private long motorId;
-
- /** The encapsulated graphical view. */
- private GraphicalView mView;
- /** The chart to be drawn. */
- private XYChart mChart;
-
- public static BurnPlotFragment newInstance( long motorId ) {
- BurnPlotFragment frag = new BurnPlotFragment();
- Bundle bundle = new Bundle();
- bundle.putLong("motorId", motorId);
- frag.setArguments(bundle);
- return frag;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- AndroidLogWrapper.d(BurnPlotFragment.class,"onCreate");
-
- if ( savedInstanceState!= null) {
- motorId = savedInstanceState.getLong("motorId",-1);
- } else {
- Bundle b = getArguments();
- motorId = b.getLong("motorId");
- }
-
- DbAdapter mDbHelper = new DbAdapter(getActivity());
- mDbHelper.open();
-
- try {
- motor = mDbHelper.getMotorDao().fetchMotor(motorId);
- } catch ( Exception e ) {
-
- }
-
- mDbHelper.close();
- super.onCreate(savedInstanceState);
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putLong("motorId", motorId);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- AndroidLogWrapper.d(BurnPlotFragment.class,"onCreateView");
-
- init(motor);
- mView = new GraphicalView(container.getContext(), mChart);
- return mView;
- }
-
- private void init( ExtendedThrustCurveMotor motor ) {
-
- XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(1);
-
- renderer.setAxisTitleTextSize(16);
- renderer.setChartTitleTextSize(20);
- renderer.setLabelsTextSize(15);
- renderer.setLegendTextSize(15);
- renderer.setPointSize(5f);
- renderer.setXLabels(10);
- renderer.setYLabels(10);
- renderer.setShowGrid(true);
- renderer.setZoomButtonsVisible(false);
- renderer.setZoomEnabled(false,false);
- renderer.setPanEnabled(false,false);
- renderer.setMargins(new int[] { 50, 40, 10, 20 });
- renderer.setShowLegend(false);
- renderer.setAxesColor(Color.LTGRAY);
- renderer.setLabelsColor(Color.LTGRAY);
-
- renderer.setChartTitle(motor.getManufacturer() + " " + motor.getDesignation());
-
- renderer.setXTitle("time (s)");
- renderer.setXLabelsAlign(Align.RIGHT);
-
- renderer.setYTitle("impuse (n)");
- renderer.setYLabelsAlign(Align.RIGHT,0);
-
- XYSeriesRenderer r = new XYSeriesRenderer();
- r.setColor(Color.RED);
- r.setPointStyle(PointStyle.CIRCLE);
- r.setFillPoints(true);
- renderer.addSeriesRenderer(r);
- // setting the YAximMin to 0 locks the origins.
- renderer.setYAxisMin(0.0, 0);
-
- // TODO get markers working in achartengine
- //YValueMarker average = new YValueMarker(motor.getThrustCurveMotor().getAverageThrustEstimate(),"average" );
- //average.getLinePaint().setColor(Color.BLACK);
- //average.getTextPaint().setColor(Color.BLACK);
- //mySimpleXYPlot.addMarker( average );
-
- XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
-
- XYSeries series = new XYSeries(motor.getDesignation(), 0);
-
- double[] timePoints = motor.getTimePoints();
- double[] thrustPoints = motor.getThrustPoints();
-
- // We are going to abuse this loop to also compute the Y axis max.
- int maxy = 0;
- int datasize = timePoints.length;
- for( int i = 0; i maxy ) {
- maxy = ceil;
- }
- }
- renderer.setYAxisMax(maxy);
-
- // Find the X axis max. compute it as next larger integer if t_max > 2 else round up to next tenth.
- double maxx = timePoints[datasize-1];
- if ( maxx >= 2.0 ) {
- maxx = Math.ceil(maxx);
- } else {
- maxx = Math.ceil(maxx*10.0) /10.0;
- }
- renderer.setXAxisMax(maxx);
-
- dataset.addSeries(series);
-
- mChart = new LineChart(dataset, renderer);
-
- }
-
-}
-
diff --git a/android/src/net/sf/openrocket/android/motor/ExtendedThrustCurveMotor.java b/android/src/net/sf/openrocket/android/motor/ExtendedThrustCurveMotor.java
deleted file mode 100644
index cd72be4897..0000000000
--- a/android/src/net/sf/openrocket/android/motor/ExtendedThrustCurveMotor.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package net.sf.openrocket.android.motor;
-
-import net.sf.openrocket.motor.ThrustCurveMotor;
-
-public class ExtendedThrustCurveMotor extends ThrustCurveMotor {
-
- private Long id;
- private String caseInfo;
- private String impulseClass;
-
- public ExtendedThrustCurveMotor( ThrustCurveMotor tcm ) {
- super(tcm);
- }
-
- /**
- * @return the id
- */
- public Long getId() {
- return id;
- }
- /**
- * @param id the id to set
- */
- public void setId(Long id) {
- this.id = id;
- }
- /**
- * @return the caseInfo
- */
- public String getCaseInfo() {
- return caseInfo;
- }
- /**
- * @param caseInfo the caseInfo to set
- */
- public void setCaseInfo(String caseInfo) {
- this.caseInfo = caseInfo;
- }
- /**
- * @return the impulseClass
- */
- public String getImpulseClass() {
- return impulseClass;
- }
- /**
- * @param impulseClass the impulseClass to set
- */
- public void setImpulseClass(String impulseClass) {
- this.impulseClass = impulseClass;
- }
-
-
-}
diff --git a/android/src/net/sf/openrocket/android/motor/MotorBrowserActivity.java b/android/src/net/sf/openrocket/android/motor/MotorBrowserActivity.java
deleted file mode 100644
index 91269d6e2b..0000000000
--- a/android/src/net/sf/openrocket/android/motor/MotorBrowserActivity.java
+++ /dev/null
@@ -1,129 +0,0 @@
-package net.sf.openrocket.android.motor;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.ActivityHelpers;
-import net.sf.openrocket.android.PreferencesActivity;
-import net.sf.openrocket.android.db.DbAdapter;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import android.content.Intent;
-import android.database.Cursor;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentTransaction;
-import android.view.View;
-
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-public class MotorBrowserActivity extends SherlockFragmentActivity
-implements MotorListFragment.OnMotorSelectedListener
-{
-
- MotorListFragment motorList;
-
- private final static int DOWNLOAD_REQUEST_CODE = 1;
- private final static String MOTOR_LIST_FRAGMENT = "motor_list";
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.motorbrowser);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- getSupportActionBar().setTitle(R.string.motorbrowsertitle);
- // Only create the motorBrowser fragment if it doesn't already exist.
- Fragment motorBrowser = getSupportFragmentManager().findFragmentByTag(MOTOR_LIST_FRAGMENT);
- if ( motorBrowser == null ) {
- getSupportFragmentManager()
- .beginTransaction()
- .add( R.id.motorBrowserList, new MotorListFragment(), MOTOR_LIST_FRAGMENT)
- .commit();
- }
-
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- int motorCount = 0;
-
- DbAdapter mDbHelper = new DbAdapter(this);
- mDbHelper.open();
- try {
- Cursor motorCounter = mDbHelper.getMotorDao().fetchAllMotors();
- motorCount = motorCounter.getCount();
- motorCounter.close();
- } finally {
- mDbHelper.close();
- }
-
- if ( motorCount == 0 ) {
- ActivityHelpers.downloadFromThrustcurve(this,DOWNLOAD_REQUEST_CODE);
- }
-
-
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getSupportMenuInflater();
- inflater.inflate(R.menu.motor_browser_option_menu, menu);
- return true;
- }
-
- @Override
- public boolean onMenuItemSelected(int featureId, MenuItem item) {
- AndroidLogWrapper.d(MotorBrowserActivity.class,"onMenuItemSelected" + item.getItemId());
- switch(item.getItemId()) {
- case android.R.id.home:
- // we implement home in the motor browser as "back" since then it will return to
- // either main or the viewer.
- finish();
- return true;
- case R.id.download_from_thrustcurve_menu_option:
- ActivityHelpers.downloadFromThrustcurve(this,DOWNLOAD_REQUEST_CODE);
- return true;
- case R.id.preference_menu_option:
- Intent intent = new Intent().setClass(this, PreferencesActivity.class);
- this.startActivity(intent);
- return true;
- case R.id.menu_about:
- ActivityHelpers.showAbout(this);
- return true;
- }
- return super.onMenuItemSelected(featureId, item);
- }
-
- @Override
- protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
- if ( requestCode == DOWNLOAD_REQUEST_CODE ) {
- MotorListFragment frag = (MotorListFragment) getSupportFragmentManager().findFragmentById(R.id.motorBrowserList);
- frag.refreshData();
- }
- }
-
- @Override
- public void onMotorSelected(long motorId) {
-
- View sidepane = findViewById(R.id.sidepane);
- if ( /* if multi pane */ sidepane != null ) {
-
- Fragment graph = BurnPlotFragment.newInstance(motorId);
-
- FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
- ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
- ft.replace(R.id.sidepane, graph);
- ft.show(graph);
- ft.commit();
-
- } else {
- Intent i = new Intent(this,BurnPlotActivity.class);
- i.putExtra("Motor", motorId);
- startActivity(i);
- }
-
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/motor/MotorDelayDialogFragment.java b/android/src/net/sf/openrocket/android/motor/MotorDelayDialogFragment.java
deleted file mode 100644
index b83c95b18d..0000000000
--- a/android/src/net/sf/openrocket/android/motor/MotorDelayDialogFragment.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package net.sf.openrocket.android.motor;
-
-import java.util.List;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.db.ConversionUtils;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.os.Bundle;
-import android.support.v4.app.DialogFragment;
-import android.view.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.inputmethod.EditorInfo;
-import android.widget.ArrayAdapter;
-import android.widget.EditText;
-import android.widget.ListView;
-import android.widget.TextView;
-
-public class MotorDelayDialogFragment extends DialogFragment
-implements View.OnClickListener, TextView.OnEditorActionListener {
-
- public interface OnDelaySelectedListener {
- public void onDelaySelected( double delay );
- }
-
- private OnDelaySelectedListener delaySelectedListener;
-
- public void setDelaySelectedListener(OnDelaySelectedListener delaySelectedListener) {
- this.delaySelectedListener = delaySelectedListener;
- }
-
- private final static String delaysArg = "delaysArg";
-
- public static MotorDelayDialogFragment newInstance( double[] delays ) {
- MotorDelayDialogFragment f = new MotorDelayDialogFragment();
- Bundle b = new Bundle();
- b.putDoubleArray(delaysArg, delays);
- f.setArguments(b);
- return f;
- }
-
- @Override
- public void onClick(View v) {
- String s = ((TextView)v).getText().toString();
- double value = ConversionUtils.stringToDelay(s);
- if ( delaySelectedListener != null ) {
- delaySelectedListener.onDelaySelected(value);
- }
- }
-
- @Override
- public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
-
- if ( actionId == EditorInfo.IME_ACTION_DONE ) {
- String s = v.getText().toString();
- if ( s != null ) { // note requires ems=10
- long value = Long.parseLong(s);
- if ( delaySelectedListener != null ) {
- delaySelectedListener.onDelaySelected(value);
- }
- }
- return true;
- }
- return false;
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
-
- if (savedInstanceState == null ) {
- savedInstanceState = getArguments();
- }
- double[] delays = savedInstanceState.getDoubleArray(delaysArg);
- List delayList = ConversionUtils.delaysToStringList(delays);
-
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- builder.setTitle("Enter or Choose Delay");
-
- LayoutInflater li = getActivity().getLayoutInflater();
- View v = li.inflate(R.layout.motor_config_delay_dialog, null);
- builder.setView(v);
-
- ArrayAdapter listAdapter = new ArrayAdapter(getActivity(),android.R.layout.simple_list_item_1,delayList) {
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- if ( convertView == null ) {
- convertView = getActivity().getLayoutInflater().inflate( android.R.layout.simple_list_item_1, null);
- }
- TextView tv = (TextView) convertView.findViewById(android.R.id.text1);
- tv.setText( getItem(position) );
- tv.setOnClickListener( MotorDelayDialogFragment.this );
- return convertView;
- }
-
-
- };
-
- ListView lv = (ListView) v.findViewById(R.id.motor_config_delay_diag_list);
- lv.setAdapter(listAdapter);
-
- EditText et = (EditText) v.findViewById(R.id.motor_config_delay_diag_edit);
- et.setOnEditorActionListener(MotorDelayDialogFragment.this);
- return builder.create();
-
- }
-
-
-
-}
diff --git a/android/src/net/sf/openrocket/android/motor/MotorDetailsFragment.java b/android/src/net/sf/openrocket/android/motor/MotorDetailsFragment.java
deleted file mode 100644
index 5bd42b9af4..0000000000
--- a/android/src/net/sf/openrocket/android/motor/MotorDetailsFragment.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package net.sf.openrocket.android.motor;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.db.ConversionUtils;
-import net.sf.openrocket.android.db.DbAdapter;
-import net.sf.openrocket.unit.UnitGroup;
-import android.os.Bundle;
-import android.support.v4.app.DialogFragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.EditText;
-
-public class MotorDetailsFragment extends DialogFragment {
-
- EditText manuField;
- EditText nameField;
- EditText delaysField;
- EditText caseField;
- EditText impulseClassField;
- EditText diameterField;
- EditText lengthField;
-
- ExtendedThrustCurveMotor motor;
-
- public static MotorDetailsFragment newInstance( long motorId ) {
- MotorDetailsFragment fragment = new MotorDetailsFragment();
- Bundle b = new Bundle();
- b.putLong("motorId", motorId);
- fragment.setArguments(b);
- return fragment;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setStyle(DialogFragment.STYLE_NO_TITLE,getTheme());
-
- Long motorId;
- if ( savedInstanceState != null ) {
- motorId = savedInstanceState.getLong("motorId");
- } else {
- Bundle b = getArguments();
- motorId = b.getLong("motorId");
- }
- DbAdapter mDbHelper = new DbAdapter(getActivity());
- mDbHelper.open();
- try {
- motor = mDbHelper.getMotorDao().fetchMotor(motorId);
- } catch ( Exception e ) {
- }
- mDbHelper.close();
- }
-
- @Override
- public void onSaveInstanceState(Bundle arg0) {
- super.onSaveInstanceState(arg0);
- arg0.putLong("motorId", motor.getId());
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View v = inflater.inflate(R.layout.motor_detail_form, container, false);
- manuField = (EditText) v.findViewById(R.id.motorDetailsManufacturer);
- nameField = (EditText) v.findViewById(R.id.motorDetailsName);
- delaysField = (EditText) v.findViewById(R.id.motorDetailsDelays);
- caseField = (EditText) v.findViewById(R.id.motorDetailsCaseInfo);
- impulseClassField = (EditText) v.findViewById(R.id.motorDetailsImpuseClass);
- diameterField = (EditText) v.findViewById(R.id.motorDetailsDiameter);
- lengthField = (EditText) v.findViewById(R.id.motorDetailsLength);
- init();
- /* TODO - enable saving.
- ((Button) v.findViewById(R.id.motorDetailsSaveButton)).setOnClickListener(
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- MotorDetailsFragment.this.saveChanges();
- }
- });
- */
- return v;
- }
-
- private void init( ) {
- manuField.setText( motor.getManufacturer().getDisplayName());
- nameField.setText( motor.getDesignation() );
- delaysField.setText( ConversionUtils.delaysToString(motor.getStandardDelays()) );
- caseField.setText( motor.getCaseInfo());
- impulseClassField.setText( motor.getImpulseClass());
- diameterField.setText( UnitGroup.UNITS_MOTOR_DIMENSIONS.toString(motor.getDiameter()) );
- lengthField.setText( UnitGroup.UNITS_LENGTH.getUnit("mm").toString(motor.getLength()) );
- }
-
- private void saveChanges() {
- DbAdapter mDbHelper = new DbAdapter(getActivity());
- mDbHelper.open();
- try {
- mDbHelper.getMotorDao().insertOrUpdateMotor(motor);
- } catch ( Exception e ) {
- }
-
- }
-}
diff --git a/android/src/net/sf/openrocket/android/motor/MotorListDialogFragment.java b/android/src/net/sf/openrocket/android/motor/MotorListDialogFragment.java
deleted file mode 100644
index 680e5775da..0000000000
--- a/android/src/net/sf/openrocket/android/motor/MotorListDialogFragment.java
+++ /dev/null
@@ -1,157 +0,0 @@
-package net.sf.openrocket.android.motor;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.db.DbAdapter;
-import net.sf.openrocket.android.db.MotorDao;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.android.util.PersistentExpandableListView;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.Context;
-import android.database.Cursor;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.ExpandableListView;
-import android.widget.ResourceCursorTreeAdapter;
-import android.widget.TextView;
-
-import com.actionbarsherlock.app.SherlockDialogFragment;
-
-public class MotorListDialogFragment extends SherlockDialogFragment
-implements ExpandableListView.OnChildClickListener
-{
-
- public interface OnMotorSelectedListener {
- public void onMotorSelected( long motorId );
- }
-
- private final static String groupColumn = MotorDao.DIAMETER;
-
- private DbAdapter mDbHelper;
-
- private ExpandableListView list;
-
- private OnMotorSelectedListener motorSelectedListener;
-
- public void setMotorSelectedListener(
- OnMotorSelectedListener motorSelectedListener) {
- this.motorSelectedListener = motorSelectedListener;
- }
-
- @Override
- public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
- if( motorSelectedListener != null ) {
- motorSelectedListener.onMotorSelected(id);
- }
- return true;
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- builder.setTitle("Select Motor");
- list = new PersistentExpandableListView(getActivity());
- list.setOnChildClickListener( this );
- refreshData();
- builder.setView( list );
- return builder.create();
- }
-
- @Override
- public void onPause() {
- super.onPause();
- mDbHelper.close();
- }
-
- public void refreshData() {
- if ( mDbHelper == null ) {
- mDbHelper = new DbAdapter(getActivity());
- }
- mDbHelper.open();
-
- Cursor motorCounter = mDbHelper.getMotorDao().fetchAllMotors();
- int motorCount = motorCounter.getCount();
- motorCounter.close();
-
- if ( motorCount == 0 ) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- builder.setTitle("No Motors Found");
- builder.setMessage("Motors can be downloaded from thrustcurve");
- builder.setCancelable(true);
- AlertDialog dialog = builder.create();
- dialog.setCanceledOnTouchOutside(true);
- dialog.show();
- }
-
- Cursor motorCursor = mDbHelper.getMotorDao().fetchGroups(groupColumn);
- MotorHierarchicalListAdapter mAdapter = new MotorHierarchicalListAdapter(
- getActivity(),
- motorCursor,
- R.layout.motor_list_group,
- R.layout.motor_list_child);
- list.setAdapter(mAdapter);
- }
-
- public class MotorHierarchicalListAdapter extends ResourceCursorTreeAdapter
- {
-
- // Note that the constructor does not take a Cursor. This is done to avoid querying the
- // database on the main thread.
- public MotorHierarchicalListAdapter(Context context, Cursor cursor, int groupLayout,
- int childLayout ) {
-
- super(context, cursor, groupLayout, childLayout);
- }
-
- @Override
- protected Cursor getChildrenCursor(Cursor arg0) {
- AndroidLogWrapper.d(MotorListFragment.class,"getChildrenCursor");
- String group = arg0.getString(arg0.getColumnIndex(groupColumn));
- Cursor c = mDbHelper.getMotorDao().fetchAllInGroups(groupColumn,group);
- return c;
- }
-
- @Override
- public long getGroupId(int groupPosition) {
- return groupPosition;
- }
-
- /* (non-Javadoc)
- * @see android.widget.CursorTreeAdapter#bindChildView(android.view.View, android.content.Context, android.database.Cursor, boolean)
- */
- @Override
- protected void bindChildView(View arg0, Context arg1, Cursor arg2,
- boolean arg3) {
-
- TextView manu = (TextView) arg0.findViewById(R.id.motorChildManu);
- manu.setText( arg2.getString(arg2.getColumnIndex(MotorDao.MANUFACTURER)));
-
- TextView desig = (TextView) arg0.findViewById(R.id.motorChildName);
- desig.setText( arg2.getString(arg2.getColumnIndex(MotorDao.DESIGNATION)));
-
- TextView delays = (TextView) arg0.findViewById(R.id.motorChildDelays);
- delays.setText( arg2.getString(arg2.getColumnIndex(MotorDao.DELAYS)));
-
- TextView totImpulse = (TextView) arg0.findViewById(R.id.motorChildImpulse);
- totImpulse.setText( arg2.getString(arg2.getColumnIndex(MotorDao.TOTAL_IMPULSE)));
- }
-
- /* (non-Javadoc)
- * @see android.widget.CursorTreeAdapter#bindGroupView(android.view.View, android.content.Context, android.database.Cursor, boolean)
- */
- @Override
- protected void bindGroupView(View view, Context context, Cursor cursor,
- boolean isExpanded) {
- TextView v = (TextView) view.findViewById(R.id.motorGroup);
- if ( MotorDao.DIAMETER.equals(groupColumn)) {
- double d = cursor.getDouble( cursor.getColumnIndex(groupColumn));
- v.setText( String.valueOf(Math.round(d * 1000.0)) + " mm");
- } else {
- v.setText( cursor.getString( cursor.getColumnIndex(groupColumn)));
- }
- }
-
- }
-
-
-}
diff --git a/android/src/net/sf/openrocket/android/motor/MotorListFragment.java b/android/src/net/sf/openrocket/android/motor/MotorListFragment.java
deleted file mode 100644
index 216e0861b1..0000000000
--- a/android/src/net/sf/openrocket/android/motor/MotorListFragment.java
+++ /dev/null
@@ -1,249 +0,0 @@
-package net.sf.openrocket.android.motor;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.db.DbAdapter;
-import net.sf.openrocket.android.db.MotorDao;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.android.util.PersistentExpandableListFragment;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.res.Resources;
-import android.database.Cursor;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.support.v4.app.DialogFragment;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentTransaction;
-import android.view.ContextMenu;
-import android.view.ContextMenu.ContextMenuInfo;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.ExpandableListView;
-import android.widget.ResourceCursorTreeAdapter;
-import android.widget.TextView;
-
-
-public class MotorListFragment extends PersistentExpandableListFragment
-implements SharedPreferences.OnSharedPreferenceChangeListener
-{
- public interface OnMotorSelectedListener {
- public void onMotorSelected( long motorId );
- }
-
- public static MotorListFragment newInstance( ) {
- MotorListFragment frag = new MotorListFragment();
- return frag;
- }
-
- private static final int CONTEXTMENU_DELETE = Menu.FIRST+1;
- private static final int CONTEXTMENU_EDIT = Menu.FIRST+2;
-
- private String groupColumnPreferenceKey;
- private String groupColumn = MotorDao.CASE_INFO;
-
- private static final String[] groupColumns = new String[] {
- MotorDao.CASE_INFO,
- MotorDao.DIAMETER,
- MotorDao.IMPULSE_CLASS,
- MotorDao.MANUFACTURER
- };
-
- private DbAdapter mDbHelper;
-
- private OnMotorSelectedListener motorSelectedListener;
-
- public void setMotorSelectedListener(
- OnMotorSelectedListener motorSelectedListener) {
- this.motorSelectedListener = motorSelectedListener;
- }
-
- public class MotorHierarchicalListAdapter extends ResourceCursorTreeAdapter
- {
-
- // Note that the constructor does not take a Cursor. This is done to avoid querying the
- // database on the main thread.
- public MotorHierarchicalListAdapter(Context context, Cursor cursor, int groupLayout,
- int childLayout ) {
-
- super(context, cursor, groupLayout, childLayout);
- }
-
- @Override
- protected Cursor getChildrenCursor(Cursor arg0) {
- AndroidLogWrapper.d(MotorListFragment.class,"getChildrenCursor");
- String group = arg0.getString(arg0.getColumnIndex(groupColumn));
- Cursor c = mDbHelper.getMotorDao().fetchAllInGroups(groupColumn,group);
- return c;
- }
-
- @Override
- public long getGroupId(int groupPosition) {
- return groupPosition;
- }
-
- /* (non-Javadoc)
- * @see android.widget.CursorTreeAdapter#bindChildView(android.view.View, android.content.Context, android.database.Cursor, boolean)
- */
- @Override
- protected void bindChildView(View arg0, Context arg1, Cursor arg2,
- boolean arg3) {
-
- TextView manu = (TextView) arg0.findViewById(R.id.motorChildManu);
- manu.setText( arg2.getString(arg2.getColumnIndex(MotorDao.MANUFACTURER)));
-
- TextView desig = (TextView) arg0.findViewById(R.id.motorChildName);
- desig.setText( arg2.getString(arg2.getColumnIndex(MotorDao.DESIGNATION)));
-
- TextView delays = (TextView) arg0.findViewById(R.id.motorChildDelays);
- delays.setText( arg2.getString(arg2.getColumnIndex(MotorDao.DELAYS)));
-
- TextView totImpulse = (TextView) arg0.findViewById(R.id.motorChildImpulse);
- totImpulse.setText( arg2.getString(arg2.getColumnIndex(MotorDao.TOTAL_IMPULSE)));
- }
-
- /* (non-Javadoc)
- * @see android.widget.CursorTreeAdapter#bindGroupView(android.view.View, android.content.Context, android.database.Cursor, boolean)
- */
- @Override
- protected void bindGroupView(View view, Context context, Cursor cursor,
- boolean isExpanded) {
- TextView v = (TextView) view.findViewById(R.id.motorGroup);
- if ( MotorDao.DIAMETER.equals(groupColumn)) {
- double d = cursor.getDouble( cursor.getColumnIndex(groupColumn));
- v.setText( String.valueOf(Math.round(d * 1000.0)) + " mm");
- } else {
- v.setText( cursor.getString( cursor.getColumnIndex(groupColumn)));
- }
- }
-
- }
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences arg0, String arg1) {
- if ( groupColumnPreferenceKey.equals(arg1) ) {
- setGroupColumnFromPreferences(arg0);
- refreshData();
- }
- }
-
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- registerForContextMenu(getExpandableListView());
-
- }
-
-
- @Override
- public void onResume() {
-
- Resources resources = this.getResources();
- groupColumnPreferenceKey = resources.getString(R.string.PreferenceMotorBrowserGroupingOption);
- SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getActivity());
-
- setGroupColumnFromPreferences(pref);
-
- pref.registerOnSharedPreferenceChangeListener(this);
-
- Activity activity = getActivity();
- if ( activity instanceof OnMotorSelectedListener ) {
- motorSelectedListener = (OnMotorSelectedListener) activity;
- }
-
- refreshData();
-
- super.onResume();
-
- }
-
- @Override
- public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
- menu.setHeaderTitle("Motor Operations");
- menu.add(Menu.NONE,CONTEXTMENU_DELETE,CONTEXTMENU_DELETE,"Delete");
- menu.add(Menu.NONE,CONTEXTMENU_EDIT,CONTEXTMENU_EDIT,"Edit");
- super.onCreateContextMenu(menu, v, menuInfo);
- }
-
- @Override
- public boolean onContextItemSelected(MenuItem item) {
- ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) item.getMenuInfo();
- long motorId = info.id;
- AndroidLogWrapper.d(MotorListFragment.class,"ContextMenu: " + motorId);
- switch(item.getItemId()) {
- case CONTEXTMENU_DELETE:
- mDbHelper.getMotorDao().deleteMotor(motorId);
- refreshData();
- return true;
- case CONTEXTMENU_EDIT:
- // DialogFragment.show() will take care of adding the fragment
- // in a transaction. We also want to remove any currently showing
- // dialog, so make our own transaction and take care of that here.
- FragmentTransaction ft = getFragmentManager().beginTransaction();
- Fragment prev = getFragmentManager().findFragmentByTag("dialog");
- if (prev != null) {
- ft.remove(prev);
- }
- ft.addToBackStack(null);
-
- // Create and show the dialog.
- DialogFragment newFragment = MotorDetailsFragment.newInstance(motorId);
- newFragment.show(ft, "dialog");
- return true;
- }
- return super.onContextItemSelected(item);
- }
-
- @Override
- public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
- super.onChildClick(parent, v, groupPosition, childPosition, id);
- if( motorSelectedListener != null ) {
- motorSelectedListener.onMotorSelected(id);
- }
- return true;
- }
-
- @Override
- public void onPause() {
- super.onPause();
- SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getActivity());
- pref.unregisterOnSharedPreferenceChangeListener(this);
-
- mDbHelper.close();
- }
-
- private void setGroupColumnFromPreferences( SharedPreferences prefs ) {
- String indexStr = prefs.getString(groupColumnPreferenceKey, "1");
- int index;
- //Dirty hack, you can't use integer-array in ListPreferences
- try {
- index = Integer.parseInt(indexStr);
- } catch ( Exception e ) {
- index = 1;
- }
- if ( index >= groupColumns.length ) {
- index = 1;
- }
- groupColumn = groupColumns[index];
-
- }
-
- public void refreshData() {
- if ( mDbHelper == null ) {
- mDbHelper = new DbAdapter(getActivity());
- }
- mDbHelper.open();
-
- Cursor motorCursor = mDbHelper.getMotorDao().fetchGroups(groupColumn);
- MotorHierarchicalListAdapter mAdapter = new MotorHierarchicalListAdapter(
- getActivity(),
- motorCursor,
- R.layout.motor_list_group,
- R.layout.motor_list_child);
- setListAdapter(mAdapter);
- onContentChanged();
- }
-}
diff --git a/android/src/net/sf/openrocket/android/rocket/Component.java b/android/src/net/sf/openrocket/android/rocket/Component.java
deleted file mode 100644
index ac8f1f993e..0000000000
--- a/android/src/net/sf/openrocket/android/rocket/Component.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package net.sf.openrocket.android.rocket;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.CurrentRocketHolder;
-import net.sf.openrocket.android.rocket.RocketComponentTreeAdapter.RocketComponentWithId;
-import net.sf.openrocket.document.OpenRocketDocument;
-import net.sf.openrocket.rocketcomponent.Rocket;
-import net.sf.openrocket.rocketcomponent.RocketComponent;
-import pl.polidea.treeview.InMemoryTreeStateManager;
-import pl.polidea.treeview.TreeBuilder;
-import pl.polidea.treeview.TreeStateManager;
-import pl.polidea.treeview.TreeViewList;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ListAdapter;
-
-public class Component extends Fragment {
-
- private TreeViewList componentTree;
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View v = inflater.inflate(R.layout.rocket_component, container, false);
- componentTree = (TreeViewList) v.findViewById(R.id.openrocketviewerComponentTree);
-
- return v;
- }
-
- @Override
- public void onResume() {
- super.onResume();
- final OpenRocketDocument rocketDocument = CurrentRocketHolder.getCurrentRocket().getRocketDocument();
- componentTree.setAdapter( buildAdapter( rocketDocument.getRocket() ) );
- }
-
- private ListAdapter buildAdapter( Rocket rocket ) {
-
- TreeStateManager manager = new InMemoryTreeStateManager();
- TreeBuilder treeBuilder = new TreeBuilder(manager);
-
- int depth = buildRecursive( rocket, treeBuilder, 0 );
- return new RocketComponentTreeAdapter(this.getActivity(), manager, depth+1);
- }
-
- long id = 0;
- private int buildRecursive( RocketComponent comp, TreeBuilder builder, int depth ) {
-
-
- int maxDepth = depth;
-
- RocketComponentWithId rcid = new RocketComponentWithId(comp, id++);
-
- // Add this component.
- builder.sequentiallyAddNextNode(rcid, depth);
-
- if ( comp.allowsChildren() ) {
-
- for( RocketComponent child : comp.getChildren() ) {
- int childDepth = buildRecursive( child, builder, depth+1);
- if ( childDepth > maxDepth) {
- maxDepth = childDepth;
- }
- }
-
- }
-
- return maxDepth;
- }
-
-
-}
diff --git a/android/src/net/sf/openrocket/android/rocket/Configurations.java b/android/src/net/sf/openrocket/android/rocket/Configurations.java
deleted file mode 100644
index 9f381de03e..0000000000
--- a/android/src/net/sf/openrocket/android/rocket/Configurations.java
+++ /dev/null
@@ -1,336 +0,0 @@
-package net.sf.openrocket.android.rocket;
-
-import java.util.List;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.CurrentRocketHolder;
-import net.sf.openrocket.android.db.DbAdapter;
-import net.sf.openrocket.android.motor.ExtendedThrustCurveMotor;
-import net.sf.openrocket.android.motor.MotorDelayDialogFragment;
-import net.sf.openrocket.android.motor.MotorListDialogFragment;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.android.util.ExpandableListFragment;
-import net.sf.openrocket.document.OpenRocketDocument;
-import net.sf.openrocket.motor.Motor;
-import net.sf.openrocket.rocketcomponent.MotorMount;
-import net.sf.openrocket.rocketcomponent.RocketComponent;
-import net.sf.openrocket.unit.UnitGroup;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.support.v4.app.FragmentTransaction;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseExpandableListAdapter;
-import android.widget.Button;
-import android.widget.ExpandableListAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-public class Configurations extends ExpandableListFragment {
-
- private final static String wizardFrag = "wizardFrag";
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- setHasOptionsMenu(true);
- View v = inflater.inflate(R.layout.rocket_configurations, container, false);
-
- return v;
- }
-
- @Override
- public void onResume() {
- setup();
- super.onResume();
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- inflater.inflate(R.menu.rocket_viewer_configurations_option_menu, menu);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId())
- {
- case R.id.menu_add:
- addConfiguration();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-
- public void refreshConfigsList() {
- setup();
- }
-
- private void addConfiguration() {
- CurrentRocketHolder.getCurrentRocket().addNewMotorConfig(getActivity());
- }
-
- private void removeConfiguration( String config ) {
- CurrentRocketHolder.getCurrentRocket().deleteMotorConfig( getActivity(), config );
- }
-
- private static class MotorMountInfo {
-
- private RocketComponent mmt;
- private String config;
- private ExtendedThrustCurveMotor motor;
- private double delay;
-
- String getMotorMountDescription() {
- String mmtDesc = mmt.getComponentName();
- mmtDesc += " (" + UnitGroup.UNITS_MOTOR_DIMENSIONS.toStringUnit( ((MotorMount)mmt).getMotorMountDiameter()) + ")";
- return mmtDesc;
- }
-
- String getMotorDescription() {
- return motor.getManufacturer().getDisplayName() + " " + motor.getDesignation();
- }
-
- }
-
- class ChildViewHolder {
- MotorMountInfo info;
- TextView motorMountName;
- Button motorDescription;
- Button motorDelay;
- void setMotor( ExtendedThrustCurveMotor motor ) {
- this.info.motor = motor;
- ((MotorMount)info.mmt).setMotor(info.config, motor);
- }
- void setDelay( double delay ) {
- this.info.delay = delay;
- ((MotorMount)info.mmt).setMotorDelay(info.config, delay);
- }
- }
-
- private void setup() {
- final OpenRocketDocument rocketDocument = CurrentRocketHolder.getCurrentRocket().getRocketDocument();
-
- ExpandableListAdapter configurationAdapter = new BaseExpandableListAdapter() {
-
- // Note: the magic 1 you see below is so the "no motors" configuration
- // does not appear in the configuration list.
- List mmts = rocketDocument.getRocket().getMotorMounts();
-
- @Override
- public int getGroupCount() {
- // don't show the "no motors" configuration, so we have one less than the
- // array length.
- return rocketDocument.getRocket().getMotorConfigurationIDs().length-1;
- }
-
- @Override
- public int getChildrenCount(int groupPosition) {
- return mmts.size();
- }
-
- @Override
- public Object getGroup(int groupPosition) {
- // Skip over the "no motors" configuration
- String config = rocketDocument.getRocket().getMotorConfigurationIDs()[groupPosition+1];
- return config;
- }
-
- @Override
- public Object getChild(int groupPosition, int childPosition) {
- MotorMountInfo info = new MotorMountInfo();
- info.mmt = (RocketComponent)(mmts.get(childPosition));
-
- String config = (String) getGroup(groupPosition);
- info.config = config;
- info.motor = (ExtendedThrustCurveMotor) ((MotorMount)info.mmt).getMotor(config);
-
- if ( info.motor != null ) {
- info.delay = ((MotorMount)info.mmt).getMotorDelay(config);
- } else {
- info.delay = -1;
- }
-
- return info;
- }
-
- @Override
- public long getGroupId(int groupPosition) {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public long getChildId(int groupPosition, int childPosition) {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public boolean hasStableIds() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
- if ( convertView == null ) {
- convertView = getActivity().getLayoutInflater().inflate(android.R.layout.simple_expandable_list_item_1,null);
- }
-
- String configDescription = rocketDocument.getRocket().getMotorConfigurationNameOrDescription((String) getGroup(groupPosition));
- ((TextView)convertView.findViewById(android.R.id.text1)).setText( configDescription );
- return convertView;
- }
-
- @Override
- public View getChildView(int groupPosition, int childPosition,
- boolean isLastChild, View convertView, ViewGroup parent) {
- if ( convertView == null ) {
- convertView = getActivity().getLayoutInflater().inflate(R.layout.motor_config_item,null);
- ChildViewHolder holder = new ChildViewHolder();
- holder.motorMountName = (TextView) convertView.findViewById(R.id.motor_config_motor_mount_name);
- holder.motorDescription = (Button) convertView.findViewById(R.id.motor_config_motor_desc);
- holder.motorDelay = (Button) convertView.findViewById(R.id.motor_config_motor_delay);
- holder.info = (MotorMountInfo) getChild(groupPosition,childPosition);
- convertView.setTag(holder);
- }
-
- ChildViewHolder cvHolder = (ChildViewHolder) convertView.getTag();
-
- cvHolder.motorMountName.setText(cvHolder.info.getMotorMountDescription());
- cvHolder.motorDescription.setOnClickListener( new MotorWizardOnClickListener() );
- if ( cvHolder.info.motor == null ) {
- cvHolder.motorDelay.setClickable(false);
- cvHolder.motorDelay.setOnClickListener(null);
- cvHolder.motorDescription.setText(R.string.select_motor);
- } else {
- cvHolder.motorDelay.setClickable(true);
- cvHolder.motorDelay.setOnClickListener( new MotorDelayOnClickListener(cvHolder.info.motor) );
- cvHolder.motorDescription.setText(cvHolder.info.getMotorDescription());
- }
- if( cvHolder.info.delay >=0 ) {
- if( cvHolder.info.delay == Motor.PLUGGED ) {
- cvHolder.motorDelay.setText("P");
- } else {
- cvHolder.motorDelay.setText( String.valueOf(Math.round(cvHolder.info.delay)));
- }
- } else {
- cvHolder.motorDelay.setText(R.string.select_delay);
- }
-
- return convertView;
- }
-
- @Override
- public boolean isChildSelectable(int groupPosition, int childPosition) {
- return false;
- }
-
- };
-
- setListAdapter(configurationAdapter);
- }
-
- @Override
- public boolean onListItemLongClick(ListView l, View v, int position, long id) {
-
- Object o = getExpandableListAdapter().getGroup(position);
-
- if ( o == null || ! (o instanceof String) ) {
- return false;
- }
- final String motorConfigId = (String)o;
-
- AlertDialog.Builder b = new AlertDialog.Builder( getActivity() );
- b.setTitle(R.string.DeleteConfigTitle);
- b.setCancelable(true);
- b.setPositiveButton(R.string.Delete, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- Configurations.this.removeConfiguration(motorConfigId);
- }
-
- });
-
- Dialog dialog = b.create();
-
- dialog.setCanceledOnTouchOutside(true);
- dialog.show();
- return true;
- }
-
- private class MotorWizardOnClickListener implements View.OnClickListener {
- @Override
- public void onClick(View v) {
- final ViewGroup parent = (ViewGroup) v.getParent();
- final ChildViewHolder cvHolder = (ChildViewHolder) parent.getTag();
- final MotorListDialogFragment f = new MotorListDialogFragment();
- f.setMotorSelectedListener( new MotorListDialogFragment.OnMotorSelectedListener() {
-
- @Override
- public void onMotorSelected(long motorId) {
- DbAdapter mdbHelper = new DbAdapter(getActivity());
- mdbHelper.open();
- try {
- ExtendedThrustCurveMotor motor = mdbHelper.getMotorDao().fetchMotor(motorId);
- cvHolder.setMotor( motor );
- ((BaseExpandableListAdapter)Configurations.this.getExpandableListAdapter()).notifyDataSetInvalidated();
- } catch (Exception ex) {
- AndroidLogWrapper.d(Configurations.class, "BlewUp looking for motor", ex);
- } finally {
- mdbHelper.close();
- }
- FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
- ft.remove(f);
- ft.commit();
-
- }
- });
- FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
- ft.add(f, wizardFrag);
- ft.commit();
- }
-
- }
-
- private class MotorDelayOnClickListener implements View.OnClickListener {
-
- double[] standardDelays;
-
- public MotorDelayOnClickListener(ExtendedThrustCurveMotor motor) {
- super();
- this.standardDelays = motor.getStandardDelays();
- }
-
- @Override
- public void onClick(View v) {
- final View parent = (View) v.getParent();
- final ChildViewHolder cvHolder = (ChildViewHolder) parent.getTag();
- final MotorDelayDialogFragment f = MotorDelayDialogFragment.newInstance(standardDelays);
- f.setDelaySelectedListener( new MotorDelayDialogFragment.OnDelaySelectedListener() {
-
- @Override
- public void onDelaySelected(double delay) {
- cvHolder.setDelay( delay );
- ((BaseExpandableListAdapter)Configurations.this.getExpandableListAdapter()).notifyDataSetInvalidated();
- FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
- ft.remove(f);
- ft.commit();
-
- }
- });
- FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
- ft.add(f, wizardFrag);
- ft.commit();
- }
-
- }
-}
diff --git a/android/src/net/sf/openrocket/android/rocket/ErrorLoadingFileDialogFragment.java b/android/src/net/sf/openrocket/android/rocket/ErrorLoadingFileDialogFragment.java
deleted file mode 100644
index 8a957f879e..0000000000
--- a/android/src/net/sf/openrocket/android/rocket/ErrorLoadingFileDialogFragment.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package net.sf.openrocket.android.rocket;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-
-import com.actionbarsherlock.app.SherlockDialogFragment;
-
-public class ErrorLoadingFileDialogFragment extends SherlockDialogFragment {
-
- public static ErrorLoadingFileDialogFragment newInstance( int titleRes, String message ) {
- ErrorLoadingFileDialogFragment dialog = new ErrorLoadingFileDialogFragment();
- Bundle b = new Bundle();
- b.putString("message", message);
- b.putInt("titleRes", titleRes);
- dialog.setArguments(b);
- dialog.setCancelable(true);
- return dialog;
- }
-
-
- @Override
- public void onCancel(DialogInterface dialog) {
- ((OpenRocketLoaderActivity)getActivity()).doDismissErrorDialog();
- }
-
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- AndroidLogWrapper.d(ErrorLoadingFileDialogFragment.class,"onCreateDialog");
-
- String message = getArguments().getString("message");
- final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
-
- if ( getArguments().containsKey("titleRes") ) {
- int titleRes = getArguments().getInt("titleRes");
- builder.setTitle(titleRes);
- }
-
- builder.setMessage(message);
- builder.setNeutralButton(R.string.dismiss, new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface arg0, int arg1) {
- ((OpenRocketLoaderActivity)getActivity()).doDismissErrorDialog();
- }
-
- });
-
- final AlertDialog dialog = builder.create();
- dialog.setOwnerActivity(getActivity());
- return dialog;
- }
-
-
-}
diff --git a/android/src/net/sf/openrocket/android/rocket/MissingMotorDialogFragment.java b/android/src/net/sf/openrocket/android/rocket/MissingMotorDialogFragment.java
deleted file mode 100644
index a0c08eecc9..0000000000
--- a/android/src/net/sf/openrocket/android/rocket/MissingMotorDialogFragment.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package net.sf.openrocket.android.rocket;
-
-import java.util.Set;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.motor.ThrustCurveMotorPlaceholder;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-
-import com.actionbarsherlock.app.SherlockDialogFragment;
-
-public class MissingMotorDialogFragment extends SherlockDialogFragment {
-
- private final static String MESSAGES_ARG_KEY = "messages";
-
- public static MissingMotorDialogFragment newInstance( Set missingMotors ) {
- MissingMotorDialogFragment frag = new MissingMotorDialogFragment();
- Bundle b = new Bundle();
- String[] messages = new String[ missingMotors.size() ];
- int index = 0;
- for( ThrustCurveMotorPlaceholder m : missingMotors ) {
- messages[index++] = m.getManufacturer() + " " + m.getDesignation();
- }
- b.putStringArray(MESSAGES_ARG_KEY, messages);
- frag.setArguments(b);
- frag.setCancelable(false);
- return frag;
- }
-
- private String buildMessage( String[] missingMotors ) {
- StringBuilder sb = new StringBuilder();
- sb.append(this.getString(R.string.missingMotorsMessageStart));
- for( String m : missingMotors ) {
- sb.append("\n").append(m);
- }
- sb.append("\n").append(this.getString(R.string.missingMotorsMessageEnd));
- return sb.toString();
- }
-
- @Override
- public void onCancel(DialogInterface dialog) {
- ((OpenRocketLoaderActivity)getActivity()).doNotFixMissingMotors();
- super.onCancel(dialog);
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
-
- AndroidLogWrapper.d(MissingMotorDialogFragment.class,"onCreateDialog");
-
- String[] messages = getArguments().getStringArray(MESSAGES_ARG_KEY);
-
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- // .setIcon(android.R.drawable.alert_dialog_icon)
- builder.setTitle(R.string.missingMotors);
- builder.setMessage(buildMessage(messages));
- builder.setPositiveButton(R.string.yes,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- ((OpenRocketLoaderActivity)getActivity()).doFixMissingMotors();
- }
- });
-
- builder.setNegativeButton(R.string.no,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- ((OpenRocketLoaderActivity)getActivity()).doNotFixMissingMotors();
- }
- });
-
- AlertDialog dialog = builder.create();
- dialog.setOwnerActivity(getActivity());
- return dialog;
- }
-
-}
-
diff --git a/android/src/net/sf/openrocket/android/rocket/MissingMotorHelpers.java b/android/src/net/sf/openrocket/android/rocket/MissingMotorHelpers.java
deleted file mode 100644
index a0179d7131..0000000000
--- a/android/src/net/sf/openrocket/android/rocket/MissingMotorHelpers.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package net.sf.openrocket.android.rocket;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import net.sf.openrocket.aerodynamics.WarningSet;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.file.DatabaseMotorFinder;
-import net.sf.openrocket.motor.Motor;
-import net.sf.openrocket.motor.ThrustCurveMotorPlaceholder;
-import net.sf.openrocket.rocketcomponent.Configuration;
-import net.sf.openrocket.rocketcomponent.MotorMount;
-import net.sf.openrocket.rocketcomponent.Rocket;
-
-public abstract class MissingMotorHelpers {
-
- public static Set findMissingMotors( Rocket rocket ) {
-
- Set missingMotors = new HashSet();
- Configuration config = rocket.getDefaultConfiguration();
- for( String configID : rocket.getMotorConfigurationIDs() ) {
- config.setMotorConfigurationID(configID);
- Iterator mmts = config.motorIterator();
- while ( mmts.hasNext() ) {
- MotorMount mmt = mmts.next();
- Motor m = mmt.getMotor(configID);
- if ( m instanceof ThrustCurveMotorPlaceholder ) {
- missingMotors.add( (ThrustCurveMotorPlaceholder) m );
- }
- }
-
- }
-
- for ( ThrustCurveMotorPlaceholder m : missingMotors ) {
- AndroidLogWrapper.d(MissingMotorHelpers.class, "Missing Motor: {}", m);
- }
-
- return missingMotors;
- }
-
- public static void updateMissingMotors( Rocket rocket, WarningSet warnings ) {
-
- DatabaseMotorFinder finder = new DatabaseMotorFinder();
-
- Configuration config = rocket.getDefaultConfiguration();
- for( String configID : rocket.getMotorConfigurationIDs() ) {
- config.setMotorConfigurationID(configID);
- Iterator mmts = config.motorIterator();
- while ( mmts.hasNext() ) {
- MotorMount mmt = mmts.next();
- Motor m = mmt.getMotor(configID);
- if ( m instanceof ThrustCurveMotorPlaceholder ) {
-
- ThrustCurveMotorPlaceholder placeholder = (ThrustCurveMotorPlaceholder)m;
- Motor newMotor = finder.findMotor(placeholder.getMotorType(),
- placeholder.getManufacturer(),
- placeholder.getDesignation(),
- placeholder.getDiameter(),
- placeholder.getLength(),
- placeholder.getDigest(),
- warnings);
-
- if ( newMotor != null ) {
- // one is now here so replace it
- mmt.setMotor(configID, newMotor);
- }
- }
- }
-
- }
-
-
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/rocket/MotorConfigSpinner.java b/android/src/net/sf/openrocket/android/rocket/MotorConfigSpinner.java
deleted file mode 100644
index e850178527..0000000000
--- a/android/src/net/sf/openrocket/android/rocket/MotorConfigSpinner.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package net.sf.openrocket.android.rocket;
-
-import net.sf.openrocket.rocketcomponent.Rocket;
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.ArrayAdapter;
-import android.widget.Spinner;
-
-public class MotorConfigSpinner extends Spinner {
-
- public MotorConfigSpinner(Context context, AttributeSet attrs,
- int defStyle, int mode) {
- super(context, attrs, defStyle, mode);
- }
-
- public MotorConfigSpinner(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- public MotorConfigSpinner(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public MotorConfigSpinner(Context context, int mode) {
- super(context, mode);
- }
-
- public MotorConfigSpinner(Context context) {
- super(context);
- }
-
- public void createAdapter(Rocket rocket ) {
-
- setAdapter(new MotorConfigSpinnerAdapter(this.getContext(), rocket) );
-
- }
-
- public void setSelectedConfiguration( String configId ) {
- this.setSelection( ((MotorConfigSpinnerAdapter)getAdapter()).getConfigurationPosition( configId ));
- }
-
- public String getSelectedConfiguration() {
- return ((MotorConfigSpinnerAdapter)getAdapter()).getConfiguration( this.getSelectedItemPosition() );
- }
-
- public class MotorConfigSpinnerAdapter extends ArrayAdapter {
-
- private String[] motorConfigs;
-
- public MotorConfigSpinnerAdapter(Context context, Rocket rocket) {
- super(context, android.R.layout.simple_spinner_item);
- setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- motorConfigs = rocket.getMotorConfigurationIDs();
-
- for( String config: motorConfigs ) {
- this.add(rocket.getMotorConfigurationNameOrDescription(config));
- }
-
- }
-
- public int getConfigurationPosition(String configId) {
-
- int selectedIndex = 0;
-
- if ( configId == null ) {
- return selectedIndex;
- }
-
- for( String s : motorConfigs ) {
- // Note - s may be null since it is a valid id.
- if ( configId.equals(s) ) {
- break;
- }
- selectedIndex++;
- }
- if( selectedIndex >= motorConfigs.length ) {
- selectedIndex = 0;
- }
-
- return selectedIndex;
- }
-
- public String getConfiguration( int position ) {
- return motorConfigs[position];
- }
- }
-}
diff --git a/android/src/net/sf/openrocket/android/rocket/OpenRocketLoaderActivity.java b/android/src/net/sf/openrocket/android/rocket/OpenRocketLoaderActivity.java
deleted file mode 100644
index 9a3a84310d..0000000000
--- a/android/src/net/sf/openrocket/android/rocket/OpenRocketLoaderActivity.java
+++ /dev/null
@@ -1,249 +0,0 @@
-package net.sf.openrocket.android.rocket;
-
-import java.io.File;
-import java.util.Set;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.aerodynamics.WarningSet;
-import net.sf.openrocket.android.CurrentRocketHolder;
-import net.sf.openrocket.android.filebrowser.SimpleFileBrowser;
-import net.sf.openrocket.android.thrustcurve.TCMissingMotorDownloadAction;
-import net.sf.openrocket.android.thrustcurve.TCQueryAction;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.motor.ThrustCurveMotorPlaceholder;
-import net.sf.openrocket.rocketcomponent.Rocket;
-import android.content.ActivityNotFoundException;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.res.Resources;
-import android.net.Uri;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.support.v4.app.DialogFragment;
-
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-
-public class OpenRocketLoaderActivity extends SherlockFragmentActivity
-implements TCQueryAction.OnTCQueryCompleteListener, OpenRocketLoaderFragment.OnOpenRocketFileLoaded
-{
-
- private static final int PICK_ORK_FILE_RESULT = 1;
-
- private final static String MISSING_MOTOR_DIAG_FRAGMENT_TAG = "missingmotordialog";
- private final static String MISSING_MOTOR_DOWNLOAD_FRAGMENT_TAG = "missingmotortask";
-
- /*
- * Set to true when we have started to load a file. Is saved in InstanceState.
- */
- private boolean isLoading = false;
- /*
- * Set to the Uri of the file we are supposed to load. Is saved in InstanceState.
- */
- private Uri fileToLoad = null;
-
- protected boolean isLoading() {
- AndroidLogWrapper.d(OpenRocketLoaderActivity.class, "isLoading " + this.hashCode());
- AndroidLogWrapper.d(OpenRocketLoaderActivity.class, "isLoading = " + isLoading);
- return isLoading;
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- Intent i = getIntent();
- if (Intent.ACTION_VIEW.equals(i.getAction()) && i.getData() != null ) {
- Uri file = i.getData();
- fileToLoad = file;
- loadOrkFile();
- } else {
- }
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- AndroidLogWrapper.d(OpenRocketLoaderActivity.class, "onSaveInstanceState " + this.hashCode());
- AndroidLogWrapper.d(OpenRocketLoaderActivity.class, "isLoading = " + isLoading);
- outState.putBoolean("isLoading", isLoading);
- if ( fileToLoad != null ) {
- outState.putParcelable("fileToLoad", fileToLoad);
- }
- super.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onRestoreInstanceState(Bundle savedInstanceState) {
- AndroidLogWrapper.d(OpenRocketLoaderActivity.class, "onRestoreInstanceState");
- isLoading = savedInstanceState.getBoolean("isLoading",false);
- AndroidLogWrapper.d(OpenRocketLoaderActivity.class, "isLoading = " + isLoading);
- if ( savedInstanceState.containsKey("fileToLoad") ) {
- fileToLoad = savedInstanceState.getParcelable("fileToLoad");
- }
- super.onRestoreInstanceState(savedInstanceState);
- }
-
- @Override
- protected void onResume() {
- AndroidLogWrapper.d(OpenRocketLoaderActivity.class, "onResume");
- super.onResume();
- // Start loading a file if we have a file and are not already loading one.
- if ( fileToLoad != null && !isLoading ) {
- loadOrkFile();
- }
- }
-
- /* (non-Javadoc)
- * @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
- */
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- AndroidLogWrapper.d(OpenRocketLoaderActivity.class, "onActivityResult");
- switch ( requestCode ) {
- case PICK_ORK_FILE_RESULT:
- if(resultCode==RESULT_OK){
- Uri file = data.getData();
- fileToLoad = file;
- // It would be nice to just start loading the file - but that doesn't work correctly.
- // I'm uncertain if it is a bug in Android 14/15 or a bug in the v4 support library.
- // essentially what happens is, when the FileBrowserActivity is brought up,
- // this activity goes through the saveInstanceState calls to push it to the background.
- // When the FileBrowserActivity returns the result, this.onActivityResult is called
- // prior to any of the other lifecycle methods (onRestoreInstanceState as documented, but onStart is
- // a bug. Since onStart hasn't been called, this activity is not able to create fragments - which
- // are used to indicate progress etc.
- // Instead of calling loadOrkFile() here, we push the file Uri into a member variable,
- // then check the member variable in onResume to actuall kick off the work.
- }
- break;
- default:
- super.onActivityResult(requestCode, resultCode, data);
- }
- }
-
- protected void pickOrkFiles( ) {
- Resources resources = this.getResources();
- String key = resources.getString(R.string.PreferenceUseInternalFileBrowserOption);
- SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
-
- boolean useinternalbrowser = pref.getBoolean(key, true);
-
- if ( useinternalbrowser ) {
- Intent intent = new Intent(OpenRocketLoaderActivity.this, SimpleFileBrowser.class);
- startActivityForResult(intent,PICK_ORK_FILE_RESULT);
- } else {
- try {
- Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
- intent.setType("file/*");
- startActivityForResult(intent,PICK_ORK_FILE_RESULT);
- } catch ( ActivityNotFoundException ex ) {
- // No activity for ACTION_GET_CONTENT use internal file browser
- // update the preference value.
- pref.edit().putBoolean(key, false).commit();
- // fire our browser
- Intent intent = new Intent(OpenRocketLoaderActivity.this, SimpleFileBrowser.class);
- startActivityForResult(intent,PICK_ORK_FILE_RESULT);
- }
- }
- }
-
- private void loadOrkFile( ) {
- // a little protection.
- if ( fileToLoad == null ) {
- return;
- }
- isLoading = true;
- CurrentRocketHolder.getCurrentRocket().setFileUri( fileToLoad );
- AndroidLogWrapper.d(OpenRocketLoaderActivity.class,"Use ork file: " + fileToLoad);
- String path = fileToLoad.getPath();
- File orkFile = new File(path);
-
- // Also need commitAllowingState loss because of a bug in v4 dialog show.
- getSupportFragmentManager().beginTransaction()
- .add( OpenRocketLoaderFragment.newInstance(orkFile), "loader")
- .commitAllowingStateLoss();
-
- }
-
- /**
- * Called by the OpenRocketLoaderTask when it completes.
- * is default visibility so it can be called from this package.
- *
- * @param result
- */
- public void onOpenRocketFileLoaded(OpenRocketLoaderResult result) {
- if ( result.loadingError != null ) {
-
- ErrorLoadingFileDialogFragment errorDialog = ErrorLoadingFileDialogFragment.newInstance(R.string.loadingErrorMessage, result.loadingError.getLocalizedMessage());
- errorDialog.show(getSupportFragmentManager(),"errorDialog");
-
- } else {
- CurrentRocketHolder.getCurrentRocket().setRocketDocument( result.rocket );
- CurrentRocketHolder.getCurrentRocket().setWarnings( result.warnings );
-
- updateMissingMotors();
- }
- }
-
- private void updateMissingMotors() {
- Rocket rocket = CurrentRocketHolder.getCurrentRocket().getRocketDocument().getRocket();
- Set missingMotors = MissingMotorHelpers.findMissingMotors(rocket);
-
- if ( missingMotors.size() > 0 ) {
- MissingMotorDialogFragment missingMotorDialog = MissingMotorDialogFragment.newInstance( missingMotors );
- missingMotorDialog.show(getSupportFragmentManager(), MISSING_MOTOR_DIAG_FRAGMENT_TAG);
- return;
- }
-
- displayWarningDialog();
- }
-
- /**
- * Called when the TCMissingMotorDownload process finishes.
- */
- @Override
- public void onTCQueryComplete(String message) {
-
- Rocket rocket = CurrentRocketHolder.getCurrentRocket().getRocketDocument().getRocket();
- WarningSet warnings = CurrentRocketHolder.getCurrentRocket().getWarnings();
- // Need to update the motor references.
- MissingMotorHelpers.updateMissingMotors(rocket, warnings);
-
- displayWarningDialog();
- }
-
- private void displayWarningDialog() {
- WarningSet warnings = CurrentRocketHolder.getCurrentRocket().getWarnings();
- if (warnings == null || warnings.isEmpty()) {
- } else {
- DialogFragment newFragment = WarningDialogFragment.newInstance();
- newFragment.show(getSupportFragmentManager(), "dialog");
- return;
- }
-
- moveOnToViewer();
- }
-
- public void doFixMissingMotors() {
- Rocket rocket = CurrentRocketHolder.getCurrentRocket().getRocketDocument().getRocket();
- Set missingMotors = MissingMotorHelpers.findMissingMotors(rocket);
-
- TCMissingMotorDownloadAction motorfrag = TCMissingMotorDownloadAction.newInstance( missingMotors );
- getSupportFragmentManager().beginTransaction().add( motorfrag, MISSING_MOTOR_DOWNLOAD_FRAGMENT_TAG).commit();
-
- }
-
- public void doNotFixMissingMotors() {
- displayWarningDialog();
- }
-
- public void doDismissErrorDialog() {
- isLoading = false;
- fileToLoad = null;
- }
-
- public void moveOnToViewer() {
- isLoading = false;
- Intent i = new Intent(this,OpenRocketViewer.class);
- startActivity(i);
- finish();
- }
-}
diff --git a/android/src/net/sf/openrocket/android/rocket/OpenRocketLoaderFragment.java b/android/src/net/sf/openrocket/android/rocket/OpenRocketLoaderFragment.java
deleted file mode 100644
index e6dc5dd3b2..0000000000
--- a/android/src/net/sf/openrocket/android/rocket/OpenRocketLoaderFragment.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package net.sf.openrocket.android.rocket;
-
-import java.io.File;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.android.util.ProgressDialogFragment;
-import net.sf.openrocket.document.OpenRocketDocument;
-import net.sf.openrocket.file.DatabaseMotorFinderWithMissingMotors;
-import net.sf.openrocket.file.GeneralRocketLoader;
-import net.sf.openrocket.file.RocketLoadException;
-import android.app.Activity;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.support.v4.app.DialogFragment;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.actionbarsherlock.app.SherlockFragment;
-
-public class OpenRocketLoaderFragment extends SherlockFragment {
-
- private final static String FILE_ARG_KEY = "file";
-
- public interface OnOpenRocketFileLoaded {
- public void onOpenRocketFileLoaded( OpenRocketLoaderResult result );
- }
-
- private File file;
- private OpenRocketLoaderTask task;
- private OnOpenRocketFileLoaded listener;
-
- public static OpenRocketLoaderFragment newInstance(File file) {
- OpenRocketLoaderFragment frag = new OpenRocketLoaderFragment();
- Bundle b = new Bundle();
- b.putSerializable(FILE_ARG_KEY, file);
- frag.setArguments(b);
- return frag;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setRetainInstance(true);
- Bundle b = getArguments();
- file = (File) b.getSerializable(FILE_ARG_KEY);
- if ( task == null ) {
- // since we retain instance state, task will be non-null if it is already loading.
- task = new OpenRocketLoaderTask();
- task.execute(file);
- }
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- return null;
- }
-
- @Override
- public void onActivityCreated(Bundle arg0) {
- super.onActivityCreated(arg0);
- Activity parent = getActivity();
- if ( parent instanceof OnOpenRocketFileLoaded ) {
- listener = (OnOpenRocketFileLoaded) parent;
- }
- }
-
- public class OpenRocketLoaderTask extends AsyncTask {
-
- private final static String PROGRESS_DIALOG_TAG = "progress_dialog";
-
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- String loading = getActivity().getResources().getString(R.string.loading);
- DialogFragment newFragment = ProgressDialogFragment.newInstance("", loading);
- newFragment.show(getFragmentManager(), PROGRESS_DIALOG_TAG);
- }
-
- /* (non-Javadoc)
- * @see android.os.AsyncTask#doInBackground(Params[])
- */
- @Override
- protected OpenRocketLoaderResult doInBackground(File... arg0) {
- AndroidLogWrapper.d(OpenRocketLoaderTask.class, "doInBackgroud");
-
- GeneralRocketLoader rocketLoader = new GeneralRocketLoader();
- OpenRocketLoaderResult result = new OpenRocketLoaderResult();
- try {
- OpenRocketDocument rocket = rocketLoader.load(arg0[0], new DatabaseMotorFinderWithMissingMotors());
- rocket.getDefaultConfiguration().setAllStages();
- result.rocket = rocket;
- result.warnings = rocketLoader.getWarnings();
- } catch (RocketLoadException ex) {
- AndroidLogWrapper.e(OpenRocketLoaderTask.class, "doInBackground rocketLaoder.load threw {}", ex);
- result.loadingError = ex;
- }
- return result;
-
- }
-
- @Override
- protected void onPostExecute(OpenRocketLoaderResult result) {
- super.onPostExecute(result);
- AndroidLogWrapper.d(OpenRocketLoaderFragment.class,"Finished loading " + OpenRocketLoaderTask.this);
- Fragment progress = getActivity().getSupportFragmentManager().findFragmentByTag(PROGRESS_DIALOG_TAG);
- if ( progress != null ) {
- // Remove the fragment instead of trying to use DialogFragment.dismiss.
- // If the dialog is now currently shown, dismiss fails.
- getFragmentManager().beginTransaction().remove(progress).commitAllowingStateLoss();
- }
- if ( listener != null ) {
- listener.onOpenRocketFileLoaded(result);
- }
- }
-
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/rocket/OpenRocketLoaderResult.java b/android/src/net/sf/openrocket/android/rocket/OpenRocketLoaderResult.java
deleted file mode 100644
index 4e3fef6d69..0000000000
--- a/android/src/net/sf/openrocket/android/rocket/OpenRocketLoaderResult.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package net.sf.openrocket.android.rocket;
-
-import net.sf.openrocket.aerodynamics.WarningSet;
-import net.sf.openrocket.document.OpenRocketDocument;
-import net.sf.openrocket.file.RocketLoadException;
-
-public class OpenRocketLoaderResult {
-
- public WarningSet warnings;
- public OpenRocketDocument rocket;
- public RocketLoadException loadingError;
-
-}
diff --git a/android/src/net/sf/openrocket/android/rocket/OpenRocketSaverFragment.java b/android/src/net/sf/openrocket/android/rocket/OpenRocketSaverFragment.java
deleted file mode 100644
index 6f6745b725..0000000000
--- a/android/src/net/sf/openrocket/android/rocket/OpenRocketSaverFragment.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package net.sf.openrocket.android.rocket;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.CurrentRocketHolder;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.android.util.ProgressDialogFragment;
-import android.app.Activity;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.support.v4.app.DialogFragment;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.Window;
-
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-
-public class OpenRocketSaverFragment extends Fragment {
-
- public static OpenRocketSaverFragment newInstance( boolean showProgressDialog) {
- OpenRocketSaverFragment frag = new OpenRocketSaverFragment();
- Bundle b = new Bundle();
- b.putBoolean(SHOW_PRGRESS_DIALOG_ARG, showProgressDialog);
- frag.setArguments(b);
- return frag;
- }
-
- public interface OnOpenRocketFileSaved {
- public void onOpenRocketFileSaved( Boolean result );
- }
-
- private final static String SHOW_PRGRESS_DIALOG_ARG = "net.sf.openrocket.android.ShowProgressDialog";
-
- private boolean showProgressDialog = true;
- private OpenRocketSaverTask task;
- private OnOpenRocketFileSaved listener;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setRetainInstance(true);
- Bundle b = getArguments();
- if ( b != null ) {
- showProgressDialog = b.getBoolean(SHOW_PRGRESS_DIALOG_ARG, true);
- }
- if ( task == null ) {
- // since we retain instance state, task will be non-null if it is already loading.
- task = new OpenRocketSaverTask();
- task.execute();
- }
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- return null;
- }
-
- @Override
- public void onActivityCreated(Bundle arg0) {
- super.onActivityCreated(arg0);
- Activity parent = getActivity();
- if ( parent instanceof OnOpenRocketFileSaved ) {
- listener = (OnOpenRocketFileSaved) parent;
- }
- }
-
- public class OpenRocketSaverTask extends AsyncTask {
-
- private final static String PROGRESS_DIALOG_TAG = "progress_dialog";
-
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- if ( showProgressDialog ) {
- String savingMessage = getActivity().getResources().getString(R.string.saving);
- DialogFragment newFragment = ProgressDialogFragment.newInstance("", savingMessage);
- newFragment.show(getFragmentManager(), PROGRESS_DIALOG_TAG);
- } else {
- ((SherlockFragmentActivity)getActivity()).setSupportProgressBarIndeterminate(true);
- ((SherlockFragmentActivity)getActivity()).setSupportProgress(0);
- }
-
- }
-
- /* (non-Javadoc)
- * @see android.os.AsyncTask#doInBackground(Params[])
- */
- @Override
- protected Boolean doInBackground(Void... arg0) {
- AndroidLogWrapper.d(OpenRocketSaverTask.class, "doInBackgroud");
-
- try {
- CurrentRocketHolder.getCurrentRocket().saveOpenRocketDocument();
- return true;
- } catch (Throwable ex) {
- AndroidLogWrapper.e(OpenRocketSaverTask.class, "doInBackground rocketLaoder.load threw {}", ex);
- }
- return false;
-
- }
-
- @Override
- protected void onPostExecute(Boolean result) {
- super.onPostExecute(result);
- AndroidLogWrapper.d(OpenRocketSaverFragment.class,"Finished saving " + OpenRocketSaverTask.this);
- if ( showProgressDialog ) {
- Fragment progress = getActivity().getSupportFragmentManager().findFragmentByTag(PROGRESS_DIALOG_TAG);
- if ( progress != null ) {
- // Remove the fragment instead of trying to use DialogFragment.dismiss.
- // If the dialog is now currently shown, dismiss fails.
- getFragmentManager().beginTransaction().remove(progress).commitAllowingStateLoss();
- }
- } else {
- ((SherlockFragmentActivity)getActivity()).setSupportProgress(Window.PROGRESS_END);
- ((SherlockFragmentActivity)getActivity()).setSupportProgressBarVisibility(false);
- }
- if ( listener != null ) {
- listener.onOpenRocketFileSaved(result);
- }
- }
-
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/rocket/OpenRocketViewer.java b/android/src/net/sf/openrocket/android/rocket/OpenRocketViewer.java
deleted file mode 100644
index 635d526434..0000000000
--- a/android/src/net/sf/openrocket/android/rocket/OpenRocketViewer.java
+++ /dev/null
@@ -1,303 +0,0 @@
-package net.sf.openrocket.android.rocket;
-
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.ActivityHelpers;
-import net.sf.openrocket.android.CurrentRocketHolder;
-import net.sf.openrocket.android.events.ChangeEventBroadcastReceiver;
-import net.sf.openrocket.android.simulation.SimulationChart;
-import net.sf.openrocket.android.simulation.SimulationViewActivity;
-import net.sf.openrocket.android.simulation.SimulationViewFragment;
-import net.sf.openrocket.android.simulation.Simulations;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.document.OpenRocketDocument;
-import net.sf.openrocket.document.Simulation;
-import android.app.AlertDialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.res.Resources;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentPagerAdapter;
-import android.support.v4.app.FragmentTransaction;
-import android.support.v4.view.ViewPager;
-import android.view.View;
-import android.widget.Toast;
-
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-import com.actionbarsherlock.view.Window;
-
-public class OpenRocketViewer extends OpenRocketLoaderActivity
-implements Simulations.OnSimulationSelectedListener, OpenRocketSaverFragment.OnOpenRocketFileSaved, SharedPreferences.OnSharedPreferenceChangeListener
-{
-
- private final static int OVERVIEW_POS = 0;
- private final static int COMPONENT_POS = 1;
- private final static int SIMS_POS = 2;
- private final static int CONFIGS_POS = 3;
- private final static int TABSIZE = 4;
-
- private OpenRocketViewerPagerAdapter viewPagerAdapter;
-
- private final static String LOAD_AFTER_SAVE = "net.sf.openrocket.android.loadAfterSave";
- private boolean loadAfterSave = false;
- private String autoSaveEnabledKey;
- private boolean autoSaveEnabled = false;
-
- private RocketChangedEventHandler handler = new RocketChangedEventHandler();
-
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // If the application sleeps for a long time, the CurrentRocketHolder might get cleaned
- // up. When this happens, we cannot restore this state, so instead we just
- // go home.
- OpenRocketDocument rocDoc = CurrentRocketHolder.getCurrentRocket().getRocketDocument();
- if ( rocDoc == null ) {
- AndroidLogWrapper.d(OpenRocketViewer.class, "No document - go home");
- ActivityHelpers.goHome(this);
- finish();
- return;
- }
- if (savedInstanceState != null ) {
- loadAfterSave = savedInstanceState.getBoolean(LOAD_AFTER_SAVE);
- }
- // Must use com.actionbarsherlock.view.Window.FEATURE_INDETERMINATE_PROGRESS
- requestWindowFeature(Window.FEATURE_PROGRESS);
- setSupportProgressBarIndeterminate(true);
-
- setTitle(rocDoc.getRocket().getName());
- getSupportActionBar().setHomeButtonEnabled(true);
-
- setContentView(R.layout.openrocketviewer);
- ViewPager viewPager = (ViewPager)findViewById(R.id.pager);
- viewPagerAdapter = new OpenRocketViewerPagerAdapter( this.getSupportFragmentManager() );
- viewPager.setAdapter( viewPagerAdapter );
- }
-
- @Override
- protected void onPause() {
- handler.unregister(this);
- SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
- pref.unregisterOnSharedPreferenceChangeListener(this);
- super.onPause();
- }
-
- @Override
- protected void onResume() {
- Resources resources = this.getResources();
- autoSaveEnabledKey = resources.getString(R.string.PreferenceAutoSaveOption);
- SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
- autoSaveEnabled = pref.getBoolean(autoSaveEnabledKey, false);
-
- pref.registerOnSharedPreferenceChangeListener(this);
-
- handler.register(this);
- super.onResume();
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putBoolean(LOAD_AFTER_SAVE, loadAfterSave);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getSupportMenuInflater();
- inflater.inflate(R.menu.rocket_viewer_option_menu, menu);
- MenuItem saveAction = menu.findItem(R.id.menu_save);
- if ( CurrentRocketHolder.getCurrentRocket().canSave() ) {
- saveAction.setVisible(true);
- saveAction.setShowAsAction( MenuItem.SHOW_AS_ACTION_ALWAYS );
- } else {
- saveAction.setVisible(false);
- saveAction.setShowAsAction( MenuItem.SHOW_AS_ACTION_NEVER );
- }
- return true;
- }
-
- @Override
- public boolean onMenuItemSelected(int featureId, MenuItem item) {
- AndroidLogWrapper.d(OpenRocketViewer.class,"onMenuItemSelected" + item.getItemId());
- switch(item.getItemId()) {
- case R.id.menu_load:
- if ( CurrentRocketHolder.getCurrentRocket().isModified() ) {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setMessage(R.string.loadWarnUnsaved);
- builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- pickOrkFiles();
- }
- });
- builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- OpenRocketViewer.this.loadAfterSave = true;
- OpenRocketViewer.this.saveRocketDocument();
- }
- });
- builder.create().show();
- } else {
- pickOrkFiles();
- }
- return true;
- case R.id.menu_save:
- OpenRocketViewer.this.saveRocketDocument();
- return true;
- case android.R.id.home:
- ActivityHelpers.goHome(this);
- return true;
- case R.id.motor_list_menu_option:
- ActivityHelpers.browseMotors(this);
- return true;
- case R.id.preference_menu_option:
- ActivityHelpers.startPreferences(this);
- return true;
- case R.id.menu_about:
- ActivityHelpers.showAbout(this);
- return true;
- }
- return super.onMenuItemSelected(featureId, item);
- }
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences arg0, String arg1) {
- if ( autoSaveEnabledKey.equals(arg1) ) {
- autoSaveEnabled = arg0.getBoolean(autoSaveEnabledKey, false);
- }
- }
-
- @Override
- public void onSimulationSelected(int simulationId) {
-
- Simulation sim = CurrentRocketHolder.getCurrentRocket().getRocketDocument().getSimulation(simulationId);
- // Check if there is data for this simulation.
- if ( sim.getSimulatedData() == null || sim.getSimulatedData().getBranchCount() == 0 ) {
- // This shouldn't happen because the Simulations list does the check.
- return;
- }
-
- View sidepane = findViewById(R.id.sidepane);
- if ( /* if multi pane */ sidepane != null ) {
- SimulationChart chart = new SimulationChart(simulationId);
-
- Fragment graph = SimulationViewFragment.newInstance(chart);
-
- FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
- ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
- // probably only want to update back stack for first time.
- ft.addToBackStack("simulationplot");
- ft.replace(R.id.sidepane, graph);
- ft.show(graph);
- ft.commit();
-
-
- } else {
- Intent i = new Intent(this, SimulationViewActivity.class);
- i.putExtra("Simulation",simulationId);
- startActivity(i);
- }
- }
-
- private void saveRocketDocument() {
- getSupportFragmentManager().beginTransaction()
- .add( OpenRocketSaverFragment.newInstance(true), "saver")
- .commitAllowingStateLoss();
- }
-
- @Override
- public void onOpenRocketFileSaved(Boolean result) {
- invalidateOptionsMenu();
- if ( loadAfterSave ) {
- loadAfterSave = false;
- pickOrkFiles();
- }
- }
-
- private class RocketChangedEventHandler extends ChangeEventBroadcastReceiver {
-
- @Override
- protected void doSimComplete() {
- if ( autoSaveEnabled && CurrentRocketHolder.getCurrentRocket().canSave() ) {
- Toast.makeText(OpenRocketViewer.this, R.string.autoSaveMessage, Toast.LENGTH_SHORT).show();
- OpenRocketViewer.this.saveRocketDocument();
- }
- doSimsChanged();
- }
-
- @Override
- protected void doSimsChanged() {
- invalidateOptionsMenu();
- Simulations sims = (Simulations) viewPagerAdapter.getFragmentAtPos(SIMS_POS);
- if ( sims != null ) {
- sims.refreshSimulationList();
- }
- }
-
- @Override
- protected void doMotorConfigsChanged() {
- invalidateOptionsMenu();
- Configurations configs = (Configurations) viewPagerAdapter.getFragmentAtPos(CONFIGS_POS);
- if ( configs != null ) {
- configs.refreshConfigsList();
- }
- }
-
- };
-
-
- private class OpenRocketViewerPagerAdapter extends FragmentPagerAdapter {
-
- public OpenRocketViewerPagerAdapter( FragmentManager fm ) {
- super(fm);
- }
- @Override
- public int getCount() {
- return TABSIZE;
- }
- @Override
- public Fragment getItem( int position ) {
- switch (position) {
- case OVERVIEW_POS:
- return new Overview();
- case COMPONENT_POS:
- return new Component();
- case SIMS_POS:
- return new Simulations();
- case CONFIGS_POS:
- return new Configurations();
- }
- return null;
- }
- @Override
- public CharSequence getPageTitle(int position) {
- switch (position) {
- case OVERVIEW_POS:
- return "Overview";
- case COMPONENT_POS:
- return "Components";
- case SIMS_POS:
- return "Simulations";
- case CONFIGS_POS:
- return "Configurations";
- }
- return null;
- }
-
- public Fragment getFragmentAtPos( int pos ) {
- String tag = "android:switcher:"+R.id.pager+":"+pos;
- Fragment f = OpenRocketViewer.this.getSupportFragmentManager().findFragmentByTag(tag);
- return f;
- }
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/rocket/Overview.java b/android/src/net/sf/openrocket/android/rocket/Overview.java
deleted file mode 100644
index 33cedaeb7b..0000000000
--- a/android/src/net/sf/openrocket/android/rocket/Overview.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package net.sf.openrocket.android.rocket;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.aerodynamics.AerodynamicCalculator;
-import net.sf.openrocket.aerodynamics.BarrowmanCalculator;
-import net.sf.openrocket.aerodynamics.FlightConditions;
-import net.sf.openrocket.aerodynamics.WarningSet;
-import net.sf.openrocket.android.CurrentRocketHolder;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.document.OpenRocketDocument;
-import net.sf.openrocket.masscalc.BasicMassCalculator;
-import net.sf.openrocket.masscalc.MassCalculator;
-import net.sf.openrocket.masscalc.MassCalculator.MassCalcType;
-import net.sf.openrocket.rocketcomponent.Configuration;
-import net.sf.openrocket.rocketcomponent.Rocket;
-import net.sf.openrocket.rocketcomponent.RocketUtils;
-import net.sf.openrocket.unit.Unit;
-import net.sf.openrocket.unit.UnitGroup;
-import net.sf.openrocket.util.Coordinate;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.TextView;
-
-public class Overview extends Fragment
-implements SharedPreferences.OnSharedPreferenceChangeListener
-{
-
- /* Calculation of CP and CG */
- private AerodynamicCalculator aerodynamicCalculator = new BarrowmanCalculator();
- private MassCalculator massCalculator = new BasicMassCalculator();
-
- private MotorConfigSpinner configurationSpinner;
-
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- AndroidLogWrapper.d(Overview.class, "Created View");
- View v = inflater.inflate(R.layout.rocket_overview, container, false);
- configurationSpinner = (MotorConfigSpinner) v.findViewById(R.id.openrocketviewerConfigurationSpinner);
-
- return v;
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
- prefs.registerOnSharedPreferenceChangeListener(this);
-
- }
-
- @Override
- public void onResume() {
- super.onResume();
- setup();
-
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
- prefs.unregisterOnSharedPreferenceChangeListener(this);
- }
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences arg0, String arg1) {
- if ( this.isVisible() ) {
- setup();
- }
- }
-
- private void setup() {
- final OpenRocketDocument rocketDocument = CurrentRocketHolder.getCurrentRocket().getRocketDocument();
- Rocket rocket = rocketDocument.getRocket();
-
- // Find the index of the default configuration so we can preselect it.
- Configuration defaultConfiguration = rocketDocument.getDefaultConfiguration();
- configurationSpinner.createAdapter(rocket);
- AndroidLogWrapper.d(Overview.class, "configurationSpinner = " + configurationSpinner);
-
- if ( defaultConfiguration != null ) {
- configurationSpinner.setSelectedConfiguration(defaultConfiguration.getMotorConfigurationID());
- }
- configurationSpinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() {
-
- /* (non-Javadoc)
- * @see android.widget.AdapterView.OnItemSelectedListener#onItemSelected(android.widget.AdapterView, android.view.View, int, long)
- */
- @Override
- public void onItemSelected(AdapterView> arg0, View arg1,
- int arg2, long arg3) {
-
- String selectedConfigId = rocketDocument.getRocket().getMotorConfigurationIDs()[arg2];
- Configuration config = new Configuration(rocketDocument.getRocket());
- config.setMotorConfigurationID(selectedConfigId);
- Coordinate cp = aerodynamicCalculator.getWorstCP(config,
- new FlightConditions(config),
- new WarningSet());
-
- Coordinate cg = massCalculator.getCG(config, MassCalcType.LAUNCH_MASS);
-
- Unit lengthUnit = UnitGroup.UNITS_LENGTH.getDefaultUnit();
- Unit massUnit = UnitGroup.UNITS_MASS.getDefaultUnit();
- Unit stabilityUnit = UnitGroup.stabilityUnits(config).getDefaultUnit();
-
- ((TextView)getActivity().findViewById(R.id.openrocketviewerCP)).setText(lengthUnit.toStringUnit(cp.x));
- ((TextView)getActivity().findViewById(R.id.openrocketviewerCG)).setText(lengthUnit.toStringUnit(cg.x));
- ((TextView)getActivity().findViewById(R.id.openrocketviewerLiftOffWeight)).setText(massUnit.toStringUnit(cg.weight));
- ((TextView)getActivity().findViewById(R.id.openrocketviewerStabilityMargin)).setText(stabilityUnit.toStringUnit(cp.x-cg.x));
-
- }
-
- /* (non-Javadoc)
- * @see android.widget.AdapterView.OnItemSelectedListener#onNothingSelected(android.widget.AdapterView)
- */
- @Override
- public void onNothingSelected(AdapterView> arg0) {
- ((TextView)getActivity().findViewById(R.id.openrocketviewerCP)).setText("");
- ((TextView)getActivity().findViewById(R.id.openrocketviewerCG)).setText("");
- ((TextView)getActivity().findViewById(R.id.openrocketviewerLiftOffWeight)).setText("");
- ((TextView)getActivity().findViewById(R.id.openrocketviewerStabilityMargin)).setText("");
- }
-
- });
-
- Unit lengthUnit = UnitGroup.UNITS_LENGTH.getDefaultUnit();
- Unit massUnit = UnitGroup.UNITS_MASS.getDefaultUnit();
-
- Coordinate cg = RocketUtils.getCG(rocket, MassCalcType.NO_MOTORS);
- double length = RocketUtils.getLength(rocket);
- ((TextView)getActivity().findViewById(R.id.openrocketviewerDesigner)).setText(rocket.getDesigner());
- ((TextView)getActivity().findViewById(R.id.openrocketviewerLength)).setText(lengthUnit.toStringUnit(length));
- ((TextView)getActivity().findViewById(R.id.openrocketviewerMass)).setText(massUnit.toStringUnit(cg.weight));
- ((TextView)getActivity().findViewById(R.id.openrocketviewerStageCount)).setText(String.valueOf(rocket.getStageCount()));
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/rocket/RocketComponentTreeAdapter.java b/android/src/net/sf/openrocket/android/rocket/RocketComponentTreeAdapter.java
deleted file mode 100644
index 4bcd6fde6c..0000000000
--- a/android/src/net/sf/openrocket/android/rocket/RocketComponentTreeAdapter.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package net.sf.openrocket.android.rocket;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.rocket.RocketComponentTreeAdapter.RocketComponentWithId;
-import net.sf.openrocket.rocketcomponent.RocketComponent;
-import pl.polidea.treeview.AbstractTreeViewAdapter;
-import pl.polidea.treeview.TreeNodeInfo;
-import pl.polidea.treeview.TreeStateManager;
-import android.app.Activity;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-/**
- * This is a very simple adapter that provides very basic tree view with a
- * checkboxes and simple item description.
- *
- */
-public class RocketComponentTreeAdapter extends AbstractTreeViewAdapter {
-
- static class RocketComponentWithId {
- RocketComponent component;
- long id;
- public RocketComponentWithId( RocketComponent c, long id ) {
- this.component = c;
- this.id = id;
- }
- }
-
- public RocketComponentTreeAdapter(final Activity treeViewListDemo,
- TreeStateManager manager,
- final int numberOfLevels) {
- super(treeViewListDemo, manager, numberOfLevels);
- }
-
- private String getDescription(final RocketComponentWithId id) {
- return id.component.getName();
- }
-
- @Override
- public View getNewChildView(final TreeNodeInfo treeNodeInfo) {
- final View viewLayout = getActivity().getLayoutInflater().inflate(R.layout.component_list_item, null);
- return updateView(viewLayout, treeNodeInfo);
- }
-
- @Override
- public View updateView(final View view,
- final TreeNodeInfo treeNodeInfo) {
- final View viewLayout = view;
- final TextView descriptionView = (TextView) viewLayout.findViewById(android.R.id.text1);
- descriptionView.setText(getDescription(treeNodeInfo.getId()));
- return viewLayout;
- }
-
- @Override
- public void handleItemClick(final View view, final Object id) {
- final RocketComponentWithId longId = (RocketComponentWithId) id;
- final TreeNodeInfo info = getManager().getNodeInfo(longId);
- if (info.isWithChildren()) {
- super.handleItemClick(view, id);
- } else {
- final ViewGroup vg = (ViewGroup) view;
- // perform click on child item
- }
- }
-
- @Override
- public long getItemId(final int position) {
- RocketComponentWithId rcid = getTreeId(position);
- return rcid.id;
- }
-}
\ No newline at end of file
diff --git a/android/src/net/sf/openrocket/android/rocket/WarningDialogFragment.java b/android/src/net/sf/openrocket/android/rocket/WarningDialogFragment.java
deleted file mode 100644
index 891062bfe0..0000000000
--- a/android/src/net/sf/openrocket/android/rocket/WarningDialogFragment.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package net.sf.openrocket.android.rocket;
-
-import net.sf.openrocket.aerodynamics.Warning;
-import net.sf.openrocket.aerodynamics.WarningSet;
-import net.sf.openrocket.android.CurrentRocketHolder;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.support.v4.app.DialogFragment;
-
-public class WarningDialogFragment extends DialogFragment {
-
- public static WarningDialogFragment newInstance() {
- WarningDialogFragment frag = new WarningDialogFragment();
- Bundle args = new Bundle();
- frag.setArguments(args);
- frag.setCancelable(false);
- return frag;
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
-
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- // .setIcon(android.R.drawable.alert_dialog_icon)
- builder.setTitle("Warnings");
- WarningSet warnings = CurrentRocketHolder.getCurrentRocket().getWarnings();
- StringBuilder message = new StringBuilder();
- for ( Warning w : warnings ) {
- message.append(w.toString()).append("\n");
- }
- builder.setMessage(message.toString());
- builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- ((OpenRocketLoaderActivity)getActivity()).moveOnToViewer();
- }
- });
- Dialog dialog = builder.create();
- return dialog;
- }
-}
diff --git a/android/src/net/sf/openrocket/android/simservice/SimulationService.java b/android/src/net/sf/openrocket/android/simservice/SimulationService.java
deleted file mode 100644
index 9a1dd49116..0000000000
--- a/android/src/net/sf/openrocket/android/simservice/SimulationService.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package net.sf.openrocket.android.simservice;
-
-import java.util.List;
-
-import net.sf.openrocket.R;
-import net.sf.openrocket.android.CurrentRocketHolder;
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.document.Simulation;
-import net.sf.openrocket.simulation.customexpression.CustomExpression;
-import net.sf.openrocket.simulation.customexpression.CustomExpressionSimulationListener;
-import net.sf.openrocket.simulation.exception.SimulationException;
-import net.sf.openrocket.simulation.listeners.SimulationListener;
-import android.app.IntentService;
-import android.app.Notification;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import android.os.IBinder;
-import android.widget.Toast;
-
-public class SimulationService extends IntentService {
-
- // We use an id (from a dummy string) as the notificationID because it is unique.
- private final static int notificationID = R.string.SimulationServiceNotificationID;
-
- private Notification notification;
-
- public static void executeSimulationTask( Context c, SimulationTask t ) {
- AndroidLogWrapper.d(SimulationService.class, "Submitting simulation " + t.simulationId );
-
- CurrentRocketHolder.getCurrentRocket().lockSimulation( c, t.simulationId );
-
- Intent intent = new Intent( c, SimulationService.class );
- intent.putExtra("net.sf.openrocket.simulationtask", t);
- c.startService(intent);
- }
-
- public SimulationService() {
- super("OpenRocket Simulation Execution Service");
- }
-
- @Override
- protected void onHandleIntent(Intent intent) {
- SimulationTask t = (SimulationTask) intent.getSerializableExtra("net.sf.openrocket.simulationtask");
- try {
- Simulation sim = CurrentRocketHolder.getCurrentRocket().getRocketDocument().getSimulation(t.simulationId);
-
- List exprs = CurrentRocketHolder.getCurrentRocket().getRocketDocument().getCustomExpressions();
- SimulationListener exprListener = new CustomExpressionSimulationListener(exprs);
-
- AndroidLogWrapper.d(SimulationService.class, "simulating " + t.simulationId );
- sim.simulate(exprListener);
- CurrentRocketHolder.getCurrentRocket().unlockSimulation(this, t.simulationId);
- }
- catch (SimulationException simex) {
- Toast.makeText(this, "Error in simulation:" + simex.getMessage(), Toast.LENGTH_LONG ).show();
- }
- }
-
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- this.notification = buildNotification();
- startForeground(notificationID, notification);
-
- }
-
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- super.onStartCommand(intent, flags, startId);
- return START_STICKY;
- }
-
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- stopForeground(true);
- }
-
- private Notification buildNotification( ) {
- String message = "OpenRocket Simulation Execution";
- Notification notification = new Notification(R.drawable.or_launcher, message, System.currentTimeMillis());
-
- notification.flags = Notification.FLAG_NO_CLEAR;
- PendingIntent contentIntent = PendingIntent.getActivity( this, 0 , new Intent( ), PendingIntent.FLAG_UPDATE_CURRENT );
- notification.setLatestEventInfo(this, "OpenRocket", message, contentIntent);
- return notification;
- }
-}
diff --git a/android/src/net/sf/openrocket/android/simservice/SimulationTask.java b/android/src/net/sf/openrocket/android/simservice/SimulationTask.java
deleted file mode 100644
index 12abc3a10b..0000000000
--- a/android/src/net/sf/openrocket/android/simservice/SimulationTask.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package net.sf.openrocket.android.simservice;
-
-import java.io.Serializable;
-
-public class SimulationTask implements Serializable {
-
- int simulationId;
-
- public SimulationTask(int simulationId) {
- this.simulationId = simulationId;
- }
-
-}
diff --git a/android/src/net/sf/openrocket/android/simulation/SimulationChart.java b/android/src/net/sf/openrocket/android/simulation/SimulationChart.java
deleted file mode 100644
index 9fa41d7ec1..0000000000
--- a/android/src/net/sf/openrocket/android/simulation/SimulationChart.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/**
- * Copyright (C) 2009, 2010 SC 4ViewSoft SRL
- *
- * 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 net.sf.openrocket.android.simulation;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.openrocket.android.util.AndroidLogWrapper;
-import net.sf.openrocket.document.OpenRocketDocument;
-import net.sf.openrocket.document.Simulation;
-import net.sf.openrocket.simulation.FlightDataBranch;
-import net.sf.openrocket.simulation.FlightDataType;
-import net.sf.openrocket.simulation.FlightEvent;
-import net.sf.openrocket.unit.Unit;
-
-import org.achartengine.chart.LineChart;
-import org.achartengine.chart.PointStyle;
-import org.achartengine.chart.XYChart;
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.model.XYSeries;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-import org.achartengine.renderer.XYSeriesRenderer;
-
-import android.graphics.Color;
-import android.graphics.Paint.Align;
-
-/**
- * This is really a flyweight object so we can serialize the
- * values behind a simulation chart. Since OpenRocketDocument, FlightDataBranch,
- * FlightDataType, Unit and all the other underlying types are not serializable,
- * we have to resort to persisting just the bare minimum of information.
- *
- * This also means without further changes to FlightDataType, we cannot actually
- * restore the displayed series.
- *
- * TODO make FlightDataBranch serializable or at least reconstructable from
- * from some the name.
- *
- */
-public class SimulationChart implements Serializable {
-
- private final int simulationIndex;
- private transient FlightDataType series1;
- private transient FlightDataType series2;
- private transient List events;
-
- // Define 4 different colors and point styles to use for the series.
- // For now only 2 series are supported though.
- private final static int[] colors = new int[] { Color.BLUE, Color.YELLOW, Color.GREEN, Color.RED };
- private final static PointStyle[] styles = new PointStyle[] { PointStyle.CIRCLE, PointStyle.DIAMOND,
- PointStyle.TRIANGLE, PointStyle.SQUARE };
-
- public SimulationChart(int simulationIndex) {
- super();
- this.simulationIndex = simulationIndex;
- }
-
- private static String formatFlightDataTypeAxisLabel( FlightDataType fdt ) {
- return fdt.getName() + " (" + fdt.getUnitGroup().getDefaultUnit().toString() + ")";
- }
-
- public void setSeries1(FlightDataType series1) {
- this.series1 = series1;
- }
-
- public FlightDataType getSeries1() {
- return series1;
- }
-
- public void setSeries2(FlightDataType series2) {
- this.series2 = series2;
- }
-
- public FlightDataType getSeries2() {
- return series2;
- }
-
- public void setEvents( List events ) {
- this.events = events;
- }
-
- public List getEvents() {
- return events;
- }
-
- public FlightDataBranch getFlightDataBranch( OpenRocketDocument rocketDocument ) {
- Simulation sim = rocketDocument.getSimulation(simulationIndex);
- FlightDataBranch flightDataBranch = sim.getSimulatedData().getBranch(0);
- return flightDataBranch;
- }
- /**
- * Executes the chart demo.
- *
- * @param context the context
- * @return the built intent
- */
- public XYChart buildChart(OpenRocketDocument rocketDocument) {
-
- Simulation sim = rocketDocument.getSimulation(simulationIndex);
- FlightDataBranch flightDataBranch = sim.getSimulatedData().getBranch(0);
- FlightDataType time = FlightDataType.TYPE_TIME;
- if (series1== null) {
- series1 = flightDataBranch.getTypes()[1];
- }
- if (series2== null) {
- series2 = flightDataBranch.getTypes()[2];
- }
-
- if ( events == null ) {
- events = new ArrayList();
- for ( FlightEvent event : flightDataBranch.getEvents() ) {
- switch( event.getType()) {
- case LAUNCHROD:
- case APOGEE:
- case BURNOUT:
- case EJECTION_CHARGE:
- events.add(event);
- default:
- break;
- }
- }
- }
-
- /*
- * TODO -
- * Figure out why you can pan all over the place even where there are no visible points.
- */
- int seriesCount = 2;
- // if the same series is selected twice, only plot it once.
- if ( series1 == series2 ) {
- seriesCount = 1;
- }
-
- XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(seriesCount);
-
- renderer.setAxisTitleTextSize(16);
- renderer.setChartTitleTextSize(20);
- renderer.setLabelsTextSize(15);
- renderer.setLegendTextSize(15);
- renderer.setPointSize(5f);
- renderer.setXLabels(10);
- renderer.setYLabels(10);
- renderer.setShowGrid(true);
- renderer.setZoomButtonsVisible(true);
- renderer.setChartTitle(sim.getName());
- renderer.setShowCustomTextGrid(true);
- renderer.setXLabelsAlign(Align.RIGHT);
- renderer.setXLabelsAngle(90); // rotate right
- for( FlightEvent event : events ) {
- renderer.addXTextLabel(event.getTime(), event.getType().toString());
- }
-
- renderer.setMargins(new int[] { 50, 30, 0, 20 });
- {
- for (int i = 0; i < seriesCount; i++) {
- XYSeriesRenderer r = new XYSeriesRenderer();
- r.setColor(colors[i]);
- r.setPointStyle(styles[i]);
- r.setFillPoints(true);
- renderer.addSeriesRenderer(r);
- // setting the YAximMin to 0 locks the origins.
- renderer.setYAxisMin(0.0, i);
- }
- }
-
- renderer.setXTitle(formatFlightDataTypeAxisLabel(time));
- renderer.setXLabelsAlign(Align.RIGHT);
-
- renderer.setYTitle(formatFlightDataTypeAxisLabel(series1),0);
- renderer.setYLabelsAlign(Align.RIGHT,0);
-
- if ( seriesCount > 1 ) {
- renderer.setYTitle(formatFlightDataTypeAxisLabel(series2), 1);
- renderer.setYAxisAlign(Align.RIGHT, 1);
- renderer.setYLabelsAlign(Align.LEFT, 1);
- }
-
- renderer.setAxesColor(Color.LTGRAY);
- renderer.setLabelsColor(Color.LTGRAY);
-
- XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
-
- List timevalues = flightDataBranch.get(time);
- List