Search in sources :

Example 21 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project CameraKit-Android by flurgle.

the class MainActivity method onMenuItemClick.

@Override
public boolean onMenuItemClick(MenuItem item) {
    if (item.getItemId() == R.id.main_menu_about) {
        AlertDialog dialog = new AlertDialog.Builder(MainActivity.this).setTitle(R.string.about_dialog_title).setMessage(R.string.about_dialog_message).setNeutralButton("Dismiss", null).show();
        dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(Color.parseColor("#91B8CC"));
        dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setText(Html.fromHtml("<b>Dismiss</b>"));
        return true;
    }
    if (item.getItemId() == R.id.main_menu_gallery) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
        startActivity(intent);
        return true;
    }
    return false;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Intent(android.content.Intent)

Example 22 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project AntennaPod by AntennaPod.

the class RenameItemDialog method show.

public void show() {
    Activity activity = activityRef.get();
    if (activity == null) {
        return;
    }
    View content = View.inflate(activity, R.layout.edit_text_dialog, null);
    EditTextDialogBinding alertViewBinding = EditTextDialogBinding.bind(content);
    String title = feed != null ? feed.getTitle() : drawerItem.getTitle();
    alertViewBinding.urlEditText.setText(title);
    AlertDialog dialog = new AlertDialog.Builder(activity).setView(content).setTitle(feed != null ? R.string.rename_feed_label : R.string.rename_tag_label).setPositiveButton(android.R.string.ok, (d, input) -> {
        String newTitle = alertViewBinding.urlEditText.getText().toString();
        if (feed != null) {
            feed.setCustomTitle(newTitle);
            DBWriter.setFeedCustomTitle(feed);
        } else {
            renameTag(newTitle);
        }
    }).setNeutralButton(de.danoeh.antennapod.core.R.string.reset, null).setNegativeButton(de.danoeh.antennapod.core.R.string.cancel_label, null).show();
    // To prevent cancelling the dialog on button click
    dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener((view) -> alertViewBinding.urlEditText.setText(title));
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) List(java.util.List) NavDrawerData(de.danoeh.antennapod.core.storage.NavDrawerData) FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) AlertDialog(androidx.appcompat.app.AlertDialog) DBWriter(de.danoeh.antennapod.core.storage.DBWriter) R(de.danoeh.antennapod.R) View(android.view.View) EditTextDialogBinding(de.danoeh.antennapod.databinding.EditTextDialogBinding) WeakReference(java.lang.ref.WeakReference) Activity(android.app.Activity) Feed(de.danoeh.antennapod.model.feed.Feed) ArrayList(java.util.ArrayList) Activity(android.app.Activity) View(android.view.View) EditTextDialogBinding(de.danoeh.antennapod.databinding.EditTextDialogBinding)

Example 23 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project AntennaPod by AntennaPod.

the class ChooseDataFolderDialog method showDialog.

