Search in sources :

Example 1 with DummyDialogListener

use of me.sheimi.sgit.dialogs.DummyDialogListener in project MGit by maks.

the class RepoListActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != Activity.RESULT_OK)
        return;
    switch(requestCode) {
        case REQUEST_IMPORT_REPO:
            final String path = data.getExtras().getString(ExploreFileActivity.RESULT_PATH);
            File file = new File(path);
            File dotGit = new File(file, Repo.DOT_GIT_DIR);
            if (!dotGit.exists()) {
                showToastMessage(getString(R.string.error_no_repository));
                return;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(R.string.dialog_comfirm_import_repo_title);
            builder.setMessage(R.string.dialog_comfirm_import_repo_msg);
            builder.setNegativeButton(R.string.label_cancel, new DummyDialogListener());
            builder.setPositiveButton(R.string.label_import, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Bundle args = new Bundle();
                    args.putString(ImportLocalRepoDialog.FROM_PATH, path);
                    ImportLocalRepoDialog rld = new ImportLocalRepoDialog();
                    rld.setArguments(args);
                    rld.show(getSupportFragmentManager(), "import-local-dialog");
                }
            });
            builder.show();
            break;
    }
}
Also used : AlertDialog(android.app.AlertDialog) ImportLocalRepoDialog(me.sheimi.sgit.dialogs.ImportLocalRepoDialog) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle) DummyDialogListener(me.sheimi.sgit.dialogs.DummyDialogListener) File(java.io.File)

Example 2 with DummyDialogListener

use of me.sheimi.sgit.dialogs.DummyDialogListener in project MGit by maks.

the class AddRemoteAction method showAddRemoteDialog.

public void showAddRemoteDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    LayoutInflater inflater = mActivity.getLayoutInflater();
    View layout = inflater.inflate(R.layout.dialog_add_remote, null);
    final EditText remoteName = (EditText) layout.findViewById(R.id.remoteName);
    final EditText remoteUrl = (EditText) layout.findViewById(R.id.remoteUrl);
    builder.setTitle(R.string.dialog_add_remote_title).setView(layout).setPositiveButton(R.string.dialog_add_remote_positive_label, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            String name = remoteName.getText().toString();
            String url = remoteUrl.getText().toString();
            try {
                addToRemote(name, url);
            } catch (IOException e) {
                Timber.e(e);
                mActivity.showMessageDialog(R.string.dialog_error_title, mActivity.getString(R.string.error_something_wrong));
            }
        }
    }).setNegativeButton(R.string.label_cancel, new DummyDialogListener()).show();
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) IOException(java.io.IOException) View(android.view.View) LayoutInflater(android.view.LayoutInflater) DummyDialogListener(me.sheimi.sgit.dialogs.DummyDialogListener)

Example 3 with DummyDialogListener

use of me.sheimi.sgit.dialogs.DummyDialogListener in project MGit by maks.

the class CommitAction method commit.

