diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java index 3f812962..581f0b80 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java @@ -50,9 +50,7 @@ public class NotesListViewActivity extends AppCompatActivity implements // First Run Wizard SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); - Log.v("Note", "First Run: " + preferences.getBoolean(SettingsActivity.SETTINGS_FIRST_RUN, true)); if(preferences.getBoolean(SettingsActivity.SETTINGS_FIRST_RUN, true)) { - Log.v("Note", "Seems to be the First Run..."); Intent settingsIntent = new Intent(this, SettingsActivity.class); startActivityForResult(settingsIntent, server_settings); } @@ -198,77 +196,21 @@ public class NotesListViewActivity extends AppCompatActivity implements } } else if (requestCode == NoteActivity.EDIT_NOTE_CMD) { if (resultCode == RESULT_OK) { - Log.v("Note", "Note was edited from single view"); - Note editedNote = (Note) data.getExtras().getSerializable( NoteActivity.EDIT_NOTE); - Log.v("Note", "Neuer Titel: " + editedNote); - int notePosition = data.getExtras().getInt( SELECTED_NOTE_POSITION); - Log.v("Note", "notePosition | NotesListViewActivity kam an " - + notePosition); - adapter.remove(adapter.getItem(notePosition)); adapter.add(editedNote); } } else if (requestCode == SettingsActivity.CREDENTIALS_CHANGED) { - Log.v("Note", "Credentials Changed!"); db = new NoteSQLiteOpenHelper(this); db.synchronizeWithServer(); // Needed to instanciate new NotesClient with new URL } - Log.v("Note", "New NoteSQLteOpenHelper instanciated"); //TODO Maybe only if previous activity == settings activity? setListView(db.getNotes()); } - // private class SingleSelectedActionModeCallback implements - // ActionMode.Callback { - // - // @Override - // public boolean onCreateActionMode(ActionMode mode, Menu menu) { - // // inflate contextual menu - // mode.getMenuInflater().inflate(R.menu.menu_list_context_single, - // menu); - // return true; - // } - // - // @Override - // public boolean onPrepareActionMode(ActionMode mode, Menu menu) { - // return false; - // } - // - // @Override - // public boolean onActionItemClicked(ActionMode mode, MenuItem item) { - // switch (item.getItemId()) { - // case R.id.menu_delete: - // SparseBooleanArray checkedItemPositions = listView - // .getCheckedItemPositions(); - // for (int i = (checkedItemPositions.size() - 1); i >= 0; i--) { - // if (checkedItemPositions.valueAt(i)) { - // - // Note checkedItem = adapter.getItem(checkedItemPositions - // .keyAt(i)); - // - // NoteDeleterAsyncTask deleter = new NoteDeleterAsyncTask(); - // deleter.execute(checkedItem); - // } - // } - // mode.finish(); // Action picked, so close the CAB - // return true; - // default: - // return false; - // } - // } - // - // @Override - // public void onDestroyActionMode(ActionMode mode) { - // removeSelection(); - // mActionMode = null; - // adapter.notifyDataSetChanged(); - // } - // } - /** * Long click on one item in the list view. It starts the Action Mode and allows selecting more * items and execute bulk functions (e. g. delete) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SettingsActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SettingsActivity.java index ecf462e1..aa770259 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SettingsActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SettingsActivity.java @@ -2,12 +2,15 @@ package it.niedermann.owncloud.notes.android.activity; import android.content.Intent; import android.content.SharedPreferences; +import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Bundle; import android.preference.PreferenceManager; +import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.text.Editable; import android.text.TextWatcher; +import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; @@ -20,7 +23,7 @@ import it.niedermann.owncloud.notes.util.NotesClientUtil; * Allows to set Settings like URL, Username and Password for Server-Synchronization * Created by stefan on 22.09.15. */ -public class SettingsActivity extends AppCompatActivity implements View.OnClickListener { +public class SettingsActivity extends AppCompatActivity { public static final String SETTINGS_FIRST_RUN = "firstRun"; public static final String SETTINGS_URL = "settingsUrl"; @@ -75,34 +78,22 @@ public class SettingsActivity extends AppCompatActivity implements View.OnClickL field_username.setText(preferences.getString(SETTINGS_USERNAME, DEFAULT_SETTINGS)); field_password.setText(preferences.getString(SETTINGS_PASSWORD, DEFAULT_SETTINGS)); - btn_submit.setOnClickListener(this); - findViewById(R.id.settings_submit).setOnClickListener(new View.OnClickListener() { + btn_submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - startActivity(new Intent(SettingsActivity.this, NotesListViewActivity.class)); + String url = field_url.getText().toString(); + String username = field_username.getText().toString(); + String password = field_password.getText().toString(); + + if (!url.endsWith("/")) { + url += "/"; + } + + new LoginValidatorAsyncTask().execute(url, username, password); } }); } - /** - * Handle Submit Button Click - * Checks and Writes the new Preferences into the SharedPreferences Object. - * - * @param v View - */ - @Override - public void onClick(View v) { - String url = field_url.getText().toString(); - String username = field_username.getText().toString(); - String password = field_password.getText().toString(); - - if (!url.endsWith("/")) { - url += "/"; - } - - new LoginValidatorAsyncTask().execute(url, username, password); - } - /************************************ Async Tasks ************************************/ /** @@ -113,7 +104,7 @@ public class SettingsActivity extends AppCompatActivity implements View.OnClickL @Override protected void onPreExecute() { - findViewById(R.id.settings_url_check).setVisibility(View.INVISIBLE); + ((EditText) findViewById(R.id.settings_url)).setCompoundDrawables(null, null, null, null); } @Override @@ -124,9 +115,11 @@ public class SettingsActivity extends AppCompatActivity implements View.OnClickL @Override protected void onPostExecute(Boolean o) { if (o) { - findViewById(R.id.settings_url_check).setVisibility(View.VISIBLE); + Drawable actionDoneDark = ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_action_done_dark); + actionDoneDark.setBounds(0, 0, 50, 50); + ((EditText) findViewById(R.id.settings_url)).setCompoundDrawables(null, null, actionDoneDark, null); } else { - findViewById(R.id.settings_url_check).setVisibility(View.INVISIBLE); + ((EditText) findViewById(R.id.settings_url)).setCompoundDrawables(null, null, null, null); } } } @@ -176,6 +169,7 @@ public class SettingsActivity extends AppCompatActivity implements View.OnClickL setResult(RESULT_OK, data); finish(); } else { + Log.e("Note", "invalid login"); btn_submit.setEnabled(true); //TODO Show Error Message } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 2a079658..992fea12 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1,103 +1,61 @@ - + android:layout_height="match_parent" + android:orientation="vertical" + android:paddingLeft="16dp" + android:paddingRight="16dp"> + android:layout_marginTop="@dimen/default_gap"> + android:inputType="textUri" /> - - + android:visibility="gone" /> + android:layout_width="match_parent" + android:layout_height="wrap_content"> + android:hint="@string/settings_username" /> + android:layout_width="match_parent" + android:layout_height="wrap_content"> + android:inputType="textPassword" /> - -