2 * Copyright (C) 2013 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.gallery3d.filtershow.filters;
19 import android.content.Context;
20 import android.content.res.Resources;
21 import android.graphics.Color;
23 import com.android.gallery3d.R;
25 public class FiltersManager extends BaseFiltersManager {
26 private static FiltersManager sInstance = null;
27 private static FiltersManager sPreviewInstance = null;
28 private static FiltersManager sHighresInstance = null;
29 private static int mImageBorderSize = 4; // in percent
30 public FiltersManager() {
34 public static FiltersManager getPreviewManager() {
35 if (sPreviewInstance == null) {
36 sPreviewInstance = new FiltersManager();
38 return sPreviewInstance;
41 public static FiltersManager getManager() {
42 if (sInstance == null) {
43 sInstance = new FiltersManager();
49 public void addBorders(Context context) {
52 String[] serializationNames = {
59 "FRAME_BLACK_ROUNDED",
61 "FRAME_WHITE_ROUNDED",
66 // The "no border" implementation
68 FilterRepresentation rep = new FilterImageBorderRepresentation(0);
72 rep = new FilterImageBorderRepresentation(R.drawable.filtershow_border_4x5);
73 rep.setSerializationName(serializationNames[i++]);
76 rep = new FilterImageBorderRepresentation(R.drawable.filtershow_border_brush);
77 rep.setSerializationName(serializationNames[i++]);
80 rep = new FilterImageBorderRepresentation(R.drawable.filtershow_border_grunge);
81 rep.setSerializationName(serializationNames[i++]);
84 rep = new FilterImageBorderRepresentation(R.drawable.filtershow_border_sumi_e);
85 rep.setSerializationName(serializationNames[i++]);
88 rep = new FilterImageBorderRepresentation(R.drawable.filtershow_border_tape);
89 rep.setSerializationName(serializationNames[i++]);
92 rep = new FilterColorBorderRepresentation(Color.BLACK, mImageBorderSize, 0);
93 rep.setSerializationName(serializationNames[i++]);
96 rep = new FilterColorBorderRepresentation(Color.BLACK, mImageBorderSize,
98 rep.setSerializationName(serializationNames[i++]);
101 rep = new FilterColorBorderRepresentation(Color.WHITE, mImageBorderSize, 0);
102 rep.setSerializationName(serializationNames[i++]);
105 rep = new FilterColorBorderRepresentation(Color.WHITE, mImageBorderSize,
107 rep.setSerializationName(serializationNames[i++]);
110 int creamColor = Color.argb(255, 237, 237, 227);
111 rep = new FilterColorBorderRepresentation(creamColor, mImageBorderSize, 0);
112 rep.setSerializationName(serializationNames[i++]);
115 rep = new FilterColorBorderRepresentation(creamColor, mImageBorderSize,
117 rep.setSerializationName(serializationNames[i++]);
121 public static FiltersManager getHighresManager() {
122 if (sHighresInstance == null) {
123 sHighresInstance = new FiltersManager();
125 return sHighresInstance;
128 public static void reset() {
130 sPreviewInstance = null;
131 sHighresInstance = null;
134 public static void setResources(Resources resources) {
135 FiltersManager.getManager().setFilterResources(resources);
136 FiltersManager.getPreviewManager().setFilterResources(resources);
137 FiltersManager.getHighresManager().setFilterResources(resources);