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 private static Context mContext
;
41 public void onCreate(){
43 MainApp
.mContext
= getApplicationContext();
45 // keep a single session per account handling session cookie in requests (& all the other cookies)
46 OwnCloudClientManagerFactory
.setDefaultPolicy(Policy
.SINGLE_SESSION_PER_ACCOUNT
);
48 // initialise thumbnails cache on background thread
49 new ThumbnailsCacheManager
.InitDiskCacheTask().execute();
51 if (BuildConfig
.DEBUG
) {
53 String dataFolder
= getDataFolder();
55 // Set folder for store logs
56 Log_OC
.setLogDataFolder(dataFolder
);
58 Log_OC
.startLogging();
59 Log_OC
.d("Debug", "start logging");
63 public static Context
getAppContext() {
64 return MainApp
.mContext
;
67 // Methods to obtain Strings referring app_name
68 // From AccountAuthenticator
69 // public static final String ACCOUNT_TYPE = "owncloud";
70 public static String
getAccountType() {
71 return getAppContext().getResources().getString(R
.string
.account_type
);
74 // From AccountAuthenticator
75 // public static final String AUTHORITY = "org.owncloud";
76 public static String
getAuthority() {
77 return getAppContext().getResources().getString(R
.string
.authority
);
80 // From AccountAuthenticator
81 // public static final String AUTH_TOKEN_TYPE = "org.owncloud";
82 public static String
getAuthTokenType() {
83 return getAppContext().getResources().getString(R
.string
.authority
);
87 // public static final String DB_FILE = "owncloud.db";
88 public static String
getDBFile() {
89 return getAppContext().getResources().getString(R
.string
.db_file
);
93 // private final String mDatabaseName = "ownCloud";
94 public static String
getDBName() {
95 return getAppContext().getResources().getString(R
.string
.db_name
);
99 public static String
getDataFolder() {
100 return getAppContext().getResources().getString(R
.string
.data_folder
);
104 public static String
getLogName() {
105 return getAppContext().getResources().getString(R
.string
.log_name
);