diff --git a/res/layout/tasker_settings.xml b/res/layout/tasker_settings.xml
index b96642aa..b50f3c3c 100644
--- a/res/layout/tasker_settings.xml
+++ b/res/layout/tasker_settings.xml
@@ -4,17 +4,6 @@
android:layout_height="fill_parent"
android:padding="5dp" >
-
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 586ec70a..7b475ddc 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -208,4 +208,5 @@
Shortcut has been placed on the home screen
Download articles and go offline
Save and close
+ Synchronize read articles and go online
diff --git a/src/org/fox/ttrss/offline/OfflineUploadService.java b/src/org/fox/ttrss/offline/OfflineUploadService.java
index 55ed4467..4c3349d4 100644
--- a/src/org/fox/ttrss/offline/OfflineUploadService.java
+++ b/src/org/fox/ttrss/offline/OfflineUploadService.java
@@ -11,7 +11,9 @@ import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
+import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
@@ -29,6 +31,7 @@ public class OfflineUploadService extends IntentService {
private String m_sessionId;
private NotificationManager m_nmgr;
private boolean m_uploadInProgress = false;
+ private boolean m_batchMode = false;
public OfflineUploadService() {
super("OfflineUploadService");
@@ -200,10 +203,19 @@ public class OfflineUploadService extends IntentService {
private void uploadSuccess() {
getWritableDb().execSQL("UPDATE articles SET modified = 0");
- Intent intent = new Intent();
- intent.setAction(INTENT_ACTION_SUCCESS);
- intent.addCategory(Intent.CATEGORY_DEFAULT);
- sendBroadcast(intent);
+ if (m_batchMode) {
+
+ SharedPreferences localPrefs = getSharedPreferences("localprefs", Context.MODE_PRIVATE);
+ SharedPreferences.Editor editor = localPrefs.edit();
+ editor.putBoolean("offline_mode_active", false);
+ editor.commit();
+
+ } else {
+ Intent intent = new Intent();
+ intent.setAction(INTENT_ACTION_SUCCESS);
+ intent.addCategory(Intent.CATEGORY_DEFAULT);
+ sendBroadcast(intent);
+ }
m_readableDb.close();
m_writableDb.close();
@@ -257,6 +269,7 @@ public class OfflineUploadService extends IntentService {
}
m_sessionId = intent.getStringExtra("sessionId");
+ m_batchMode = intent.getBooleanExtra("batchMode", false);
if (!m_uploadInProgress) {
m_uploadInProgress = true;
diff --git a/src/org/fox/ttrss/tasker/TaskerReceiver.java b/src/org/fox/ttrss/tasker/TaskerReceiver.java
index 6a61e30b..bdd85e3f 100644
--- a/src/org/fox/ttrss/tasker/TaskerReceiver.java
+++ b/src/org/fox/ttrss/tasker/TaskerReceiver.java
@@ -4,12 +4,14 @@ import org.fox.ttrss.ApiRequest;
import org.fox.ttrss.CommonActivity;
import org.fox.ttrss.OnlineActivity;
import org.fox.ttrss.offline.OfflineDownloadService;
+import org.fox.ttrss.offline.OfflineUploadService;
import org.fox.ttrss.util.SimpleLoginManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
@@ -24,21 +26,41 @@ public class TaskerReceiver extends BroadcastReceiver {
final Context fContext = context;
if (com.twofortyfouram.locale.Intent.ACTION_FIRE_SETTING.equals(intent.getAction())) {
- Log.d(TAG, "about to download stuff!");
+
+ final Bundle settings = intent.getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE);
+ final int actionId = settings != null ? settings.getInt("actionId", -1) : -1;
+
+ Log.d(TAG, "received action id=" + actionId);
SimpleLoginManager loginMgr = new SimpleLoginManager() {
@Override
protected void onLoginSuccess(int requestId, String sessionId, int apiLevel) {
- Log.d(TAG, "Got SID=" + sessionId);
-
- Intent intent = new Intent(
- fContext,
- OfflineDownloadService.class);
- intent.putExtra("sessionId", sessionId);
- intent.putExtra("batchMode", true);
- fContext.startService(intent);
+ switch (actionId) {
+ case TaskerSettingsActivity.ACTION_DOWNLOAD:
+ if (true) {
+ Intent intent = new Intent(fContext,
+ OfflineDownloadService.class);
+ intent.putExtra("sessionId", sessionId);
+ intent.putExtra("batchMode", true);
+
+ fContext.startService(intent);
+ }
+ break;
+ case TaskerSettingsActivity.ACTION_UPLOAD:
+ if (true) {
+ Intent intent = new Intent(fContext,
+ OfflineUploadService.class);
+ intent.putExtra("sessionId", sessionId);
+ intent.putExtra("batchMode", true);
+
+ fContext.startService(intent);
+ }
+ break;
+ default:
+ Log.d(TAG, "unknown action id=" + actionId);
+ }
}
@Override
diff --git a/src/org/fox/ttrss/tasker/TaskerSettingsActivity.java b/src/org/fox/ttrss/tasker/TaskerSettingsActivity.java
index 50c500d1..ff56ad1a 100644
--- a/src/org/fox/ttrss/tasker/TaskerSettingsActivity.java
+++ b/src/org/fox/ttrss/tasker/TaskerSettingsActivity.java
@@ -1,15 +1,23 @@
package org.fox.ttrss.tasker;
import org.fox.ttrss.R;
+import org.fox.ttrss.offline.OfflineDownloadService;
+import org.fox.ttrss.offline.OfflineUploadService;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
+import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
+import android.widget.RadioGroup;
+import android.widget.RadioGroup.OnCheckedChangeListener;
public class TaskerSettingsActivity extends Activity {
+ protected static final int ACTION_DOWNLOAD = 0;
+ protected static final int ACTION_UPLOAD = 1;
+
private final String TAG = this.getClass().getSimpleName();
protected Bundle m_settings = new Bundle();
@@ -18,14 +26,42 @@ public class TaskerSettingsActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- //Bundle settings = getIntent().getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE);
+ Bundle settings = getIntent().getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE);
+
+ int actionId = settings != null ? settings.getInt("actionId", -1) : -1;
setContentView(R.layout.tasker_settings);
+
+ RadioGroup radioGroup = (RadioGroup) findViewById(R.id.taskerActions);
+
+ switch (actionId) {
+ case TaskerSettingsActivity.ACTION_DOWNLOAD:
+ radioGroup.check(R.id.actionDownload);
+ break;
+ case TaskerSettingsActivity.ACTION_UPLOAD:
+ radioGroup.check(R.id.actionUpload);
+ break;
+ default:
+ Log.d(TAG, "unknown action id=" + actionId);
+ }
+
+ radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
+ switch (checkedId) {
+ case R.id.actionDownload:
+ m_settings.putInt("actionId", ACTION_DOWNLOAD);
+ break;
+ case R.id.actionUpload:
+ m_settings.putInt("actionId", ACTION_UPLOAD);
+ break;
+ }
+ }
+ });
Button button = (Button)findViewById(R.id.close_button);
- button.setOnClickListener(new OnClickListener() {
-
+ button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
@@ -38,7 +74,19 @@ public class TaskerSettingsActivity extends Activity {
final Intent intent = new Intent();
intent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE, m_settings);
- intent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB, getString(R.string.download_articles_and_go_offline));
+
+ String blurb = "?";
+
+ switch (m_settings.getInt("actionId")) {
+ case TaskerSettingsActivity.ACTION_DOWNLOAD:
+ blurb = getString(R.string.download_articles_and_go_offline);
+ break;
+ case TaskerSettingsActivity.ACTION_UPLOAD:
+ blurb = getString(R.string.synchronize_read_articles_and_go_online);
+ break;
+ }
+
+ intent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB, blurb);
setResult(RESULT_OK, intent);