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;
}
}
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();
}
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();
}
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();
}
Aggregations