|
|
@ -14,41 +14,41 @@
|
|
|
|
* limitations under the License.
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
package net.micode.notes.ui;
|
|
|
|
package net.micode.notes.ui;
|
|
|
|
|
|
|
|
|
|
|
|
import android.accounts.Account;
|
|
|
|
import android.accounts.Account;
|
|
|
|
import android.accounts.AccountManager;
|
|
|
|
import android.accounts.AccountManager;
|
|
|
|
import android.app.ActionBar;
|
|
|
|
import android.app.ActionBar;
|
|
|
|
import android.app.AlertDialog;
|
|
|
|
import android.app.AlertDialog;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.ContentValues;
|
|
|
|
import android.content.ContentValues;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.preference.Preference;
|
|
|
|
import android.preference.Preference;
|
|
|
|
import android.preference.Preference.OnPreferenceClickListener;
|
|
|
|
import android.preference.Preference.OnPreferenceClickListener;
|
|
|
|
import android.preference.PreferenceActivity;
|
|
|
|
import android.preference.PreferenceActivity;
|
|
|
|
import android.preference.PreferenceCategory;
|
|
|
|
import android.preference.PreferenceCategory;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.format.DateFormat;
|
|
|
|
import android.text.format.DateFormat;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.Button;
|
|
|
|
import android.widget.Button;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.Toast;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
|
|
import net.micode.notes.R;
|
|
|
|
import net.micode.notes.R;
|
|
|
|
import net.micode.notes.data.Notes;
|
|
|
|
import net.micode.notes.data.Notes;
|
|
|
|
import net.micode.notes.data.Notes.NoteColumns;
|
|
|
|
import net.micode.notes.data.Notes.NoteColumns;
|
|
|
|
import net.micode.notes.gtask.remote.GTaskSyncService;
|
|
|
|
import net.micode.notes.gtask.remote.GTaskSyncService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
public static final String PREFERENCE_NAME = "notes_preferences";
|
|
|
|
public static final String PREFERENCE_NAME = "notes_preferences";
|
|
|
|
|
|
|
|
|
|
|
|
public static final String PREFERENCE_SYNC_ACCOUNT_NAME = "pref_key_account_name";
|
|
|
|
public static final String PREFERENCE_SYNC_ACCOUNT_NAME = "pref_key_account_name";
|
|
|
@ -69,14 +69,17 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
|
|
|
|
|
|
|
|
private boolean mHasAddedAccount;
|
|
|
|
private boolean mHasAddedAccount;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
|
|
|
|
|
|
|
|
protected void onCreate(Bundle icicle) {
|
|
|
|
protected void onCreate(Bundle icicle) {
|
|
|
|
|
|
|
|
|
|
|
|
super.onCreate(icicle);
|
|
|
|
super.onCreate(icicle);
|
|
|
|
|
|
|
|
|
|
|
|
/* using the app icon for navigation */
|
|
|
|
|
|
|
|
getActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
|
getActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
|
|
|
|
|
|
|
|
|
addPreferencesFromResource(R.xml.preferences);
|
|
|
|
addPreferencesFromResource(R.xml.preferences);
|
|
|
|
|
|
|
|
|
|
|
|
mAccountCategory = (PreferenceCategory) findPreference(PREFERENCE_SYNC_ACCOUNT_KEY);
|
|
|
|
mAccountCategory = (PreferenceCategory) findPreference(PREFERENCE_SYNC_ACCOUNT_KEY);
|
|
|
|
mReceiver = new GTaskReceiver();
|
|
|
|
mReceiver = new GTaskReceiver();
|
|
|
|
IntentFilter filter = new IntentFilter();
|
|
|
|
IntentFilter filter = new IntentFilter();
|
|
|
@ -89,13 +92,15 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
|
|
|
|
|
|
|
|
protected void onResume() {
|
|
|
|
protected void onResume() {
|
|
|
|
|
|
|
|
|
|
|
|
super.onResume();
|
|
|
|
super.onResume();
|
|
|
|
|
|
|
|
|
|
|
|
// need to set sync account automatically if user has added a new
|
|
|
|
|
|
|
|
// account
|
|
|
|
|
|
|
|
if (mHasAddedAccount) {
|
|
|
|
if (mHasAddedAccount) {
|
|
|
|
|
|
|
|
|
|
|
|
Account[] accounts = getGoogleAccounts();
|
|
|
|
Account[] accounts = getGoogleAccounts();
|
|
|
|
|
|
|
|
|
|
|
|
if (mOriAccounts != null && accounts.length > mOriAccounts.length) {
|
|
|
|
if (mOriAccounts != null && accounts.length > mOriAccounts.length) {
|
|
|
|
for (Account accountNew : accounts) {
|
|
|
|
for (Account accountNew : accounts) {
|
|
|
|
boolean found = false;
|
|
|
|
boolean found = false;
|
|
|
@ -114,32 +119,35 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
refreshUI();
|
|
|
|
refreshUI();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
|
|
|
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
protected void onDestroy() {
|
|
|
|
if (mReceiver != null) {
|
|
|
|
if (mReceiver != null) {
|
|
|
|
unregisterReceiver(mReceiver);
|
|
|
|
unregisterReceiver(mReceiver);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
super.onDestroy();
|
|
|
|
super.onDestroy();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void loadAccountPreference() {
|
|
|
|
private void loadAccountPreference() {
|
|
|
|
mAccountCategory.removeAll();
|
|
|
|
mAccountCategory.removeAll();
|
|
|
|
|
|
|
|
|
|
|
|
Preference accountPref = new Preference(this);
|
|
|
|
Preference accountPref = new Preference(this);
|
|
|
|
|
|
|
|
|
|
|
|
final String defaultAccount = getSyncAccountName(this);
|
|
|
|
final String defaultAccount = getSyncAccountName(this);
|
|
|
|
accountPref.setTitle(getString(R.string.preferences_account_title));
|
|
|
|
accountPref.setTitle(getString(R.string.preferences_account_title));
|
|
|
|
accountPref.setSummary(getString(R.string.preferences_account_summary));
|
|
|
|
accountPref.setSummary(getString(R.string.preferences_account_summary));
|
|
|
|
|
|
|
|
|
|
|
|
accountPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
|
|
|
accountPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
|
|
|
public boolean onPreferenceClick(Preference preference) {
|
|
|
|
public boolean onPreferenceClick(Preference preference) {
|
|
|
|
|
|
|
|
|
|
|
|
if (!GTaskSyncService.isSyncing()) {
|
|
|
|
if (!GTaskSyncService.isSyncing()) {
|
|
|
|
if (TextUtils.isEmpty(defaultAccount)) {
|
|
|
|
if (TextUtils.isEmpty(defaultAccount)) {
|
|
|
|
// the first time to set account
|
|
|
|
|
|
|
|
showSelectAccountAlertDialog();
|
|
|
|
showSelectAccountAlertDialog();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// if the account has already been set, we need to promp
|
|
|
|
|
|
|
|
// user about the risk
|
|
|
|
|
|
|
|
showChangeAccountConfirmAlertDialog();
|
|
|
|
showChangeAccountConfirmAlertDialog();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -157,15 +165,15 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
private void loadSyncButton() {
|
|
|
|
private void loadSyncButton() {
|
|
|
|
Button syncButton = (Button) findViewById(R.id.preference_sync_button);
|
|
|
|
Button syncButton = (Button) findViewById(R.id.preference_sync_button);
|
|
|
|
TextView lastSyncTimeView = (TextView) findViewById(R.id.prefenerece_sync_status_textview);
|
|
|
|
TextView lastSyncTimeView = (TextView) findViewById(R.id.prefenerece_sync_status_textview);
|
|
|
|
|
|
|
|
|
|
|
|
// set button state
|
|
|
|
|
|
|
|
if (GTaskSyncService.isSyncing()) {
|
|
|
|
if (GTaskSyncService.isSyncing()) {
|
|
|
|
|
|
|
|
|
|
|
|
syncButton.setText(getString(R.string.preferences_button_sync_cancel));
|
|
|
|
syncButton.setText(getString(R.string.preferences_button_sync_cancel));
|
|
|
|
syncButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
syncButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View v) {
|
|
|
|
public void onClick(View v) {
|
|
|
|
GTaskSyncService.cancelSync(NotesPreferenceActivity.this);
|
|
|
|
GTaskSyncService.cancelSync(NotesPreferenceActivity.this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
syncButton.setText(getString(R.string.preferences_button_sync_immediately));
|
|
|
|
syncButton.setText(getString(R.string.preferences_button_sync_immediately));
|
|
|
|
syncButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
syncButton.setOnClickListener(new View.OnClickListener() {
|
|
|
@ -173,21 +181,25 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
GTaskSyncService.startSync(NotesPreferenceActivity.this);
|
|
|
|
GTaskSyncService.startSync(NotesPreferenceActivity.this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
syncButton.setEnabled(!TextUtils.isEmpty(getSyncAccountName(this)));
|
|
|
|
syncButton.setEnabled(!TextUtils.isEmpty(getSyncAccountName(this)));
|
|
|
|
|
|
|
|
|
|
|
|
// set last sync time
|
|
|
|
|
|
|
|
if (GTaskSyncService.isSyncing()) {
|
|
|
|
if (GTaskSyncService.isSyncing()) {
|
|
|
|
lastSyncTimeView.setText(GTaskSyncService.getProgressString());
|
|
|
|
lastSyncTimeView.setText(GTaskSyncService.getProgressString());
|
|
|
|
lastSyncTimeView.setVisibility(View.VISIBLE);
|
|
|
|
lastSyncTimeView.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
long lastSyncTime = getLastSyncTime(this);
|
|
|
|
long lastSyncTime = getLastSyncTime(this);
|
|
|
|
if (lastSyncTime != 0) {
|
|
|
|
if (lastSyncTime != 0) {
|
|
|
|
lastSyncTimeView.setText(getString(R.string.preferences_last_sync_time,
|
|
|
|
lastSyncTimeView.setText(getString(R.string.preferences_last_sync_time,
|
|
|
|
DateFormat.format(getString(R.string.preferences_last_sync_time_format),
|
|
|
|
DateFormat.format(getString(R.string.preferences_last_sync_time_format),
|
|
|
|
lastSyncTime)));
|
|
|
|
lastSyncTime)));
|
|
|
|
lastSyncTimeView.setVisibility(View.VISIBLE);
|
|
|
|
lastSyncTimeView.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
lastSyncTimeView.setVisibility(View.GONE);
|
|
|
|
lastSyncTimeView.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -201,6 +213,7 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
private void showSelectAccountAlertDialog() {
|
|
|
|
private void showSelectAccountAlertDialog() {
|
|
|
|
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
|
|
|
|
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
View titleView = LayoutInflater.from(this).inflate(R.layout.account_dialog_title, null);
|
|
|
|
View titleView = LayoutInflater.from(this).inflate(R.layout.account_dialog_title, null);
|
|
|
|
TextView titleTextView = (TextView) titleView.findViewById(R.id.account_dialog_title);
|
|
|
|
TextView titleTextView = (TextView) titleView.findViewById(R.id.account_dialog_title);
|
|
|
|
titleTextView.setText(getString(R.string.preferences_dialog_select_account_title));
|
|
|
|
titleTextView.setText(getString(R.string.preferences_dialog_select_account_title));
|
|
|
@ -249,9 +262,11 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
"gmail-ls"
|
|
|
|
"gmail-ls"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
startActivityForResult(intent, -1);
|
|
|
|
startActivityForResult(intent, -1);
|
|
|
|
|
|
|
|
|
|
|
|
dialog.dismiss();
|
|
|
|
dialog.dismiss();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void showChangeAccountConfirmAlertDialog() {
|
|
|
|
private void showChangeAccountConfirmAlertDialog() {
|
|
|
@ -263,6 +278,7 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
getSyncAccountName(this)));
|
|
|
|
getSyncAccountName(this)));
|
|
|
|
TextView subtitleTextView = (TextView) titleView.findViewById(R.id.account_dialog_subtitle);
|
|
|
|
TextView subtitleTextView = (TextView) titleView.findViewById(R.id.account_dialog_subtitle);
|
|
|
|
subtitleTextView.setText(getString(R.string.preferences_dialog_change_account_warn_msg));
|
|
|
|
subtitleTextView.setText(getString(R.string.preferences_dialog_change_account_warn_msg));
|
|
|
|
|
|
|
|
|
|
|
|
dialogBuilder.setCustomTitle(titleView);
|
|
|
|
dialogBuilder.setCustomTitle(titleView);
|
|
|
|
|
|
|
|
|
|
|
|
CharSequence[] menuItemArray = new CharSequence[] {
|
|
|
|
CharSequence[] menuItemArray = new CharSequence[] {
|
|
|
@ -270,8 +286,10 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
getString(R.string.preferences_menu_remove_account),
|
|
|
|
getString(R.string.preferences_menu_remove_account),
|
|
|
|
getString(R.string.preferences_menu_cancel)
|
|
|
|
getString(R.string.preferences_menu_cancel)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
dialogBuilder.setItems(menuItemArray, new DialogInterface.OnClickListener() {
|
|
|
|
dialogBuilder.setItems(menuItemArray, new DialogInterface.OnClickListener() {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
|
|
|
|
|
|
|
if (which == 0) {
|
|
|
|
if (which == 0) {
|
|
|
|
showSelectAccountAlertDialog();
|
|
|
|
showSelectAccountAlertDialog();
|
|
|
|
} else if (which == 1) {
|
|
|
|
} else if (which == 1) {
|
|
|
@ -281,28 +299,32 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
dialogBuilder.show();
|
|
|
|
dialogBuilder.show();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Account[] getGoogleAccounts() {
|
|
|
|
private Account[] getGoogleAccounts() {
|
|
|
|
AccountManager accountManager = AccountManager.get(this);
|
|
|
|
AccountManager accountManager = AccountManager.get(this);
|
|
|
|
return accountManager.getAccountsByType("com.google");
|
|
|
|
return accountManager.getAccountsByType("com.google");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setSyncAccount(String account) {
|
|
|
|
private void setSyncAccount(String account) {
|
|
|
|
if (!getSyncAccountName(this).equals(account)) {
|
|
|
|
if (!getSyncAccountName(this).equals(account)) {
|
|
|
|
SharedPreferences settings = getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
|
|
|
|
SharedPreferences settings = getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
|
|
|
|
SharedPreferences.Editor editor = settings.edit();
|
|
|
|
SharedPreferences.Editor editor = settings.edit();
|
|
|
|
|
|
|
|
|
|
|
|
if (account != null) {
|
|
|
|
if (account != null) {
|
|
|
|
editor.putString(PREFERENCE_SYNC_ACCOUNT_NAME, account);
|
|
|
|
editor.putString(PREFERENCE_SYNC_ACCOUNT_NAME, account);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
editor.putString(PREFERENCE_SYNC_ACCOUNT_NAME, "");
|
|
|
|
editor.putString(PREFERENCE_SYNC_ACCOUNT_NAME, "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
editor.commit();
|
|
|
|
editor.commit();
|
|
|
|
|
|
|
|
|
|
|
|
// clean up last sync time
|
|
|
|
|
|
|
|
setLastSyncTime(this, 0);
|
|
|
|
setLastSyncTime(this, 0);
|
|
|
|
|
|
|
|
|
|
|
|
// clean up local gtask related info
|
|
|
|
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
ContentValues values = new ContentValues();
|
|
|
|
ContentValues values = new ContentValues();
|
|
|
@ -312,15 +334,18 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Toast.makeText(NotesPreferenceActivity.this,
|
|
|
|
Toast.makeText(NotesPreferenceActivity.this,
|
|
|
|
getString(R.string.preferences_toast_success_set_accout, account),
|
|
|
|
getString(R.string.preferences_toast_success_set_accout, account),
|
|
|
|
Toast.LENGTH_SHORT).show();
|
|
|
|
Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void removeSyncAccount() {
|
|
|
|
private void removeSyncAccount() {
|
|
|
|
SharedPreferences settings = getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
|
|
|
|
SharedPreferences settings = getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
|
|
|
|
SharedPreferences.Editor editor = settings.edit();
|
|
|
|
SharedPreferences.Editor editor = settings.edit();
|
|
|
|
|
|
|
|
|
|
|
|
if (settings.contains(PREFERENCE_SYNC_ACCOUNT_NAME)) {
|
|
|
|
if (settings.contains(PREFERENCE_SYNC_ACCOUNT_NAME)) {
|
|
|
|
editor.remove(PREFERENCE_SYNC_ACCOUNT_NAME);
|
|
|
|
editor.remove(PREFERENCE_SYNC_ACCOUNT_NAME);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -329,7 +354,8 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
editor.commit();
|
|
|
|
editor.commit();
|
|
|
|
|
|
|
|
|
|
|
|
// clean up local gtask related info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
ContentValues values = new ContentValues();
|
|
|
|
ContentValues values = new ContentValues();
|
|
|
@ -338,20 +364,25 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
getContentResolver().update(Notes.CONTENT_NOTE_URI, values, null, null);
|
|
|
|
getContentResolver().update(Notes.CONTENT_NOTE_URI, values, null, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String getSyncAccountName(Context context) {
|
|
|
|
public static String getSyncAccountName(Context context) {
|
|
|
|
SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME,
|
|
|
|
SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME,
|
|
|
|
Context.MODE_PRIVATE);
|
|
|
|
Context.MODE_PRIVATE);
|
|
|
|
return settings.getString(PREFERENCE_SYNC_ACCOUNT_NAME, "");
|
|
|
|
return settings.getString(PREFERENCE_SYNC_ACCOUNT_NAME, "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void setLastSyncTime(Context context, long time) {
|
|
|
|
public static void setLastSyncTime(Context context, long time) {
|
|
|
|
SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME,
|
|
|
|
SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME,
|
|
|
|
Context.MODE_PRIVATE);
|
|
|
|
Context.MODE_PRIVATE);
|
|
|
|
SharedPreferences.Editor editor = settings.edit();
|
|
|
|
SharedPreferences.Editor editor = settings.edit();
|
|
|
|
|
|
|
|
|
|
|
|
editor.putLong(PREFERENCE_LAST_SYNC_TIME, time);
|
|
|
|
editor.putLong(PREFERENCE_LAST_SYNC_TIME, time);
|
|
|
|
editor.commit();
|
|
|
|
editor.commit();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static long getLastSyncTime(Context context) {
|
|
|
|
public static long getLastSyncTime(Context context) {
|
|
|
@ -360,6 +391,7 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
return settings.getLong(PREFERENCE_LAST_SYNC_TIME, 0);
|
|
|
|
return settings.getLong(PREFERENCE_LAST_SYNC_TIME, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class GTaskReceiver extends BroadcastReceiver {
|
|
|
|
private class GTaskReceiver extends BroadcastReceiver {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -374,6 +406,7 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
case android.R.id.home:
|
|
|
|
case android.R.id.home:
|
|
|
@ -385,4 +418,5 @@ public class NotesPreferenceActivity extends PreferenceActivity {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|