Skip to content

Commit

Permalink
Convert to kt
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 authored and tobiasKaminsky committed Dec 1, 2023
1 parent 61e3d99 commit 4d8c97e
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.owncloud.android.ui.events;
package com.owncloud.android.ui.events

/**
* Event that notifies that an account was removed
*/

public class AccountRemovedEvent {

}
class AccountRemovedEvent
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http:></http:>//www.gnu.org/licenses/>.
*/
package com.owncloud.android.ui.events;
package com.owncloud.android.ui.events

/**
* Currently a dummy event to restore grid view, sort, and search
*/
public class ChangeMenuEvent {
}
class ChangeMenuEvent
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.owncloud.android.ui.events;
package com.owncloud.android.ui.events

/**
* Event for refreshing comment state of a file
*/
public class CommentsEvent {
public final String remoteId;

public CommentsEvent(String remoteId) {
this.remoteId = remoteId;
}
}
class CommentsEvent(val remoteId: String)
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http:></http:>//www.gnu.org/licenses/>.
*/
package com.owncloud.android.ui.events;
package com.owncloud.android.ui.events

/**
* Dummy drawer event
*/
public class DummyDrawerEvent {
}
class DummyDrawerEvent
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,14 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.owncloud.android.ui.events;
package com.owncloud.android.ui.events

/**
* Event for set folder as encrypted/decrypted
*/
public class EncryptionEvent {
public final long localId;
public final String remotePath;
public final String remoteId;
public final boolean shouldBeEncrypted;

public EncryptionEvent(long localId, String remoteId, String remotePath, boolean shouldBeEncrypted) {
this.localId = localId;
this.remoteId = remoteId;
this.remotePath = remotePath;
this.shouldBeEncrypted = shouldBeEncrypted;
}
}
class EncryptionEvent(
val localId: Long,
val remoteId: String,
val remotePath: String,
val shouldBeEncrypted: Boolean
)
14 changes: 3 additions & 11 deletions app/src/main/java/com/owncloud/android/ui/events/FavoriteEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,11 @@
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http:></http:>//www.gnu.org/licenses/>.
*/
package com.owncloud.android.ui.events;
package com.owncloud.android.ui.events

/**
* Event for making favoriting work
*/
public class FavoriteEvent {
public final String remotePath;
public final boolean shouldFavorite;

public FavoriteEvent(String remotePath, boolean shouldFavorite) {
this.remotePath = remotePath;
this.shouldFavorite = shouldFavorite;
}
}
class FavoriteEvent(val remotePath: String, val shouldFavorite: Boolean)

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.owncloud.android.ui.events;
package com.owncloud.android.ui.events

/**
* Event to send push token where it belongs
*/
public class TokenPushEvent {
}
class TokenPushEvent
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http:></http:>//www.gnu.org/licenses/>.
*/
package com.owncloud.android.ui.events;
package com.owncloud.android.ui.events

public class VCardToggleEvent {
public boolean showRestoreButton;

public VCardToggleEvent(boolean showRestore) {
this.showRestoreButton = showRestore;
}
}
class VCardToggleEvent(var showRestoreButton: Boolean)
Original file line number Diff line number Diff line change
Expand Up @@ -783,13 +783,13 @@ public void onMessageEvent(FavoriteEvent event) {
OwnCloudClient client = clientFactory.create(user);

ToggleFavoriteRemoteOperation toggleFavoriteOperation = new ToggleFavoriteRemoteOperation(
event.shouldFavorite, event.remotePath);
event.getShouldFavorite(), event.getRemotePath());
RemoteOperationResult remoteOperationResult = toggleFavoriteOperation.execute(client);

if (remoteOperationResult.isSuccess()) {
getFile().setFavorite(event.shouldFavorite);
OCFile file = storageManager.getFileByEncryptedRemotePath(event.remotePath);
file.setFavorite(event.shouldFavorite);
getFile().setFavorite(event.getShouldFavorite());
OCFile file = storageManager.getFileByEncryptedRemotePath(event.getRemotePath());
file.setFavorite(event.getShouldFavorite());
storageManager.saveFile(file);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ private void resetSearchAttributes() {

@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onMessageEvent(CommentsEvent event) {
mAdapter.refreshCommentsCount(event.remoteId);
mAdapter.refreshCommentsCount(event.getRemoteId());
}

@Subscribe(threadMode = ThreadMode.BACKGROUND)
Expand All @@ -1598,13 +1598,13 @@ public void onMessageEvent(FavoriteEvent event) {
OwnCloudClient client = clientFactory.create(user);

ToggleFavoriteRemoteOperation toggleFavoriteOperation = new ToggleFavoriteRemoteOperation(
event.shouldFavorite, event.remotePath);
event.getShouldFavorite(), event.getRemotePath());
RemoteOperationResult remoteOperationResult = toggleFavoriteOperation.execute(client);

if (remoteOperationResult.isSuccess()) {
boolean removeFromList = currentSearchType == SearchType.FAVORITE_SEARCH && !event.shouldFavorite;
boolean removeFromList = currentSearchType == SearchType.FAVORITE_SEARCH && !event.getShouldFavorite();
setEmptyListMessage(SearchType.FAVORITE_SEARCH);
mAdapter.setFavoriteAttributeForItemID(event.remotePath, event.shouldFavorite, removeFromList);
mAdapter.setFavoriteAttributeForItemID(event.getRemotePath(), event.getShouldFavorite(), removeFromList);
}

} catch (ClientFactory.CreationException e) {
Expand Down Expand Up @@ -1692,7 +1692,7 @@ public void onMessageEvent(EncryptionEvent event) {
String privateKey = arbitraryDataProvider.getValue(user, EncryptionUtils.PRIVATE_KEY);

FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
OCFile file = storageManager.getFileByRemoteId(event.remoteId);
OCFile file = storageManager.getFileByRemoteId(event.getRemoteId());

if (publicKey.isEmpty() || privateKey.isEmpty()) {
Log_OC.d(TAG, "no public key for " + user.getAccountName());
Expand All @@ -1706,10 +1706,10 @@ public void onMessageEvent(EncryptionEvent event) {
dialog.show(getParentFragmentManager(), SETUP_ENCRYPTION_DIALOG_TAG);
} else {
encryptFolder(file,
event.localId,
event.remoteId,
event.remotePath,
event.shouldBeEncrypted,
event.getLocalId(),
event.getRemoteId(),
event.getRemotePath(),
event.getShouldBeEncrypted(),
publicKey,
privateKey);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public void onSaveInstanceState(@NonNull Bundle outState) {

@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(VCardToggleEvent event) {
if (event.showRestoreButton) {
if (event.getShowRestoreButton()) {
binding.contactlistRestoreSelectedContainer.setVisibility(View.VISIBLE);
} else {
binding.contactlistRestoreSelectedContainer.setVisibility(View.GONE);
Expand Down

0 comments on commit 4d8c97e

Please sign in to comment.