Skip to content

Commit

Permalink
issue 48 - added warning message when refresh is requested but wifi i…
Browse files Browse the repository at this point in the history
…s off and required
  • Loading branch information
thasmin committed Apr 21, 2012
1 parent e93cfb8 commit 3dcf21f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@
<string name="skip_to_end">Skip To End</string>
<string name="thumbnail">thumbnail</string>
<string name="unsubscribe">Unsubscribe</string>
<string name="update_request_no_wifi">Podax will not update because there is no Wi-Fi connection. This can be changed in the preferences.</string>
</resources>
1 change: 1 addition & 0 deletions src/com/axelby/podax/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class Constants {
public static final String EXTRA_URL = "com.axelby.podax.url";
public static final String EXTRA_POPULAR_SOURCE_URL = "com.axelby.podax.popular_source_url";
public static final String EXTRA_POPULAR_SOURCE_NAME = "com.axelby.popular_source_name";
public static final String EXTRA_MANUAL_REFRESH = "com.axelby.podax.manual_refresh";

public static final String EXTRA_PLAYER_COMMAND = "com.axelby.podax.player_command";
public static final String EXTRA_PLAYER_COMMAND_ARG = "com.axelby.podax.player_command_arg";
Expand Down
9 changes: 9 additions & 0 deletions src/com/axelby/podax/UpdateService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,36 @@
import android.net.Uri;
import android.os.Binder;
import android.os.IBinder;
import android.widget.Toast;

public class UpdateService extends Service {
public static void updateSubscriptions(Context context) {
Intent intent = new Intent(context, UpdateService.class);
intent.setAction(Constants.ACTION_REFRESH_ALL_SUBSCRIPTIONS);
intent.putExtra(Constants.EXTRA_MANUAL_REFRESH, true);
context.startService(intent);
}

public static void updateSubscription(Context context, int subscriptionId) {
Intent intent = new Intent(context, UpdateService.class);
intent.setAction(Constants.ACTION_REFRESH_SUBSCRIPTION);
intent.putExtra(Constants.EXTRA_SUBSCRIPTION_ID, subscriptionId);
intent.putExtra(Constants.EXTRA_MANUAL_REFRESH, true);
context.startService(intent);
}

public static void updateSubscription(Context context, Uri subscriptionUri) {
Intent intent = new Intent(context, UpdateService.class);
intent.setAction(Constants.ACTION_REFRESH_SUBSCRIPTION);
intent.putExtra(Constants.EXTRA_SUBSCRIPTION_ID, Integer.valueOf(subscriptionUri.getLastPathSegment()));
intent.putExtra(Constants.EXTRA_MANUAL_REFRESH, true);
context.startService(intent);
}

public static void downloadPodcasts(Context context) {
Intent intent = new Intent(context, UpdateService.class);
intent.setAction(Constants.ACTION_DOWNLOAD_PODCASTS);
intent.putExtra(Constants.EXTRA_MANUAL_REFRESH, true);
context.startService(intent);
}

Expand Down Expand Up @@ -74,6 +79,10 @@ private void handleIntent(Intent intent) {
if (action == null)
return;

if (intent.getBooleanExtra(Constants.EXTRA_MANUAL_REFRESH, false) && !Helper.ensureWifi(this)) {
Toast.makeText(this, R.string.update_request_no_wifi, Toast.LENGTH_SHORT).show();
return;
}
if (action.equals(Constants.ACTION_REFRESH_ALL_SUBSCRIPTIONS)) {
_subscriptionUpdater.addAllSubscriptions();
_subscriptionUpdater.run();
Expand Down

0 comments on commit 3dcf21f

Please sign in to comment.