diff --git a/.gitignore b/.gitignore
index 7625933acc..0c6719fca7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,4 +11,4 @@ release
dev
lp-translations/
translations/strings.xml
-
+keys
diff --git a/api/src/com/todoroo/andlib/service/DependencyInjectionService.java b/api/src/com/todoroo/andlib/service/DependencyInjectionService.java
index c73858ccea..f842d86ea2 100644
--- a/api/src/com/todoroo/andlib/service/DependencyInjectionService.java
+++ b/api/src/com/todoroo/andlib/service/DependencyInjectionService.java
@@ -72,6 +72,8 @@ private boolean isQualifiedPackage(String packageName) {
return true;
if(packageName.startsWith("org.weloveastrid"))
return true;
+ if(packageName.startsWith("ru.otdelit"))
+ return true;
return false;
}
diff --git a/astrid/.classpath b/astrid/.classpath
index 5e1a35c024..404a2b1064 100644
--- a/astrid/.classpath
+++ b/astrid/.classpath
@@ -16,7 +16,8 @@
-
+
+
diff --git a/astrid/.project b/astrid/.project
index 7955497d12..cf33b0731a 100644
--- a/astrid/.project
+++ b/astrid/.project
@@ -47,6 +47,11 @@
2
_android_astridApi_98e6a2cf/src
+
+ facebook_android_src
+ 2
+ _android_facebook_android_1d8d51f6/src
+
facebook_src
2
diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml
index 1ea6e9aaac..d9b76941a2 100644
--- a/astrid/AndroidManifest.xml
+++ b/astrid/AndroidManifest.xml
@@ -533,8 +533,8 @@
-
-
+
+
diff --git a/astrid/default.properties b/astrid/default.properties
index 0537306e2f..6e01a4ec25 100644
--- a/astrid/default.properties
+++ b/astrid/default.properties
@@ -15,3 +15,4 @@ target=android-8
apk-configurations=
android.library.reference.2=../greendroid/GreenDroid/
android.library.reference.3=../facebook/facebook/
+android.library.reference.4=../../astrid-opencrx
diff --git a/astrid/plugin-src/ru/otdelit/astrid/opencrx/OpencrxControlSet.java b/astrid/plugin-src/ru/otdelit/astrid/opencrx/OpencrxControlSet.java
new file mode 100644
index 0000000000..3597473472
--- /dev/null
+++ b/astrid/plugin-src/ru/otdelit/astrid/opencrx/OpencrxControlSet.java
@@ -0,0 +1,406 @@
+package ru.otdelit.astrid.opencrx;
+
+import java.util.ArrayList;
+
+import android.app.Activity;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.AutoCompleteTextView;
+import android.widget.Spinner;
+import android.widget.TextView;
+import android.widget.AdapterView.OnItemClickListener;
+
+import com.timsu.astrid.R;
+import com.todoroo.andlib.data.TodorooCursor;
+import com.todoroo.andlib.data.Property.LongProperty;
+import com.todoroo.andlib.data.Property.StringProperty;
+import com.todoroo.andlib.service.Autowired;
+import com.todoroo.andlib.service.DependencyInjectionService;
+import com.todoroo.andlib.sql.Query;
+import com.todoroo.andlib.utility.DateUtilities;
+import com.todoroo.astrid.activity.TaskEditActivity.TaskEditControlSet;
+import com.todoroo.astrid.dao.StoreObjectDao;
+import com.todoroo.astrid.dao.StoreObjectDao.StoreObjectCriteria;
+import com.todoroo.astrid.data.Metadata;
+import com.todoroo.astrid.data.StoreObject;
+import com.todoroo.astrid.data.Task;
+import com.todoroo.astrid.data.MetadataApiDao.MetadataCriteria;
+import com.todoroo.astrid.service.MetadataService;
+
+/**
+ * Control Set for managing contact/creator assignments in OpenCRX
+ *
+ * @author Andrey Marchenko
+ *
+ */
+public class OpencrxControlSet implements TaskEditControlSet {
+
+ /**
+ * Class that represents OpenCRX ActivityCreator. Duplicates some functionality of OpenCRX plugin.
+ *
+ */
+ @SuppressWarnings("unused")
+ private static class OpencrxActivityCreator {
+ /** type*/
+ public static final String TYPE = "opencrx-creator"; //$NON-NLS-1$
+
+ /** hashed creator id in opencrx */
+ public static final LongProperty REMOTE_ID = new LongProperty(StoreObject.TABLE,
+ StoreObject.ITEM.name);
+
+ /** creator name */
+ public static final StringProperty NAME = new StringProperty(StoreObject.TABLE,
+ StoreObject.VALUE1.name);
+
+ /**
+ * String ID in OpenCRX system (ActivityCreator)
+ */
+ public static final StringProperty CRX_ID = new StringProperty(StoreObject.TABLE,
+ StoreObject.VALUE3.name);
+
+ // data class-part
+ private final long id;
+ private final String name;
+
+ private final String crxId;
+
+ public OpencrxActivityCreator (StoreObject creatorData) {
+ this(creatorData.getValue(REMOTE_ID),creatorData.getValue(NAME),
+ creatorData.containsValue(CRX_ID) ? creatorData.getValue(CRX_ID) : ""); //$NON-NLS-1$
+ }
+
+ public OpencrxActivityCreator(long id, String name, String crxId) {
+ this.id = id;
+ this.name = name;
+ this.crxId = crxId;
+ }
+ public long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getCrxId() {
+ return crxId;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+ }
+
+ /**
+ * Class that represents OpenCRX Contact. Duplicates some functionality of OpenCRX plugin.
+ *
+ */
+ @SuppressWarnings("unused")
+ private static class OpencrxContact {
+ public static final String TYPE = "opencrx-contacts"; //$NON-NLS-1$
+
+ /** hash contact id in opencrx */
+ public static final LongProperty REMOTE_ID = new LongProperty(StoreObject.TABLE,
+ StoreObject.ITEM.name);
+
+ /** contact first name */
+ public static final StringProperty FIRST_NAME = new StringProperty(StoreObject.TABLE,
+ StoreObject.VALUE1.name);
+
+ /** contact last name */
+ public static final StringProperty LAST_NAME = new StringProperty(StoreObject.TABLE,
+ StoreObject.VALUE2.name);
+
+ /** id in OpenCRX as string */
+ public static final StringProperty CRX_ID = new StringProperty(StoreObject.TABLE,
+ StoreObject.VALUE3.name);
+
+ private final long id;
+
+ private final String email;
+
+ private final String firstname;
+
+ private final String lastname;
+
+ private final String crxId;
+
+ public OpencrxContact(long id, String email, String firstname,
+ String lastname, String crxId) {
+ this.id = id;
+ this.email = email;
+ this.firstname = firstname;
+ this.lastname = lastname;
+ this.crxId = crxId;
+ }
+
+ public OpencrxContact(StoreObject userData){
+ this(userData.getValue(REMOTE_ID), "", userData.getValue(FIRST_NAME), userData.getValue(LAST_NAME), userData.getValue(CRX_ID) ); //$NON-NLS-1$
+ }
+
+ public String getEmail() {
+ return email;
+ }
+ public String getFirstname() {
+ return firstname;
+ }
+ public String getLastname() {
+ return lastname;
+ }
+ public String getCrxId() {
+ return crxId;
+ }
+ public long getId() {
+ return id;
+ }
+
+ @Override
+ public String toString() {
+ String displayString = ""; //$NON-NLS-1$
+ boolean hasFirstname = false;
+ boolean hasLastname = false;
+ if (firstname != null && firstname.length() > 0) {
+ displayString += firstname;
+ hasFirstname = true;
+ }
+ if (lastname != null && lastname.length() > 0)
+ hasLastname = true;
+ if (hasFirstname && hasLastname)
+ displayString += " "; //$NON-NLS-1$
+ if (hasLastname)
+ displayString += lastname;
+
+ if (!hasFirstname && !hasLastname && email != null
+ && email.length() > 0)
+ displayString += email;
+ return displayString;
+ }
+ }
+
+
+ // --- instance variables
+
+ private final Activity activity;
+
+ private final Spinner assignedToSelector;
+ private final Spinner creatorSelector;
+
+ private final AutoCompleteTextView assignedToTextInput;
+ private final AutoCompleteTextView creatorTextInput;
+
+ private ArrayList users = null;
+ private ArrayList dashboards = null;
+
+ @Autowired
+ private MetadataService metadataService;
+
+ @Autowired
+ private StoreObjectDao storeObjectDao;
+
+ @SuppressWarnings("unused")
+ public OpencrxControlSet(final Activity activity, ViewGroup parent) {
+ DependencyInjectionService.getInstance().inject(this);
+
+ this.activity = activity;
+
+ View view = LayoutInflater.from(activity).inflate(R.layout.opencrx_control, parent, true);
+
+ this.assignedToSelector = (Spinner) activity.findViewById(R.id.opencrx_TEA_task_assign);
+ TextView emptyView = new TextView(activity);
+ emptyView.setText(activity.getText(R.string.opencrx_no_creator));
+ assignedToSelector.setEmptyView(emptyView);
+
+ this.creatorSelector = (Spinner) activity.findViewById(R.id.opencrx_TEA_dashboard_assign);
+
+ this.assignedToTextInput = (AutoCompleteTextView) activity.findViewById(R.id.opencrx_TEA_contact_textinput);
+ this.creatorTextInput = (AutoCompleteTextView) activity.findViewById(R.id.opencrx_TEA_creator_textinput);
+
+ }
+
+ @Override
+ public void readFromTask(Task task) {
+
+
+ Metadata metadata = getTaskMetadata(task.getId());
+ if(metadata == null)
+ metadata = OpencrxCoreUtils.INSTANCE.newMetadata();
+
+ // Fill the dashboard-spinner and set the current dashboard
+ long dashboardId = OpencrxCoreUtils.INSTANCE.getDefaultCreator();
+ if(metadata.containsNonNullValue(OpencrxCoreUtils.ACTIVITY_CREATOR_ID))
+ dashboardId = metadata.getValue(OpencrxCoreUtils.ACTIVITY_CREATOR_ID);
+
+ StoreObject[] dashboardsData = readStoreObjects(OpencrxActivityCreator.TYPE);
+ dashboards = new ArrayList(dashboardsData.length);
+ int dashboardSpinnerIndex = -1;
+
+ for (int i=0;i dashAdapter = new ArrayAdapter(activity,
+ android.R.layout.simple_spinner_item, dashboards);
+ dashAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ creatorSelector.setAdapter(dashAdapter);
+ creatorSelector.setSelection(dashboardSpinnerIndex+1);
+
+ ArrayAdapter creatorAdapterTextInput = new ArrayAdapter(activity,
+ android.R.layout.simple_spinner_item, dashboards);
+ creatorTextInput.setAdapter(creatorAdapterTextInput);
+ creatorTextInput.setOnItemClickListener(new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView> adapter, View view, int position,
+ long id) {
+ OpencrxActivityCreator creatorInput = (OpencrxActivityCreator) adapter.getItemAtPosition(position);
+
+ if (creatorInput == null) return;
+
+ int selectedIndex = creatorSelector.getSelectedItemPosition();
+
+ for (int i = 0; i < creatorSelector.getAdapter().getCount(); ++i){
+ OpencrxActivityCreator current = (OpencrxActivityCreator) creatorSelector.getAdapter().getItem(i);
+ if (current != null && current.getId() == creatorInput.getId()){
+ selectedIndex = i;
+ break;
+ }
+ }
+
+ creatorSelector.setSelection(selectedIndex);
+ }
+ });
+
+ // Assigned user
+ long responsibleId = OpencrxCoreUtils.INSTANCE.getDefaultAssignedUser();
+ if (metadata.containsNonNullValue(OpencrxCoreUtils.ACTIVITY_ASSIGNED_TO_ID)){
+ responsibleId = metadata.getValue(OpencrxCoreUtils.ACTIVITY_ASSIGNED_TO_ID);
+ }
+
+ StoreObject[] usersData = readStoreObjects(OpencrxContact.TYPE);
+ this.users = new ArrayList();
+ for (StoreObject user : usersData){
+ this.users.add(new OpencrxContact(user));
+ }
+
+ ArrayAdapter usersAdapter = new ArrayAdapter(activity,
+ android.R.layout.simple_spinner_item, this.users);
+ usersAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ assignedToSelector.setAdapter(usersAdapter);
+
+ int responsibleSpinnerIndex = 0;
+
+ for (int i = 0; i < this.users.size() ; i++) {
+ if (this.users.get(i).getId() == responsibleId ) {
+ responsibleSpinnerIndex = i;
+ break;
+ }
+ }
+ assignedToSelector.setSelection(responsibleSpinnerIndex);
+
+ ArrayAdapter contactAdapterTextInput = new ArrayAdapter(activity,
+ android.R.layout.simple_spinner_item, this.users);
+
+ assignedToTextInput.setAdapter(contactAdapterTextInput);
+ assignedToTextInput.setOnItemClickListener(new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView> adapter, View view, int position,
+ long id) {
+
+ OpencrxContact userInput = (OpencrxContact) adapter.getItemAtPosition(position);
+
+ if (userInput == null) return;
+
+ int selectedIndex = assignedToSelector.getSelectedItemPosition();
+
+ for (int i = 0; i < assignedToSelector.getAdapter().getCount(); ++i){
+ OpencrxContact current = (OpencrxContact) assignedToSelector.getAdapter().getItem(i);
+ if (current != null && current.getId() == userInput.getId()){
+ selectedIndex = i;
+ break;
+ }
+ }
+
+ assignedToSelector.setSelection(selectedIndex);
+
+ }
+ });
+ }
+
+ @Override
+ public String writeToModel(Task task) {
+ Metadata metadata = getTaskMetadata(task.getId());
+ try {
+ if (metadata == null) {
+ metadata = OpencrxCoreUtils.INSTANCE.newMetadata();
+ }
+
+ OpencrxActivityCreator dashboard = (OpencrxActivityCreator) creatorSelector.getSelectedItem();
+ metadata.setValue(OpencrxCoreUtils.ACTIVITY_CREATOR_ID, dashboard.getId());
+
+ OpencrxContact responsibleUser = (OpencrxContact) assignedToSelector.getSelectedItem();
+
+ if(responsibleUser == null)
+ metadata.setValue(OpencrxCoreUtils.ACTIVITY_ASSIGNED_TO_ID, 0L);
+ else
+ metadata.setValue(OpencrxCoreUtils.ACTIVITY_ASSIGNED_TO_ID, responsibleUser.getId());
+
+ if(metadata.getSetValues().size() > 0) {
+ metadataService.save(metadata);
+ task.setValue(Task.MODIFICATION_DATE, DateUtilities.now());
+ }
+ } catch (Exception e) {
+ Log.e("opencrx-error", "Error Saving Metadata", e); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return null;
+ }
+
+ /**
+ * Reads metadata out of a task
+ * @return null if no metadata found
+ */
+ private Metadata getTaskMetadata(long taskId) {
+ TodorooCursor cursor = metadataService.query(Query.select(Metadata.PROPERTIES).where(
+ MetadataCriteria.byTaskAndwithKey(taskId, OpencrxCoreUtils.OPENCRX_ACTIVITY_METADATA_KEY))
+ );
+ try {
+ if(cursor.getCount() == 0)
+ return null;
+ cursor.moveToFirst();
+ return new Metadata(cursor);
+ } finally {
+ cursor.close();
+ }
+ }
+
+ private StoreObject[] readStoreObjects(String type) {
+ StoreObject[] ret;
+ TodorooCursor cursor = storeObjectDao.query(Query.select(StoreObject.PROPERTIES).
+ where(StoreObjectCriteria.byType(type)));
+ try {
+ ret = new StoreObject[cursor.getCount()];
+ for(int i = 0; i < ret.length; i++) {
+ cursor.moveToNext();
+ StoreObject dashboard = new StoreObject(cursor);
+ ret[i] = dashboard;
+ }
+ } finally {
+ cursor.close();
+ }
+
+ return ret;
+ }
+
+}
\ No newline at end of file
diff --git a/astrid/plugin-src/ru/otdelit/astrid/opencrx/OpencrxCoreUtils.java b/astrid/plugin-src/ru/otdelit/astrid/opencrx/OpencrxCoreUtils.java
new file mode 100644
index 0000000000..4ab9de46fa
--- /dev/null
+++ b/astrid/plugin-src/ru/otdelit/astrid/opencrx/OpencrxCoreUtils.java
@@ -0,0 +1,124 @@
+package ru.otdelit.astrid.opencrx;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
+import android.content.pm.PackageManager.NameNotFoundException;
+
+import com.todoroo.andlib.data.Property.LongProperty;
+import com.todoroo.andlib.data.Property.StringProperty;
+import com.todoroo.andlib.service.ContextManager;
+import com.todoroo.astrid.data.Metadata;
+import com.todoroo.astrid.sync.SyncProviderUtilities;
+
+public class OpencrxCoreUtils extends SyncProviderUtilities{
+
+ public static final String OPENCRX_ACTIVITY_METADATA_KEY = "opencrx"; //$NON-NLS-1$
+
+ public static final String IDENTIFIER = "crx"; //$NON-NLS-1$
+
+ public static final LongProperty ACTIVITY_ID = new LongProperty(Metadata.TABLE, Metadata.VALUE1.name);
+ public static final LongProperty ACTIVITY_CREATOR_ID = new LongProperty(Metadata.TABLE, Metadata.VALUE2.name);
+ public static final LongProperty ACTIVITY_USERCREATOR_ID = new LongProperty(Metadata.TABLE, Metadata.VALUE3.name);
+ public static final LongProperty ACTIVITY_ASSIGNED_TO_ID = new LongProperty(Metadata.TABLE, Metadata.VALUE4.name);
+ public static final StringProperty ACTIVITY_CRX_ID = new StringProperty(Metadata.TABLE, Metadata.VALUE5.name);
+
+ private static final String PREF_USER_ID = "crx_userid"; //$NON-NLS-1$
+ private static final String PREF_DEFAULT_CREATOR = "opencrx_defaultcreator"; //$NON-NLS-1$
+ private static final String PREFS_FILE = "crx-prefs"; //$NON-NLS-1$
+
+ private static final String OPENCRX_PACKAGE = "ru.otdelit.astrid.opencrx"; //$NON-NLS-1$
+
+ public static final long CREATOR_NO_SYNC = -1;
+
+ public static final OpencrxCoreUtils INSTANCE = new OpencrxCoreUtils();
+
+ private OpencrxCoreUtils(){
+ // prevent instantiation
+ }
+
+ public Metadata newMetadata() {
+ Metadata metadata = new Metadata();
+ metadata.setValue(Metadata.KEY, OPENCRX_ACTIVITY_METADATA_KEY);
+ metadata.setValue(ACTIVITY_ID, 0L);
+ metadata.setValue(ACTIVITY_CREATOR_ID, getDefaultCreator());
+ metadata.setValue(ACTIVITY_USERCREATOR_ID, getDefaultAssignedUser());
+ metadata.setValue(ACTIVITY_ASSIGNED_TO_ID, getDefaultAssignedUser());
+ metadata.setValue(ACTIVITY_CRX_ID, ""); //$NON-NLS-1$
+ return metadata;
+ }
+
+ @Override
+ public void stopOngoing() {
+ SharedPreferences sharedPreferences = OpencrxCoreUtils.getPrefs();
+
+ if (sharedPreferences != null){
+ Editor editor = sharedPreferences.edit();
+ editor.putBoolean(getIdentifier() + PREF_ONGOING, false);
+ editor.commit();
+ }
+ }
+
+ /**
+ * Gets default creator from setting
+ * @return CREATOR_NO_SYNC if should not sync, otherwise remote id
+ */
+ public long getDefaultCreator() {
+ long defaultCreatorId = CREATOR_NO_SYNC ;
+ SharedPreferences sharedPreferences = OpencrxCoreUtils.getPrefs();
+
+ if (sharedPreferences != null){
+ String defCreatorString = sharedPreferences.getString(PREF_DEFAULT_CREATOR, String.valueOf(CREATOR_NO_SYNC));
+
+ try{
+ defaultCreatorId = Long.parseLong(defCreatorString);
+ }catch(Exception ex){
+ defaultCreatorId = CREATOR_NO_SYNC;
+ }
+ }
+
+ return defaultCreatorId;
+ }
+
+ public long getDefaultAssignedUser(){
+ SharedPreferences sharedPreferences = OpencrxCoreUtils.getPrefs();
+
+ if (sharedPreferences != null){
+ return sharedPreferences.getLong(PREF_USER_ID, -1);
+ }else{
+ return -1;
+ }
+ }
+
+ protected static SharedPreferences getPrefs() {
+ try {
+ Context crxContext = ContextManager.getContext().createPackageContext(OPENCRX_PACKAGE, 0);
+ SharedPreferences sharedPreferences = crxContext.getSharedPreferences(PREFS_FILE,
+ Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
+ return sharedPreferences;
+ } catch (NameNotFoundException e) {
+ return null;
+ }
+ }
+
+ @Override
+ public boolean isLoggedIn() {
+ SharedPreferences sharedPreferences = OpencrxCoreUtils.getPrefs();
+
+ if (sharedPreferences != null)
+ return sharedPreferences.getString(getIdentifier() + PREF_TOKEN, null) != null;
+ else
+ return false;
+ }
+
+ @Override
+ public String getIdentifier() {
+ return IDENTIFIER;
+ }
+ @Override
+ public int getSyncIntervalKey() {
+ return 0;
+ }
+
+
+}
diff --git a/astrid/res/layout/opencrx_control.xml b/astrid/res/layout/opencrx_control.xml
new file mode 100644
index 0000000000..2a82730bab
--- /dev/null
+++ b/astrid/res/layout/opencrx_control.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/astrid/res/values-ru/strings-opencrx.xml b/astrid/res/values-ru/strings-opencrx.xml
new file mode 100644
index 0000000000..e0378dfba4
--- /dev/null
+++ b/astrid/res/values-ru/strings-opencrx.xml
@@ -0,0 +1,142 @@
+
+
+
+
+
+
+
+ OpenCRX
+
+
+ Создатели деятельности
+
+
+ Ответственный
+
+
+ Ответственный \'%s\'
+
+
+ от %s
+
+
+ Добавить комментарий
+
+
+
+
+ OpenCRX
+
+
+ Не синхронизировать
+
+
+ Создатель деятельности по умолчанию
+
+
+ Добавлять новые задачи в %s
+
+
+ Новые задачи не будут синхонизированы по умолчанию
+
+
+ Адрес OpenCRX
+
+
+ Адрес
+
+
+ Адрес OpenCRX
+
+
+ Например: mydomain.com/opencrx-rest-CRX
+
+
+ Сегмент
+
+
+ Синхронизируемый сегмент
+
+
+ Например: Standard
+
+
+ Standard
+
+
+ Provider
+
+
+ OpenCRX data provider
+
+
+ Например: CRX
+
+
+ CRX
+
+
+
+
+
+ Войти в OpenCRX
+
+
+ Войдите в OpenCRX, используя существующую учётную запись!
+
+
+ Войти
+
+
+ Имя пользователя
+
+
+ Пароль
+
+
+ Ошибка: заполните все поля!
+
+
+ Ошибка: неправильное имя пользователя или пароль!
+
+
+
+
+ OpenCRX
+
+
+ %s задач обновлено / кликните для подробностей
+
+
+ Ошибка соединения! Проверьте подключение к интернету.
+
+
+ Не указано имя пользователя!
+
+
+ Не указан пароль!
+
+
+
+
+ Назначить эту задачу этому человеку:
+
+
+ <Без назначения>
+
+
+ Назначить эту задачу этому создателю деятельности:
+
+
+ <По умолчанию>
+
+ в среде: ?
+
+ в среде...
+
+ Присвоено: ?
+
+ Присвоено ...
+
+
+
\ No newline at end of file
diff --git a/astrid/res/values/keys-opencrx.xml b/astrid/res/values/keys-opencrx.xml
new file mode 100644
index 0000000000..81ee783547
--- /dev/null
+++ b/astrid/res/values/keys-opencrx.xml
@@ -0,0 +1,14 @@
+
+
+
+ opencrx_sync_freq
+ opencrx_email
+ opencrx_password
+ opencrx_defaultcreator
+ opencrx_host
+ opencrx_segment
+ opencrx_provider
+
\ No newline at end of file
diff --git a/astrid/res/values/strings-opencrx.xml b/astrid/res/values/strings-opencrx.xml
new file mode 100644
index 0000000000..ad90f8560e
--- /dev/null
+++ b/astrid/res/values/strings-opencrx.xml
@@ -0,0 +1,142 @@
+
+
+
+
+
+
+
+ OpenCRX
+
+
+ Workspaces
+
+
+ Assigned To
+
+
+ Assigned To \'%s\'
+
+
+ from %s
+
+
+ Add a Comment
+
+ Creator
+
+ Assigned to
+
+
+
+ OpenCRX
+
+
+ (Do Not Synchronize)
+
+
+ Default ActivityCreator
+
+
+ New activities will be created by: %s
+
+
+ New activities will not be synchronized by default
+
+
+ OpenCRX server
+
+
+ Host
+
+
+ OpenCRX host
+
+
+ For example: mydomain.com
+
+
+ Segment
+
+
+ Synchronized segment
+
+
+ For example: Standard
+
+
+ Standard
+
+
+ Provider
+
+
+ OpenCRX data provider
+
+
+ For example: CRX
+
+
+ CRX
+
+
+
+ Log In to OpenCRX
+
+
+ Sign in with your OpenCRX account
+
+
+ Sign In
+
+
+ Login
+
+
+ Password
+
+
+ Error: fillout all fields
+
+
+ Error: login or password incorrect!
+
+
+
+
+ OpenCRX
+
+
+ %s tasks updated / click for more details
+
+
+ Connection Error! Check your Internet connection.
+
+
+ Login was not specified!
+
+
+ Password was not specified!
+
+
+
+
+ Assign this task to this person:
+
+
+ <Unassigned>
+
+
+ Assign this task to this creator:
+
+
+ <Default>
+
+ In workspace: ?
+
+ In workspace...
+
+ Assigned to: ?
+
+ Assigned to...
+
+
\ No newline at end of file
diff --git a/astrid/res/xml/preferences_opencrx.xml b/astrid/res/xml/preferences_opencrx.xml
new file mode 100644
index 0000000000..0cdd8da7ab
--- /dev/null
+++ b/astrid/res/xml/preferences_opencrx.xml
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java
index 392cbb9b4f..7e4c17575c 100755
--- a/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java
+++ b/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java
@@ -26,16 +26,18 @@
import java.util.LinkedList;
import java.util.List;
+import ru.otdelit.astrid.opencrx.OpencrxControlSet;
+import ru.otdelit.astrid.opencrx.OpencrxCoreUtils;
import android.app.AlertDialog;
import android.app.TabActivity;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.DialogInterface.OnCancelListener;
-import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.DialogInterface.OnCancelListener;
+import android.content.DialogInterface.OnDismissListener;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
@@ -48,7 +50,6 @@
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
@@ -63,6 +64,7 @@
import android.widget.TimePicker;
import android.widget.Toast;
import android.widget.ToggleButton;
+import android.widget.AdapterView.OnItemSelectedListener;
import com.timsu.astrid.R;
import com.todoroo.andlib.data.Property.StringProperty;
@@ -285,6 +287,16 @@ public void run() {
Log.e("astrid-error", "loading-control-set", e); //$NON-NLS-1$ //$NON-NLS-2$
}
+ try {
+ if(OpencrxCoreUtils.INSTANCE.isLoggedIn()) {
+ controls.add(new OpencrxControlSet(TaskEditActivity.this, addonsAddons));
+ notesEditText.setHint(R.string.opencrx_TEA_notes);
+ ((TextView)findViewById(R.id.notes_label)).setHint(R.string.opencrx_TEA_notes);
+ }
+ } catch (Exception e) {
+ Log.e("astrid-error", "loading-control-set", e); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
controls.add(new TimerControlSet(TaskEditActivity.this, addonsAddons));
controls.add(new AlarmControlSet(TaskEditActivity.this, addonsAddons));
@@ -736,7 +748,7 @@ public ImportanceControlSet(int containerId) {
int min = Task.IMPORTANCE_MOST;
int max = Task.IMPORTANCE_LEAST;
- if(ProducteevUtilities.INSTANCE.isLoggedIn())
+ if(ProducteevUtilities.INSTANCE.isLoggedIn() || OpencrxCoreUtils.INSTANCE.isLoggedIn())
max = 5;
for(int i = min; i <= max; i++) {
@@ -745,7 +757,7 @@ public ImportanceControlSet(int containerId) {
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1));
StringBuilder label = new StringBuilder();
- if(ProducteevUtilities.INSTANCE.isLoggedIn())
+ if(ProducteevUtilities.INSTANCE.isLoggedIn() || OpencrxCoreUtils.INSTANCE.isLoggedIn())
label.append(5 - i).append("\n\u2605"); //$NON-NLS-1$
else {
for(int j = Task.IMPORTANCE_LEAST; j >= i; j--)
diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java
index 1e4d225b79..930b592c3a 100644
--- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java
+++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java
@@ -3,9 +3,9 @@
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
-import java.util.Map.Entry;
import java.util.Timer;
import java.util.TimerTask;
+import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicReference;
import org.weloveastrid.rmilk.MilkPreferences;
@@ -32,28 +32,28 @@
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.ContextMenu;
-import android.view.ContextMenu.ContextMenuInfo;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.View.OnKeyListener;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
+import android.view.ContextMenu.ContextMenuInfo;
+import android.view.View.OnClickListener;
+import android.view.View.OnKeyListener;
import android.view.inputmethod.EditorInfo;
import android.widget.AbsListView;
-import android.widget.AbsListView.OnScrollListener;
-import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
-import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;
+import android.widget.AbsListView.OnScrollListener;
+import android.widget.AdapterView.AdapterContextMenuInfo;
+import android.widget.TextView.OnEditorActionListener;
import com.timsu.astrid.R;
import com.todoroo.andlib.data.Property;
@@ -180,7 +180,6 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
/* ======================================================================
* ======================================================= initialization
* ====================================================================== */
-
static {
AstridDependencyInjector.initialize();
}
diff --git a/astrid/src/com/todoroo/astrid/service/StartupService.java b/astrid/src/com/todoroo/astrid/service/StartupService.java
index 493a08b40d..754dd515cb 100644
--- a/astrid/src/com/todoroo/astrid/service/StartupService.java
+++ b/astrid/src/com/todoroo/astrid/service/StartupService.java
@@ -5,6 +5,7 @@
import org.weloveastrid.rmilk.MilkUtilities;
+import ru.otdelit.astrid.opencrx.OpencrxCoreUtils;
import android.Manifest;
import android.app.Activity;
import android.app.AlarmManager;
@@ -12,8 +13,8 @@
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
+import android.content.DialogInterface.OnClickListener;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
@@ -153,6 +154,7 @@ public void run() {
// if sync ongoing flag was set, clear it
ProducteevUtilities.INSTANCE.stopOngoing();
MilkUtilities.INSTANCE.stopOngoing();
+ OpencrxCoreUtils.INSTANCE.stopOngoing();
BackupService.scheduleService(context);
diff --git a/astrid/src/com/todoroo/astrid/service/TaskService.java b/astrid/src/com/todoroo/astrid/service/TaskService.java
index d4bb697005..68737599fe 100644
--- a/astrid/src/com/todoroo/astrid/service/TaskService.java
+++ b/astrid/src/com/todoroo/astrid/service/TaskService.java
@@ -6,6 +6,7 @@
import org.weloveastrid.rmilk.data.MilkTaskFields;
+import ru.otdelit.astrid.opencrx.OpencrxCoreUtils;
import android.content.ContentValues;
import com.todoroo.andlib.data.Property;
@@ -19,8 +20,8 @@
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.PermaSql;
import com.todoroo.astrid.dao.MetadataDao;
-import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.dao.TaskDao;
+import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task;
@@ -121,6 +122,8 @@ public Task clone(Task task) {
continue;
if(MilkTaskFields.METADATA_KEY.equals(metadata.getValue(Metadata.KEY)))
continue;
+ if(OpencrxCoreUtils.OPENCRX_ACTIVITY_METADATA_KEY.equals(metadata.getValue(Metadata.KEY)))
+ continue;
metadata.setValue(Metadata.TASK, newId);
metadata.clearValue(Metadata.ID);
@@ -342,7 +345,7 @@ public static void parseQuickAddMarkup(Task task, ArrayList tags) {
// not in producteev world: !1 to !4 => importance 3 to 0
int importance = Math.max(Task.IMPORTANCE_MOST, Task.IMPORTANCE_LEAST + 1 - value);
// in the producteev world, !1 to !4 => importance 4 to 1
- if(ProducteevUtilities.INSTANCE.isLoggedIn())
+ if(ProducteevUtilities.INSTANCE.isLoggedIn() || OpencrxCoreUtils.INSTANCE.isLoggedIn())
importance++;
task.setValue(Task.IMPORTANCE, importance);