mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 21:25:35 +03:00
unify use of boolean, make use of lombok getter/setters, remove unneeded boolean boxing
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
bedc2b48ee
commit
7c62ad6b06
7 changed files with 56 additions and 165 deletions
|
@ -338,23 +338,23 @@ public class SyncedFolderProvider extends Observable {
|
|||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH));
|
||||
String remotePath = cursor.getString(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_REMOTE_PATH));
|
||||
Boolean wifiOnly = cursor.getInt(cursor.getColumnIndex(
|
||||
boolean wifiOnly = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY)) == 1;
|
||||
Boolean chargingOnly = cursor.getInt(cursor.getColumnIndex(
|
||||
boolean chargingOnly = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY)) == 1;
|
||||
Boolean subfolderByDate = cursor.getInt(cursor.getColumnIndex(
|
||||
boolean subfolderByDate = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE)) == 1;
|
||||
String accountName = cursor.getString(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT));
|
||||
Integer uploadAction = cursor.getInt(cursor.getColumnIndex(
|
||||
int uploadAction = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION));
|
||||
Boolean enabled = cursor.getInt(cursor.getColumnIndex(
|
||||
boolean enabled = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED)) == 1;
|
||||
long enabledTimestampMs = cursor.getLong(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS));
|
||||
MediaFolderType type = MediaFolderType.getById(cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_TYPE)));
|
||||
Boolean hidden = cursor.getInt(cursor.getColumnIndex(
|
||||
boolean hidden = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_HIDDEN)) == 1;
|
||||
|
||||
syncedFolder = new SyncedFolder(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate,
|
||||
|
@ -374,15 +374,15 @@ public class SyncedFolderProvider extends Observable {
|
|||
ContentValues cv = new ContentValues();
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH, syncedFolder.getLocalPath());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_REMOTE_PATH, syncedFolder.getRemotePath());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY, syncedFolder.getWifiOnly());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY, syncedFolder.getChargingOnly());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY, syncedFolder.isWifiOnly());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY, syncedFolder.isChargingOnly());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED, syncedFolder.isEnabled());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS, syncedFolder.getEnabledTimestampMs());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE, syncedFolder.getSubfolderByDate());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE, syncedFolder.isSubfolderByDate());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT, syncedFolder.getAccount());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION, syncedFolder.getUploadAction());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_TYPE, syncedFolder.getType().getId());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_HIDDEN, syncedFolder.getHidden());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_HIDDEN, syncedFolder.isHidden());
|
||||
|
||||
return cv;
|
||||
}
|
||||
|
|
|
@ -192,10 +192,10 @@ public class FilesSyncJob extends Job {
|
|||
|
||||
remotePath = resources.getString(R.string.syncedFolder_remote_folder);
|
||||
} else {
|
||||
needsCharging = syncedFolder.getChargingOnly();
|
||||
needsWifi = syncedFolder.getWifiOnly();
|
||||
needsCharging = syncedFolder.isChargingOnly();
|
||||
needsWifi = syncedFolder.isWifiOnly();
|
||||
uploadAction = syncedFolder.getUploadAction();
|
||||
subfolderByDate = syncedFolder.getSubfolderByDate();
|
||||
subfolderByDate = syncedFolder.isSubfolderByDate();
|
||||
remotePath = syncedFolder.getRemotePath();
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.Unbinder;
|
||||
|
||||
import static android.provider.Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS;
|
||||
import static com.owncloud.android.datamodel.SyncedFolderDisplayItem.UNPERSISTED_ID;
|
||||
|
@ -702,9 +701,9 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
|||
if (MediaFolderType.CUSTOM == syncedFolder.getType() && syncedFolder.getId() == UNPERSISTED_ID) {
|
||||
SyncedFolderDisplayItem newCustomFolder = new SyncedFolderDisplayItem(
|
||||
SyncedFolder.UNPERSISTED_ID, syncedFolder.getLocalPath(), syncedFolder.getRemotePath(),
|
||||
syncedFolder.getWifiOnly(), syncedFolder.getChargingOnly(), syncedFolder.getSubfolderByDate(),
|
||||
syncedFolder.getAccount(), syncedFolder.getUploadAction(), syncedFolder.getEnabled(),
|
||||
clock.getCurrentTime(), new File(syncedFolder.getLocalPath()).getName(), syncedFolder.getType(), syncedFolder.getHidden());
|
||||
syncedFolder.isWifiOnly(), syncedFolder.isChargingOnly(), syncedFolder.isSubfolderByDate(),
|
||||
syncedFolder.getAccount(), syncedFolder.getUploadAction(), syncedFolder.isEnabled(),
|
||||
clock.getCurrentTime(), new File(syncedFolder.getLocalPath()).getName(), syncedFolder.getType(), syncedFolder.isHidden());
|
||||
|
||||
saveOrUpdateSyncedFolder(newCustomFolder);
|
||||
mAdapter.addSyncFolderItem(newCustomFolder);
|
||||
|
@ -712,8 +711,8 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
|||
SyncedFolderDisplayItem item = mAdapter.get(syncedFolder.getSection());
|
||||
updateSyncedFolderItem(item, syncedFolder.getId(), syncedFolder.getLocalPath(),
|
||||
syncedFolder.getRemotePath(), syncedFolder
|
||||
.getWifiOnly(), syncedFolder.getChargingOnly(), syncedFolder.getSubfolderByDate(), syncedFolder
|
||||
.getUploadAction(), syncedFolder.getEnabled());
|
||||
.isWifiOnly(), syncedFolder.isChargingOnly(), syncedFolder.isSubfolderByDate(), syncedFolder
|
||||
.getUploadAction(), syncedFolder.isEnabled());
|
||||
|
||||
saveOrUpdateSyncedFolder(item);
|
||||
|
||||
|
@ -723,7 +722,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
|||
|
||||
mSyncedFolderPreferencesDialogFragment = null;
|
||||
|
||||
if (syncedFolder.getEnabled()) {
|
||||
if (syncedFolder.isEnabled()) {
|
||||
showBatteryOptimizationInfo();
|
||||
}
|
||||
}
|
||||
|
@ -789,11 +788,11 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
|||
long id,
|
||||
String localPath,
|
||||
String remotePath,
|
||||
Boolean wifiOnly,
|
||||
Boolean chargingOnly,
|
||||
Boolean subfolderByDate,
|
||||
boolean wifiOnly,
|
||||
boolean chargingOnly,
|
||||
boolean subfolderByDate,
|
||||
Integer uploadAction,
|
||||
Boolean enabled) {
|
||||
boolean enabled) {
|
||||
item.setId(id);
|
||||
item.setLocalPath(localPath);
|
||||
item.setRemotePath(remotePath);
|
||||
|
|
|
@ -145,7 +145,9 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
|
|||
* @return Non-hidden items
|
||||
*/
|
||||
private List<SyncedFolderDisplayItem> filterHiddenItems(List<SyncedFolderDisplayItem> items, boolean hide) {
|
||||
if (hide) {
|
||||
if (!hide) {
|
||||
return items;
|
||||
} else {
|
||||
List<SyncedFolderDisplayItem> ret = new ArrayList<>();
|
||||
|
||||
for (SyncedFolderDisplayItem item : items) {
|
||||
|
@ -155,8 +157,6 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
|
|||
}
|
||||
|
||||
return ret;
|
||||
} else {
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
|
|||
ThemeUtils.themeDialogActionButton(mSave);
|
||||
|
||||
// Set values
|
||||
setEnabled(mSyncedFolder.getEnabled());
|
||||
setEnabled(mSyncedFolder.isEnabled());
|
||||
|
||||
if (!TextUtils.isEmpty(mSyncedFolder.getLocalPath())) {
|
||||
mLocalFolderPath.setText(
|
||||
|
@ -223,11 +223,11 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
|
|||
mRemoteFolderSummary.setText(R.string.choose_remote_folder);
|
||||
}
|
||||
|
||||
mUploadOnWifiCheckbox.setChecked(mSyncedFolder.getWifiOnly());
|
||||
mUploadOnWifiCheckbox.setChecked(mSyncedFolder.isWifiOnly());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
mUploadOnChargingCheckbox.setChecked(mSyncedFolder.getChargingOnly());
|
||||
mUploadOnChargingCheckbox.setChecked(mSyncedFolder.isChargingOnly());
|
||||
}
|
||||
mUploadUseSubfoldersCheckbox.setChecked(mSyncedFolder.getSubfolderByDate());
|
||||
mUploadUseSubfoldersCheckbox.setChecked(mSyncedFolder.isSubfolderByDate());
|
||||
|
||||
mUploadBehaviorSummary.setText(mUploadBehaviorItemStrings[mSyncedFolder.getUploadActionInteger()]);
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
|
|||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mSyncedFolder.setWifiOnly(!mSyncedFolder.getWifiOnly());
|
||||
mSyncedFolder.setWifiOnly(!mSyncedFolder.isWifiOnly());
|
||||
mUploadOnWifiCheckbox.toggle();
|
||||
}
|
||||
});
|
||||
|
@ -355,7 +355,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
|
|||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mSyncedFolder.setChargingOnly(!mSyncedFolder.getChargingOnly());
|
||||
mSyncedFolder.setChargingOnly(!mSyncedFolder.isChargingOnly());
|
||||
mUploadOnChargingCheckbox.toggle();
|
||||
}
|
||||
});
|
||||
|
@ -365,7 +365,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
|
|||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mSyncedFolder.setSubfolderByDate(!mSyncedFolder.getSubfolderByDate());
|
||||
mSyncedFolder.setSubfolderByDate(!mSyncedFolder.isSubfolderByDate());
|
||||
mUploadUseSubfoldersCheckbox.toggle();
|
||||
}
|
||||
});
|
||||
|
@ -401,7 +401,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
|
|||
view.findViewById(R.id.sync_enabled).setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setEnabled(!mSyncedFolder.getEnabled());
|
||||
setEnabled(!mSyncedFolder.isEnabled());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -27,41 +27,43 @@ import com.owncloud.android.datamodel.MediaFolderType;
|
|||
import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Parcelable for {@link SyncedFolderDisplayItem} objects to transport them from/to dialog fragments.
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
public class SyncedFolderParcelable implements Parcelable {
|
||||
private String folderName;
|
||||
private String localPath;
|
||||
private String remotePath;
|
||||
private Boolean wifiOnly = false;
|
||||
private Boolean chargingOnly = false;
|
||||
private Boolean enabled = false;
|
||||
private Boolean subfolderByDate = false;
|
||||
private Integer uploadAction;
|
||||
private MediaFolderType type;
|
||||
private Boolean hidden = false;
|
||||
private long id;
|
||||
private String account;
|
||||
private int section;
|
||||
@Getter @Setter private String folderName;
|
||||
@Getter @Setter private String localPath;
|
||||
@Getter @Setter private String remotePath;
|
||||
@Getter @Setter private boolean wifiOnly = false;
|
||||
@Getter @Setter private boolean chargingOnly = false;
|
||||
@Getter @Setter private boolean enabled = false;
|
||||
@Getter @Setter private boolean subfolderByDate = false;
|
||||
@Getter private Integer uploadAction;
|
||||
@Getter @Setter private MediaFolderType type;
|
||||
@Getter @Setter private boolean hidden = false;
|
||||
@Getter @Setter private long id;
|
||||
@Getter @Setter private String account;
|
||||
@Getter @Setter private int section;
|
||||
|
||||
public SyncedFolderParcelable(SyncedFolderDisplayItem syncedFolderDisplayItem, int section) {
|
||||
id = syncedFolderDisplayItem.getId();
|
||||
folderName = syncedFolderDisplayItem.getFolderName();
|
||||
localPath = syncedFolderDisplayItem.getLocalPath();
|
||||
remotePath = syncedFolderDisplayItem.getRemotePath();
|
||||
wifiOnly = syncedFolderDisplayItem.getWifiOnly();
|
||||
chargingOnly = syncedFolderDisplayItem.getChargingOnly();
|
||||
wifiOnly = syncedFolderDisplayItem.isWifiOnly();
|
||||
chargingOnly = syncedFolderDisplayItem.isChargingOnly();
|
||||
enabled = syncedFolderDisplayItem.isEnabled();
|
||||
subfolderByDate = syncedFolderDisplayItem.getSubfolderByDate();
|
||||
subfolderByDate = syncedFolderDisplayItem.isSubfolderByDate();
|
||||
type = syncedFolderDisplayItem.getType();
|
||||
account = syncedFolderDisplayItem.getAccount();
|
||||
uploadAction = syncedFolderDisplayItem.getUploadAction();
|
||||
this.section = section;
|
||||
hidden = syncedFolderDisplayItem.getHidden();
|
||||
hidden = syncedFolderDisplayItem.isHidden();
|
||||
}
|
||||
|
||||
private SyncedFolderParcelable(Parcel read) {
|
||||
|
@ -116,82 +118,6 @@ public class SyncedFolderParcelable implements Parcelable {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public String getFolderName() {
|
||||
return folderName;
|
||||
}
|
||||
|
||||
public void setFolderName(String mFolderName) {
|
||||
this.folderName = mFolderName;
|
||||
}
|
||||
|
||||
public String getLocalPath() {
|
||||
return localPath;
|
||||
}
|
||||
|
||||
public void setLocalPath(String mLocalPath) {
|
||||
this.localPath = mLocalPath;
|
||||
}
|
||||
|
||||
public String getRemotePath() {
|
||||
return remotePath;
|
||||
}
|
||||
|
||||
public void setRemotePath(String mRemotePath) {
|
||||
this.remotePath = mRemotePath;
|
||||
}
|
||||
|
||||
public Boolean getWifiOnly() {
|
||||
return wifiOnly;
|
||||
}
|
||||
|
||||
public void setWifiOnly(Boolean mWifiOnly) {
|
||||
this.wifiOnly = mWifiOnly;
|
||||
}
|
||||
|
||||
public Boolean getChargingOnly() {
|
||||
return chargingOnly;
|
||||
}
|
||||
|
||||
public void setChargingOnly(Boolean mChargingOnly) {
|
||||
this.chargingOnly = mChargingOnly;
|
||||
}
|
||||
|
||||
public Boolean getEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean mEnabled) {
|
||||
this.enabled = mEnabled;
|
||||
}
|
||||
|
||||
public Boolean getSubfolderByDate() {
|
||||
return subfolderByDate;
|
||||
}
|
||||
|
||||
public void setSubfolderByDate(Boolean mSubfolderByDate) {
|
||||
this.subfolderByDate = mSubfolderByDate;
|
||||
}
|
||||
|
||||
public MediaFolderType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(MediaFolderType mType) {
|
||||
this.type = mType;
|
||||
}
|
||||
|
||||
public Boolean getHidden() {
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(boolean mHidden) {
|
||||
this.hidden = mHidden;
|
||||
}
|
||||
|
||||
public Integer getUploadAction() {
|
||||
return uploadAction;
|
||||
}
|
||||
|
||||
public Integer getUploadActionInteger() {
|
||||
switch (uploadAction) {
|
||||
case FileUploader.LOCAL_BEHAVIOUR_FORGET:
|
||||
|
@ -204,8 +130,8 @@ public class SyncedFolderParcelable implements Parcelable {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public void setUploadAction(String mUploadAction) {
|
||||
switch (mUploadAction) {
|
||||
public void setUploadAction(String uploadAction) {
|
||||
switch (uploadAction) {
|
||||
case "LOCAL_BEHAVIOUR_FORGET":
|
||||
this.uploadAction = FileUploader.LOCAL_BEHAVIOUR_FORGET;
|
||||
break;
|
||||
|
@ -217,28 +143,4 @@ public class SyncedFolderParcelable implements Parcelable {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public int getSection() {
|
||||
return section;
|
||||
}
|
||||
|
||||
public void setSection(int section) {
|
||||
this.section = section;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,8 +32,6 @@ import java.util.Arrays;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import third_parties.daveKoeller.AlphanumComparator;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class SyncedFoldersActivityTest {
|
||||
|
@ -123,14 +121,6 @@ public class SyncedFoldersActivityTest {
|
|||
return test(sortedList, SyncedFoldersActivity.sortSyncedFolderItems(unsortedList));
|
||||
}
|
||||
|
||||
private List<SyncedFolderDisplayItem> sort(List<SyncedFolderDisplayItem> sortedList) {
|
||||
List<SyncedFolderDisplayItem> unsortedList = shuffle(sortedList);
|
||||
|
||||
Collections.sort(unsortedList, new AlphanumComparator<>());
|
||||
|
||||
return unsortedList;
|
||||
}
|
||||
|
||||
private boolean test(List<SyncedFolderDisplayItem> target, List<SyncedFolderDisplayItem> actual) {
|
||||
|
||||
for (int i = 0; i < target.size(); i++) {
|
||||
|
@ -167,7 +157,7 @@ public class SyncedFoldersActivityTest {
|
|||
return true;
|
||||
}
|
||||
|
||||
private SyncedFolderDisplayItem create(String folderName, Boolean enabled) {
|
||||
private SyncedFolderDisplayItem create(String folderName, boolean enabled) {
|
||||
return new SyncedFolderDisplayItem(1,
|
||||
"localPath",
|
||||
"remotePath",
|
||||
|
|
Loading…
Reference in a new issue