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
.lib
.common
.OwnCloudClientManagerFactory
;
23 import com
.owncloud
.android
.lib
.common
.OwnCloudClientManagerFactory
.Policy
;
24 import com
.owncloud
.android
.lib
.common
.utils
.Log_OC
;
26 * Main Application of the project
28 * Contains methods to build the "static" strings. These strings were before constants in different
32 * @author David A. Velasco
34 public class MainApp
extends Application
{
36 private static final String AUTH_ON
= "on";
38 @SuppressWarnings("unused")
39 private static final String POLICY_SINGLE_SESSION_PER_ACCOUNT
= "single session per account";
40 @SuppressWarnings("unused")
41 private static final String POLICY_ALWAYS_NEW_CLIENT
= "always new client";
43 private static Context mContext
;
45 public void onCreate(){
47 MainApp
.mContext
= getApplicationContext();
49 boolean isSamlAuth
= AUTH_ON
.equals(getString(R
.string
.auth_method_saml_web_sso
));
52 OwnCloudClientManagerFactory
.setDefaultPolicy(Policy
.SINGLE_SESSION_PER_ACCOUNT
);
55 OwnCloudClientManagerFactory
.setDefaultPolicy(Policy
.ALWAYS_NEW_CLIENT
);
58 if (BuildConfig
.DEBUG
) {
60 String dataFolder
= getDataFolder();
62 // Set folder for store logs
63 Log_OC
.setLogDataFolder(dataFolder
);
65 Log_OC
.startLogging();
66 Log_OC
.d("Debug", "start logging");
70 public static Context
getAppContext() {
71 return MainApp
.mContext
;
74 // Methods to obtain Strings referring app_name
75 // From AccountAuthenticator
76 // public static final String ACCOUNT_TYPE = "owncloud";
77 public static String
getAccountType() {
78 return getAppContext().getResources().getString(R
.string
.account_type
);
81 // From AccountAuthenticator
82 // public static final String AUTHORITY = "org.owncloud";
83 public static String
getAuthority() {
84 return getAppContext().getResources().getString(R
.string
.authority
);
87 // From AccountAuthenticator
88 // public static final String AUTH_TOKEN_TYPE = "org.owncloud";
89 public static String
getAuthTokenType() {
90 return getAppContext().getResources().getString(R
.string
.authority
);
94 // public static final String DB_FILE = "owncloud.db";
95 public static String
getDBFile() {
96 return getAppContext().getResources().getString(R
.string
.db_file
);
100 // private final String mDatabaseName = "ownCloud";
101 public static String
getDBName() {
102 return getAppContext().getResources().getString(R
.string
.db_name
);
106 public static String
getDataFolder() {
107 return getAppContext().getResources().getString(R
.string
.data_folder
);
111 public static String
getLogName() {
112 return getAppContext().getResources().getString(R
.string
.log_name
);