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
|
||||
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)
|
||||
|
|
|
@ -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,21 +78,7 @@ 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() {
|
||||
@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
|
||||
*/
|
||||
btn_submit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String url = field_url.getText().toString();
|
||||
|
@ -102,6 +91,8 @@ public class SettingsActivity extends AppCompatActivity implements View.OnClickL
|
|||
|
||||
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
|
||||
}
|
||||
|
|
|
@ -1,23 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.GridLayout
|
||||
android:id="@+id/settings_grid_layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/activity_horizontal_margin"
|
||||
app:columnCount="2"
|
||||
app:orientation="horizontal"
|
||||
>
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp">
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/settings_url_wrapper"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_column="0"
|
||||
app:layout_row="0"
|
||||
app:layout_gravity="fill"
|
||||
>
|
||||
android:layout_marginTop="@dimen/default_gap">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/settings_url"
|
||||
|
@ -27,32 +20,17 @@
|
|||
android:inputType="textUri" />
|
||||
</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
|
||||
android:id="@+id/settings_url_warn_http"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/settings_url_warn_http"
|
||||
android:visibility="gone"
|
||||
android:text="@string/settings_url_warn_http"
|
||||
app:layout_columnSpan="2"/>
|
||||
android:visibility="gone" />
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/settings_username_wrapper"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_column="0"
|
||||
app:layout_row="2"
|
||||
app:layout_gravity="fill">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/settings_username"
|
||||
|
@ -63,11 +41,8 @@
|
|||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/settings_password_wrapper"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_column="0"
|
||||
app:layout_row="3"
|
||||
app:layout_gravity="fill">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/settings_password"
|
||||
|
@ -77,27 +52,10 @@
|
|||
android:inputType="textPassword" />
|
||||
</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
|
||||
android:id="@+id/settings_submit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:shadowColor="@color/fg_default_low"
|
||||
android:text="@string/settings_submit"
|
||||
app:layout_gravity="end"
|
||||
app:layout_row="4"
|
||||
app:layout_column="0"
|
||||
app:layout_columnSpan="2"
|
||||
/>
|
||||
|
||||
</android.support.v7.widget.GridLayout>
|
||||
android:text="@string/settings_submit" />
|
||||
</LinearLayout>
|
Loading…
Reference in a new issue