package acr.browser.lightning.dialog; import android.app.Activity; import android.content.DialogInterface; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.StringRes; import android.support.v7.app.AlertDialog; import android.text.TextUtils; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.LinearLayout; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import acr.browser.lightning.utils.Utils; /** * Copyright 7/31/2016 Anthony Restaino *
* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class BrowserDialog { public interface Listener { void onClick(); } public interface EditorListener { void onClick(String text); } public static abstract class Item { private int mTitle; public Item(@StringRes int title) { mTitle = title; } @StringRes private int getTitle() { return mTitle; } public abstract void onClick(); } public static void show(@NonNull Activity activity, @NonNull Item item, @Nullable Item... items) { show(activity, null, item, items); } public static void show(@NonNull Activity activity, @StringRes int title, @NonNull Item item, @Nullable Item... items) { show(activity, activity.getString(title), item, items); } public static void show(@NonNull Activity activity, @Nullable String title, @NonNull Item item, @Nullable Item... items) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); ArrayAdapter