1 /* ownCloud Android client application
2 * Copyright (C) 2012-2013 ownCloud Inc.
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.
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.
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/>.
17 package com
.owncloud
.android
;
19 import android
.app
.Application
;
20 import android
.content
.Context
;
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
;
27 * Main Application of the project
29 * Contains methods to build the "static" strings. These strings were before constants in different
33 * @author David A. Velasco
35 public class MainApp
extends Application
{
37 private static final String AUTH_ON
= "on";
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";
44 private static Context mContext
;
46 public void onCreate(){
48 MainApp
.mContext
= getApplicationContext();
50 boolean isSamlAuth
= AUTH_ON
.equals(getString(R
.string
.auth_method_saml_web_sso
));
53 OwnCloudClientManagerFactory
.setDefaultPolicy(Policy
.SINGLE_SESSION_PER_ACCOUNT
);
56 OwnCloudClientManagerFactory
.setDefaultPolicy(Policy
.ALWAYS_NEW_CLIENT
);
59 // initialise thumbnails cache on background thread
60 new ThumbnailsCacheManager
.InitDiskCacheTask().execute();
62 if (BuildConfig
.DEBUG
) {
64 String dataFolder
= getDataFolder();
66 // Set folder for store logs
67 Log_OC
.setLogDataFolder(dataFolder
);
69 Log_OC
.startLogging();
70 Log_OC
.d("Debug", "start logging");
74 public static Context
getAppContext() {
75 return MainApp
.mContext
;
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
);
85 // From AccountAuthenticator
86 // public static final String AUTHORITY = "org.owncloud";
87 public static String
getAuthority() {
88 return getAppContext().getResources().getString(R
.string
.authority
);
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
);
98 // public static final String DB_FILE = "owncloud.db";
99 public static String
getDBFile() {
100 return getAppContext().getResources().getString(R
.string
.db_file
);
104 // private final String mDatabaseName = "ownCloud";
105 public static String
getDBName() {
106 return getAppContext().getResources().getString(R
.string
.db_name
);
110 public static String
getDataFolder() {
111 return getAppContext().getResources().getString(R
.string
.data_folder
);
115 public static String
getLogName() {
116 return getAppContext().getResources().getString(R
.string
.log_name
);