Config.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. Licensed to the Apache Software Foundation (ASF) under one
  3. or more contributor license agreements. See the NOTICE file
  4. distributed with this work for additional information
  5. regarding copyright ownership. The ASF licenses this file
  6. to you under the Apache License, Version 2.0 (the
  7. "License"); you may not use this file except in compliance
  8. with the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing,
  11. software distributed under the License is distributed on an
  12. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  13. KIND, either express or implied. See the License for the
  14. specific language governing permissions and limitations
  15. under the License.
  16. */
  17. package org.apache.cordova;
  18. import java.util.List;
  19. import android.app.Activity;
  20. @Deprecated // Use Whitelist, CordovaPrefences, etc. directly.
  21. public class Config {
  22. private static final String TAG = "Config";
  23. static ConfigXmlParser parser;
  24. private Config() {
  25. }
  26. public static void init(Activity action) {
  27. parser = new ConfigXmlParser();
  28. parser.parse(action);
  29. //TODO: Add feature to bring this back. Some preferences should be overridden by intents, but not all
  30. parser.getPreferences().setPreferencesBundle(action.getIntent().getExtras());
  31. }
  32. // Intended to be used for testing only; creates an empty configuration.
  33. public static void init() {
  34. if (parser == null) {
  35. parser = new ConfigXmlParser();
  36. }
  37. }
  38. public static String getStartUrl() {
  39. if (parser == null) {
  40. return "file:///android_asset/www/index.html";
  41. }
  42. return parser.getLaunchUrl();
  43. }
  44. public static String getErrorUrl() {
  45. return parser.getPreferences().getString("errorurl", null);
  46. }
  47. public static List<PluginEntry> getPluginEntries() {
  48. return parser.getPluginEntries();
  49. }
  50. public static CordovaPreferences getPreferences() {
  51. return parser.getPreferences();
  52. }
  53. public static boolean isInitialized() {
  54. return parser != null;
  55. }
  56. }