Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import it.niedermann.owncloud.notes.model.ItemAdapter;
import it.niedermann.owncloud.notes.model.SectionItem;
import it.niedermann.owncloud.notes.persistence.NoteSQLiteOpenHelper;
import it.niedermann.owncloud.notes.persistence.NoteServerSyncHelper;
import it.niedermann.owncloud.notes.util.ICallback;
import it.niedermann.owncloud.notes.util.NotesClientUtil;

Expand Down Expand Up @@ -72,7 +73,7 @@ protected void onCreate(Bundle savedInstanceState) {
// First Run Wizard
SharedPreferences preferences = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
if (preferences.getBoolean(SettingsActivity.SETTINGS_FIRST_RUN, true)) {
if (!NoteServerSyncHelper.isConfigured(this)) {
Intent settingsIntent = new Intent(this, SettingsActivity.class);
startActivityForResult(settingsIntent, server_settings);
}
Expand Down Expand Up @@ -107,7 +108,7 @@ public void onRefresh() {
*/
@Override
protected void onResume() {
if (db.getNoteServerSyncHelper().isSyncPossible() && !PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean(SettingsActivity.SETTINGS_FIRST_RUN, true)) {
if (db.getNoteServerSyncHelper().isSyncPossible()) {
synchronize();
}
super.onResume();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.widget.Toast;

import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.persistence.NoteServerSyncHelper;
import it.niedermann.owncloud.notes.util.NotesClientUtil;
import it.niedermann.owncloud.notes.util.NotesClientUtil.LoginStatus;

Expand All @@ -28,7 +29,6 @@
*/
public class SettingsActivity extends AppCompatActivity {

public static final String SETTINGS_FIRST_RUN = "firstRun";
public static final String SETTINGS_URL = "settingsUrl";
public static final String SETTINGS_USERNAME = "settingsUsername";
public static final String SETTINGS_PASSWORD = "settingsPassword";
Expand All @@ -50,7 +50,7 @@ public void onCreate(Bundle savedInstanceState) {
preferences = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());

if (preferences.getBoolean(SettingsActivity.SETTINGS_FIRST_RUN, true)) {
if (!NoteServerSyncHelper.isConfigured(this)) {
first_run = true;
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
}
Expand Down Expand Up @@ -223,8 +223,6 @@ protected void onPostExecute(LoginStatus status) {
editor.putString(SETTINGS_URL, url);
editor.putString(SETTINGS_USERNAME, username);
editor.putString(SETTINGS_PASSWORD, password);
// Now it is no more First Run
editor.putBoolean(SETTINGS_FIRST_RUN, false);
editor.apply();

//NoteSQLiteOpenHelper db = new NoteSQLiteOpenHelper(getApplicationContext());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ protected void finalize() throws Throwable {
super.finalize();
}

public static boolean isConfigured(Context context) {
return !PreferenceManager.getDefaultSharedPreferences(context).getString(SettingsActivity.SETTINGS_URL, SettingsActivity.DEFAULT_SETTINGS).isEmpty();
}

/**
* Synchronization is only possible, if there is an active network connection.
Expand All @@ -108,7 +111,7 @@ protected void finalize() throws Throwable {
* @return true if sync is possible, otherwise false.
*/
public boolean isSyncPossible() {
return networkConnected;
return networkConnected && isConfigured(appContext);
}


Expand Down