Skip to content
Open
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
9 changes: 9 additions & 0 deletions res/layout/notification_progress_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,14 @@
android:layout_weight="1"
android:spacing="0dip"
android:text="@string/error_no_featured_casts" />
<TextView
android:id="@+id/noDataTextView"
style="@style/EmptyList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:spacing="0dip"
android:text="@string/error_no_data_connection"
android:visibility="gone" />

</FrameLayout>
Expand Down
1 change: 1 addition & 0 deletions res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@
<string name="auth_error_network_protocol_error">Errore di protocollo Network: %1$s</string>
<string name="videoplayer_notice_loading_video">Caricamento video...</string>
<string name="loading_data">Caricamento dati...</string>
<string name="error_no_data_connection">Connessione a internet necessaria per caricare i contenuti. Riprovare con connessione dati attiva</string>
</resources>
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,5 @@
<string name="cast_edit_error_camera_did_not_return_image">Error: camera did not return an image. Please try again.</string>
<string name="cast_edit_media_empty">Tap the buttons below to add photos and videos</string>
<string name="loading_data">Loading data...</string>
<string name="error_no_data_connection">You need a data connection to load this content. Please try again with data enabled</string>
</resources>
19 changes: 11 additions & 8 deletions src/edu/mit/mobile/android/locast/sync/LocastSyncService.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import edu.mit.mobile.android.locast.data.SyncException;
import edu.mit.mobile.android.locast.net.NetworkClient;
import edu.mit.mobile.android.locast.net.NetworkProtocolException;
import edu.mit.mobile.android.widget.NotificationProgressBar;

/**
* A wrapper to {@link SyncEngine} which provides the interface to the
Expand Down Expand Up @@ -85,7 +86,7 @@ public class LocastSyncService extends Service {
* @see #startSync(Account, Uri, boolean, Bundle)
*/
public static void startSync(Context context, Uri what) {
startSync(Authenticator.getFirstAccount(context), what, false, new Bundle());
startSync(context,Authenticator.getFirstAccount(context), what, false, new Bundle());
}

/**
Expand All @@ -97,7 +98,7 @@ public static void startSync(Context context, Uri what) {
* @see #startSync(Account, Uri, boolean, Bundle)
*/
public static void startSync(Context context, Uri what, boolean explicitSync) {
startSync(Authenticator.getFirstAccount(context), what, explicitSync, new Bundle());
startSync(context,Authenticator.getFirstAccount(context), what, explicitSync, new Bundle());
}

/**
Expand All @@ -108,14 +109,14 @@ public static void startSync(Context context, Uri what, boolean explicitSync) {
* @see #startSync(Account, Uri, boolean, Bundle)
*/
public static void startSync(Context context, Uri what, boolean explicitSync, Bundle extras) {
startSync(Authenticator.getFirstAccount(context), what, explicitSync, extras);
startSync(context,Authenticator.getFirstAccount(context), what, explicitSync, extras);
}

public static void startExpeditedAutomaticSync(Context context, Uri what){
final Bundle extras = new Bundle();
extras.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);

startSync(Authenticator.getFirstAccount(context), what, false, extras);
startSync(context,Authenticator.getFirstAccount(context), what, false, extras);
}