public static void showDialog(final Context context, Consumer<String> handlerFunc) {
    View content = View.inflate(context, R.layout.choose_data_folder_dialog, null);
    AlertDialog dialog = new AlertDialog.Builder(context).setView(content).setTitle(R.string.choose_data_directory).setMessage(R.string.choose_data_directory_message).setNegativeButton(R.string.cancel_label, null).create();
    ((RecyclerView) content.findViewById(R.id.recyclerView)).setLayoutManager(new LinearLayoutManager(context));
    DataFolderAdapter adapter = new DataFolderAdapter(context, path -> {
        dialog.dismiss();
        handlerFunc.accept(path);
    });
    ((RecyclerView) content.findViewById(R.id.recyclerView)).setAdapter(adapter);
    if (adapter.getItemCount() > 0) {
        dialog.show();
    } else {
        new AlertDialog.Builder(context).setTitle(R.string.error_label).setMessage(R.string.external_storage_error_msg).setPositiveButton(android.R.string.ok, null).show();
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) DataFolderAdapter(de.danoeh.antennapod.adapter.DataFolderAdapter)

Example 24 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project kcanotify by antest1.

the class UpdateCheckActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_rescheck);
    Intent intent = this.getIntent();
    if (intent != null && intent.getExtras() != null) {
        main_flag = intent.getExtras().getBoolean("main_flag", false);
    }
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(getResources().getString(R.string.setting_menu_kand_title_game_data_down));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
    KcaApiData.setDBHelper(dbHelper);
    downloader = KcaUtils.getInfoDownloader(getApplicationContext());
    FetchConfiguration fetchConfiguration = new FetchConfiguration.Builder(getApplicationContext()).setDownloadConcurrentLimit(80).build();
    fetch = Fetch.Impl.getInstance(fetchConfiguration);
    handler = new UpdateHandler(this);
    gamedata_adapter.setHandler(handler);
    resource_adapter.setHandler(handler);
    checkstart_chkbox = findViewById(R.id.reschk_checkatstart);
    checkstart_chkbox.setText(getStringWithLocale(R.string.download_setting_checkatstart));
    checkstart_chkbox.setChecked(getBooleanPreferences(getApplicationContext(), PREF_CHECK_UPDATE_START));
    checkstart_chkbox.setOnCheckedChangeListener((buttonView, isChecked) -> setPreferences(getApplicationContext(), PREF_CHECK_UPDATE_START, isChecked));
    localonly_chkbox = findViewById(R.id.reschk_local);
    localonly_chkbox.setText(getStringWithLocale(R.string.download_use_internal_data));
    localonly_chkbox.setChecked(getBooleanPreferences(getApplicationContext(), PREF_RES_USELOCAL));
    localonly_chkbox.setOnCheckedChangeListener((buttonView, isChecked) -> setPreferences(getApplicationContext(), PREF_RES_USELOCAL, isChecked));
    resource_reset = findViewById(R.id.reschk_reset);
    resource_reset.setText(getStringWithLocale(R.string.download_reset));
    resource_reset.setOnCheckedChangeListener((buttonView, isChecked) -> {
        if (isChecked) {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(UpdateCheckActivity.this);
            alertDialog.setMessage(getString(R.string.download_reset_message));
            alertDialog.setPositiveButton(getStringWithLocale(R.string.dialog_ok), (dialog, which) -> {
                dbHelper.clearResVer();
                setPreferences(getApplicationContext(), PREF_KCARESOURCE_VERSION, 0);
                Intent mainIntent = new Intent(this, InitStartActivity.class);
                mainIntent.putExtra(ACTION_RESET, true);
                startActivity(mainIntent);
                finish();
            });
            alertDialog.setNegativeButton(getStringWithLocale(R.string.dialog_cancel), (dialog, which) -> {
                resource_reset.setChecked(false);
                dialog.dismiss();
            });
            AlertDialog alert = alertDialog.create();
            alert.setIcon(R.mipmap.ic_launcher);
            alert.show();
        }
    });
    data_list = findViewById(R.id.gamedata_list);
    resource_list = findViewById(R.id.resources_list);
    data_list.setAdapter(gamedata_adapter);
    resource_list.setAdapter(resource_adapter);
    gamedata_load = findViewById(R.id.gamedata_loading);
    resource_load = findViewById(R.id.resources_loading);
    gamedata_chk = findViewById(R.id.gamedata_updatecheck);
    resource_chk = findViewById(R.id.resources_updatecheck);
    resource_downall = findViewById(R.id.resources_downloadall);
    gamedata_chk.setOnClickListener(v -> checkVersionUpdate());
    resource_chk.setOnClickListener(v -> checkResourceUpdate());
    resource_downall.setOnClickListener(v -> downloadAllResources());
    resource_downall.setVisibility(View.GONE);
    gamedata_server = findViewById(R.id.gamedata_server);
    gamedata_server.setText(getStringWithLocale(R.string.action_server));
    gamedata_server.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final int initValue = checked;
            String[] listItems = getResources().getStringArray(R.array.ServerLocation);
            String[] listEntry = getResources().getStringArray(R.array.ServerLocationValue);
            AlertDialog.Builder mBuilder = new AlertDialog.Builder(UpdateCheckActivity.this);
            mBuilder.setTitle(getStringWithLocale(R.string.setting_menu_app_title_updatecheckserver));
            String currentServer = getStringPreferences(getApplicationContext(), PREF_UPDATE_SERVER);
            for (int i = 0; i < listEntry.length; i++) if (currentServer.equals(listEntry[i])) {
                checked = i;
                break;
            }
            mBuilder.setSingleChoiceItems(listItems, checked, (dialog, which) -> {
                checked = which;
            });
            mBuilder.setPositiveButton(getStringWithLocale(R.string.dialog_ok), (dialog, which) -> {
                Log.e("KCA", "selected: " + checked);
                if (checked != -1) {
                    String selectedServer = listEntry[checked];
                    setPreferences(getApplicationContext(), PREF_UPDATE_SERVER, selectedServer);
                }
            });
            mBuilder.setNegativeButton(getStringWithLocale(R.string.dialog_cancel), ((dialog, which) -> {
                checked = initValue;
            }));
            AlertDialog mDialog = mBuilder.create();
            mDialog.show();
        }
    });
    checkVersionUpdate();
    checkResourceUpdate();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) JsonObject(com.google.gson.JsonObject) Bundle(android.os.Bundle) TypeToken(com.google.gson.reflect.TypeToken) NonNull(androidx.annotation.NonNull) FetchListener(com.tonyodev.fetch2.FetchListener) PREF_KCARESOURCE_VERSION(com.antest1.kcanotify.KcaConstants.PREF_KCARESOURCE_VERSION) PREF_RES_USELOCAL(com.antest1.kcanotify.KcaConstants.PREF_RES_USELOCAL) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) CheckBox(android.widget.CheckBox) Gson(com.google.gson.Gson) Locale(java.util.Locale) DB_KEY_STARTDATA(com.antest1.kcanotify.KcaConstants.DB_KEY_STARTDATA) Handler(android.os.Handler) View(android.view.View) PREF_CHECK_UPDATE_START(com.antest1.kcanotify.KcaConstants.PREF_CHECK_UPDATE_START) ERROR_TYPE_SETTING(com.antest1.kcanotify.KcaConstants.ERROR_TYPE_SETTING) Log(android.util.Log) AsyncTask(android.os.AsyncTask) KcaApiData.loadTranslationData(com.antest1.kcanotify.KcaApiData.loadTranslationData) KcaUtils.getStringPreferences(com.antest1.kcanotify.KcaUtils.getStringPreferences) FetchConfiguration(com.tonyodev.fetch2.FetchConfiguration) JsonArray(com.google.gson.JsonArray) List(java.util.List) KcaUtils.getStringFromException(com.antest1.kcanotify.KcaUtils.getStringFromException) TextView(android.widget.TextView) Message(android.os.Message) Type(java.lang.reflect.Type) KcaUtils.compareVersion(com.antest1.kcanotify.KcaUtils.compareVersion) Toolbar(androidx.appcompat.widget.Toolbar) ListView(android.widget.ListView) Download(com.tonyodev.fetch2.Download) NotNull(org.jetbrains.annotations.NotNull) Call(retrofit2.Call) KcaUtils.getBooleanPreferences(com.antest1.kcanotify.KcaUtils.getBooleanPreferences) Fetch(com.tonyodev.fetch2.Fetch) Context(android.content.Context) AlertDialog(androidx.appcompat.app.AlertDialog) Intent(android.content.Intent) KCANOTIFY_DB_VERSION(com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION) Response(retrofit2.Response) JsonParser(com.google.gson.JsonParser) ACTION_RESET(com.antest1.kcanotify.InitStartActivity.ACTION_RESET) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) PREF_UPDATE_SERVER(com.antest1.kcanotify.KcaConstants.PREF_UPDATE_SERVER) Toast(android.widget.Toast) PREF_KCA_LANGUAGE(com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE) PREF_KCA_DATA_VERSION(com.antest1.kcanotify.KcaConstants.PREF_KCA_DATA_VERSION) ContextWrapper(android.content.ContextWrapper) Build(android.os.Build) WeakReference(java.lang.ref.WeakReference) PREF_KCA_VERSION(com.antest1.kcanotify.KcaConstants.PREF_KCA_VERSION) RESCHK_KEY(com.antest1.kcanotify.KcaResCheckItemAdpater.RESCHK_KEY) ProgressDialog(android.app.ProgressDialog) File(java.io.File) PREF_FAIRY_DOWN_FLAG(com.antest1.kcanotify.KcaConstants.PREF_FAIRY_DOWN_FLAG) Callback(retrofit2.Callback) Configuration(android.content.res.Configuration) KcaUtils.setPreferences(com.antest1.kcanotify.KcaUtils.setPreferences) Request(com.tonyodev.fetch2.Request) Activity(android.app.Activity) Intent(android.content.Intent) FetchConfiguration(com.tonyodev.fetch2.FetchConfiguration) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 25 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project kcanotify by antest1.

