2 * ownCloud Android client application
5 * @author David A. Velasco
6 * Copyright (C) 2015 ownCloud Inc.
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 package com
.owncloud
.android
;
23 import android
.app
.Application
;
24 import android
.content
.Context
;
26 import com
.owncloud
.android
.datamodel
.ThumbnailsCacheManager
;
27 import com
.owncloud
.android
.lib
.common
.OwnCloudClientManagerFactory
;
28 import com
.owncloud
.android
.lib
.common
.OwnCloudClientManagerFactory
.Policy
;
29 import com
.owncloud
.android
.lib
.common
.utils
.Log_OC
;
31 * Main Application of the project
33 * Contains methods to build the "static" strings. These strings were before constants in different
36 public class MainApp
extends Application
{
38 private static final String AUTH_ON
= "on";
40 @SuppressWarnings("unused")
41 private static final String POLICY_SINGLE_SESSION_PER_ACCOUNT
= "single session per account";
42 @SuppressWarnings("unused")
43 private static final String POLICY_ALWAYS_NEW_CLIENT
= "always new client";
45 private static Context mContext
;
47 public void onCreate(){
49 MainApp
.mContext
= getApplicationContext();
51 boolean isSamlAuth
= AUTH_ON
.equals(getString(R
.string
.auth_method_saml_web_sso
));
54 OwnCloudClientManagerFactory
.setDefaultPolicy(Policy
.SINGLE_SESSION_PER_ACCOUNT
);
57 OwnCloudClientManagerFactory
.setDefaultPolicy(Policy
.ALWAYS_NEW_CLIENT
);
60 // initialise thumbnails cache on background thread
61 new ThumbnailsCacheManager
.InitDiskCacheTask().execute();
63 if (BuildConfig
.DEBUG
) {
65 String dataFolder
= getDataFolder();
67 // Set folder for store logs
68 Log_OC
.setLogDataFolder(dataFolder
);
70 Log_OC
.startLogging();
71 Log_OC
.d("Debug", "start logging");
75 public static Context
getAppContext() {
76 return MainApp
.mContext
;
79 // Methods to obtain Strings referring app_name
80 // From AccountAuthenticator
81 // public static final String ACCOUNT_TYPE = "owncloud";
82 public static String
getAccountType() {
83 return getAppContext().getResources().getString(R
.string
.account_type
);
86 // From AccountAuthenticator
87 // public static final String AUTHORITY = "org.owncloud";
88 public static String
getAuthority() {
89 return getAppContext().getResources().getString(R
.string
.authority
);
92 // From AccountAuthenticator
93 // public static final String AUTH_TOKEN_TYPE = "org.owncloud";
94 public static String
getAuthTokenType() {
95 return getAppContext().getResources().getString(R
.string
.authority
);
99 // public static final String DB_FILE = "owncloud.db";
100 public static String
getDBFile() {
101 return getAppContext().getResources().getString(R
.string
.db_file
);
105 // private final String mDatabaseName = "ownCloud";
106 public static String
getDBName() {
107 return getAppContext().getResources().getString(R
.string
.db_name
);
111 public static String
getDataFolder() {
112 return getAppContext().getResources().getString(R
.string
.data_folder
);
116 public static String
getLogName() {
117 return getAppContext().getResources().getString(R
.string
.log_name
);
121 // TODO: decide if it use account_type or another string for user_agent
122 public static String
getUserAgent() {
123 return getAppContext().getResources().getString(R
.string
.account_type
);