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.presets;
19 import android.os.Bundle;
20 import androidx.fragment.app.DialogFragment;
21 import android.view.LayoutInflater;
22 import android.view.View;
23 import android.view.ViewGroup;
24 import android.widget.EditText;
25 import android.widget.ImageView;
26 import android.widget.ListView;
27 import com.android.gallery3d.R;
28 import com.android.gallery3d.filtershow.FilterShowActivity;
30 public class PresetManagementDialog extends DialogFragment implements View.OnClickListener {
31 private UserPresetsAdapter mAdapter;
32 private EditText mEditText;
35 public View onCreateView(LayoutInflater inflater, ViewGroup container,
36 Bundle savedInstanceState) {
37 View view = inflater.inflate(R.layout.filtershow_presets_management_dialog, container);
39 FilterShowActivity activity = (FilterShowActivity) getActivity();
40 mAdapter = activity.getUserPresetsAdapter();
41 mEditText = (EditText) view.findViewById(R.id.editView);
42 view.findViewById(R.id.cancel).setOnClickListener(this);
43 view.findViewById(R.id.ok).setOnClickListener(this);
44 getDialog().setTitle(getString(R.string.filtershow_save_preset));
49 public void onClick(View v) {
50 FilterShowActivity activity = (FilterShowActivity) getActivity();
53 mAdapter.clearChangedRepresentations();
54 mAdapter.clearDeletedRepresentations();
55 activity.updateUserPresetsFromAdapter(mAdapter);
59 String text = String.valueOf(mEditText.getText());
60 activity.saveCurrentImagePreset(text);
61 mAdapter.updateCurrent();
62 activity.updateUserPresetsFromAdapter(mAdapter);