Work around constaint in valid key for DiskLruCache (capital letters are not allowed)
[pub/Android/ownCloud.git] / src / com / owncloud / android / MainApp.java
1 /* ownCloud Android client application
2 * Copyright (C) 2012-2013 ownCloud Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17 package com.owncloud.android;
18
19 import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
20 import com.owncloud.android.lib.common.OwnCloudClientManagerFactory.Policy;
21
22 import android.app.Application;
23 import android.content.Context;
24 /**
25 * Main Application of the project
26 *
27 * Contains methods to build the "static" strings. These strings were before constants in different
28 * classes
29 *
30 * @author masensio
31 * @author David A. Velasco
32 */
33 public class MainApp extends Application {
34
35 private static final String AUTH_ON = "on";
36
37 @SuppressWarnings("unused")
38 private static final String POLICY_SINGLE_SESSION_PER_ACCOUNT = "single session per account";
39 @SuppressWarnings("unused")
40 private static final String POLICY_ALWAYS_NEW_CLIENT = "always new client";
41
42 private static Context mContext;
43
44 public void onCreate(){
45 super.onCreate();
46 MainApp.mContext = getApplicationContext();
47
48 boolean isSamlAuth = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));
49
50 if (isSamlAuth) {
51 OwnCloudClientManagerFactory.setDefaultPolicy(Policy.SINGLE_SESSION_PER_ACCOUNT);
52
53 } else {
54 OwnCloudClientManagerFactory.setDefaultPolicy(Policy.ALWAYS_NEW_CLIENT);
55 }
56
57 }
58
59 public static Context getAppContext() {
60 return MainApp.mContext;
61 }
62
63 // Methods to obtain Strings referring app_name
64 // From AccountAuthenticator
65 // public static final String ACCOUNT_TYPE = "owncloud";
66 public static String getAccountType() {
67 return getAppContext().getResources().getString(R.string.account_type);
68 }
69
70 // From AccountAuthenticator
71 // public static final String AUTHORITY = "org.owncloud";
72 public static String getAuthority() {
73 return getAppContext().getResources().getString(R.string.authority);
74 }
75
76 // From AccountAuthenticator
77 // public static final String AUTH_TOKEN_TYPE = "org.owncloud";
78 public static String getAuthTokenType() {
79 return getAppContext().getResources().getString(R.string.authority);
80 }
81
82 // From ProviderMeta
83 // public static final String DB_FILE = "owncloud.db";
84 public static String getDBFile() {
85 return getAppContext().getResources().getString(R.string.db_file);
86 }
87
88 // From ProviderMeta
89 // private final String mDatabaseName = "ownCloud";
90 public static String getDBName() {
91 return getAppContext().getResources().getString(R.string.db_name);
92 }
93
94 // data_folder
95 public static String getDataFolder() {
96 return getAppContext().getResources().getString(R.string.data_folder);
97 }
98
99 // log_name
100 public static String getLogName() {
101 return getAppContext().getResources().getString(R.string.log_name);
102 }
103
104 }