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 com
.owncloud
.android
.lib
.common
.OwnCloudClientManagerFactory
;
20 import com
.owncloud
.android
.lib
.common
.OwnCloudClientManagerFactory
.Policy
;
22 import android
.app
.Application
;
23 import android
.content
.Context
;
25 * Main Application of the project
27 * Contains methods to build the "static" strings. These strings were before constants in different
31 * @author David A. Velasco
33 public class MainApp
extends Application
{
35 private static final String POLICY_SINGLE_SESSION_PER_ACCOUNT
= "single session per account";
36 @SuppressWarnings("unused")
37 private static final String POLICY_ALWAYS_NEW_CLIENT
= "always new client";
39 private static Context mContext
;
41 public void onCreate(){
43 MainApp
.mContext
= getApplicationContext();
45 String clientPolicy
= getString(R
.string
.client_creation_policy
);
46 if (clientPolicy
!= null
&&
47 POLICY_SINGLE_SESSION_PER_ACCOUNT
.equals(clientPolicy
.toLowerCase())) {
49 OwnCloudClientManagerFactory
.setDefaultPolicy(Policy
.SINGLE_SESSION_PER_ACCOUNT
);
52 OwnCloudClientManagerFactory
.setDefaultPolicy(Policy
.ALWAYS_NEW_CLIENT
);
57 public static Context
getAppContext() {
58 return MainApp
.mContext
;
61 // Methods to obtain Strings referring app_name
62 // From AccountAuthenticator
63 // public static final String ACCOUNT_TYPE = "owncloud";
64 public static String
getAccountType() {
65 return getAppContext().getResources().getString(R
.string
.account_type
);
68 // From AccountAuthenticator
69 // public static final String AUTHORITY = "org.owncloud";
70 public static String
getAuthority() {
71 return getAppContext().getResources().getString(R
.string
.authority
);
74 // From AccountAuthenticator
75 // public static final String AUTH_TOKEN_TYPE = "org.owncloud";
76 public static String
getAuthTokenType() {
77 return getAppContext().getResources().getString(R
.string
.authority
);
81 // public static final String DB_FILE = "owncloud.db";
82 public static String
getDBFile() {
83 return getAppContext().getResources().getString(R
.string
.db_file
);
87 // private final String mDatabaseName = "ownCloud";
88 public static String
getDBName() {
89 return getAppContext().getResources().getString(R
.string
.db_name
);
93 public static String
getDataFolder() {
94 return getAppContext().getResources().getString(R
.string
.data_folder
);
98 public static String
getLogName() {
99 return getAppContext().getResources().getString(R
.string
.log_name
);