зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1182514 - Add Lightweight theme for restricted profiles. r=margaret
--HG-- extra : commitid : 5oxYhEqVgGY extra : amend_source : 8caa50a3d30dc2e377611d87f906a08d85e71d30
This commit is contained in:
Родитель
f5ac77c078
Коммит
70f4d0f828
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 2.8 KiB |
|
@ -5,6 +5,8 @@
|
|||
|
||||
package org.mozilla.gecko.lwt;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -21,6 +23,7 @@ import org.mozilla.gecko.util.ThreadUtils.AssertBehavior;
|
|||
import android.app.Application;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
|
@ -40,6 +43,8 @@ public class LightweightTheme implements GeckoEventListener {
|
|||
private static final String PREFS_URL = "lightweightTheme.headerURL";
|
||||
private static final String PREFS_COLOR = "lightweightTheme.color";
|
||||
|
||||
private static final String ASSETS_PREFIX = "resource://android/assets/";
|
||||
|
||||
private final Application mApplication;
|
||||
|
||||
private Bitmap mBitmap;
|
||||
|
@ -119,8 +124,31 @@ public class LightweightTheme implements GeckoEventListener {
|
|||
croppedURL = croppedURL.substring(0, mark);
|
||||
}
|
||||
|
||||
// Get the image and convert it to a bitmap.
|
||||
final Bitmap bitmap = BitmapUtils.decodeUrl(croppedURL);
|
||||
if (croppedURL.startsWith(ASSETS_PREFIX)) {
|
||||
onBitmapLoaded(loadFromAssets(croppedURL));
|
||||
} else {
|
||||
onBitmapLoaded(BitmapUtils.decodeUrl(croppedURL));
|
||||
}
|
||||
}
|
||||
|
||||
private Bitmap loadFromAssets(String url) {
|
||||
InputStream stream = null;
|
||||
|
||||
try {
|
||||
stream = mApplication.getAssets().open(url.substring(ASSETS_PREFIX.length()));
|
||||
return BitmapFactory.decodeStream(stream);
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
} finally {
|
||||
if (stream != null) {
|
||||
try {
|
||||
stream.close();
|
||||
} catch (IOException e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onBitmapLoaded(final Bitmap bitmap) {
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
@ -3083,6 +3083,10 @@ var LightWeightThemeWebInstaller = {
|
|||
BrowserApp.deck.addEventListener("InstallBrowserTheme", this, false, true);
|
||||
BrowserApp.deck.addEventListener("PreviewBrowserTheme", this, false, true);
|
||||
BrowserApp.deck.addEventListener("ResetBrowserThemePreview", this, false, true);
|
||||
|
||||
if (ParentalControls.parentalControlsEnabled && !this._manager.currentTheme) {
|
||||
this._installParentalControlsTheme();
|
||||
}
|
||||
},
|
||||
|
||||
handleEvent: function (event) {
|
||||
|
@ -3119,6 +3123,18 @@ var LightWeightThemeWebInstaller = {
|
|||
return this._manager = temp.LightweightThemeManager;
|
||||
},
|
||||
|
||||
_installParentalControlsTheme: function() {
|
||||
let mgr = this._manager;
|
||||
let parentalControlsTheme = {
|
||||
"headerURL": "resource://android/assets/parental_controls_theme.png",
|
||||
"name": "Parental Controls Theme",
|
||||
"id": "parental-controls-theme@mozilla.org"
|
||||
};
|
||||
|
||||
mgr.addBuiltInTheme(parentalControlsTheme);
|
||||
mgr.themeChanged(parentalControlsTheme);
|
||||
},
|
||||
|
||||
_installRequest: function (event) {
|
||||
let node = event.target;
|
||||
let data = this._getThemeFromNode(node);
|
||||
|
|
Загрузка…
Ссылка в новой задаче