Merge remote-tracking branch 'origin/master'

This commit is contained in:
David A. Velasco 2012-10-09 14:54:14 +02:00
commit 38512099c4
5 changed files with 24 additions and 7 deletions

View file

@ -64,8 +64,8 @@
android:layout_weight="1" android:layout_weight="1"
android:ems="10" android:ems="10"
android:hint="@string/auth_host_url" android:hint="@string/auth_host_url"
android:singleLine="true" > android:singleLine="true"
android:inputType="textNoSuggestions">
<requestFocus /> <requestFocus />
</EditText> </EditText>

View file

@ -17,7 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:oc="http://schemas.android.com/apk/res/com.owncloud.android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:focusable="true" android:focusable="true"
@ -60,8 +59,8 @@
android:layout_weight="1" android:layout_weight="1"
android:ems="10" android:ems="10"
android:hint="@string/auth_host_url" android:hint="@string/auth_host_url"
android:singleLine="true" > android:singleLine="true"
android:inputType="textNoSuggestions" >
<requestFocus /> <requestFocus />
</EditText> </EditText>

View file

@ -194,4 +194,6 @@
<string name="ssl_validator_not_saved">The certificate could not be saved</string> <string name="ssl_validator_not_saved">The certificate could not be saved</string>
<string name="text_placeholder">This is a placeholder</string> <string name="text_placeholder">This is a placeholder</string>
<string name="instant_upload_on_wifi">Upload pictures via WiFi only</string>
</resources> </resources>

View file

@ -13,6 +13,7 @@
<CheckBoxPreference android:key="instant_uploading" <CheckBoxPreference android:key="instant_uploading"
android:title="@string/prefs_instant_upload" android:title="@string/prefs_instant_upload"
android:summary="@string/prefs_instant_upload_summary"/> android:summary="@string/prefs_instant_upload_summary"/>
<CheckBoxPreference android:dependency="instant_uploading" android:disableDependentsState="true" android:title="@string/instant_upload_on_wifi" android:key="instant_upload_on_wifi"/>
</PreferenceCategory> </PreferenceCategory>

View file

@ -31,6 +31,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo.State;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.MediaStore.Images.Media; import android.provider.MediaStore.Images.Media;
import android.util.Log; import android.util.Log;
@ -45,10 +46,13 @@ public class PhotoTakenBroadcastReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (!PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_uploading", false)) { boolean iu_enabled = PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_uploading", false);
if (!iu_enabled) {
Log.d(TAG, "Instant upload disabled, abording uploading"); Log.d(TAG, "Instant upload disabled, abording uploading");
return; return;
} }
if (intent.getAction().equals(android.net.ConnectivityManager.CONNECTIVITY_ACTION)) { if (intent.getAction().equals(android.net.ConnectivityManager.CONNECTIVITY_ACTION)) {
handleConnectivityAction(context, intent); handleConnectivityAction(context, intent);
} else if (intent.getAction().equals(NEW_PHOTO_ACTION)) { } else if (intent.getAction().equals(NEW_PHOTO_ACTION)) {
@ -72,6 +76,17 @@ public class PhotoTakenBroadcastReceiver extends BroadcastReceiver {
return; return;
} }
boolean iu_via_wifi = PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_upload_on_wifi", false);
boolean is_conn_via_wifi = false;
if (iu_via_wifi) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm != null && cm.getActiveNetworkInfo() != null &&
cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI &&
cm.getActiveNetworkInfo().getState() == State.CONNECTED)
is_conn_via_wifi = true;
}
String file_path = c.getString(c.getColumnIndex(Media.DATA)); String file_path = c.getString(c.getColumnIndex(Media.DATA));
String file_name = c.getString(c.getColumnIndex(Media.DISPLAY_NAME)); String file_name = c.getString(c.getColumnIndex(Media.DISPLAY_NAME));
String mime_type = c.getString(c.getColumnIndex(Media.MIME_TYPE)); String mime_type = c.getString(c.getColumnIndex(Media.MIME_TYPE));
@ -79,7 +94,7 @@ public class PhotoTakenBroadcastReceiver extends BroadcastReceiver {
c.close(); c.close();
if (!isOnline(context)) { if (!isOnline(context) || (iu_via_wifi && !is_conn_via_wifi)) {
DbHandler db = new DbHandler(context); DbHandler db = new DbHandler(context);
db.putFileForLater(file_path, account.name); db.putFileForLater(file_path, account.name);
db.close(); db.close();