Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
konradrenner committed Jun 23, 2015
1 parent c7c07bf commit 9dac869
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "org.kore.kolabnotes.android"
minSdkVersion 21
targetSdkVersion 21
versionCode 2
versionName "0.1.0-alpha2"
versionCode 3
versionName "0.1.0-alpha3"
}
buildTypes {
release {
Expand Down
67 changes: 63 additions & 4 deletions app/src/main/java/org/kore/kolabnotes/android/DetailActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public class DetailActivity extends ActionBarActivity implements ShareActionProv

private List<String> allTags = new ArrayList<>();

private boolean notebookSelectionOK = true;

//Given notebook is set, if a notebook uid was in the start intent,
//intialNotebook ist the notebook-UID which is selected after setSpinnerSelection was called
private String givenNotebook;
Expand Down Expand Up @@ -376,17 +378,74 @@ String getDescriptionFromView(){
return null;
}

private AlertDialog createNotebookDialog(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);

builder.setTitle(R.string.dialog_input_text_notebook);

LayoutInflater inflater = getLayoutInflater();
View view = inflater.inflate(R.layout.dialog_text_input, null);

builder.setView(view);

builder.setPositiveButton(R.string.ok,new CreateNotebookButtonListener((EditText)view.findViewById(R.id.dialog_text_input_field)));
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
notebookSelectionOK = false;
}
});
return builder.create();
}

public class CreateNotebookButtonListener implements DialogInterface.OnClickListener{

private final EditText textField;

public CreateNotebookButtonListener(EditText textField) {
this.textField = textField;
}


@Override
public void onClick(DialogInterface dialog, int which) {
if(textField == null || textField.getText() == null || textField.getText().toString().trim().length() == 0){
notebookSelectionOK = false;
return;
}

ActiveAccount activeAccount = activeAccountRepository.getActiveAccount();

Identification ident = new Identification(UUID.randomUUID().toString(),"kolabnotes-android");
Timestamp now = new Timestamp(System.currentTimeMillis());
AuditInformation audit = new AuditInformation(now,now);

String value = textField.getText().toString();

Notebook nb = new Notebook(ident,audit, Note.Classification.PUBLIC, value);
nb.setDescription(value);
notebookRepository.insert(activeAccount.getAccount(), activeAccount.getRootFolder(), nb);
notebookSelectionOK = true;
}
}

void saveNote(){
EditText summary = (EditText) findViewById(R.id.detail_summary);

Spinner spinner = (Spinner) findViewById(R.id.spinner_notebook);

if(spinner.getSelectedItem() == null){
((TextView)spinner.getSelectedView()).setError(getString(R.string.error_field_required));
spinner.requestFocus();
//Just possible if there is no notebook created
AlertDialog notebookDialog = createNotebookDialog();

return;
}else if(TextUtils.isEmpty(summary.getText().toString())){
notebookDialog.show();

if(!notebookSelectionOK){
return;
}
}

if(TextUtils.isEmpty(summary.getText().toString())){
summary.setError(getString(R.string.error_field_required));
summary.requestFocus();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public class MainPhoneActivity extends ActionBarActivity implements SyncStatusOb
@Override
protected void onCreate(Bundle savedInstanceState) {
//supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_phone);

Expand Down Expand Up @@ -287,12 +286,14 @@ public void onResume(){
}


if(fromDetailActivity && selectedNotebookName != null){
Notebook nb = notebookRepository.getBySummary(activeAccount.getAccount(),activeAccount.getRootFolder(),selectedNotebookName);
if(fromDetailActivity){
if(selectedNotebookName != null) {
Notebook nb = notebookRepository.getBySummary(activeAccount.getAccount(), activeAccount.getRootFolder(), selectedNotebookName);

//GitHub Issue 31
if(nb != null) {
notebookUID = nb.getIdentification().getUid();
//GitHub Issue 31
if (nb != null) {
notebookUID = nb.getIdentification().getUid();
}
}
fromDetailActivity = false;

Expand Down

0 comments on commit 9dac869

Please sign in to comment.