mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 17:46:37 +03:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
38512099c4
5 changed files with 24 additions and 7 deletions
|
@ -64,8 +64,8 @@
|
|||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:hint="@string/auth_host_url"
|
||||
android:singleLine="true" >
|
||||
|
||||
android:singleLine="true"
|
||||
android:inputType="textNoSuggestions">
|
||||
<requestFocus />
|
||||
</EditText>
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<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_height="fill_parent"
|
||||
android:focusable="true"
|
||||
|
@ -60,8 +59,8 @@
|
|||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:hint="@string/auth_host_url"
|
||||
android:singleLine="true" >
|
||||
|
||||
android:singleLine="true"
|
||||
android:inputType="textNoSuggestions" >
|
||||
<requestFocus />
|
||||
</EditText>
|
||||
|
||||
|
|
|
@ -194,4 +194,6 @@
|
|||
<string name="ssl_validator_not_saved">The certificate could not be saved</string>
|
||||
|
||||
<string name="text_placeholder">This is a placeholder</string>
|
||||
|
||||
<string name="instant_upload_on_wifi">Upload pictures via WiFi only</string>
|
||||
</resources>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<CheckBoxPreference android:key="instant_uploading"
|
||||
android:title="@string/prefs_instant_upload"
|
||||
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>
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo.State;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore.Images.Media;
|
||||
import android.util.Log;
|
||||
|
@ -45,10 +46,13 @@ public class PhotoTakenBroadcastReceiver extends BroadcastReceiver {
|
|||
|
||||
@Override
|
||||
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");
|
||||
return;
|
||||
}
|
||||
|
||||
if (intent.getAction().equals(android.net.ConnectivityManager.CONNECTIVITY_ACTION)) {
|
||||
handleConnectivityAction(context, intent);
|
||||
} else if (intent.getAction().equals(NEW_PHOTO_ACTION)) {
|
||||
|
@ -71,6 +75,17 @@ public class PhotoTakenBroadcastReceiver extends BroadcastReceiver {
|
|||
Log.e(TAG, "Couldn't resolve given uri!");
|
||||
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_name = c.getString(c.getColumnIndex(Media.DISPLAY_NAME));
|
||||
|
@ -79,7 +94,7 @@ public class PhotoTakenBroadcastReceiver extends BroadcastReceiver {
|
|||
|
||||
c.close();
|
||||
|
||||
if (!isOnline(context)) {
|
||||
if (!isOnline(context) || (iu_via_wifi && !is_conn_via_wifi)) {
|
||||
DbHandler db = new DbHandler(context);
|
||||
db.putFileForLater(file_path, account.name);
|
||||
db.close();
|
||||
|
|
Loading…
Reference in a new issue