- removed uneccessary improts
[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 android.app.Application;
20 import android.content.Context;
21
22 import com.owncloud.android.datamodel.ThumbnailsCacheManager;
23 import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
24 import com.owncloud.android.lib.common.OwnCloudClientManagerFactory.Policy;
25 import com.owncloud.android.lib.common.utils.Log_OC;
26 /**
27 * Main Application of the project
28 *
29 * Contains methods to build the "static" strings. These strings were before constants in different
30 * classes
31 *
32 * @author masensio
33 * @author David A. Velasco
34 */
35 public class MainApp extends Application {
36
37 private static final String AUTH_ON = "on";
38
39 @SuppressWarnings("unused")
40 private static final String POLICY_SINGLE_SESSION_PER_ACCOUNT = "single session per account";
41 @SuppressWarnings("unused")
42 private static final String POLICY_ALWAYS_NEW_CLIENT = "always new client";
43
44 private static Context mContext;
45
46 public void onCreate(){
47 super.onCreate();
48 MainApp.mContext = getApplicationContext();
49
50 boolean isSamlAuth = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));
51
52 if (isSamlAuth) {
53 OwnCloudClientManagerFactory.setDefaultPolicy(Policy.SINGLE_SESSION_PER_ACCOUNT);
54
55 } else {
56 OwnCloudClientManagerFactory.setDefaultPolicy(Policy.ALWAYS_NEW_CLIENT);
57 }
58
59 // initialise thumbnails cache on background thread
60 new ThumbnailsCacheManager.InitDiskCacheTask().execute();
61
62 if (BuildConfig.DEBUG) {
63
64 String dataFolder = getDataFolder();
65
66 // Set folder for store logs
67 Log_OC.setLogDataFolder(dataFolder);
68
69 Log_OC.startLogging();
70 Log_OC.d("Debug", "start logging");
71 }
72 }
73
74 public static Context getAppContext() {
75 return MainApp.mContext;
76 }
77
78 // Methods to obtain Strings referring app_name
79 // From AccountAuthenticator
80 // public static final String ACCOUNT_TYPE = "owncloud";
81 public static String getAccountType() {
82 return getAppContext().getResources().getString(R.string.account_type);
83 }
84
85 // From AccountAuthenticator
86 // public static final String AUTHORITY = "org.owncloud";
87 public static String getAuthority() {
88 return getAppContext().getResources().getString(R.string.authority);
89 }
90
91 // From AccountAuthenticator
92 // public static final String AUTH_TOKEN_TYPE = "org.owncloud";
93 public static String getAuthTokenType() {
94 return getAppContext().getResources().getString(R.string.authority);
95 }
96
97 // From ProviderMeta
98 // public static final String DB_FILE = "owncloud.db";
99 public static String getDBFile() {
100 return getAppContext().getResources().getString(R.string.db_file);
101 }
102
103 // From ProviderMeta
104 // private final String mDatabaseName = "ownCloud";
105 public static String getDBName() {
106 return getAppContext().getResources().getString(R.string.db_name);
107 }
108
109 // data_folder
110 public static String getDataFolder() {
111 return getAppContext().getResources().getString(R.string.data_folder);
112 }
113
114 // log_name
115 public static String getLogName() {
116 return getAppContext().getResources().getString(R.string.log_name);
117 }
118
119 }