2014-07-04 19:35:59 -04:00
|
|
|
package acr.browser.lightning;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.SharedPreferences;
|
2015-01-29 13:52:56 -05:00
|
|
|
import android.os.Build;
|
2014-07-04 19:35:59 -04:00
|
|
|
import android.os.Bundle;
|
|
|
|
import android.view.Menu;
|
|
|
|
import android.webkit.CookieManager;
|
|
|
|
import android.webkit.CookieSyncManager;
|
|
|
|
|
2015-01-29 21:56:48 -05:00
|
|
|
@SuppressWarnings("deprecation")
|
2014-07-04 19:35:59 -04:00
|
|
|
public class MainActivity extends BrowserActivity {
|
|
|
|
|
|
|
|
SharedPreferences mPreferences;
|
|
|
|
CookieManager mCookieManager;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
2015-03-31 11:20:41 -04:00
|
|
|
super.onCreate(savedInstanceState);
|
2015-04-01 21:31:28 +02:00
|
|
|
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
2014-07-04 19:35:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateCookiePreference() {
|
|
|
|
if (mPreferences == null) {
|
2014-08-08 18:17:52 -04:00
|
|
|
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
2014-07-04 19:35:59 -04:00
|
|
|
}
|
|
|
|
mCookieManager = CookieManager.getInstance();
|
2015-01-29 13:52:56 -05:00
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
|
|
|
CookieSyncManager.createInstance(this);
|
|
|
|
}
|
2014-08-08 18:17:52 -04:00
|
|
|
mCookieManager.setAcceptCookie(mPreferences.getBoolean(PreferenceConstants.COOKIES, true));
|
2014-07-04 19:35:59 -04:00
|
|
|
super.updateCookiePreference();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized void initializeTabs() {
|
|
|
|
restoreOrNewTab();
|
2014-08-08 18:17:52 -04:00
|
|
|
// if incognito mode use newTab(null, true); instead
|
2014-07-04 19:35:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
getMenuInflater().inflate(R.menu.main, menu);
|
|
|
|
return super.onCreateOptionsMenu(menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onNewIntent(Intent intent) {
|
|
|
|
handleNewIntent(intent);
|
|
|
|
super.onNewIntent(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPause() {
|
|
|
|
super.onPause();
|
|
|
|
saveOpenTabs();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateHistory(String title, String url) {
|
|
|
|
super.updateHistory(title, url);
|
|
|
|
addItemToHistory(title, url);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isIncognito() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-01-26 13:07:57 -05:00
|
|
|
@Override
|
|
|
|
public int getMenu() {
|
|
|
|
return R.menu.main;
|
|
|
|
}
|
|
|
|
|
2014-07-04 19:35:59 -04:00
|
|
|
@Override
|
|
|
|
public void closeActivity() {
|
2014-07-14 23:03:37 -04:00
|
|
|
closeDrawers();
|
2014-07-04 19:35:59 -04:00
|
|
|
moveTaskToBack(true);
|
|
|
|
}
|
|
|
|
}
|