Search in sources :

Example 6 with Builder

use of android.support.v7.app.AlertDialog.Builder in project Signal-Android by WhisperSystems.

the class ConversationFragment method handleDeleteMessages.

private void handleDeleteMessages(final Set<MessageRecord> messageRecords) {
    int messagesCount = messageRecords.size();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setIconAttribute(R.attr.dialog_alert_icon);
    builder.setTitle(getActivity().getResources().getQuantityString(R.plurals.ConversationFragment_delete_selected_messages, messagesCount, messagesCount));
    builder.setMessage(getActivity().getResources().getQuantityString(R.plurals.ConversationFragment_this_will_permanently_delete_all_n_selected_messages, messagesCount, messagesCount));
    builder.setCancelable(true);
    builder.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            new ProgressDialogAsyncTask<MessageRecord, Void, Void>(getActivity(), R.string.ConversationFragment_deleting, R.string.ConversationFragment_deleting_messages) {

                @Override
                protected Void doInBackground(MessageRecord... messageRecords) {
                    for (MessageRecord messageRecord : messageRecords) {
                        boolean threadDeleted;
                        if (messageRecord.isMms()) {
                            threadDeleted = DatabaseFactory.getMmsDatabase(getActivity()).delete(messageRecord.getId());
                        } else {
                            threadDeleted = DatabaseFactory.getSmsDatabase(getActivity()).deleteMessage(messageRecord.getId());
                        }
                        if (threadDeleted) {
                            threadId = -1;
                            listener.setThreadId(threadId);
                        }
                    }
                    return null;
                }
            }.execute(messageRecords.toArray(new MessageRecord[messageRecords.size()]));
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    builder.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) MessageRecord(org.thoughtcrime.securesms.database.model.MessageRecord) MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) ProgressDialogAsyncTask(org.thoughtcrime.securesms.util.task.ProgressDialogAsyncTask)

Example 7 with Builder

use of android.support.v7.app.AlertDialog.Builder in project Signal-Android by WhisperSystems.

the class ImportExportFragment method handleImportSms.

private void handleImportSms() {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setIconAttribute(R.attr.dialog_info_icon);
    builder.setTitle(getActivity().getString(R.string.ImportFragment_import_system_sms_database));
    builder.setMessage(getActivity().getString(R.string.ImportFragment_this_will_import_messages_from_the_system));
    builder.setPositiveButton(getActivity().getString(R.string.ImportFragment_import), new AlertDialog.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(getActivity(), ApplicationMigrationService.class);
            intent.setAction(ApplicationMigrationService.MIGRATE_DATABASE);
            intent.putExtra("master_secret", masterSecret);
            getActivity().startService(intent);
            Intent nextIntent = new Intent(getActivity(), ConversationListActivity.class);
            Intent activityIntent = new Intent(getActivity(), DatabaseMigrationActivity.class);
            activityIntent.putExtra("next_intent", nextIntent);
            getActivity().startActivity(activityIntent);
        }
    });
    builder.setNegativeButton(getActivity().getString(R.string.ImportFragment_cancel), null);
    builder.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) ApplicationMigrationService(org.thoughtcrime.securesms.service.ApplicationMigrationService)

Example 8 with Builder

use of android.support.v7.app.AlertDialog.Builder in project MVCHelper by LuckyJayce.

the class ABSTestCaseFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    this.inflater = inflater;
    View view = inflater.inflate(R.layout.testcase, container, false);
    taskHelper = new TaskHelper<>();
    GsonBuilder builder = new GsonBuilder();
    // 格式化输出
    builder.setPrettyPrinting();
    // builder.serializeNulls();
    builder.addSerializationExclusionStrategy(new ExclusionStrategy() {

        @Override
        public boolean shouldSkipField(FieldAttributes f) {
            // true; //按注解排除
            return false;
        }

        @Override
        public boolean shouldSkipClass(Class<?> clazz) {
            // 直接排除某个类 ,return true为排除
            return clazz == Gson.class || clazz == Bitmap.class;
        }
    }).create();
    gson = builder.create();
    recyclerView = (RecyclerView) view.findViewById(R.id.testcase2_recyclerView);
    paramsRecyclerView = (LinearLayout) view.findViewById(R.id.testcase2_params_recyclerView);
    resultTextView = (TextView) view.findViewById(R.id.testcase2_result_textView);
    runButton = (Button) view.findViewById(R.id.testcase2_run_button);
    resetButton = (Button) view.findViewById(R.id.testcase2_reset_button);
    itemRunButton = view.findViewById(R.id.testcase2_run2_button);
    resultStateTextView = (TextView) view.findViewById(R.id.testcase2_resultState_textView);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setAdapter(tasksAdapter = new TasksAdapter());
    // recyclerView.addItemDecoration(new DividerItemDecoration(getContext()));
    //
    // // paramsRecyclerView.setLayoutManager(new
    // // LinearLayoutManager(getContext()));
    // // paramsRecyclerView.addItemDecoration(new
    // // DividerItemDecoration(getContext()));
    // // paramsRecyclerView.setAdapter(paramsAdapter = new ParamsAdapter());
    datas = getTestCaseDatas();
    resetButton.setOnClickListener(onClickListener);
    runButton.setOnClickListener(onClickListener);
    itemRunButton.setOnClickListener(onClickListener);
    tasksAdapter.setOnItemClickListener(onItemClickListener);
    resultTextView.setOnClickListener(onClickListener);
    updateRight();
    return view;
}
Also used : Bitmap(android.graphics.Bitmap) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) ExclusionStrategy(com.google.gson.ExclusionStrategy) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) FieldAttributes(com.google.gson.FieldAttributes)

