diff --git a/CHANGELOG.md b/CHANGELOG.md
index 19582cd30e6..7baa3627776 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -32,9 +32,11 @@ ownCloud admins and users.
* Bugfix - "Clear data" button enabled in the app settings in device settings: [#4309](https://github.com/owncloud/android/issues/4309)
* Bugfix - Remove lens icon in folder picker: [#4311](https://github.com/owncloud/android/issues/4311)
* Bugfix - Retried successful uploads are cleaned up from the temporary folder: [#4335](https://github.com/owncloud/android/issues/4335)
+* Bugfix - Resolve incorrect truncation of long display names in Manage Accounts: [#4351](https://github.com/owncloud/android/issues/4351)
* Change - Upgrade minimum SDK version to Android 7.0 (v24): [#4230](https://github.com/owncloud/android/issues/4230)
* Change - Automatic discovery of the account in login: [#4301](https://github.com/owncloud/android/issues/4301)
* Change - Add new prefixes in commit messages of 3rd party contributors: [#4346](https://github.com/owncloud/android/pull/4346)
+* Change - Kotlinize PreviewTextFragment: [#4356](https://github.com/owncloud/android/issues/4356)
* Enhancement - Correct "Local only" option in remove dialog: [#3936](https://github.com/owncloud/android/issues/3936)
* Enhancement - Improvements in Manage Accounts view: [#4148](https://github.com/owncloud/android/issues/4148)
* Enhancement - New setting for manual removal of local storage: [#4174](https://github.com/owncloud/android/issues/4174)
@@ -71,6 +73,15 @@ ownCloud admins and users.
https://github.com/owncloud/android/issues/4335
https://github.com/owncloud/android/pull/4341
+* Bugfix - Resolve incorrect truncation of long display names in Manage Accounts: [#4351](https://github.com/owncloud/android/issues/4351)
+
+ Resolved the bug where long display names were truncated incorrectly in the
+ Manage Accounts view. Now, display names are properly truncated in the middle
+ with ellipsis (...) to maintain readability.
+
+ https://github.com/owncloud/android/issues/4351
+ https://github.com/owncloud/android/pull/4380
+
* Change - Upgrade minimum SDK version to Android 7.0 (v24): [#4230](https://github.com/owncloud/android/issues/4230)
The minimum Android version will be Android 7.0 Nougat (API 24). The application
@@ -94,6 +105,13 @@ ownCloud admins and users.
https://github.com/owncloud/android/pull/4346
+* Change - Kotlinize PreviewTextFragment: [#4356](https://github.com/owncloud/android/issues/4356)
+
+ PreviewTextFragment class has been moved from Java to Kotlin.
+
+ https://github.com/owncloud/android/issues/4356
+ https://github.com/owncloud/android/pull/4376
+
* Enhancement - Correct "Local only" option in remove dialog: [#3936](https://github.com/owncloud/android/issues/3936)
"Local only" option in remove dialog will only be shown if checking selected
diff --git a/changelog/unreleased/4351 b/changelog/unreleased/4351
index edafdc3d174..592a382e281 100644
--- a/changelog/unreleased/4351
+++ b/changelog/unreleased/4351
@@ -1,4 +1,4 @@
-Bugfix: Resolve incorrect truncation of long display names in Manage Accounts view
+Bugfix: Resolve incorrect truncation of long display names in Manage Accounts
Resolved the bug where long display names were truncated incorrectly in the Manage Accounts view.
Now, display names are properly truncated in the middle with ellipsis (...) to maintain readability.
diff --git a/changelog/unreleased/4376 b/changelog/unreleased/4376
new file mode 100644
index 00000000000..e3ebe0f22e8
--- /dev/null
+++ b/changelog/unreleased/4376
@@ -0,0 +1,6 @@
+Change: Kotlinize PreviewTextFragment
+
+PreviewTextFragment class has been moved from Java to Kotlin.
+
+https://github.com/owncloud/android/issues/4356
+https://github.com/owncloud/android/pull/4376
diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt
index 47c947d31b8..c783e28a91f 100644
--- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt
+++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt
@@ -1561,7 +1561,7 @@ class FileDisplayActivity : FileActivity(),
*
* @param file Text [OCFile] to preview.
*/
- fun startTextPreview(file: OCFile?) {
+ fun startTextPreview(file: OCFile) {
val textPreviewFragment = PreviewTextFragment.newInstance(
file,
account
diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java
deleted file mode 100644
index 0618da60401..00000000000
--- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java
+++ /dev/null
@@ -1,537 +0,0 @@
-/**
- * ownCloud Android client application
- *
- * @author Christian Schabesberger
- * @author Shashvat Kedia
- * @author Juan Carlos Garrote Gascón
- * @author Parneet Singh
- * @author Aitor Ballesteros Pavón
- *
- * Copyright (C) 2024 ownCloud GmbH.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.owncloud.android.ui.preview;
-
-import android.accounts.Account;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ProgressBar;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-import androidx.lifecycle.Lifecycle;
-import androidx.viewpager2.widget.ViewPager2;
-import com.google.android.material.tabs.TabLayout;
-import com.google.android.material.tabs.TabLayoutMediator;
-import com.owncloud.android.R;
-import com.owncloud.android.datamodel.FileDataStorageManager;
-import com.owncloud.android.domain.files.model.OCFile;
-import com.owncloud.android.extensions.ActivityExtKt;
-import com.owncloud.android.extensions.FragmentExtKt;
-import com.owncloud.android.extensions.MenuExtKt;
-import com.owncloud.android.presentation.files.operations.FileOperation;
-import com.owncloud.android.presentation.files.operations.FileOperationsViewModel;
-import com.owncloud.android.presentation.files.removefile.RemoveFilesDialogFragment;
-import com.owncloud.android.presentation.previews.PreviewTextViewModel;
-import com.owncloud.android.ui.controller.TransferProgressController;
-import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
-import com.owncloud.android.ui.dialog.LoadingDialog;
-import com.owncloud.android.ui.fragment.FileFragment;
-import com.owncloud.android.utils.PreferenceUtils;
-import timber.log.Timber;
-
-import java.io.BufferedWriter;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Scanner;
-
-import static org.koin.java.KoinJavaComponent.get;
-
-public class PreviewTextFragment extends FileFragment {
- private static final String EXTRA_FILE = "FILE";
- private static final String EXTRA_ACCOUNT = "ACCOUNT";
- private static final String TAG_SECOND_FRAGMENT = "SECOND_FRAGMENT";
-
- private Account mAccount;
- private ProgressBar mProgressBar;
- private TransferProgressController mProgressController;
- private TextView mTextPreview;
- private View mTextLayout;
- private TabLayout mTabLayout;
- private ViewPager2 mViewPager2;
- private RelativeLayout rootView;
- private TextLoadAsyncTask mTextLoadTask;
- public static boolean isOpen = false;
- public static OCFile currentFilePreviewing = null;
-
- PreviewTextViewModel previewTextViewModel = get(PreviewTextViewModel.class);
- FileOperationsViewModel fileOperationsViewModel = get(FileOperationsViewModel.class);
-
- /**
- * Public factory method to create new PreviewTextFragment instances.
- *
- * @param file An {@link OCFile} to preview in the fragment
- * @param account ownCloud account containing file
- * @return Fragment ready to be used.
- */
- public static PreviewTextFragment newInstance(
- OCFile file,
- Account account
- ) {
- PreviewTextFragment frag = new PreviewTextFragment();
- Bundle args = new Bundle();
- args.putParcelable(EXTRA_FILE, file);
- args.putParcelable(EXTRA_ACCOUNT, account);
- frag.setArguments(args);
- return frag;
- }
-
- /**
- * Creates an empty fragment for previews.
- *
- * MUST BE KEPT: the system uses it when tries to reinstantiate a fragment automatically
- * (for instance, when the device is turned a aside).
- *
- * DO NOT CALL IT: an {@link OCFile} and {@link Account} must be provided for a successful
- * construction
- */
- public PreviewTextFragment() {
- super();
- mAccount = null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- super.onCreateView(inflater, container, savedInstanceState);
- Timber.v("onCreateView");
-
- View ret = inflater.inflate(R.layout.preview_text_fragment, container, false);
- ret.setFilterTouchesWhenObscured(
- PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(getContext())
- );
-
- rootView = ret.findViewById(R.id.top);
- mProgressBar = ret.findViewById(R.id.syncProgressBar);
- mTabLayout = ret.findViewById(R.id.tab_layout);
- mViewPager2 = ret.findViewById(R.id.view_pager);
- mTextPreview = ret.findViewById(R.id.text_preview);
-
- mTextLayout = ret.findViewById(R.id.text_layout);
- return ret;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- OCFile file;
- if (savedInstanceState == null) {
- Bundle args = getArguments();
- file = args.getParcelable(EXTRA_FILE);
- mAccount = args.getParcelable(EXTRA_ACCOUNT);
- if (file == null) {
- throw new IllegalStateException("Instanced with a NULL OCFile");
- }
- if (mAccount == null) {
- throw new IllegalStateException("Instanced with a NULL ownCloud Account");
- }
- } else {
- file = savedInstanceState.getParcelable(EXTRA_FILE);
- mAccount = savedInstanceState.getParcelable(EXTRA_ACCOUNT);
- }
- setFile(file);
- setHasOptionsMenu(true);
- isOpen = true;
- currentFilePreviewing = file;
- }
-
- @Override
- public void onActivityCreated(Bundle savedState) {
- super.onActivityCreated(savedState);
- mProgressController = new TransferProgressController(mContainerActivity);
- mProgressController.setProgressBar(mProgressBar);
- }
-
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- loadAndShowTextPreview();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putParcelable(EXTRA_FILE, getFile());
- outState.putParcelable(EXTRA_ACCOUNT, mAccount);
- }
-
- private void loadAndShowTextPreview() {
- mTextLoadTask = new TextLoadAsyncTask(new WeakReference(mTextPreview),
- new WeakReference(rootView), new WeakReference(mTextLayout),
- new WeakReference(mTabLayout),
- new WeakReference(mViewPager2));
- mTextLoadTask.execute(getFile());
- }
-
- /**
- * Reads the file to preview and shows its contents. Too critical to be anonymous.
- */
- private class TextLoadAsyncTask extends AsyncTask