Reviewed integration with sychronization framework to fix problems in Android 4.4
[pub/Android/ownCloud.git] / src / com / owncloud / android / MainApp.java
1 /* ownCloud Android client application
2 * Copyright (C) 2012-2013 ownCloud Inc.
3 *
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.
7 *
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.
12 *
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/>.
15 *
16 */
17 package com.owncloud.android;
18
19 import android.app.Application;
20 import android.content.Context;
21 /**
22 * Main Application of the project
23 *
24 * Contains methods to build the "static" strings. These strings were before constants in different classes
25 *
26 * @author masensio
27 */
28 public class MainApp extends Application {
29
30 private static Context mContext;
31
32 public void onCreate(){
33 super.onCreate();
34 MainApp.mContext = getApplicationContext();
35 }
36
37 public static Context getAppContext() {
38 return MainApp.mContext;
39 }
40
41 // Methods to obtain Strings referring app_name
42 // From AccountAuthenticator
43 // public static final String ACCOUNT_TYPE = "owncloud";
44 public static String getAccountType() {
45 return getAppContext().getResources().getString(R.string.account_type);
46 }
47
48 // From AccountAuthenticator
49 // public static final String AUTHORITY = "org.owncloud";
50 public static String getAuthority() {
51 return getAppContext().getResources().getString(R.string.authority);
52 }
53
54 // From AccountAuthenticator
55 // public static final String AUTH_TOKEN_TYPE = "org.owncloud";
56 public static String getAuthTokenType() {
57 return getAppContext().getResources().getString(R.string.authority);
58 }
59
60 // From AccountAuthenticator
61 // public static final String AUTH_TOKEN_TYPE_PASSWORD = "owncloud.password";
62 public static String getAuthTokenTypePass() {
63 return getAppContext().getResources().getString(R.string.account_type) + ".password";
64 }
65
66 // From AccountAuthenticator
67 // public static final String AUTH_TOKEN_TYPE_ACCESS_TOKEN = "owncloud.oauth2.access_token";
68 public static String getAuthTokenTypeAccessToken() {
69 return getAppContext().getResources().getString(R.string.account_type) + ".oauth2.access_token";
70 }
71
72 // From AccountAuthenticator
73 // public static final String AUTH_TOKEN_TYPE_REFRESH_TOKEN = "owncloud.oauth2.refresh_token";
74 public static String getAuthTokenTypeRefreshToken() {
75 return getAppContext().getResources().getString(R.string.account_type) + ".oauth2.refresh_token";
76 }
77
78 // From AccountAuthenticator
79 // public static final String AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE = "owncloud.saml.web_sso.session_cookie";
80 public static String getAuthTokenTypeSamlSessionCookie() {
81 return getAppContext().getResources().getString(R.string.account_type) + ".saml.web_sso.session_cookie";
82 }
83
84 // From ProviderMeta
85 // public static final String DB_FILE = "owncloud.db";
86 public static String getDBFile() {
87 return getAppContext().getResources().getString(R.string.db_file);
88 }
89
90 // From ProviderMeta
91 // private final String mDatabaseName = "ownCloud";
92 public static String getDBName() {
93 return getAppContext().getResources().getString(R.string.db_name);
94 }
95
96 // data_folder
97 public static String getDataFolder() {
98 return getAppContext().getResources().getString(R.string.data_folder);
99 }
100
101 // log_name
102 public static String getLogName() {
103 return getAppContext().getResources().getString(R.string.log_name);
104 }
105 }