2016-07-29 14:00:28 +02:00
|
|
|
/*
|
|
|
|
This file is part of the Diaspora for Android.
|
|
|
|
|
|
|
|
Diaspora for Android is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Diaspora for Android is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with the Diaspora for Android.
|
|
|
|
|
|
|
|
If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-03-29 19:38:50 +02:00
|
|
|
package com.github.dfa.diaspora_android;
|
2016-03-24 13:56:30 +01:00
|
|
|
|
|
|
|
import android.app.Application;
|
2016-03-30 03:13:38 +02:00
|
|
|
import android.content.Context;
|
|
|
|
import android.os.Build;
|
2016-06-04 03:48:57 +02:00
|
|
|
import android.support.annotation.Nullable;
|
2016-03-30 03:13:38 +02:00
|
|
|
import android.webkit.CookieManager;
|
|
|
|
import android.webkit.CookieSyncManager;
|
2016-06-04 03:48:57 +02:00
|
|
|
import android.webkit.WebView;
|
2016-03-24 13:56:30 +01:00
|
|
|
|
2016-03-29 19:38:50 +02:00
|
|
|
import com.github.dfa.diaspora_android.data.AppSettings;
|
2016-06-05 17:25:11 +02:00
|
|
|
import com.github.dfa.diaspora_android.data.PodUserProfile;
|
2016-03-29 19:38:50 +02:00
|
|
|
import com.github.dfa.diaspora_android.util.AvatarImageLoader;
|
2016-03-25 00:12:00 +01:00
|
|
|
|
2016-03-24 13:56:30 +01:00
|
|
|
public class App extends Application {
|
2016-03-30 03:13:38 +02:00
|
|
|
public static final String TAG = "DIASPORA_";
|
|
|
|
|
2016-03-24 13:56:30 +01:00
|
|
|
private AppSettings appSettings;
|
2016-03-25 00:12:00 +01:00
|
|
|
private AvatarImageLoader avatarImageLoader;
|
2016-03-30 03:13:38 +02:00
|
|
|
private CookieManager cookieManager;
|
2016-06-05 17:25:11 +02:00
|
|
|
private PodUserProfile podUserProfile;
|
2016-03-24 13:56:30 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate() {
|
|
|
|
super.onCreate();
|
2016-03-30 03:13:38 +02:00
|
|
|
final Context c = getApplicationContext();
|
|
|
|
appSettings = new AppSettings(c);
|
|
|
|
avatarImageLoader = new AvatarImageLoader(c);
|
2016-06-05 17:25:11 +02:00
|
|
|
podUserProfile = new PodUserProfile(this);
|
2016-03-30 03:13:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
// Get cookie manager
|
|
|
|
cookieManager = CookieManager.getInstance();
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
|
|
|
CookieSyncManager.createInstance(c);
|
|
|
|
}
|
|
|
|
cookieManager.setAcceptCookie(true);
|
2016-03-24 13:56:30 +01:00
|
|
|
}
|
|
|
|
|
2016-06-04 03:48:57 +02:00
|
|
|
public void resetPodData(@Nullable WebView webView){
|
|
|
|
if(webView != null){
|
|
|
|
webView.stopLoading();
|
|
|
|
webView.loadUrl("about:blank");
|
|
|
|
webView.clearFormData();
|
|
|
|
webView.clearHistory();
|
|
|
|
webView.clearCache(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear avatar image
|
|
|
|
new AvatarImageLoader(this).clearAvatarImage();
|
|
|
|
|
|
|
|
// Clear preferences
|
|
|
|
appSettings.clearPodSettings();
|
|
|
|
|
|
|
|
// Clear cookies
|
|
|
|
cookieManager.removeAllCookie();
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
|
|
cookieManager.removeAllCookies(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-05 17:25:11 +02:00
|
|
|
public PodUserProfile getPodUserProfile(){
|
|
|
|
return podUserProfile;
|
|
|
|
}
|
|
|
|
|
2016-03-24 13:56:30 +01:00
|
|
|
public AppSettings getSettings() {
|
|
|
|
return appSettings;
|
|
|
|
}
|
2016-03-25 00:12:00 +01:00
|
|
|
|
|
|
|
public AvatarImageLoader getAvatarImageLoader() {
|
|
|
|
return avatarImageLoader;
|
|
|
|
}
|
2016-03-30 03:13:38 +02:00
|
|
|
|
|
|
|
public CookieManager getCookieManager() {
|
|
|
|
return cookieManager;
|
|
|
|
}
|
2016-03-24 13:56:30 +01:00
|
|
|
}
|