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
;
21 import android
.app
.Application
;
22 import android
.content
.Context
;
23 import android
.os
.Environment
;
25 import com
.owncloud
.android
.lib
.common
.OwnCloudClientManagerFactory
;
26 import com
.owncloud
.android
.lib
.common
.OwnCloudClientManagerFactory
.Policy
;
27 import com
.owncloud
.android
.lib
.common
.utils
.Log_OC
;
29 * Main Application of the project
31 * Contains methods to build the "static" strings. These strings were before constants in different
35 * @author David A. Velasco
37 public class MainApp
extends Application
{
39 private static final String AUTH_ON
= "on";
41 @SuppressWarnings("unused")
42 private static final String POLICY_SINGLE_SESSION_PER_ACCOUNT
= "single session per account";
43 @SuppressWarnings("unused")
44 private static final String POLICY_ALWAYS_NEW_CLIENT
= "always new client";
46 private static Context mContext
;
48 public void onCreate(){
50 MainApp
.mContext
= getApplicationContext();
52 boolean isSamlAuth
= AUTH_ON
.equals(getString(R
.string
.auth_method_saml_web_sso
));
55 OwnCloudClientManagerFactory
.setDefaultPolicy(Policy
.SINGLE_SESSION_PER_ACCOUNT
);
58 OwnCloudClientManagerFactory
.setDefaultPolicy(Policy
.ALWAYS_NEW_CLIENT
);
61 if (BuildConfig
.DEBUG
) {
62 String logpath
= Environment
.getExternalStorageDirectory()+File
.separator
+"owncloud"+File
.separator
+"log";
63 Log_OC
.d("Debug", "start logging");
64 Log_OC
.v("PATH", logpath
);
65 Log_OC
.startLogging(logpath
);
69 public static Context
getAppContext() {
70 return MainApp
.mContext
;
73 // Methods to obtain Strings referring app_name
74 // From AccountAuthenticator
75 // public static final String ACCOUNT_TYPE = "owncloud";
76 public static String
getAccountType() {
77 return getAppContext().getResources().getString(R
.string
.account_type
);
80 // From AccountAuthenticator
81 // public static final String AUTHORITY = "org.owncloud";
82 public static String
getAuthority() {
83 return getAppContext().getResources().getString(R
.string
.authority
);
86 // From AccountAuthenticator
87 // public static final String AUTH_TOKEN_TYPE = "org.owncloud";
88 public static String
getAuthTokenType() {
89 return getAppContext().getResources().getString(R
.string
.authority
);
93 // public static final String DB_FILE = "owncloud.db";
94 public static String
getDBFile() {
95 return getAppContext().getResources().getString(R
.string
.db_file
);
99 // private final String mDatabaseName = "ownCloud";
100 public static String
getDBName() {
101 return getAppContext().getResources().getString(R
.string
.db_name
);
105 public static String
getDataFolder() {
106 return getAppContext().getResources().getString(R
.string
.data_folder
);
110 public static String
getLogName() {
111 return getAppContext().getResources().getString(R
.string
.log_name
);