commit
5dafd6f815
@ -5,33 +5,24 @@ package acr.browser.lightning;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class AboutSettingsActivity extends ActionBarActivity {
|
public class AboutSettingsActivity extends ThemableSettingsActivity {
|
||||||
|
|
||||||
// mPreferences variables
|
|
||||||
private SharedPreferences mPreferences;
|
|
||||||
private int mEasterEggCounter;
|
private int mEasterEggCounter;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
|
||||||
if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
|
||||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
|
||||||
}
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.about_settings);
|
setContentView(R.layout.about_settings);
|
||||||
|
|
||||||
@ -41,11 +32,6 @@ public class AboutSettingsActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
|
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
mContext = this;
|
mContext = this;
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,10 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
@ -22,7 +20,7 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class AdvancedSettingsActivity extends ActionBarActivity {
|
public class AdvancedSettingsActivity extends ThemableSettingsActivity {
|
||||||
|
|
||||||
private SharedPreferences mPreferences;
|
private SharedPreferences mPreferences;
|
||||||
private CheckBox cbAllowPopups, cbAllowCookies, cbAllowIncognitoCookies, cbRestoreTabs;
|
private CheckBox cbAllowPopups, cbAllowCookies, cbAllowIncognitoCookies, cbRestoreTabs;
|
||||||
@ -34,10 +32,6 @@ public class AdvancedSettingsActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
|
||||||
if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
|
||||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
|
||||||
}
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.advanced_settings);
|
setContentView(R.layout.advanced_settings);
|
||||||
|
|
||||||
@ -47,11 +41,6 @@ public class AdvancedSettingsActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
|
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
mContext = this;
|
mContext = this;
|
||||||
mActivity = this;
|
mActivity = this;
|
||||||
initialize();
|
initialize();
|
||||||
@ -64,6 +53,7 @@ public class AdvancedSettingsActivity extends ActionBarActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
|
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||||
|
|
||||||
RelativeLayout rAllowPopups, rAllowCookies, rAllowIncognitoCookies, rRestoreTabs;
|
RelativeLayout rAllowPopups, rAllowCookies, rAllowIncognitoCookies, rRestoreTabs;
|
||||||
LinearLayout lRenderPicker, lUrlContent;
|
LinearLayout lRenderPicker, lUrlContent;
|
||||||
|
@ -11,7 +11,6 @@ import android.content.DialogInterface;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -19,7 +18,7 @@ import android.view.View.OnClickListener;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class BookmarkActivity extends ActionBarActivity implements OnClickListener {
|
public class BookmarkActivity extends ThemableSettingsActivity implements OnClickListener {
|
||||||
|
|
||||||
private BookmarkManager mBookmarkManager;
|
private BookmarkManager mBookmarkManager;
|
||||||
private boolean mSystemBrowser;
|
private boolean mSystemBrowser;
|
||||||
@ -31,10 +30,6 @@ public class BookmarkActivity extends ActionBarActivity implements OnClickListen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
|
||||||
if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
|
||||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
|
||||||
}
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.bookmark_settings);
|
setContentView(R.layout.bookmark_settings);
|
||||||
|
|
||||||
@ -52,6 +47,8 @@ public class BookmarkActivity extends ActionBarActivity implements OnClickListen
|
|||||||
|
|
||||||
mBookmarkManager = new BookmarkManager(this);
|
mBookmarkManager = new BookmarkManager(this);
|
||||||
|
|
||||||
|
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||||
|
|
||||||
mSystemBrowser = mPreferences.getBoolean(PreferenceConstants.SYSTEM_BROWSER_PRESENT, false);
|
mSystemBrowser = mPreferences.getBoolean(PreferenceConstants.SYSTEM_BROWSER_PRESENT, false);
|
||||||
|
|
||||||
exportBackup.setOnClickListener(this);
|
exportBackup.setOnClickListener(this);
|
||||||
@ -63,7 +60,6 @@ public class BookmarkActivity extends ActionBarActivity implements OnClickListen
|
|||||||
} else {
|
} else {
|
||||||
importBookmarks.setText(getResources().getString(R.string.stock_browser_unavailable));
|
importBookmarks.setText(getResources().getString(R.string.stock_browser_unavailable));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,7 +55,6 @@ import android.webkit.*;
|
|||||||
import android.webkit.WebChromeClient.CustomViewCallback;
|
import android.webkit.WebChromeClient.CustomViewCallback;
|
||||||
import android.webkit.WebView.HitTestResult;
|
import android.webkit.WebView.HitTestResult;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.graphics.Palette;
|
import android.support.v7.graphics.Palette;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
@ -72,14 +71,12 @@ import java.net.URL;
|
|||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class BrowserActivity extends ActionBarActivity implements BrowserController {
|
public class BrowserActivity extends ThemableActivity implements BrowserController, OnClickListener {
|
||||||
|
|
||||||
private DrawerLayout mDrawerLayout;
|
private DrawerLayout mDrawerLayout;
|
||||||
private ListView mDrawerListLeft;
|
private ListView mDrawerListLeft, mDrawerListRight;
|
||||||
private LinearLayout mDrawerLeft;
|
private LinearLayout mDrawerLeft, mDrawerRight, mPageLayout, mUiLayout, mToolbarLayout;
|
||||||
private LinearLayout mDrawerRight;
|
private RelativeLayout mNewTab, mSearchBar;
|
||||||
private ListView mDrawerListRight;
|
|
||||||
private RelativeLayout mNewTab;
|
|
||||||
private List<LightningView> mWebViews = new ArrayList<LightningView>();
|
private List<LightningView> mWebViews = new ArrayList<LightningView>();
|
||||||
private LightningView mCurrentView;
|
private LightningView mCurrentView;
|
||||||
private int mIdGenerator;
|
private int mIdGenerator;
|
||||||
@ -94,42 +91,29 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
|||||||
private AnimatedProgressBar mProgressBar;
|
private AnimatedProgressBar mProgressBar;
|
||||||
private boolean mSystemBrowser = false;
|
private boolean mSystemBrowser = false;
|
||||||
private ValueCallback<Uri> mUploadMessage;
|
private ValueCallback<Uri> mUploadMessage;
|
||||||
private View mCustomView;
|
private View mCustomView, mVideoProgressView;
|
||||||
private int mOriginalOrientation;
|
private int mOriginalOrientation, mBackgroundColor;
|
||||||
private int mBackgroundColor;
|
|
||||||
private ActionBar mActionBar;
|
private ActionBar mActionBar;
|
||||||
private boolean mFullScreen;
|
private boolean mFullScreen, mColorMode, mDarkTheme;
|
||||||
private boolean mColorMode;
|
|
||||||
private FrameLayout mBrowserFrame;
|
private FrameLayout mBrowserFrame;
|
||||||
private LinearLayout mPageLayout;
|
|
||||||
private LinearLayout mUiLayout;
|
|
||||||
private FullscreenHolder mFullscreenContainer;
|
private FullscreenHolder mFullscreenContainer;
|
||||||
private CustomViewCallback mCustomViewCallback;
|
private CustomViewCallback mCustomViewCallback;
|
||||||
private final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams(
|
private final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
private Bitmap mDefaultVideoPoster;
|
private Bitmap mDefaultVideoPoster, mWebpageBitmap;
|
||||||
private View mVideoProgressView;
|
|
||||||
private LinearLayout mToolbarLayout;
|
|
||||||
private HistoryDatabase mHistoryDatabase;
|
private HistoryDatabase mHistoryDatabase;
|
||||||
private SharedPreferences mPreferences;
|
private SharedPreferences mPreferences;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private Bitmap mWebpageBitmap;
|
private String mSearchText, mUntitledTitle, mHomepage;
|
||||||
private String mSearchText;
|
|
||||||
private String mUntitledTitle;
|
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
private final int API = android.os.Build.VERSION.SDK_INT;
|
private final int API = android.os.Build.VERSION.SDK_INT;
|
||||||
private Drawable mDeleteIcon;
|
private Drawable mDeleteIcon, mRefreshIcon, mCopyIcon, mIcon;
|
||||||
private Drawable mRefreshIcon;
|
|
||||||
private Drawable mCopyIcon;
|
|
||||||
private Drawable mIcon;
|
|
||||||
private String mHomepage;
|
|
||||||
private boolean mIsNewIntent = false;
|
private boolean mIsNewIntent = false;
|
||||||
private VideoView mVideoView;
|
private VideoView mVideoView;
|
||||||
private static SearchAdapter mSearchAdapter;
|
private static SearchAdapter mSearchAdapter;
|
||||||
private static LayoutParams mMatchParent = new LayoutParams(LayoutParams.MATCH_PARENT,
|
private static LayoutParams mMatchParent = new LayoutParams(LayoutParams.MATCH_PARENT,
|
||||||
LayoutParams.MATCH_PARENT);
|
LayoutParams.MATCH_PARENT);
|
||||||
private BookmarkManager mBookmarkManager;
|
private BookmarkManager mBookmarkManager;
|
||||||
private boolean mDarkTheme;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -211,7 +195,6 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
|||||||
mHistoryDatabase = HistoryDatabase.getInstance(this);
|
mHistoryDatabase = HistoryDatabase.getInstance(this);
|
||||||
|
|
||||||
// set display options of the ActionBar
|
// set display options of the ActionBar
|
||||||
|
|
||||||
mActionBar.setDisplayShowTitleEnabled(false);
|
mActionBar.setDisplayShowTitleEnabled(false);
|
||||||
mActionBar.setHomeButtonEnabled(false);
|
mActionBar.setHomeButtonEnabled(false);
|
||||||
mActionBar.setDisplayShowHomeEnabled(false);
|
mActionBar.setDisplayShowHomeEnabled(false);
|
||||||
@ -233,51 +216,13 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
|||||||
mArrowImage.setImageDrawable(mArrowDrawable);
|
mArrowImage.setImageDrawable(mArrowDrawable);
|
||||||
LinearLayout arrowButton = (LinearLayout) mActionBar.getCustomView().findViewById(
|
LinearLayout arrowButton = (LinearLayout) mActionBar.getCustomView().findViewById(
|
||||||
R.id.arrow_button);
|
R.id.arrow_button);
|
||||||
arrowButton.setOnClickListener(new OnClickListener() {
|
arrowButton.setOnClickListener(this);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (mSearch != null && mSearch.hasFocus()) {
|
|
||||||
mCurrentView.requestFocus();
|
|
||||||
} else {
|
|
||||||
mDrawerLayout.openDrawer(mDrawerLeft);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
RelativeLayout back = (RelativeLayout) findViewById(R.id.action_back);
|
RelativeLayout back = (RelativeLayout) findViewById(R.id.action_back);
|
||||||
|
back.setOnClickListener(this);
|
||||||
|
|
||||||
RelativeLayout forward = (RelativeLayout) findViewById(R.id.action_forward);
|
RelativeLayout forward = (RelativeLayout) findViewById(R.id.action_forward);
|
||||||
if (back != null) {
|
forward.setOnClickListener(this);
|
||||||
back.setOnClickListener(new OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (mCurrentView != null) {
|
|
||||||
if (mCurrentView.canGoBack()) {
|
|
||||||
mCurrentView.goBack();
|
|
||||||
} else {
|
|
||||||
deleteTab(mDrawerListLeft.getCheckedItemPosition());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (forward != null) {
|
|
||||||
forward.setOnClickListener(new OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (mCurrentView != null) {
|
|
||||||
if (mCurrentView.canGoForward()) {
|
|
||||||
mCurrentView.goForward();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the search EditText in the ToolBar
|
// create the search EditText in the ToolBar
|
||||||
mSearch = (AutoCompleteTextView) mActionBar.getCustomView().findViewById(R.id.search);
|
mSearch = (AutoCompleteTextView) mActionBar.getCustomView().findViewById(R.id.search);
|
||||||
@ -316,15 +261,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
|||||||
});
|
});
|
||||||
initialize.run();
|
initialize.run();
|
||||||
|
|
||||||
mNewTab.setOnClickListener(new OnClickListener() {
|
mNewTab.setOnClickListener(this);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View arg0) {
|
|
||||||
newTab(null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
mNewTab.setOnLongClickListener(new OnLongClickListener() {
|
mNewTab.setOnLongClickListener(new OnLongClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -351,7 +288,6 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkForTor();
|
checkForTor();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SearchClass {
|
private class SearchClass {
|
||||||
@ -540,92 +476,6 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean handleMenuItemClick(MenuItem item) {
|
|
||||||
// Handle action buttons
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case android.R.id.home:
|
|
||||||
if (mDrawerLayout.isDrawerOpen(mDrawerRight)) {
|
|
||||||
mDrawerLayout.closeDrawer(mDrawerRight);
|
|
||||||
}
|
|
||||||
// mDrawerToggle.syncState();
|
|
||||||
return true;
|
|
||||||
case R.id.action_back:
|
|
||||||
if (mCurrentView != null) {
|
|
||||||
if (mCurrentView.canGoBack()) {
|
|
||||||
mCurrentView.goBack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.action_forward:
|
|
||||||
if (mCurrentView != null) {
|
|
||||||
if (mCurrentView.canGoForward()) {
|
|
||||||
mCurrentView.goForward();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.action_new_tab:
|
|
||||||
newTab(null, true);
|
|
||||||
return true;
|
|
||||||
case R.id.action_incognito:
|
|
||||||
startActivity(new Intent(this, IncognitoActivity.class));
|
|
||||||
return true;
|
|
||||||
case R.id.action_share:
|
|
||||||
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
|
|
||||||
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
|
|
||||||
shareIntent.setType("text/plain");
|
|
||||||
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
|
|
||||||
mCurrentView.getTitle());
|
|
||||||
String shareMessage = mCurrentView.getUrl();
|
|
||||||
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage);
|
|
||||||
startActivity(Intent.createChooser(shareIntent,
|
|
||||||
getResources().getString(R.string.dialog_title_share)));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.action_bookmarks:
|
|
||||||
openBookmarks();
|
|
||||||
return true;
|
|
||||||
case R.id.action_copy:
|
|
||||||
if (mCurrentView != null) {
|
|
||||||
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
|
|
||||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
|
||||||
ClipData clip = ClipData.newPlainText("label", mCurrentView.getUrl());
|
|
||||||
clipboard.setPrimaryClip(clip);
|
|
||||||
Utils.showToast(mContext,
|
|
||||||
mContext.getResources().getString(R.string.message_link_copied));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.action_settings:
|
|
||||||
startActivity(new Intent(this, SettingsActivity.class));
|
|
||||||
return true;
|
|
||||||
case R.id.action_history:
|
|
||||||
openHistory();
|
|
||||||
return true;
|
|
||||||
case R.id.action_add_bookmark:
|
|
||||||
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
|
|
||||||
HistoryItem bookmark = new HistoryItem(mCurrentView.getUrl(),
|
|
||||||
mCurrentView.getTitle());
|
|
||||||
if (mBookmarkManager.addBookmark(bookmark)) {
|
|
||||||
mBookmarkList.add(bookmark);
|
|
||||||
Collections.sort(mBookmarkList, new SortIgnoreCase());
|
|
||||||
notifyBookmarkDataSetChanged();
|
|
||||||
mSearchAdapter.refreshBookmarks();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.action_find:
|
|
||||||
findInPage();
|
|
||||||
return true;
|
|
||||||
case R.id.action_reading_mode:
|
|
||||||
Intent read = new Intent(this, ReadingActivity.class);
|
|
||||||
read.putExtra(Constants.LOAD_READING_URL, mCurrentView.getUrl());
|
|
||||||
startActivity(read);
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If Orbot/Tor is installed, prompt the user if they want to enable
|
* If Orbot/Tor is installed, prompt the user if they want to enable
|
||||||
* proxying for this session
|
* proxying for this session
|
||||||
@ -997,35 +847,20 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
|||||||
if (mCurrentView != null) {
|
if (mCurrentView != null) {
|
||||||
mCurrentView.find(text);
|
mCurrentView.find(text);
|
||||||
}
|
}
|
||||||
final RelativeLayout bar = (RelativeLayout) findViewById(R.id.search_bar);
|
mSearchBar = (RelativeLayout) findViewById(R.id.search_bar);
|
||||||
bar.setVisibility(View.VISIBLE);
|
mSearchBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
TextView tw = (TextView) findViewById(R.id.search_query);
|
TextView tw = (TextView) findViewById(R.id.search_query);
|
||||||
tw.setText("'" + text + "'");
|
tw.setText("'" + text + "'");
|
||||||
|
|
||||||
ImageButton up = (ImageButton) findViewById(R.id.button_next);
|
ImageButton up = (ImageButton) findViewById(R.id.button_next);
|
||||||
up.setOnClickListener(new View.OnClickListener() {
|
up.setOnClickListener(this);
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
mCurrentView.getWebView().findNext(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ImageButton down = (ImageButton) findViewById(R.id.button_back);
|
ImageButton down = (ImageButton) findViewById(R.id.button_back);
|
||||||
down.setOnClickListener(new View.OnClickListener() {
|
down.setOnClickListener(this);
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
mCurrentView.getWebView().findNext(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ImageButton quit = (ImageButton) findViewById(R.id.button_quit);
|
ImageButton quit = (ImageButton) findViewById(R.id.button_quit);
|
||||||
quit.setOnClickListener(new View.OnClickListener() {
|
quit.setOnClickListener(this);
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
mCurrentView.getWebView().clearMatches();
|
|
||||||
bar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showCloseDialog(final int position) {
|
private void showCloseDialog(final int position) {
|
||||||
@ -1545,6 +1380,8 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
supportInvalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2693,4 +2530,46 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
|||||||
public int getMenu() {
|
public int getMenu() {
|
||||||
return R.menu.main;
|
return R.menu.main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
switch (v.getId()) {
|
||||||
|
case R.id.action_back:
|
||||||
|
if (mCurrentView != null) {
|
||||||
|
if (mCurrentView.canGoBack()) {
|
||||||
|
mCurrentView.goBack();
|
||||||
|
} else {
|
||||||
|
deleteTab(mDrawerListLeft.getCheckedItemPosition());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R.id.action_forward:
|
||||||
|
if (mCurrentView != null) {
|
||||||
|
if (mCurrentView.canGoForward()) {
|
||||||
|
mCurrentView.goForward();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R.id.arrow_button:
|
||||||
|
if (mSearch != null && mSearch.hasFocus()) {
|
||||||
|
mCurrentView.requestFocus();
|
||||||
|
} else {
|
||||||
|
mDrawerLayout.openDrawer(mDrawerLeft);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R.id.new_tab_button:
|
||||||
|
newTab(null, true);
|
||||||
|
break;
|
||||||
|
case R.id.button_next:
|
||||||
|
mCurrentView.getWebView().findNext(false);
|
||||||
|
break;
|
||||||
|
case R.id.button_back:
|
||||||
|
mCurrentView.getWebView().findNext(true);
|
||||||
|
break;
|
||||||
|
case R.id.button_quit:
|
||||||
|
mCurrentView.getWebView().clearMatches();
|
||||||
|
mSearchBar.setVisibility(View.GONE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,40 +3,32 @@
|
|||||||
*/
|
*/
|
||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
public class DisplaySettingsActivity extends ActionBarActivity {
|
public class DisplaySettingsActivity extends ThemableSettingsActivity {
|
||||||
|
|
||||||
// mPreferences variables
|
// mPreferences variables
|
||||||
private SharedPreferences mPreferences;
|
private SharedPreferences mPreferences;
|
||||||
private CheckBox cbHideStatusBar, cbFullScreen, cbWideViewPort, cbOverView, cbTextReflow,
|
private CheckBox cbHideStatusBar, cbFullScreen, cbWideViewPort, cbOverView, cbTextReflow,
|
||||||
cbDarkTheme;
|
cbDarkTheme;
|
||||||
private Activity mActivity;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
|
||||||
if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
|
||||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
|
||||||
}
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.display_settings);
|
setContentView(R.layout.display_settings);
|
||||||
|
|
||||||
mActivity = this;
|
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||||
|
|
||||||
// set up ActionBar
|
// set up ActionBar
|
||||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
@ -44,10 +36,6 @@ public class DisplaySettingsActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
|
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
||||||
}
|
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +117,7 @@ public class DisplaySettingsActivity extends ActionBarActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
mPreferences.edit().putBoolean(PreferenceConstants.DARK_THEME, isChecked).apply();
|
mPreferences.edit().putBoolean(PreferenceConstants.DARK_THEME, isChecked).apply();
|
||||||
mActivity.recreate();
|
restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -10,14 +10,12 @@ import android.content.SharedPreferences;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
@ -26,7 +24,7 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class GeneralSettingsActivity extends ActionBarActivity {
|
public class GeneralSettingsActivity extends ThemableSettingsActivity {
|
||||||
|
|
||||||
// mPreferences variables
|
// mPreferences variables
|
||||||
private static final int API = android.os.Build.VERSION.SDK_INT;
|
private static final int API = android.os.Build.VERSION.SDK_INT;
|
||||||
@ -44,10 +42,6 @@ public class GeneralSettingsActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
|
||||||
if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
|
||||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
|
||||||
}
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.general_settings);
|
setContentView(R.layout.general_settings);
|
||||||
|
|
||||||
@ -57,13 +51,9 @@ public class GeneralSettingsActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
|
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO WARNING: SharedPreferences.edit() without a corresponding
|
// TODO WARNING: SharedPreferences.edit() without a corresponding
|
||||||
// commit() or apply() call
|
// commit() or apply() call
|
||||||
|
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||||
mEditPrefs = mPreferences.edit();
|
mEditPrefs = mPreferences.edit();
|
||||||
|
|
||||||
mActivity = this;
|
mActivity = this;
|
||||||
|
@ -4,10 +4,8 @@
|
|||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -17,14 +15,10 @@ import android.view.View;
|
|||||||
*under which this code is licensed. Unless you plan on providing other attribution in the app to
|
*under which this code is licensed. Unless you plan on providing other attribution in the app to
|
||||||
*the original source in another visible way, it is advised against the removal of this Activity.
|
*the original source in another visible way, it is advised against the removal of this Activity.
|
||||||
*/
|
*/
|
||||||
public class LicenseActivity extends ActionBarActivity implements View.OnClickListener {
|
public class LicenseActivity extends ThemableSettingsActivity implements View.OnClickListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
SharedPreferences preferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
|
||||||
if (preferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
|
||||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
|
||||||
}
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.license_activity);
|
setContentView(R.layout.license_activity);
|
||||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
|
@ -13,16 +13,11 @@ public class MainActivity extends BrowserActivity {
|
|||||||
|
|
||||||
SharedPreferences mPreferences;
|
SharedPreferences mPreferences;
|
||||||
CookieManager mCookieManager;
|
CookieManager mCookieManager;
|
||||||
private boolean mDark;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
|
||||||
mDark = mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false);
|
|
||||||
if (mDark) {
|
|
||||||
this.setTheme(R.style.Theme_DarkTheme);
|
|
||||||
}
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -62,15 +57,6 @@ public class MainActivity extends BrowserActivity {
|
|||||||
saveOpenTabs();
|
saveOpenTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
if (mPreferences != null
|
|
||||||
&& mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false) != mDark) {
|
|
||||||
this.recreate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateHistory(String title, String url) {
|
public void updateHistory(String title, String url) {
|
||||||
super.updateHistory(title, url);
|
super.updateHistory(title, url);
|
||||||
|
@ -12,12 +12,10 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.provider.Browser;
|
import android.provider.Browser;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.webkit.*;
|
import android.webkit.*;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
@ -25,7 +23,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
|
|||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class PrivacySettingsActivity extends ActionBarActivity {
|
public class PrivacySettingsActivity extends ThemableSettingsActivity {
|
||||||
|
|
||||||
// mPreferences variables
|
// mPreferences variables
|
||||||
private static final int API = android.os.Build.VERSION.SDK_INT;
|
private static final int API = android.os.Build.VERSION.SDK_INT;
|
||||||
@ -39,10 +37,6 @@ public class PrivacySettingsActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
|
||||||
if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
|
||||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
|
||||||
}
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.privacy_settings);
|
setContentView(R.layout.privacy_settings);
|
||||||
|
|
||||||
@ -52,13 +46,9 @@ public class PrivacySettingsActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
|
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO WARNING: SharedPreferences.edit() without a corresponding
|
// TODO WARNING: SharedPreferences.edit() without a corresponding
|
||||||
// commit() or apply() call
|
// commit() or apply() call
|
||||||
|
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||||
mEditPrefs = mPreferences.edit();
|
mEditPrefs = mPreferences.edit();
|
||||||
|
|
||||||
mSystemBrowser = mPreferences.getBoolean(PreferenceConstants.SYSTEM_BROWSER_PRESENT, false);
|
mSystemBrowser = mPreferences.getBoolean(PreferenceConstants.SYSTEM_BROWSER_PRESENT, false);
|
||||||
|
@ -15,12 +15,10 @@ import android.content.pm.ApplicationInfo;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
@ -28,24 +26,18 @@ import android.widget.EditText;
|
|||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import info.guardianproject.onionkit.ui.OrbotHelper;
|
import info.guardianproject.onionkit.ui.OrbotHelper;
|
||||||
|
|
||||||
public class SettingsActivity extends ActionBarActivity {
|
public class SettingsActivity extends ThemableSettingsActivity {
|
||||||
|
|
||||||
private static int API = android.os.Build.VERSION.SDK_INT;
|
private static int API = android.os.Build.VERSION.SDK_INT;
|
||||||
private SharedPreferences.Editor mEditPrefs;
|
private SharedPreferences.Editor mEditPrefs;
|
||||||
private SharedPreferences mPreferences;
|
private SharedPreferences mPreferences;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
private boolean mDark;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
|
||||||
if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
|
||||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
|
||||||
}
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.settings);
|
setContentView(R.layout.settings);
|
||||||
mDark = mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false);
|
|
||||||
mContext = this;
|
mContext = this;
|
||||||
mActivity = this;
|
mActivity = this;
|
||||||
init();
|
init();
|
||||||
@ -57,15 +49,6 @@ public class SettingsActivity extends ActionBarActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
if (mPreferences != null
|
|
||||||
&& mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false) != mDark) {
|
|
||||||
this.recreate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
public void init() {
|
public void init() {
|
||||||
// set up ActionBar
|
// set up ActionBar
|
||||||
@ -75,11 +58,7 @@ public class SettingsActivity extends ActionBarActivity {
|
|||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
// mPreferences storage
|
// mPreferences storage
|
||||||
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
|
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
mEditPrefs = mPreferences.edit();
|
mEditPrefs = mPreferences.edit();
|
||||||
|
|
||||||
// initialize UI
|
// initialize UI
|
||||||
|
43
src/acr/browser/lightning/ThemableActivity.java
Normal file
43
src/acr/browser/lightning/ThemableActivity.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package acr.browser.lightning;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
|
||||||
|
public abstract class ThemableActivity extends ActionBarActivity {
|
||||||
|
|
||||||
|
private SharedPreferences mPreferences;
|
||||||
|
private boolean mDark;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||||
|
mDark = mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false);
|
||||||
|
|
||||||
|
// set the theme
|
||||||
|
if (mDark) {
|
||||||
|
setTheme(R.style.Theme_DarkTheme);
|
||||||
|
}
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if (mPreferences != null
|
||||||
|
&& mPreferences.getBoolean(PreferenceConstants.DARK_THEME,
|
||||||
|
false) != mDark) {
|
||||||
|
restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void restart() {
|
||||||
|
final Bundle outState = new Bundle();
|
||||||
|
onSaveInstanceState(outState);
|
||||||
|
final Intent intent = new Intent(this, getClass());
|
||||||
|
finish();
|
||||||
|
overridePendingTransition(0, 0);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
43
src/acr/browser/lightning/ThemableSettingsActivity.java
Normal file
43
src/acr/browser/lightning/ThemableSettingsActivity.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package acr.browser.lightning;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
|
||||||
|
public abstract class ThemableSettingsActivity extends ActionBarActivity {
|
||||||
|
|
||||||
|
private SharedPreferences mPreferences;
|
||||||
|
private boolean mDark;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||||
|
mDark = mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false);
|
||||||
|
|
||||||
|
// set the theme
|
||||||
|
if (mDark) {
|
||||||
|
setTheme(R.style.Theme_SettingsTheme_Dark);
|
||||||
|
}
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if (mPreferences != null
|
||||||
|
&& mPreferences.getBoolean(PreferenceConstants.DARK_THEME,
|
||||||
|
false) != mDark) {
|
||||||
|
restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void restart() {
|
||||||
|
final Bundle outState = new Bundle();
|
||||||
|
onSaveInstanceState(outState);
|
||||||
|
final Intent intent = new Intent(this, getClass());
|
||||||
|
finish();
|
||||||
|
overridePendingTransition(0, 0);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user