the class InitStartActivity method dataCheck.

private void dataCheck(JsonObject response_data) {
    boolean latest_flag = true;
    List<String> update_text = new ArrayList<>();
    String currentDataVersion = getStringPreferences(getApplicationContext(), PREF_KCA_DATA_VERSION);
    int currentKcaResVersion = dbHelper.getTotalResVer();
    if (response_data.has("data_version")) {
        String recentVersion = response_data.get("data_version").getAsString();
        latest_flag = compareVersion(currentDataVersion, recentVersion);
    }
    if (response_data.has("kcadata_version")) {
        new_resversion = response_data.get("kcadata_version").getAsInt();
        latest_flag = latest_flag && new_resversion <= currentKcaResVersion;
    }
    setPreferences(getApplicationContext(), PREF_LAST_UPDATE_CHECK, String.valueOf(System.currentTimeMillis()));
    if (latest_flag) {
        startMainActivity(true);
    } else {
        String message = getStringWithLocale(R.string.download_description_head);
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(InitStartActivity.this);
        alertDialog.setTitle(getStringWithLocale(R.string.download_title));
        alertDialog.setMessage(message.trim());
        alertDialog.setCancelable(false);
        alertDialog.setPositiveButton(getStringWithLocale(R.string.dialog_ok), (dialog, which) -> {
            startUpdateActivity();
        });
        alertDialog.setNegativeButton(getStringWithLocale(R.string.dialog_cancel), (dialog, which) -> {
            startMainActivity(true);
        });
        handler.post(() -> {
            if (!is_destroyed && !InitStartActivity.this.isFinishing()) {
                AlertDialog alert = alertDialog.create();
                alert.setIcon(R.mipmap.ic_launcher);
                alert.show();
            }
        });
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint)

Aggregations

AlertDialog (androidx.appcompat.app.AlertDialog)261 Test (org.junit.Test)89 View (android.view.View)49 DialogInterface (android.content.DialogInterface)42 TextView (android.widget.TextView)40 Button (android.widget.Button)39 Intent (android.content.Intent)30 ShadowAlertDialogCompat (com.android.settings.testutils.shadow.ShadowAlertDialogCompat)30 NonNull (androidx.annotation.NonNull)28 Context (android.content.Context)26 Bundle (android.os.Bundle)20 EditText (android.widget.EditText)18 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)18 SuppressLint (android.annotation.SuppressLint)17 ArrayList (java.util.ArrayList)17 List (java.util.List)12 Activity (android.app.Activity)11 Uri (android.net.Uri)11 LayoutInflater (android.view.LayoutInflater)11 ListView (android.widget.ListView)10