Browse Source

Preliminary fix for permissions, fixed a new crash, formatted some code

master
Anthony Restaino 9 years ago
parent
commit
99e4773e45
  1. 10
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 2
      app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java
  3. 15
      app/src/main/java/acr/browser/lightning/activity/TabsManager.java
  4. 13
      app/src/main/java/acr/browser/lightning/download/FetchUrlMimeType.java
  5. 32
      app/src/main/java/acr/browser/lightning/download/LightningDownloadListener.java
  6. 31
      app/src/main/java/acr/browser/lightning/fragment/BookmarkSettingsFragment.java
  7. 84
      app/src/main/java/acr/browser/lightning/utils/PermissionsManager.java
  8. 13
      app/src/main/java/acr/browser/lightning/utils/Utils.java
  9. 14
      app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java
  10. 6
      app/src/main/java/acr/browser/lightning/view/LightningView.java

10
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -11,14 +11,12 @@ import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.app.Activity; import android.app.Activity;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteException;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
@ -45,7 +43,6 @@ import android.support.v7.graphics.drawable.DrawerArrowDrawable;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -77,7 +74,6 @@ import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener; import android.widget.TextView.OnEditorActionListener;
@ -88,8 +84,6 @@ import com.squareup.otto.Subscribe;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
@ -109,7 +103,6 @@ import acr.browser.lightning.dialog.LightningDialogBuilder;
import acr.browser.lightning.fragment.BookmarksFragment; import acr.browser.lightning.fragment.BookmarksFragment;
import acr.browser.lightning.fragment.TabsFragment; import acr.browser.lightning.fragment.TabsFragment;
import acr.browser.lightning.object.SearchAdapter; import acr.browser.lightning.object.SearchAdapter;
import acr.browser.lightning.preference.PreferenceManager;
import acr.browser.lightning.receiver.NetworkReceiver; import acr.browser.lightning.receiver.NetworkReceiver;
import acr.browser.lightning.utils.PermissionsManager; import acr.browser.lightning.utils.PermissionsManager;
import acr.browser.lightning.utils.ProxyUtils; import acr.browser.lightning.utils.ProxyUtils;
@ -1848,6 +1841,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
// TODO Check if all the calls are relative to TabsFragement // TODO Check if all the calls are relative to TabsFragement
/** /**
* A utility method that creates a FrameLayout button with the given ID and * A utility method that creates a FrameLayout button with the given ID and
* sets the image of the button to the given image ID. The OnClick and OnLongClick * sets the image of the button to the given image ID. The OnClick and OnLongClick
@ -1894,7 +1888,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
*/ */
@Override @Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
PermissionsManager.getInstance().notifyPermissionsChange(permissions); PermissionsManager.getInstance().notifyPermissionsChange(permissions, grantResults);
super.onRequestPermissionsResult(requestCode, permissions, grantResults); super.onRequestPermissionsResult(requestCode, permissions, grantResults);
} }

2
app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java

@ -61,7 +61,7 @@ public class SettingsActivity extends ThemableSettingsActivity {
@Override @Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
PermissionsManager.getInstance().notifyPermissionsChange(permissions); PermissionsManager.getInstance().notifyPermissionsChange(permissions, grantResults);
super.onRequestPermissionsResult(requestCode, permissions, grantResults); super.onRequestPermissionsResult(requestCode, permissions, grantResults);
} }
} }

15
app/src/main/java/acr/browser/lightning/activity/TabsManager.java

