mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-24 05:46:14 +03:00
Improved Settings Activity UX
This commit is contained in:
parent
b92810a1f3
commit
896121bb62
3 changed files with 38 additions and 144 deletions
|
@ -50,9 +50,7 @@ public class NotesListViewActivity extends AppCompatActivity implements
|
||||||
// First Run Wizard
|
// First Run Wizard
|
||||||
SharedPreferences preferences = PreferenceManager
|
SharedPreferences preferences = PreferenceManager
|
||||||
.getDefaultSharedPreferences(getApplicationContext());
|
.getDefaultSharedPreferences(getApplicationContext());
|
||||||
Log.v("Note", "First Run: " + preferences.getBoolean(SettingsActivity.SETTINGS_FIRST_RUN, true));
|
|
||||||
if(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);
|
Intent settingsIntent = new Intent(this, SettingsActivity.class);
|
||||||
startActivityForResult(settingsIntent, server_settings);
|
startActivityForResult(settingsIntent, server_settings);
|
||||||
}
|
}
|
||||||
|
@ -198,77 +196,21 @@ public class NotesListViewActivity extends AppCompatActivity implements
|
||||||
}
|
}
|
||||||
} else if (requestCode == NoteActivity.EDIT_NOTE_CMD) {
|
} else if (requestCode == NoteActivity.EDIT_NOTE_CMD) {
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
Log.v("Note", "Note was edited from single view");
|
|
||||||
|
|
||||||
Note editedNote = (Note) data.getExtras().getSerializable(
|
Note editedNote = (Note) data.getExtras().getSerializable(
|
||||||
NoteActivity.EDIT_NOTE);
|
NoteActivity.EDIT_NOTE);
|
||||||
Log.v("Note", "Neuer Titel: " + editedNote);
|
|
||||||
|
|
||||||
int notePosition = data.getExtras().getInt(
|
int notePosition = data.getExtras().getInt(
|
||||||
SELECTED_NOTE_POSITION);
|
SELECTED_NOTE_POSITION);
|
||||||
Log.v("Note", "notePosition | NotesListViewActivity kam an "
|
|
||||||
+ notePosition);
|
|
||||||
|
|
||||||
adapter.remove(adapter.getItem(notePosition));
|
adapter.remove(adapter.getItem(notePosition));
|
||||||
adapter.add(editedNote);
|
adapter.add(editedNote);
|
||||||
}
|
}
|
||||||
} else if (requestCode == SettingsActivity.CREDENTIALS_CHANGED) {
|
} else if (requestCode == SettingsActivity.CREDENTIALS_CHANGED) {
|
||||||
Log.v("Note", "Credentials Changed!");
|
|
||||||
db = new NoteSQLiteOpenHelper(this);
|
db = new NoteSQLiteOpenHelper(this);
|
||||||
db.synchronizeWithServer(); // Needed to instanciate new NotesClient with new URL
|
db.synchronizeWithServer(); // Needed to instanciate new NotesClient with new URL
|
||||||
}
|
}
|
||||||
Log.v("Note", "New NoteSQLteOpenHelper instanciated");
|
|
||||||
//TODO Maybe only if previous activity == settings activity?
|
//TODO Maybe only if previous activity == settings activity?
|
||||||
setListView(db.getNotes());
|
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
|
* 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)
|
* items and execute bulk functions (e. g. delete)
|
||||||
|
|
|
@ -2,12 +2,15 @@ package it.niedermann.owncloud.notes.android.activity;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
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
|
* Allows to set Settings like URL, Username and Password for Server-Synchronization
|
||||||
* Created by stefan on 22.09.15.
|
* 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_FIRST_RUN = "firstRun";
|
||||||
public static final String SETTINGS_URL = "settingsUrl";
|
public static final String SETTINGS_URL = "settingsUrl";
|
||||||
|
@ -75,21 +78,7 @@ public class SettingsActivity extends AppCompatActivity implements View.OnClickL
|
||||||
field_username.setText(preferences.getString(SETTINGS_USERNAME, DEFAULT_SETTINGS));
|
field_username.setText(preferences.getString(SETTINGS_USERNAME, DEFAULT_SETTINGS));
|
||||||
field_password.setText(preferences.getString(SETTINGS_PASSWORD, DEFAULT_SETTINGS));
|
field_password.setText(preferences.getString(SETTINGS_PASSWORD, DEFAULT_SETTINGS));
|
||||||
|
|
||||||
btn_submit.setOnClickListener(this);
|
btn_submit.setOnClickListener(new View.OnClickListener() {
|
||||||
findViewById(R.id.settings_submit).setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
startActivity(new Intent(SettingsActivity.this, NotesListViewActivity.class));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle Submit Button Click
|
|
||||||
* Checks and Writes the new Preferences into the SharedPreferences Object.
|
|
||||||
*
|
|
||||||
* @param v View
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
String url = field_url.getText().toString();
|
String url = field_url.getText().toString();
|
||||||
|
@ -102,6 +91,8 @@ public class SettingsActivity extends AppCompatActivity implements View.OnClickL
|
||||||
|
|
||||||
new LoginValidatorAsyncTask().execute(url, username, password);
|
new LoginValidatorAsyncTask().execute(url, username, password);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/************************************ Async Tasks ************************************/
|
/************************************ Async Tasks ************************************/
|
||||||
|
|
||||||
|
@ -113,7 +104,7 @@ public class SettingsActivity extends AppCompatActivity implements View.OnClickL
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
findViewById(R.id.settings_url_check).setVisibility(View.INVISIBLE);
|
((EditText) findViewById(R.id.settings_url)).setCompoundDrawables(null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -124,9 +115,11 @@ public class SettingsActivity extends AppCompatActivity implements View.OnClickL
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Boolean o) {
|
protected void onPostExecute(Boolean o) {
|
||||||
if (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 {
|
} 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);
|
setResult(RESULT_OK, data);
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
|
Log.e("Note", "invalid login");
|
||||||
btn_submit.setEnabled(true);
|
btn_submit.setEnabled(true);
|
||||||
//TODO Show Error Message
|
//TODO Show Error Message
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,16 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.v7.widget.GridLayout
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/settings_grid_layout"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:padding="@dimen/activity_horizontal_margin"
|
android:orientation="vertical"
|
||||||
app:columnCount="2"
|
android:paddingLeft="16dp"
|
||||||
app:orientation="horizontal"
|
android:paddingRight="16dp">
|
||||||
>
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
android:id="@+id/settings_url_wrapper"
|
android:id="@+id/settings_url_wrapper"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_column="0"
|
android:layout_marginTop="@dimen/default_gap">
|
||||||
app:layout_row="0"
|
|
||||||
app:layout_gravity="fill"
|
|
||||||
>
|
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/settings_url"
|
android:id="@+id/settings_url"
|
||||||
|
@ -27,32 +20,17 @@
|
||||||
android:inputType="textUri" />
|
android:inputType="textUri" />
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/settings_url_check"
|
|
||||||
android:src="@drawable/ic_action_done_dark"
|
|
||||||
android:contentDescription="@string/settings_url_check_description"
|
|
||||||
android:visibility="invisible"
|
|
||||||
app:layout_column="1"
|
|
||||||
app:layout_row="0"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/settings_url_warn_http"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/settings_url_warn_http"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:text="@string/settings_url_warn_http"
|
android:text="@string/settings_url_warn_http"
|
||||||
app:layout_columnSpan="2"/>
|
android:visibility="gone" />
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
android:id="@+id/settings_username_wrapper"
|
android:id="@+id/settings_username_wrapper"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
app:layout_column="0"
|
|
||||||
app:layout_row="2"
|
|
||||||
app:layout_gravity="fill">
|
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/settings_username"
|
android:id="@+id/settings_username"
|
||||||
|
@ -63,11 +41,8 @@
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
android:id="@+id/settings_password_wrapper"
|
android:id="@+id/settings_password_wrapper"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
app:layout_column="0"
|
|
||||||
app:layout_row="3"
|
|
||||||
app:layout_gravity="fill">
|
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/settings_password"
|
android:id="@+id/settings_password"
|
||||||
|
@ -77,27 +52,10 @@
|
||||||
android:inputType="textPassword" />
|
android:inputType="textPassword" />
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/settings_password_check"
|
|
||||||
android:src="@drawable/ic_action_done_dark"
|
|
||||||
android:contentDescription="@string/settings_password_check_description"
|
|
||||||
android:visibility="invisible"
|
|
||||||
app:layout_column="1"
|
|
||||||
app:layout_row="3"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/settings_submit"
|
android:id="@+id/settings_submit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:shadowColor="@color/fg_default_low"
|
android:shadowColor="@color/fg_default_low"
|
||||||
android:text="@string/settings_submit"
|
android:text="@string/settings_submit" />
|
||||||
app:layout_gravity="end"
|
</LinearLayout>
|
||||||
app:layout_row="4"
|
|
||||||
app:layout_column="0"
|
|
||||||
app:layout_columnSpan="2"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</android.support.v7.widget.GridLayout>
|
|
Loading…
Reference in a new issue