Merge pull request #825 from owncloud/SettingsGreyedOut

Instant Upload settings hide/show
This commit is contained in:
jabarros 2015-01-23 09:29:11 +01:00
commit 7d21a9ec5d
2 changed files with 65 additions and 13 deletions

View file

@ -31,25 +31,23 @@
android:summary="@string/prefs_pincode_summary"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/prefs_category_instant_uploading">
<com.owncloud.android.ui.PreferenceWithLongSummary
android:title="@string/prefs_instant_upload_path_title"
android:key="instant_upload_path" />
<PreferenceCategory android:title="@string/prefs_category_instant_uploading" android:key="instant_uploading_category">
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:key="instant_uploading"
android:title="@string/prefs_instant_upload"
android:summary="@string/prefs_instant_upload_summary"/>
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:dependency="instant_uploading"
android:disableDependentsState="true"
<com.owncloud.android.ui.PreferenceWithLongSummary
android:title="@string/prefs_instant_upload_path_title"
android:key="instant_upload_path" />
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
android:title="@string/instant_upload_on_wifi"
android:key="instant_upload_on_wifi"/>
<com.owncloud.android.ui.PreferenceWithLongSummary
android:title="@string/prefs_instant_video_upload_path_title"
android:key="instant_video_upload_path" />
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:key="instant_video_uploading"
android:title="@string/prefs_instant_video_upload"
android:summary="@string/prefs_instant_video_upload_summary" />
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:dependency="instant_video_uploading"
android:disableDependentsState="true"
<com.owncloud.android.ui.PreferenceWithLongSummary
android:title="@string/prefs_instant_video_upload_path_title"
android:key="instant_video_upload_path" />
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
android:title="@string/instant_video_upload_on_wifi"
android:key="instant_video_upload_on_wifi"/>
<!-- DISABLED FOR RELEASE UNTIL FIXED

View file

@ -79,8 +79,13 @@ public class Preferences extends SherlockPreferenceActivity implements AccountMa
private String mAccountName;
private boolean mShowContextMenu = false;
private String mUploadPath;
private PreferenceCategory mPrefInstantUploadCategory;
private Preference mPrefInstantUpload;
private Preference mPrefInstantUploadPath;
private Preference mPrefInstantUploadPathWiFi;
private Preference mPrefInstantVideoUpload;
private Preference mPrefInstantVideoUploadPath;
private Preference mPrefInstantVideoUploadPathWiFi;
private String mUploadVideoPath;
@ -276,6 +281,22 @@ public class Preferences extends SherlockPreferenceActivity implements AccountMa
});
}
mPrefInstantUploadCategory = (PreferenceCategory) findPreference("instant_uploading_category");
mPrefInstantUploadPathWiFi = findPreference("instant_upload_on_wifi");
mPrefInstantUpload = findPreference("instant_uploading");
toggleInstantPictureOptions(((CheckBoxPreference) mPrefInstantUpload).isChecked());
mPrefInstantUpload.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
toggleInstantPictureOptions((Boolean) newValue);
return true;
}
});
mPrefInstantVideoUploadPath = findPreference("instant_video_upload_path");
if (mPrefInstantVideoUploadPath != null){
@ -293,6 +314,19 @@ public class Preferences extends SherlockPreferenceActivity implements AccountMa
});
}
mPrefInstantVideoUploadPathWiFi = findPreference("instant_video_upload_on_wifi");
mPrefInstantVideoUpload = findPreference("instant_video_uploading");
toggleInstantVideoOptions(((CheckBoxPreference) mPrefInstantVideoUpload).isChecked());
mPrefInstantVideoUpload.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
toggleInstantVideoOptions((Boolean) newValue);
return true;
}
});
/* About App */
pAboutApp = (Preference) findPreference("about_app");
if (pAboutApp != null) {
@ -305,6 +339,26 @@ public class Preferences extends SherlockPreferenceActivity implements AccountMa
}
private void toggleInstantPictureOptions(Boolean value){
if (value){
mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPathWiFi);
mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPath);
} else {
mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPathWiFi);
mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPath);
}
}
private void toggleInstantVideoOptions(Boolean value){
if (value){
mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPathWiFi);
mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPath);
} else {
mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPathWiFi);
mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPath);
}
}
@Override
protected void onPause() {
super.onPause();