/**
Expand All @@ -136,7 +137,7 @@ public static void startSync(Context context, Uri httpPubUrl, Uri destination,
final Bundle b = new Bundle();
b.putString(SyncEngine.EXTRA_DESTINATION_URI, destination.toString());

startSync(Authenticator.getFirstAccount(context), httpPubUrl, explicitSync, b);
startSync(context,Authenticator.getFirstAccount(context), httpPubUrl, explicitSync, b);
}

/**
Expand All @@ -147,10 +148,10 @@ public static void startSync(Context context, Uri httpPubUrl, Uri destination,
* @param explicitSync
* @see #startSync(Account, Uri, boolean, Bundle)
*/
public static void startSync(Account account, Uri what, boolean explicitSync) {
public static void startSync(Context context,Account account, Uri what, boolean explicitSync) {
final Bundle b = new Bundle();

startSync(account, what, explicitSync, b);
startSync(context,account, what, explicitSync, b);
}

/**
Expand All @@ -166,7 +167,7 @@ public static void startSync(Account account, Uri what, boolean explicitSync) {
* the extras
* @param extras
*/
public static void startSync(Account account, Uri what, boolean explicitSync, Bundle extras) {
public static void startSync(Context context,Account account, Uri what, boolean explicitSync, Bundle extras) {
if (explicitSync) {
extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
if (!extras.containsKey(ContentResolver.SYNC_EXTRAS_EXPEDITED)) {
Expand All @@ -188,6 +189,8 @@ public static void startSync(Account account, Uri what, boolean explicitSync, Bu
Log.d(TAG, "requesting sync for "+account + " with extras: "+extras);
}
ContentResolver.requestSync(account, MediaProvider.AUTHORITY, extras);
context.sendBroadcast(new Intent(NotificationProgressBar.INTENT_UPDATE_NETWORK_STATUS));

}

@Override
Expand Down
57 changes: 53 additions & 4 deletions src/edu/mit/mobile/android/locast/ver2/browser/BrowserHome.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
*/

import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
Expand Down Expand Up @@ -55,6 +60,7 @@
import edu.mit.mobile.android.locast.sync.LocastSyncStatusObserver;
import edu.mit.mobile.android.locast.ver2.R;
import edu.mit.mobile.android.locast.ver2.casts.LocatableListWithMap;
import edu.mit.mobile.android.widget.NetworkStatusBroadcastReceiver;
import edu.mit.mobile.android.widget.NotificationProgressBar;
import edu.mit.mobile.android.widget.RefreshButton;

Expand All @@ -77,6 +83,8 @@ public class BrowserHome extends FragmentActivity implements LoaderManager.Loade
private static final int LOADER_FEATURED_CASTS = 0;

private static final int DIALOG_LOGOUT = 100;

private static NetworkStatusBroadcastReceiver mNetworkBroadcastReceiver;

private final Handler mHandler = new Handler() {
@Override
Expand All @@ -97,6 +105,27 @@ public void handleMessage(Message msg) {
mProgressBar.showProgressBar(false);
mRefresh.setRefreshing(false);
break;
case NetworkStatusBroadcastReceiver.MSG_NETWORK_STATE:
if (Constants.DEBUG) {
Log.d(TAG, "Network state changed");
}
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo != null && netInfo.isConnectedOrConnecting()) {
if (Constants.DEBUG) {
Log.d(TAG, "Network state connecting");
}
mProgressBar.setNetworkStatus(true);
mRefresh.setRefreshing(true);
}
else{
if (Constants.DEBUG) {
Log.d(TAG, "Network state not connecting");
}
mProgressBar.setNetworkStatus(false);
mRefresh.setRefreshing(false);
}
break;
}
};
};
Expand All @@ -106,11 +135,28 @@ public void handleMessage(Message msg) {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

mNetworkBroadcastReceiver=new NetworkStatusBroadcastReceiver(this, mHandler);
mImageCache = ImageCache.getInstance(this);

setContentView(R.layout.browser_main);
mProgressBar =(NotificationProgressBar) (findViewById(R.id.progressNotification));
mRefresh = (RefreshButton) findViewById(R.id.refresh);
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo != null && netInfo.isConnectedOrConnecting()) {
if (Constants.DEBUG) {
Log.d(TAG, "Network state connecting");
}
mProgressBar.setNetworkStatus(true);
mRefresh.setRefreshing(true);
}
else{
if (Constants.DEBUG) {
Log.d(TAG, "Network state not connecting");
}
mProgressBar.setNetworkStatus(false);
mRefresh.setRefreshing(false);
}
if (Constants.USE_APPUPDATE_CHECKER) {
mAppUpdateChecker = new AppUpdateChecker(this, getString(R.string.app_update_url),
new AppUpdateChecker.OnUpdateDialog(this, getString(R.string.app_name)));
Expand All @@ -130,7 +176,7 @@ protected void onCreate(Bundle savedInstanceState) {
final LoaderManager lm = getSupportLoaderManager();
lm.initLoader(LOADER_FEATURED_CASTS, null, this);

mRefresh = (RefreshButton) findViewById(R.id.refresh);

mRefresh.setOnClickListener(this);
findViewById(R.id.itineraries).setOnClickListener(this);
findViewById(R.id.events).setOnClickListener(this);
Expand All @@ -149,7 +195,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
protected void onPause() {
super.onPause();

this.unregisterReceiver(mNetworkBroadcastReceiver);
if (mSyncHandle != null) {
ContentResolver.removeStatusChangeListener(mSyncHandle);
}
Expand All @@ -158,10 +204,13 @@ protected void onPause() {
@Override
protected void onResume() {
super.onResume();
IntentFilter intentFilter=new IntentFilter();
intentFilter.addAction(android.net.ConnectivityManager.CONNECTIVITY_ACTION);
intentFilter.addAction(NotificationProgressBar.INTENT_UPDATE_NETWORK_STATUS);
this.registerReceiver(mNetworkBroadcastReceiver, intentFilter);
mSyncHandle = ContentResolver.addStatusChangeListener(0xff, new LocastSyncStatusObserver(
this, mHandler));
LocastSyncStatusObserver.notifySyncStatusToHandler(this, mHandler);

if (shouldRefresh) {
refresh(false);
}
Expand Down
33 changes: 33 additions & 0 deletions src/edu/mit/mobile/android/locast/ver2/casts/CastDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
Expand Down Expand Up @@ -59,6 +62,7 @@
import edu.mit.mobile.android.locast.ver2.R;
import edu.mit.mobile.android.locast.ver2.itineraries.LocatableItemOverlay;
import edu.mit.mobile.android.locast.widget.FavoriteClickHandler;
import edu.mit.mobile.android.widget.NetworkStatusBroadcastReceiver;
import edu.mit.mobile.android.widget.NotificationProgressBar;
import edu.mit.mobile.android.widget.RefreshButton;
import edu.mit.mobile.android.widget.ValidatingCheckBox;
Expand All @@ -79,6 +83,8 @@ public class CastDetail extends LocatableDetail implements LoaderManager.LoaderC
private Uri mCastMediaUri;

private static final int REQUEST_SIGNIN = 0;

private static NetworkStatusBroadcastReceiver mNetworkBroadcastReceiver;

private static final String[] CAST_PROJECTION = ArrayUtils.concat(new String[] { Cast._ID,
Cast._TITLE, Cast._AUTHOR, Cast._DESCRIPTION, Cast._FAVORITED },
Expand Down Expand Up @@ -109,6 +115,27 @@ public void handleMessage(Message msg) {
mProgressBar.showProgressBar(false);
mRefresh.setRefreshing(false);
break;
case NetworkStatusBroadcastReceiver.MSG_NETWORK_STATE:
if (Constants.DEBUG) {
Log.d(TAG, "Network state changed");
}
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo != null && netInfo.isConnectedOrConnecting()) {
if (Constants.DEBUG) {
Log.d(TAG, "Network state connecting");
}
mProgressBar.setNetworkStatus(true);
mRefresh.setRefreshing(true);
}
else{
if (Constants.DEBUG) {
Log.d(TAG, "Network state not connecting");
}
mProgressBar.setNetworkStatus(false);
mRefresh.setRefreshing(false);
}
break;
}
};
};
Expand All @@ -119,6 +146,7 @@ public void handleMessage(Message msg) {
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
mNetworkBroadcastReceiver=new NetworkStatusBroadcastReceiver(this, mHandler);
setContentView(R.layout.cast_detail);

initOverlays();
Expand Down Expand Up @@ -161,6 +189,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
protected void onPause() {
super.onPause();
this.unregisterReceiver(mNetworkBroadcastReceiver);
if (mSyncHandle != null) {
ContentResolver.removeStatusChangeListener(mSyncHandle);
}
Expand All @@ -169,6 +198,10 @@ protected void onPause() {
@Override
protected void onResume() {
super.onResume();
IntentFilter intentFilter=new IntentFilter();
intentFilter.addAction(android.net.ConnectivityManager.CONNECTIVITY_ACTION);
intentFilter.addAction(NotificationProgressBar.INTENT_UPDATE_NETWORK_STATUS);
this.registerReceiver(mNetworkBroadcastReceiver, intentFilter);
mSyncHandle = ContentResolver.addStatusChangeListener(0xff, new LocastSyncStatusObserver(
this, mHandler));
LocastSyncStatusObserver.notifySyncStatusToHandler(this, mHandler);
Expand Down
Loading