summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/Controller.java
diff options
context:
space:
mode:
authorDave Tharp <dtharp@codeaurora.org>2015-06-19 08:46:57 -0700
committerjrizzoli <joey@cyanogenmoditalia.it>2015-08-28 13:15:45 +0200
commit9a082b13f1011a40d3dea942fa8ad3d40ed41971 (patch)
tree08d48b2ceab57e4df09e108f38e619e1d5eeaa01 /src/com/android/browser/Controller.java
parent490ca7fb96367bd8444698b59a5d0fe17f1a90d1 (diff)
downloadandroid_packages_apps_Gello-9a082b13f1011a40d3dea942fa8ad3d40ed41971.tar.gz
android_packages_apps_Gello-9a082b13f1011a40d3dea942fa8ad3d40ed41971.tar.bz2
android_packages_apps_Gello-9a082b13f1011a40d3dea942fa8ad3d40ed41971.zip
MDM Edit Bookmark Restriction
When enabled through the MDM mechanism, Bookmark editing operations are disabled: - Edit and Delete pop-up menu options are disabled - The 'Add Bookmark' and 'New Folder' buttons are greyed and if pressed a Toast message is displayed: 'Managed by your administrator' - All existing bookmark items (except the MDM Managed tree if it is present) are overlaid with a lock icon (existing: ic_deco_secure). - The 'Star' icon is greyed and if pressed results in the above Toast message New files are the core implementation of the EditBookmarksRestriction and the tests for it: EditBookmarksRestriction.java EditBookmarkRestrictionsTest.java Note the has been some refactoring in BrowserBookmarksAdapter.java to simplify the handling of bitmaps with regard to overlay operations. We now always set the bitmaps with setImageBitmap() instead of sometimes using setImageResource(). This simplifies the code considerably but does result in a side effect: Folder icons look a bit different now because they are translated and scaled the same way as bookmark bitmaps. So instead of center-crop, they appear as if they are scaled width-wise and top-aligned. Personally, I like the look, but if its not acceptable, I'll adjust it as needed. Change-Id: I966f84485873593ca70f2822cdace30a15464c44
Diffstat (limited to 'src/com/android/browser/Controller.java')
-rw-r--r--src/com/android/browser/Controller.java39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 99a40fef..2f8db527 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -98,6 +98,7 @@ import com.android.browser.AppAdapter;
import com.android.browser.R;
import com.android.browser.IntentHandler.UrlData;
import com.android.browser.UI.ComboViews;
+import com.android.browser.mdm.EditBookmarksRestriction;
import com.android.browser.mdm.IncognitoRestriction;
import com.android.browser.mdm.URLFilterRestriction;
import com.android.browser.mynavigation.AddMyNavigationPage;
@@ -1933,8 +1934,9 @@ public class Controller
mUi.onPrepareOptionsMenu(menu);
IncognitoRestriction.getInstance()
- .registerControl(menu.findItem(R.id.incognito_menu_id)
- .getIcon());
+ .registerControl(menu.findItem(R.id.incognito_menu_id).getIcon());
+ EditBookmarksRestriction.getInstance()
+ .registerControl(menu.findItem(R.id.bookmark_this_page_id).getIcon());
}
private void setMenuItemVisibility(Menu menu, int id,
@@ -2347,20 +2349,25 @@ public class Controller
@Override
public void bookmarkCurrentPage() {
- WebView w = getCurrentTopWebView();
- if (w == null)
- return;
- final Intent i = createBookmarkCurrentPageIntent(false);
- createScreenshotAsync(
- w, getDesiredThumbnailWidth(mActivity),
- getDesiredThumbnailHeight(mActivity),
- new ValueCallback<Bitmap>() {
- @Override
- public void onReceiveValue(Bitmap bitmap) {
- mBookmarkBitmap = bitmap;
- mActivity.startActivity(i);
- }
- });
+ if(EditBookmarksRestriction.getInstance().isEnabled()) {
+ Toast.makeText(getContext(), R.string.mdm_managed_alert, Toast.LENGTH_SHORT).show();
+ }
+ else {
+ WebView w = getCurrentTopWebView();
+ if (w == null)
+ return;
+ final Intent i = createBookmarkCurrentPageIntent(false);
+ createScreenshotAsync(
+ w, getDesiredThumbnailWidth(mActivity),
+ getDesiredThumbnailHeight(mActivity),
+ new ValueCallback<Bitmap>() {
+ @Override
+ public void onReceiveValue(Bitmap bitmap) {
+ mBookmarkBitmap = bitmap;
+ mActivity.startActivity(i);
+ }
+ });
+ }
}
private void goLive() {