@ -1,6 +1,5 @@
package acr.browser.lightning.activity; package acr.browser.lightning.activity;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.webkit.WebView; import android.webkit.WebView;
@ -11,7 +10,6 @@ import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import acr.browser.lightning.controller.BrowserController;
import acr.browser.lightning.preference.PreferenceManager; import acr.browser.lightning.preference.PreferenceManager;
import acr.browser.lightning.utils.Utils; import acr.browser.lightning.utils.Utils;
import acr.browser.lightning.view.LightningView; import acr.browser.lightning.view.LightningView;
@ -122,6 +120,7 @@ public class TabsManager {
} }
} }
} }
/** /**
* @return The number of currently opened tabs * @return The number of currently opened tabs
*/ */
@ -163,9 +162,10 @@ public class TabsManager {
} }
/** /**
* Return the position of the given tab * Return the position of the given tab.
* @param tab *
* @return * @param tab the tab to look for
* @return the position of the tab or -1 if the tab is not in the list
*/ */
public int positionOf(final LightningView tab) { public int positionOf(final LightningView tab) {
return mWebViewList.indexOf(tab); return mWebViewList.indexOf(tab);
@ -178,7 +178,7 @@ public class TabsManager {
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
for (LightningView tab : mWebViewList) { for (LightningView tab : mWebViewList) {
final String url = tab.getUrl(); final String url = tab.getUrl();
if (url != null && !url.isEmpty()) { if (!url.isEmpty()) {
builder.append(url).append("|$|SEPARATOR|$|"); builder.append(url).append("|$|SEPARATOR|$|");
} }
} }
@ -187,6 +187,7 @@ public class TabsManager {
/** /**
* Return the {@link WebView} associated to the current tab, or null if there is no current tab * Return the {@link WebView} associated to the current tab, or null if there is no current tab
*
* @return a {@link WebView} or null * @return a {@link WebView} or null
*/ */
@Nullable @Nullable
@ -196,8 +197,10 @@ public class TabsManager {
/** /**
* TODO We should remove also this, but probably not * TODO We should remove also this, but probably not
*
* @return * @return
*/ */
@Nullable
public LightningView getCurrentTab() { public LightningView getCurrentTab() {
return mCurrentTab; return mCurrentTab;
} }

13
app/src/main/java/acr/browser/lightning/download/FetchUrlMimeType.java

@ -6,6 +6,8 @@ package acr.browser.lightning.download;
import android.app.DownloadManager; import android.app.DownloadManager;
import android.content.Context; import android.content.Context;
import android.os.Environment; import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.webkit.MimeTypeMap; import android.webkit.MimeTypeMap;
import android.webkit.URLUtil; import android.webkit.URLUtil;
@ -53,7 +55,7 @@ class FetchUrlMimeType extends Thread {
public void run() { public void run() {
// User agent is likely to be null, though the AndroidHttpClient // User agent is likely to be null, though the AndroidHttpClient
// seems ok with that. // seems ok with that.
final Bus evenBus = BrowserApp.getAppComponent().getBus(); final Bus eventBus = BrowserApp.getAppComponent().getBus();
String mimeType = null; String mimeType = null;
String contentDisposition = null; String contentDisposition = null;
HttpURLConnection connection = null; HttpURLConnection connection = null;
@ -108,6 +110,13 @@ class FetchUrlMimeType extends Thread {
DownloadManager manager = (DownloadManager) mContext DownloadManager manager = (DownloadManager) mContext
.getSystemService(Context.DOWNLOAD_SERVICE); .getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(mRequest); manager.enqueue(mRequest);
evenBus.post(new BrowserEvents.ShowSnackBarMessage(mContext.getString(R.string.download_pending) + ' ' + filename)); Handler handler = new Handler(Looper.getMainLooper());
final String file = filename;
handler.post(new Runnable() {
@Override
public void run() {
eventBus.post(new BrowserEvents.ShowSnackBarMessage(mContext.getString(R.string.download_pending) + ' ' + file));
}
});
} }
} }

32
app/src/main/java/acr/browser/lightning/download/LightningDownloadListener.java

@ -3,7 +3,8 @@
*/ */
package acr.browser.lightning.download; package acr.browser.lightning.download;
import android.content.Context; import android.Manifest;
import android.app.Activity;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.util.Log; import android.util.Log;
@ -16,23 +17,26 @@ import acr.browser.lightning.utils.PermissionsManager;
public class LightningDownloadListener implements DownloadListener { public class LightningDownloadListener implements DownloadListener {
private final Context mContext; private final Activity mActivity;
public LightningDownloadListener(Context context) { public LightningDownloadListener(Activity context) {
mContext = context; mActivity = context;
} }
//TODO implement permissions for downloading
@Override @Override
public void onDownloadStart(final String url, final String userAgent, public void onDownloadStart(final String url, final String userAgent,
final String contentDisposition, final String mimetype, long contentLength) { final String contentDisposition, final String mimetype, long contentLength) {
PermissionsManager.getInstance().requestPermissionsIfNecessary(mActivity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE}, new PermissionsManager.PermissionResult() {
@Override
public void onGranted() {
String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype); String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
switch (which) { switch (which) {
case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_POSITIVE:
DownloadHandler.onDownloadStart(mContext, url, userAgent, DownloadHandler.onDownloadStart(mActivity, url, userAgent,
contentDisposition, mimetype); contentDisposition, mimetype);
break; break;
@ -42,14 +46,22 @@ public class LightningDownloadListener implements DownloadListener {
} }
}; };
AlertDialog.Builder builder = new AlertDialog.Builder(mContext); // dialog AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
builder.setTitle(fileName) builder.setTitle(fileName)
.setMessage(mContext.getResources().getString(R.string.dialog_download)) .setMessage(mActivity.getResources().getString(R.string.dialog_download))
.setPositiveButton(mContext.getResources().getString(R.string.action_download), .setPositiveButton(mActivity.getResources().getString(R.string.action_download),
dialogClickListener) dialogClickListener)
.setNegativeButton(mContext.getResources().getString(R.string.action_cancel), .setNegativeButton(mActivity.getResources().getString(R.string.action_cancel),
dialogClickListener).show(); dialogClickListener).show();
Log.i(Constants.TAG, "Downloading" + fileName); Log.i(Constants.TAG, "Downloading" + fileName);
}
@Override
public void onDenied(String permission) {
//TODO show message
}
});
} }
} }

31
app/src/main/java/acr/browser/lightning/fragment/BookmarkSettingsFragment.java

@ -88,7 +88,7 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
PermissionsManager permissionsManager = PermissionsManager.getInstance(); PermissionsManager permissionsManager = PermissionsManager.getInstance();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
permissionsManager.requestPermissionsIfNecessary(getActivity(), REQUIRED_PERMISSIONS); permissionsManager.requestPermissionsIfNecessary(getActivity(), REQUIRED_PERMISSIONS, null);
} }
} }
@ -124,15 +124,40 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
switch (preference.getKey()) { switch (preference.getKey()) {
case SETTINGS_EXPORT: case SETTINGS_EXPORT:
if (PermissionsManager.checkPermissions(getActivity(), REQUIRED_PERMISSIONS)) { // if (PermissionsManager.checkPermissions(getActivity(), REQUIRED_PERMISSIONS)) {
// mBookmarkManager.exportBookmarks(getActivity());
// }
PermissionsManager.getInstance().requestPermissionsIfNecessary(getActivity(), REQUIRED_PERMISSIONS,
new PermissionsManager.PermissionResult() {
@Override
public void onGranted() {
mBookmarkManager.exportBookmarks(getActivity()); mBookmarkManager.exportBookmarks(getActivity());
} }
@Override
public void onDenied(String permission) {
//TODO Show message
}
});
return true; return true;
case SETTINGS_IMPORT: case SETTINGS_IMPORT:
if (PermissionsManager.checkPermissions(getActivity(), REQUIRED_PERMISSIONS)) { // if (PermissionsManager.checkPermissions(getActivity(), REQUIRED_PERMISSIONS)) {
// loadFileList(null);
// createDialog();
// }
PermissionsManager.getInstance().requestPermissionsIfNecessary(getActivity(), REQUIRED_PERMISSIONS,
new PermissionsManager.PermissionResult() {
@Override
public void onGranted() {
loadFileList(null); loadFileList(null);
createDialog(); createDialog();
} }
@Override
public void onDenied(String permission) {
//TODO Show message
}
});
return true; return true;
case SETTINGS_IMPORT_BROWSER: case SETTINGS_IMPORT_BROWSER:
new ImportBookmarksTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new ImportBookmarksTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

84
app/src/main/java/acr/browser/lightning/utils/PermissionsManager.java

@ -4,8 +4,11 @@ import android.app.Activity;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Build; import android.os.Build;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -13,10 +16,11 @@ import java.util.Set;
/** /**
* Copyright 8/22/2015 Anthony Restaino * Copyright 8/22/2015 Anthony Restaino
*/ */
public class PermissionsManager { public final class PermissionsManager {
private static PermissionsManager mInstance; private static PermissionsManager mInstance;
private final Set<String> mPendingRequests = new HashSet<>(); private final Set<String> mPendingRequests = new HashSet<>();
private final List<PermissionResult> mPendingActions = new ArrayList<>();
public static PermissionsManager getInstance() { public static PermissionsManager getInstance() {
if (mInstance == null) { if (mInstance == null) {
@ -25,34 +29,47 @@ public class PermissionsManager {
return mInstance; return mInstance;
} }
public void requestPermissionsIfNecessary(Activity activity, @NonNull String[] permissions) { private void addPendingAction(@NonNull String[] permissions, @Nullable PermissionResult result) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || activity == null) { if (result == null) {
return;
}
result.addPermissions(permissions);
mPendingActions.add(result);
}
public void requestPermissionsIfNecessary(@Nullable Activity activity, @NonNull String[] permissions, @Nullable PermissionResult result) {
if (activity == null) {
return;
}
addPendingAction(permissions, result);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
for (String perm : permissions) {
if (result != null) {
result.onResult(perm, PackageManager.PERMISSION_GRANTED);
}
}
return; return;
} }
List<String> permList = new ArrayList<>(); List<String> permList = new ArrayList<>();
for (String perm : permissions) { for (String perm : permissions) {
if (activity.checkSelfPermission(perm) != PackageManager.PERMISSION_GRANTED if (ActivityCompat.checkSelfPermission(activity, perm) != PackageManager.PERMISSION_GRANTED) {
&& !mPendingRequests.contains(perm)) { if (!mPendingRequests.contains(perm)) {
permList.add(perm); permList.add(perm);
} }
} else {
if (result != null) {
result.onResult(perm, PackageManager.PERMISSION_GRANTED);
}
}
} }
if (!permList.isEmpty()) { if (!permList.isEmpty()) {
String[] permsToRequest = permList.toArray(new String[permList.size()]); String[] permsToRequest = permList.toArray(new String[permList.size()]);
mPendingRequests.addAll(permList); mPendingRequests.addAll(permList);
activity.requestPermissions(permsToRequest, 1); ActivityCompat.requestPermissions(activity, permsToRequest, 1);
} }
} }
public static boolean checkPermission(Activity activity, @NonNull String permission) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return true;
} else if (activity == null) {
return false;
}
return activity.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED;
}
public static boolean checkPermissions(Activity activity, @NonNull String[] permissions) { public static boolean checkPermissions(Activity activity, @NonNull String[] permissions) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return true; return true;
@ -66,9 +83,40 @@ public class PermissionsManager {
return permissionsNecessary; return permissionsNecessary;
} }
public void notifyPermissionsChange(String[] permissions) { public void notifyPermissionsChange(@NonNull String[] permissions, @NonNull int[] results) {
for (String perm : permissions) { int size = permissions.length;
mPendingRequests.remove(perm); if (results.length < size) {
size = results.length;
}
for (int n = 0; n < size; n++) {
for (PermissionResult result : mPendingActions) {
result.onResult(permissions[n], results[n]);
mPendingRequests.remove(permissions[n]);
}
}
}
public static abstract class PermissionResult {
private Set<String> mPermissions = new HashSet<>();
public abstract void onGranted();
public abstract void onDenied(String permission);
public void onResult(String permission, int result) {
if (result == PackageManager.PERMISSION_GRANTED) {
mPermissions.remove(permission);
if (mPermissions.isEmpty()) {
onGranted();
}
} else {
onDenied(permission);
}
}
public void addPermissions(@NonNull String[] perms) {
Collections.addAll(mPermissions, perms);
} }
} }

13
app/src/main/java/acr/browser/lightning/utils/Utils.java

@ -3,6 +3,7 @@
*/ */
package acr.browser.lightning.utils; package acr.browser.lightning.utils;
import android.Manifest;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
@ -44,12 +45,24 @@ public final class Utils {
public static void downloadFile(final Activity activity, final String url, public static void downloadFile(final Activity activity, final String url,
final String userAgent, final String contentDisposition) { final String userAgent, final String contentDisposition) {
PermissionsManager.getInstance().requestPermissionsIfNecessary(activity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE}, new PermissionsManager.PermissionResult() {
@Override
public void onGranted() {
String fileName = URLUtil.guessFileName(url, null, null); String fileName = URLUtil.guessFileName(url, null, null);
DownloadHandler.onDownloadStart(activity, url, userAgent, contentDisposition, null DownloadHandler.onDownloadStart(activity, url, userAgent, contentDisposition, null
); );
Log.i(Constants.TAG, "Downloading" + fileName); Log.i(Constants.TAG, "Downloading" + fileName);
} }
@Override
public void onDenied(String permission) {
// TODO Show Message
}
});
}
public static Intent newEmailIntent(String address, String subject, public static Intent newEmailIntent(String address, String subject,
String body, String cc) { String body, String cc) {
Intent intent = new Intent(Intent.ACTION_SEND); Intent intent = new Intent(Intent.ACTION_SEND);

14
app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java

@ -61,12 +61,14 @@ class LightningChromeClient extends WebChromeClient {
if (icon == null) if (icon == null)
return; return;
mLightningView.mTitle.setFavicon(icon); mLightningView.mTitle.setFavicon(icon);
eventBus.post(new BrowserEvents.TabsChanged()); ; eventBus.post(new BrowserEvents.TabsChanged());
;
cacheFavicon(view.getUrl(), icon); cacheFavicon(view.getUrl(), icon);
} }
/** /**
* Naive caching of the favicon according to the domain name of the URL * Naive caching of the favicon according to the domain name of the URL
*
* @param icon the icon to cache * @param icon the icon to cache
*/ */
private void cacheFavicon(final String url, final Bitmap icon) { private void cacheFavicon(final String url, final Bitmap icon) {
@ -112,7 +114,9 @@ class LightningChromeClient extends WebChromeClient {
@Override @Override
public void onGeolocationPermissionsShowPrompt(final String origin, public void onGeolocationPermissionsShowPrompt(final String origin,
final GeolocationPermissions.Callback callback) { final GeolocationPermissions.Callback callback) {
PermissionsManager.getInstance().requestPermissionsIfNecessary(mActivity, PERMISSIONS); PermissionsManager.getInstance().requestPermissionsIfNecessary(mActivity, PERMISSIONS, new PermissionsManager.PermissionResult() {
@Override
public void onGranted() {
final boolean remember = true; final boolean remember = true;
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
builder.setTitle(mActivity.getString(R.string.location)); builder.setTitle(mActivity.getString(R.string.location));
@ -140,7 +144,13 @@ class LightningChromeClient extends WebChromeClient {
}); });
AlertDialog alert = builder.create(); AlertDialog alert = builder.create();
alert.show(); alert.show();
}
@Override
public void onDenied(String permission) {
//TODO show message and/or turn off setting
}
});
} }
@Override @Override

6
app/src/main/java/acr/browser/lightning/view/LightningView.java

@ -39,6 +39,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -198,9 +199,6 @@ public class LightningView {
if (!mIsIncognitoTab) { if (!mIsIncognitoTab) {
settings.setGeolocationEnabled(mPreferences.getLocationEnabled()); settings.setGeolocationEnabled(mPreferences.getLocationEnabled());
if (mPreferences.getLocationEnabled() && !PermissionsManager.checkPermissions(mActivity, PERMISSIONS)) {
mPermissionsManager.requestPermissionsIfNecessary(mActivity, PERMISSIONS);
}
} else { } else {
settings.setGeolocationEnabled(false); settings.setGeolocationEnabled(false);
} }
@ -527,6 +525,7 @@ public class LightningView {
/** /**
* Naive caching of the favicon according to the domain name of the URL * Naive caching of the favicon according to the domain name of the URL
*
* @param icon the icon to cache * @param icon the icon to cache
*/ */
private void cacheFavicon(final Bitmap icon) { private void cacheFavicon(final Bitmap icon) {
@ -591,6 +590,7 @@ public class LightningView {
public boolean getInvertePage() { public boolean getInvertePage() {
return mInvertPage; return mInvertPage;
} }
/** /**
* handles a long click on the page, parameter String url * handles a long click on the page, parameter String url
* is the url that should have been obtained from the WebView touch node * is the url that should have been obtained from the WebView touch node

Loading…
Cancel
Save