Localizing log tags
This commit is contained in:
parent
5af0f5f0c1
commit
7fa3315662
@ -187,8 +187,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
private String mUntitledTitle;
|
private String mUntitledTitle;
|
||||||
private String mCameraPhotoPath;
|
private String mCameraPhotoPath;
|
||||||
|
|
||||||
private final Handler mDrawerHandler = new Handler();
|
|
||||||
|
|
||||||
// The singleton BookmarkManager
|
// The singleton BookmarkManager
|
||||||
@Inject BookmarkManager mBookmarkManager;
|
@Inject BookmarkManager mBookmarkManager;
|
||||||
|
|
||||||
@ -991,7 +989,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
// Use a delayed handler to make the transition smooth
|
// Use a delayed handler to make the transition smooth
|
||||||
// otherwise it will get caught up with the showTab code
|
// otherwise it will get caught up with the showTab code
|
||||||
// and cause a janky motion
|
// and cause a janky motion
|
||||||
mDrawerHandler.postDelayed(new Runnable() {
|
Handlers.MAIN.postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mDrawerLayout.closeDrawers();
|
mDrawerLayout.closeDrawers();
|
||||||
@ -1030,14 +1028,14 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
// Use a delayed handler to make the transition smooth
|
// Use a delayed handler to make the transition smooth
|
||||||
// otherwise it will get caught up with the showTab code
|
// otherwise it will get caught up with the showTab code
|
||||||
// and cause a janky motion
|
// and cause a janky motion
|
||||||
mDrawerHandler.postDelayed(new Runnable() {
|
Handlers.MAIN.postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mDrawerLayout.closeDrawers();
|
mDrawerLayout.closeDrawers();
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
|
|
||||||
// mDrawerHandler.postDelayed(new Runnable() {
|
// Handlers.MAIN.postDelayed(new Runnable() {
|
||||||
// @Override
|
// @Override
|
||||||
// public void run() {
|
// public void run() {
|
||||||
// Remove browser frame background to reduce overdraw
|
// Remove browser frame background to reduce overdraw
|
||||||
@ -1114,7 +1112,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
mPresenter.loadUrlInCurrentView(item.getUrl());
|
mPresenter.loadUrlInCurrentView(item.getUrl());
|
||||||
// keep any jank from happening when the drawer is closed after the
|
// keep any jank from happening when the drawer is closed after the
|
||||||
// URL starts to load
|
// URL starts to load
|
||||||
mDrawerHandler.postDelayed(new Runnable() {
|
Handlers.MAIN.postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
closeDrawers(null);
|
closeDrawers(null);
|
||||||
@ -1311,7 +1309,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
Log.d(TAG, "onDestroy");
|
Log.d(TAG, "onDestroy");
|
||||||
|
|
||||||
mDrawerHandler.removeCallbacksAndMessages(null);
|
Handlers.MAIN.removeCallbacksAndMessages(null);
|
||||||
|
|
||||||
mPresenter.shutdown();
|
mPresenter.shutdown();
|
||||||
|
|
||||||
|
@ -155,97 +155,97 @@ public class TabsManager {
|
|||||||
@NonNull final CompletableSubscriber subscriber) {
|
@NonNull final CompletableSubscriber subscriber) {
|
||||||
|
|
||||||
restoreState()
|
restoreState()
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(Schedulers.main())
|
.observeOn(Schedulers.main())
|
||||||
.subscribe(new StreamOnSubscribe<Bundle>() {
|
.subscribe(new StreamOnSubscribe<Bundle>() {
|
||||||
@Override
|
@Override
|
||||||
public void onNext(@Nullable Bundle item) {
|
public void onNext(@Nullable Bundle item) {
|
||||||
final LightningView tab = newTab(activity, "", false);
|
final LightningView tab = newTab(activity, "", false);
|
||||||
Preconditions.checkNonNull(item);
|
Preconditions.checkNonNull(item);
|
||||||
String url = item.getString(URL_KEY);
|
String url = item.getString(URL_KEY);
|
||||||
if (url != null && tab.getWebView() != null) {
|
if (url != null && tab.getWebView() != null) {
|
||||||
if (UrlUtils.isBookmarkUrl(url)) {
|
if (UrlUtils.isBookmarkUrl(url)) {
|
||||||
new BookmarkPage(activity).getBookmarkPage()
|
new BookmarkPage(activity).getBookmarkPage()
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(Schedulers.main())
|
.observeOn(Schedulers.main())
|
||||||
.subscribe(new SingleOnSubscribe<String>() {
|
.subscribe(new SingleOnSubscribe<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onItem(@Nullable String item) {
|
public void onItem(@Nullable String item) {
|
||||||
Preconditions.checkNonNull(item);
|
Preconditions.checkNonNull(item);
|
||||||
tab.loadUrl(item);
|
tab.loadUrl(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (UrlUtils.isStartPageUrl(url)) {
|
} else if (UrlUtils.isStartPageUrl(url)) {
|
||||||
new StartPage().getHomepage()
|
new StartPage().getHomepage()
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(Schedulers.main())
|
.observeOn(Schedulers.main())
|
||||||
.subscribe(new SingleOnSubscribe<String>() {
|
.subscribe(new SingleOnSubscribe<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onItem(@Nullable String item) {
|
public void onItem(@Nullable String item) {
|
||||||
Preconditions.checkNonNull(item);
|
Preconditions.checkNonNull(item);
|
||||||
tab.loadUrl(item);
|
tab.loadUrl(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (UrlUtils.isHistoryUrl(url)) {
|
} else if (UrlUtils.isHistoryUrl(url)) {
|
||||||
new HistoryPage().getHistoryPage()
|
new HistoryPage().getHistoryPage()
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(Schedulers.main())
|
.observeOn(Schedulers.main())
|
||||||
.subscribe(new SingleOnSubscribe<String>() {
|
.subscribe(new SingleOnSubscribe<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onItem(@Nullable String item) {
|
public void onItem(@Nullable String item) {
|
||||||
Preconditions.checkNonNull(item);
|
Preconditions.checkNonNull(item);
|
||||||
tab.loadUrl(item);
|
tab.loadUrl(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
} else if (tab.getWebView() != null) {
|
|
||||||
tab.getWebView().restoreState(item);
|
|
||||||
}
|
}
|
||||||
|
} else if (tab.getWebView() != null) {
|
||||||
|
tab.getWebView().restoreState(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
if (url.startsWith(Constants.FILE)) {
|
if (url.startsWith(Constants.FILE)) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
Dialog dialog = builder.setCancelable(true)
|
Dialog dialog = builder.setCancelable(true)
|
||||||
.setTitle(R.string.title_warning)
|
.setTitle(R.string.title_warning)
|
||||||
.setMessage(R.string.message_blocked_local)
|
.setMessage(R.string.message_blocked_local)
|
||||||
.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(DialogInterface dialog) {
|
public void onDismiss(DialogInterface dialog) {
|
||||||
if (mTabList.isEmpty()) {
|
if (mTabList.isEmpty()) {
|
||||||
newTab(activity, null, false);
|
newTab(activity, null, false);
|
||||||
}
|
}
|
||||||
finishInitialization();
|
finishInitialization();
|
||||||
subscriber.onComplete();
|
subscriber.onComplete();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.setPositiveButton(R.string.action_open, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.action_open, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
newTab(activity, url, false);
|
newTab(activity, url, false);
|
||||||
}
|
}
|
||||||
}).show();
|
}).show();
|
||||||
BrowserDialog.setDialogSize(activity, dialog);
|
BrowserDialog.setDialogSize(activity, dialog);
|
||||||
} else {
|
|
||||||
newTab(activity, url, false);
|
|
||||||
if (mTabList.isEmpty()) {
|
|
||||||
newTab(activity, null, false);
|
|
||||||
}
|
|
||||||
finishInitialization();
|
|
||||||
subscriber.onComplete();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
newTab(activity, url, false);
|
||||||
if (mTabList.isEmpty()) {
|
if (mTabList.isEmpty()) {
|
||||||
newTab(activity, null, false);
|
newTab(activity, null, false);
|
||||||
}
|
}
|
||||||
finishInitialization();
|
finishInitialization();
|
||||||
subscriber.onComplete();
|
subscriber.onComplete();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (mTabList.isEmpty()) {
|
||||||
|
newTab(activity, null, false);
|
||||||
|
}
|
||||||
|
finishInitialization();
|
||||||
|
subscriber.onComplete();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -475,7 +475,7 @@ public class TabsManager {
|
|||||||
*/
|
*/
|
||||||
public void saveState() {
|
public void saveState() {
|
||||||
Bundle outState = new Bundle(ClassLoader.getSystemClassLoader());
|
Bundle outState = new Bundle(ClassLoader.getSystemClassLoader());
|
||||||
Log.d(Constants.TAG, "Saving tab state");
|
Log.d(TAG, "Saving tab state");
|
||||||
for (int n = 0; n < mTabList.size(); n++) {
|
for (int n = 0; n < mTabList.size(); n++) {
|
||||||
LightningView tab = mTabList.get(n);
|
LightningView tab = mTabList.get(n);
|
||||||
if (TextUtils.isEmpty(tab.getUrl())) {
|
if (TextUtils.isEmpty(tab.getUrl())) {
|
||||||
@ -515,7 +515,7 @@ public class TabsManager {
|
|||||||
public void onSubscribe(@NonNull StreamSubscriber<Bundle> subscriber) {
|
public void onSubscribe(@NonNull StreamSubscriber<Bundle> subscriber) {
|
||||||
Bundle savedState = FileUtils.readBundleFromStorage(mApp, BUNDLE_STORAGE);
|
Bundle savedState = FileUtils.readBundleFromStorage(mApp, BUNDLE_STORAGE);
|
||||||
if (savedState != null) {
|
if (savedState != null) {
|
||||||
Log.d(Constants.TAG, "Restoring previous WebView state now");
|
Log.d(TAG, "Restoring previous WebView state now");
|
||||||
for (String key : savedState.keySet()) {
|
for (String key : savedState.keySet()) {
|
||||||
if (key.startsWith(BUNDLE_KEY)) {
|
if (key.startsWith(BUNDLE_KEY)) {
|
||||||
subscriber.onNext(savedState.getBundle(key));
|
subscriber.onNext(savedState.getBundle(key));
|
||||||
|
@ -67,13 +67,10 @@ public final class Constants {
|
|||||||
public static final String ABOUT = "about:";
|
public static final String ABOUT = "about:";
|
||||||
public static final String FOLDER = "folder://";
|
public static final String FOLDER = "folder://";
|
||||||
|
|
||||||
// Application log tag
|
|
||||||
public static final String TAG = "Lightning";
|
|
||||||
|
|
||||||
// These should match the order of @array/proxy_choices_array
|
// These should match the order of @array/proxy_choices_array
|
||||||
@IntDef({NO_PROXY, PROXY_ORBOT, PROXY_I2P, PROXY_MANUAL})
|
@IntDef({NO_PROXY, PROXY_ORBOT, PROXY_I2P, PROXY_MANUAL})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface PROXY {}
|
public @interface Proxy {}
|
||||||
|
|
||||||
public static final int NO_PROXY = 0;
|
public static final int NO_PROXY = 0;
|
||||||
public static final int PROXY_ORBOT = 1;
|
public static final int PROXY_ORBOT = 1;
|
||||||
|
@ -25,6 +25,8 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
public class LightningDownloadListener implements DownloadListener {
|
public class LightningDownloadListener implements DownloadListener {
|
||||||
|
|
||||||
|
private static final String TAG = "LightningDownloader";
|
||||||
|
|
||||||
private final Activity mActivity;
|
private final Activity mActivity;
|
||||||
|
|
||||||
@Inject PreferenceManager mPreferenceManager;
|
@Inject PreferenceManager mPreferenceManager;
|
||||||
@ -65,7 +67,7 @@ public class LightningDownloadListener implements DownloadListener {
|
|||||||
.setNegativeButton(mActivity.getResources().getString(R.string.action_cancel),
|
.setNegativeButton(mActivity.getResources().getString(R.string.action_cancel),
|
||||||
dialogClickListener).show();
|
dialogClickListener).show();
|
||||||
BrowserDialog.setDialogSize(mActivity, dialog);
|
BrowserDialog.setDialogSize(mActivity, dialog);
|
||||||
Log.i(Constants.TAG, "Downloading: " + fileName);
|
Log.i(TAG, "Downloading: " + fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,6 +41,7 @@ import acr.browser.lightning.database.BookmarkLocalSync;
|
|||||||
import acr.browser.lightning.database.BookmarkLocalSync.Source;
|
import acr.browser.lightning.database.BookmarkLocalSync.Source;
|
||||||
import acr.browser.lightning.database.BookmarkManager;
|
import acr.browser.lightning.database.BookmarkManager;
|
||||||
import acr.browser.lightning.database.HistoryItem;
|
import acr.browser.lightning.database.HistoryItem;
|
||||||
|
|
||||||
import com.anthonycr.bonsai.Schedulers;
|
import com.anthonycr.bonsai.Schedulers;
|
||||||
|
|
||||||
import acr.browser.lightning.dialog.BrowserDialog;
|
import acr.browser.lightning.dialog.BrowserDialog;
|
||||||
@ -49,6 +50,8 @@ import acr.browser.lightning.utils.Utils;
|
|||||||
|
|
||||||
public class BookmarkSettingsFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener {
|
public class BookmarkSettingsFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener {
|
||||||
|
|
||||||
|
private static final String TAG = "BookmarkSettingsFrag";
|
||||||
|
|
||||||
private static final String SETTINGS_EXPORT = "export_bookmark";
|
private static final String SETTINGS_EXPORT = "export_bookmark";
|
||||||
private static final String SETTINGS_IMPORT = "import_bookmark";
|
private static final String SETTINGS_IMPORT = "import_bookmark";
|
||||||
private static final String SETTINGS_IMPORT_BROWSER = "import_browser";
|
private static final String SETTINGS_IMPORT_BROWSER = "import_browser";
|
||||||
@ -62,8 +65,8 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
|
|||||||
@Nullable private BookmarkLocalSync mSync;
|
@Nullable private BookmarkLocalSync mSync;
|
||||||
|
|
||||||
private static final String[] REQUIRED_PERMISSIONS = new String[]{
|
private static final String[] REQUIRED_PERMISSIONS = new String[]{
|
||||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
};
|
};
|
||||||
private static final File mPath = new File(Environment.getExternalStorageDirectory().toString());
|
private static final File mPath = new File(Environment.getExternalStorageDirectory().toString());
|
||||||
|
|
||||||
@ -80,7 +83,7 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
|
|||||||
@Override
|
@Override
|
||||||
protected Integer doInBackground(Void... params) {
|
protected Integer doInBackground(Void... params) {
|
||||||
List<HistoryItem> list;
|
List<HistoryItem> list;
|
||||||
Log.d(Constants.TAG, "Loading bookmarks from: " + mSource.name());
|
Log.d(TAG, "Loading bookmarks from: " + mSource.name());
|
||||||
switch (mSource) {
|
switch (mSource) {
|
||||||
case STOCK:
|
case STOCK:
|
||||||
list = getSync().getBookmarksFromStockBrowser();
|
list = getSync().getBookmarksFromStockBrowser();
|
||||||
@ -184,36 +187,36 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
|
|||||||
switch (preference.getKey()) {
|
switch (preference.getKey()) {
|
||||||
case SETTINGS_EXPORT:
|
case SETTINGS_EXPORT:
|
||||||
PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(getActivity(), REQUIRED_PERMISSIONS,
|
PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(getActivity(), REQUIRED_PERMISSIONS,
|
||||||
new PermissionsResultAction() {
|
new PermissionsResultAction() {
|
||||||
@Override
|
@Override
|
||||||
public void onGranted() {
|
public void onGranted() {
|
||||||
mBookmarkManager.exportBookmarks(getActivity());
|
mBookmarkManager.exportBookmarks(getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDenied(String permission) {
|
public void onDenied(String permission) {
|
||||||
//TODO Show message
|
//TODO Show message
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
case SETTINGS_IMPORT:
|
case SETTINGS_IMPORT:
|
||||||
PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(getActivity(), REQUIRED_PERMISSIONS,
|
PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(getActivity(), REQUIRED_PERMISSIONS,
|
||||||
new PermissionsResultAction() {
|
new PermissionsResultAction() {
|
||||||
@Override
|
@Override
|
||||||
public void onGranted() {
|
public void onGranted() {
|
||||||
loadFileList(null);
|
loadFileList(null);
|
||||||
createDialog();
|
createDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDenied(String permission) {
|
public void onDenied(String permission) {
|
||||||
//TODO Show message
|
//TODO Show message
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
case SETTINGS_IMPORT_BROWSER:
|
case SETTINGS_IMPORT_BROWSER:
|
||||||
getSync().getSupportedBrowsers().subscribeOn(Schedulers.worker())
|
getSync().getSupportedBrowsers().subscribeOn(Schedulers.worker())
|
||||||
.observeOn(Schedulers.main()).subscribe(new SingleOnSubscribe<List<Source>>() {
|
.observeOn(Schedulers.main()).subscribe(new SingleOnSubscribe<List<Source>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onItem(@Nullable List<Source> item) {
|
public void onItem(@Nullable List<Source> item) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
@ -289,7 +292,7 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
|
|||||||
private void showChooserDialog(final Activity activity, List<String> list) {
|
private void showChooserDialog(final Activity activity, List<String> list) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
final ArrayAdapter<String> adapter = new ArrayAdapter<>(activity,
|
final ArrayAdapter<String> adapter = new ArrayAdapter<>(activity,
|
||||||
android.R.layout.simple_list_item_1);
|
android.R.layout.simple_list_item_1);
|
||||||
for (String title : list) {
|
for (String title : list) {
|
||||||
adapter.add(title);
|
adapter.add(title);
|
||||||
}
|
}
|
||||||
@ -385,7 +388,7 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createDialog() {
|
private void createDialog() {
|
||||||
if(mActivity == null){
|
if (mActivity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
||||||
|
@ -230,7 +230,7 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
|
|||||||
BrowserDialog.setDialogSize(mActivity, dialog);
|
BrowserDialog.setDialogSize(mActivity, dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setProxyChoice(@Constants.PROXY int choice) {
|
private void setProxyChoice(@Constants.Proxy int choice) {
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case Constants.PROXY_ORBOT:
|
case Constants.PROXY_ORBOT:
|
||||||
choice = ProxyUtils.setProxyChoice(choice, mActivity);
|
choice = ProxyUtils.setProxyChoice(choice, mActivity);
|
||||||
|
@ -251,9 +251,9 @@ public class PreferenceManager {
|
|||||||
return mPrefs.getBoolean(Name.USE_PROXY, false);
|
return mPrefs.getBoolean(Name.USE_PROXY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Constants.PROXY
|
@Constants.Proxy
|
||||||
public int getProxyChoice() {
|
public int getProxyChoice() {
|
||||||
@Constants.PROXY int proxy = mPrefs.getInt(Name.PROXY_CHOICE, Constants.NO_PROXY);
|
@Constants.Proxy int proxy = mPrefs.getInt(Name.PROXY_CHOICE, Constants.NO_PROXY);
|
||||||
switch (proxy) {
|
switch (proxy) {
|
||||||
case Constants.NO_PROXY:
|
case Constants.NO_PROXY:
|
||||||
case Constants.PROXY_ORBOT:
|
case Constants.PROXY_ORBOT:
|
||||||
@ -473,7 +473,7 @@ public class PreferenceManager {
|
|||||||
*
|
*
|
||||||
* @param choice the proxy to use.
|
* @param choice the proxy to use.
|
||||||
*/
|
*/
|
||||||
public void setProxyChoice(@Constants.PROXY int choice) {
|
public void setProxyChoice(@Constants.Proxy int choice) {
|
||||||
putBoolean(Name.USE_PROXY, choice != Constants.NO_PROXY);
|
putBoolean(Name.USE_PROXY, choice != Constants.NO_PROXY);
|
||||||
putInt(Name.PROXY_CHOICE, choice);
|
putInt(Name.PROXY_CHOICE, choice);
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,8 @@ import acr.browser.lightning.constant.Constants;
|
|||||||
*/
|
*/
|
||||||
public class Converter {
|
public class Converter {
|
||||||
|
|
||||||
|
private static final String TAG = "Converter";
|
||||||
|
|
||||||
private final static String UTF8 = "UTF-8";
|
private final static String UTF8 = "UTF-8";
|
||||||
private final static String ISO = "ISO-8859-1";
|
private final static String ISO = "ISO-8859-1";
|
||||||
private final static int K2 = 2048;
|
private final static int K2 = 2048;
|
||||||
@ -118,20 +120,20 @@ public class Converter {
|
|||||||
if (tmpEnc != null)
|
if (tmpEnc != null)
|
||||||
encoding = tmpEnc;
|
encoding = tmpEnc;
|
||||||
else {
|
else {
|
||||||
Log.d(Constants.TAG, "no charset found in first stage");
|
Log.d(TAG, "no charset found in first stage");
|
||||||
// detect with the help of xml beginning ala
|
// detect with the help of xml beginning ala
|
||||||
// encoding="charset"
|
// encoding="charset"
|
||||||
tmpEnc = detectCharset("encoding=", output, in, encoding);
|
tmpEnc = detectCharset("encoding=", output, in, encoding);
|
||||||
if (tmpEnc != null)
|
if (tmpEnc != null)
|
||||||
encoding = tmpEnc;
|
encoding = tmpEnc;
|
||||||
else
|
else
|
||||||
Log.d(Constants.TAG, "no charset found in second stage");
|
Log.d(TAG, "no charset found in second stage");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Charset.isSupported(encoding))
|
if (!Charset.isSupported(encoding))
|
||||||
throw new UnsupportedEncodingException(encoding);
|
throw new UnsupportedEncodingException(encoding);
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
Log.d(Constants.TAG,
|
Log.d(TAG,
|
||||||
"Using default encoding:" + UTF8 + " problem:" + e.getMessage()
|
"Using default encoding:" + UTF8 + " problem:" + e.getMessage()
|
||||||
+ " encoding:" + encoding + ' ' + url);
|
+ " encoding:" + encoding + ' ' + url);
|
||||||
encoding = UTF8;
|
encoding = UTF8;
|
||||||
@ -146,7 +148,7 @@ public class Converter {
|
|||||||
byte[] arr = new byte[K2];
|
byte[] arr = new byte[K2];
|
||||||
while (true) {
|
while (true) {
|
||||||
if (bytesRead >= maxBytes) {
|
if (bytesRead >= maxBytes) {
|
||||||
Log.d(Constants.TAG, "Maxbyte of " + maxBytes
|
Log.d(TAG, "Maxbyte of " + maxBytes
|
||||||
+ " exceeded! Maybe html is now broken but try it nevertheless. Url: "
|
+ " exceeded! Maybe html is now broken but try it nevertheless. Url: "
|
||||||
+ url);
|
+ url);
|
||||||
break;
|
break;
|
||||||
@ -161,7 +163,7 @@ public class Converter {
|
|||||||
|
|
||||||
return output.toString(encoding);
|
return output.toString(encoding);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(Constants.TAG, e.toString() + " url:" + url);
|
Log.e(TAG, e.toString() + " url:" + url);
|
||||||
} finally {
|
} finally {
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
try {
|
try {
|
||||||
@ -236,7 +238,7 @@ public class Converter {
|
|||||||
bos.reset();
|
bos.reset();
|
||||||
return tmpEnc;
|
return tmpEnc;
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Log.e(Constants.TAG, "Couldn't reset stream to re-read with new encoding "
|
Log.e(TAG, "Couldn't reset stream to re-read with new encoding "
|
||||||
+ tmpEnc + ' ' + ex.toString());
|
+ tmpEnc + ' ' + ex.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ import acr.browser.lightning.constant.Constants;
|
|||||||
*/
|
*/
|
||||||
public class FileUtils {
|
public class FileUtils {
|
||||||
|
|
||||||
|
private static final String TAG = "FileUtils";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a bundle to persistent storage in the files directory
|
* Writes a bundle to persistent storage in the files directory
|
||||||
* using the specified file name. This method is a blocking
|
* using the specified file name. This method is a blocking
|
||||||
@ -51,7 +53,7 @@ public class FileUtils {
|
|||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
parcel.recycle();
|
parcel.recycle();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(Constants.TAG, "Unable to write bundle to storage");
|
Log.e(TAG, "Unable to write bundle to storage");
|
||||||
} finally {
|
} finally {
|
||||||
Utils.close(outputStream);
|
Utils.close(outputStream);
|
||||||
}
|
}
|
||||||
@ -103,7 +105,7 @@ public class FileUtils {
|
|||||||
parcel.recycle();
|
parcel.recycle();
|
||||||
return out;
|
return out;
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
Log.e(Constants.TAG, "Unable to read bundle from storage");
|
Log.e(TAG, "Unable to read bundle from storage");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
@ -131,7 +133,7 @@ public class FileUtils {
|
|||||||
throwable.printStackTrace(new PrintStream(outputStream));
|
throwable.printStackTrace(new PrintStream(outputStream));
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(Constants.TAG, "Unable to write bundle to storage");
|
Log.e(TAG, "Unable to write bundle to storage");
|
||||||
} finally {
|
} finally {
|
||||||
Utils.close(outputStream);
|
Utils.close(outputStream);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,9 @@ import info.guardianproject.netcipher.webkit.WebkitProxy;
|
|||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ProxyUtils {
|
public class ProxyUtils {
|
||||||
|
|
||||||
|
private static final String TAG = "ProxyUtils";
|
||||||
|
|
||||||
// Helper
|
// Helper
|
||||||
private static boolean mI2PHelperBound;
|
private static boolean mI2PHelperBound;
|
||||||
private static boolean mI2PProxyInitialized;
|
private static boolean mI2PProxyInitialized;
|
||||||
@ -141,7 +144,7 @@ public class ProxyUtils {
|
|||||||
try {
|
try {
|
||||||
WebkitProxy.setProxy(BrowserApp.class.getName(), activity.getApplicationContext(), null, host, port);
|
WebkitProxy.setProxy(BrowserApp.class.getName(), activity.getApplicationContext(), null, host, port);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(Constants.TAG, "error enabling web proxying", e);
|
Log.d(TAG, "error enabling web proxying", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -193,7 +196,7 @@ public class ProxyUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Constants.PROXY
|
@Constants.Proxy
|
||||||
public static int setProxyChoice(int choice, @NonNull Activity activity) {
|
public static int setProxyChoice(int choice, @NonNull Activity activity) {
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case Constants.PROXY_ORBOT:
|
case Constants.PROXY_ORBOT:
|
||||||
|
@ -80,7 +80,7 @@ public final class Utils {
|
|||||||
public void onGranted() {
|
public void onGranted() {
|
||||||
String fileName = URLUtil.guessFileName(url, null, null);
|
String fileName = URLUtil.guessFileName(url, null, null);
|
||||||
DownloadHandler.onDownloadStart(activity, manager, url, userAgent, contentDisposition, null);
|
DownloadHandler.onDownloadStart(activity, manager, url, userAgent, contentDisposition, null);
|
||||||
Log.i(Constants.TAG, "Downloading: " + fileName);
|
Log.i(TAG, "Downloading: " + fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -418,7 +418,7 @@ public final class Utils {
|
|||||||
if (TextUtils.isEmpty(item.getUrl())) {
|
if (TextUtils.isEmpty(item.getUrl())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.d(Constants.TAG, "Creating shortcut: " + item.getTitle() + ' ' + item.getUrl());
|
Log.d(TAG, "Creating shortcut: " + item.getTitle() + ' ' + item.getUrl());
|
||||||
Intent shortcutIntent = new Intent(activity, MainActivity.class);
|
Intent shortcutIntent = new Intent(activity, MainActivity.class);
|
||||||
shortcutIntent.setData(Uri.parse(item.getUrl()));
|
shortcutIntent.setData(Uri.parse(item.getUrl()));
|
||||||
|
|
||||||
|
@ -48,6 +48,8 @@ import acr.browser.lightning.utils.Utils;
|
|||||||
|
|
||||||
public class LightningWebClient extends WebViewClient {
|
public class LightningWebClient extends WebViewClient {
|
||||||
|
|
||||||
|
private static final String TAG = "LightningWebClient";
|
||||||
|
|
||||||
@NonNull private final Activity mActivity;
|
@NonNull private final Activity mActivity;
|
||||||
@NonNull private final LightningView mLightningView;
|
@NonNull private final LightningView mLightningView;
|
||||||
@NonNull private final UIController mUIController;
|
@NonNull private final UIController mUIController;
|
||||||
@ -149,7 +151,7 @@ public class LightningWebClient extends WebViewClient {
|
|||||||
String user = name.getText().toString();
|
String user = name.getText().toString();
|
||||||
String pass = password.getText().toString();
|
String pass = password.getText().toString();
|
||||||
handler.proceed(user.trim(), pass.trim());
|
handler.proceed(user.trim(), pass.trim());
|
||||||
Log.d(Constants.TAG, "Request Login");
|
Log.d(TAG, "Request Login");
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -364,7 +366,7 @@ public class LightningWebClient extends WebViewClient {
|
|||||||
try {
|
try {
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
Log.e(Constants.TAG, "ActivityNotFoundException");
|
Log.e(TAG, "ActivityNotFoundException");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user