private void commit() {
    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    LayoutInflater inflater = mActivity.getLayoutInflater();
    View layout = inflater.inflate(R.layout.dialog_commit, null);
    final EditText commitMsg = (EditText) layout.findViewById(R.id.commitMsg);
    final AutoCompleteTextView commitAuthor = (AutoCompleteTextView) layout.findViewById(R.id.commitAuthor);
    final CheckBox isAmend = (CheckBox) layout.findViewById(R.id.isAmend);
    final CheckBox autoStage = (CheckBox) layout.findViewById(R.id.autoStage);
    HashSet<Author> authors = new HashSet<Author>();
    try {
        Iterable<RevCommit> commits = mRepo.getGit().log().setMaxCount(500).call();
        for (RevCommit commit : commits) {
            authors.add(new Author(commit.getAuthorIdent()));
        }
    } catch (Exception e) {
    }
    String profileUsername = Profile.getUsername(mActivity.getApplicationContext());
    String profileEmail = Profile.getEmail(mActivity.getApplicationContext());
    if (profileUsername != null && !profileUsername.equals("") && profileEmail != null && !profileEmail.equals("")) {
        authors.add(new Author(profileUsername, profileEmail));
    }
    ArrayList<Author> authorList = new ArrayList<Author>(authors);
    Collections.sort(authorList);
    AuthorsAdapter adapter = new AuthorsAdapter(mActivity, authorList);
    commitAuthor.setAdapter(adapter);
    isAmend.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                commitMsg.setText(mRepo.getLastCommitFullMsg());
            } else {
                commitMsg.setText("");
            }
        }
    });
    final AlertDialog d = builder.setTitle(R.string.dialog_commit_title).setView(layout).setPositiveButton(R.string.dialog_commit_positive_label, null).setNegativeButton(R.string.label_cancel, new DummyDialogListener()).create();
    d.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            Button b = d.getButton(AlertDialog.BUTTON_POSITIVE);
            b.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    String msg = commitMsg.getText().toString();
                    String author = commitAuthor.getText().toString().trim();
                    String authorName = null, authorEmail = null;
                    int ltidx;
                    if (msg.trim().equals("")) {
                        commitMsg.setError(mActivity.getString(R.string.error_no_commit_msg));
                        return;
                    }
                    if (!author.equals("")) {
                        ltidx = author.indexOf('<');
                        if (!author.endsWith(">") || ltidx == -1) {
                            commitAuthor.setError(mActivity.getString(R.string.error_invalid_author));
                            return;
                        }
                        authorName = author.substring(0, ltidx);
                        authorEmail = author.substring(ltidx + 1, author.length() - 1);
                    }
                    boolean amend = isAmend.isChecked();
                    boolean stage = autoStage.isChecked();
                    commit(msg, amend, stage, authorName, authorEmail);
                    d.dismiss();
                }
            });
        }
    });
    d.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) HashSet(java.util.HashSet) RevCommit(org.eclipse.jgit.revwalk.RevCommit) EditText(android.widget.EditText) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) View(android.view.View) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) CheckBox(android.widget.CheckBox) LayoutInflater(android.view.LayoutInflater) DummyDialogListener(me.sheimi.sgit.dialogs.DummyDialogListener) CompoundButton(android.widget.CompoundButton) AutoCompleteTextView(android.widget.AutoCompleteTextView)

Example 4 with DummyDialogListener

use of me.sheimi.sgit.dialogs.DummyDialogListener in project MGit by maks.

the class SheimiFragmentActivity method showEditTextDialog.

public void showEditTextDialog(int title, int hint, int positiveBtn, final OnEditTextDialogClicked positiveListener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    LayoutInflater inflater = getLayoutInflater();
    View layout = inflater.inflate(R.layout.dialog_edit_text, null);
    final EditText editText = (EditText) layout.findViewById(R.id.editText);
    editText.setHint(hint);
    builder.setTitle(title).setView(layout).setPositiveButton(positiveBtn, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            String text = editText.getText().toString();
            if (text == null || text.trim().isEmpty()) {
                showToastMessage(R.string.alert_you_should_input_something);
                return;
            }
            positiveListener.onClicked(text);
        }
    }).setNegativeButton(R.string.label_cancel, new DummyDialogListener()).show();
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) LayoutInflater(android.view.LayoutInflater) DummyDialogListener(me.sheimi.sgit.dialogs.DummyDialogListener) View(android.view.View)

Aggregations

AlertDialog (android.app.AlertDialog)4 DialogInterface (android.content.DialogInterface)4 DummyDialogListener (me.sheimi.sgit.dialogs.DummyDialogListener)4 LayoutInflater (android.view.LayoutInflater)3 View (android.view.View)3 EditText (android.widget.EditText)3 Bundle (android.os.Bundle)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 Button (android.widget.Button)1 CheckBox (android.widget.CheckBox)1 CompoundButton (android.widget.CompoundButton)1 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)1 TextView (android.widget.TextView)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ImportLocalRepoDialog (me.sheimi.sgit.dialogs.ImportLocalRepoDialog)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1