Example 9 with Builder

use of android.support.v7.app.AlertDialog.Builder in project actor-platform by actorapp.

the class BaseAuthFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int i = item.getItemId();
    if (i == R.id.sign_in) {
        startSignIn();
        return true;
    } else if (i == R.id.sign_up) {
        startSignUp();
        return true;
    } else if (i == R.id.change_endpoint) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle(R.string.auth_change_endpoint);
        final EditText input = new EditText(getActivity());
        input.setText("tcp://");
        input.setSelection(input.getText().length());
        int padding = Screen.dp(25);
        FrameLayout inputContainer = new FrameLayout(getActivity());
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.setMargins(padding, padding, padding, 0);
        inputContainer.addView(input, params);
        builder.setView(inputContainer);
        builder.setPositiveButton(R.string.dialog_ok, (dialog, which) -> {
            try {
                messenger().changeEndpoint(input.getText().toString());
            } catch (ConnectionEndpointArray.UnknownSchemeException e) {
                Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
            }
        });
        builder.setNegativeButton(R.string.auth_reset_default_endpoint, (dialog, which) -> {
            try {
                messenger().changeEndpoint(null);
            } catch (ConnectionEndpointArray.UnknownSchemeException e) {
                e.printStackTrace();
            }
        });
        builder.show();
        input.requestFocus();
        return true;
    } else {
        return super.onOptionsItemSelected(item);
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) EditText(android.widget.EditText) ConnectionEndpointArray(im.actor.runtime.mtproto.ConnectionEndpointArray) SpannableStringBuilder(android.text.SpannableStringBuilder) FrameLayout(android.widget.FrameLayout)

Example 10 with Builder

use of android.support.v7.app.AlertDialog.Builder in project actor-platform by actorapp.

the class MapPickerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.picker_activity_map_picker);
    list = (ListView) findViewById(R.id.list);
    list.setOnScrollListener(this);
    list.setOnItemClickListener(this);
    list.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    loading = (ProgressBar) findViewById(R.id.loading);
    status = (TextView) findViewById(R.id.status);
    header = findViewById(R.id.header);
    listHolder = findViewById(R.id.listNearbyHolder);
    mapHolder = findViewById(R.id.mapholder);
    accuranceView = (TextView) findViewById(R.id.accurance);
    setUpMapIfNeeded();
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(false);
    fullSizeButton = (ImageView) findViewById(R.id.full);
    fullSizeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            togglePlacesList();
        }
    });
    defineMyLocationButton = findViewById(R.id.define_my_location);
    defineMyLocationButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Location location = mMap.getMyLocation();
            if (location != null) {
                LatLng target = new LatLng(location.getLatitude(), location.getLongitude());
                CameraPosition.Builder builder = new CameraPosition.Builder();
                builder.zoom(17);
                builder.target(target);
                mMap.animateCamera(CameraUpdateFactory.newCameraPosition(builder.build()));
            } else {
                Toast.makeText(getBaseContext(), R.string.picker_map_pick_my_wait, Toast.LENGTH_SHORT).show();
            }
        }
    });
    pickCurrent = findViewById(R.id.pick_current);
    pickCurrent.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (currentLocation != null) {
                Intent returnIntent = new Intent();
                returnIntent.putExtra("latitude", currentLocation.getLatitude());
                returnIntent.putExtra("longitude", currentLocation.getLongitude());
                setResult(RESULT_OK, returnIntent);
                finish();
            }
        }
    });
    // we dont need these buttons
    select = findViewById(R.id.select);
    select.setEnabled(false);
    findViewById(R.id.select_text).setEnabled(false);
    select.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent returnIntent = new Intent();
            returnIntent.putExtra("latitude", geoData.latitude);
            returnIntent.putExtra("longitude", geoData.longitude);
            setResult(RESULT_OK, returnIntent);
            finish();
        }
    });
    View cancel = findViewById(R.id.cancel);
    cancel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            finish();
        }
    });
}
Also used : CameraPosition(com.google.android.gms.maps.model.CameraPosition) Intent(android.content.Intent) LatLng(com.google.android.gms.maps.model.LatLng) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ListView(android.widget.ListView) Location(android.location.Location)

Aggregations

AlertDialog (android.support.v7.app.AlertDialog)114 DialogInterface (android.content.DialogInterface)76 View (android.view.View)67 TextView (android.widget.TextView)48 Intent (android.content.Intent)36 RecyclerView (android.support.v7.widget.RecyclerView)27 ListView (android.widget.ListView)23 Dialog (android.app.Dialog)22 LayoutInflater (android.view.LayoutInflater)20 ImageView (android.widget.ImageView)20 EditText (android.widget.EditText)18 SuppressLint (android.annotation.SuppressLint)17 Context (android.content.Context)17 Bundle (android.os.Bundle)15 NonNull (android.support.annotation.NonNull)14 Button (android.widget.Button)13 ArrayList (java.util.ArrayList)12 BrowserDialog (acr.browser.lightning.dialog.BrowserDialog)10 OnClickListener (android.content.DialogInterface.OnClickListener)10 ScrollView (android.widget.ScrollView)10