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
.OwnCloudClientManager
;
20 import com
.owncloud
.android
.lib
.common
.OwnCloudClientManagerFactory
;
21 import com
.owncloud
.android
.lib
.common
.OwnCloudClientManagerFactory
.Policy
;
23 import android
.app
.Application
;
24 import android
.content
.Context
;
26 * Main Application of the project
28 * Contains methods to build the "static" strings. These strings were before constants in different classes
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 private OwnCloudClientManager mOwnCloudClientManager
;
43 public void onCreate(){
45 MainApp
.mContext
= getApplicationContext();
47 String clientPolicy
= getString(R
.string
.client_creation_policy
);
48 if (clientPolicy
!= null
&&
49 POLICY_SINGLE_SESSION_PER_ACCOUNT
.equals(clientPolicy
.toLowerCase())) {
51 mOwnCloudClientManager
= OwnCloudClientManagerFactory
.newOwnCloudClientManager(
52 Policy
.SINGLE_SESSION_PER_ACCOUNT
);
55 mOwnCloudClientManager
= OwnCloudClientManagerFactory
.newOwnCloudClientManager(
56 Policy
.ALWAYS_NEW_CLIENT
);
61 public static Context
getAppContext() {
62 return MainApp
.mContext
;
65 // Methods to obtain Strings referring app_name
66 // From AccountAuthenticator
67 // public static final String ACCOUNT_TYPE = "owncloud";
68 public static String
getAccountType() {
69 return getAppContext().getResources().getString(R
.string
.account_type
);
72 // From AccountAuthenticator
73 // public static final String AUTHORITY = "org.owncloud";
74 public static String
getAuthority() {
75 return getAppContext().getResources().getString(R
.string
.authority
);
78 // From AccountAuthenticator
79 // public static final String AUTH_TOKEN_TYPE = "org.owncloud";
80 public static String
getAuthTokenType() {
81 return getAppContext().getResources().getString(R
.string
.authority
);
85 // public static final String DB_FILE = "owncloud.db";
86 public static String
getDBFile() {
87 return getAppContext().getResources().getString(R
.string
.db_file
);
91 // private final String mDatabaseName = "ownCloud";
92 public static String
getDBName() {
93 return getAppContext().getResources().getString(R
.string
.db_name
);
97 public static String
getDataFolder() {
98 return getAppContext().getResources().getString(R
.string
.data_folder
);
102 public static String
getLogName() {
103 return getAppContext().getResources().getString(R
.string
.log_name
);
106 public OwnCloudClientManager
getOwnCloudClientManager() {
107 return mOwnCloudClientManager
;