Removed the unused code from project to cleanup the code.

This commit is contained in:
MohitMaliFtechiz 2025-04-17 17:46:31 +05:30 committed by Kelson
parent 2d36f36aed
commit 6e7c9c7d6a
9 changed files with 2 additions and 517 deletions

View File

@ -1,90 +0,0 @@
/*
* Kiwix Android
* Copyright (c) 2019 Kiwix <android.kiwix.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
@file:Suppress("PackageNaming")
package org.kiwix.kiwixmobile.localFileTransfer
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.base.adapter.BaseViewHolder
import org.kiwix.kiwixmobile.databinding.ItemTransferListBinding
import org.kiwix.kiwixmobile.localFileTransfer.FileItem.FileStatus.ERROR
import org.kiwix.kiwixmobile.localFileTransfer.FileItem.FileStatus.SENDING
import org.kiwix.kiwixmobile.localFileTransfer.FileItem.FileStatus.SENT
import org.kiwix.kiwixmobile.localFileTransfer.FileListAdapter.FileViewHolder
/**
* Helper class, part of the local file sharing module.
*
* Defines the Adapter for the list of file-items displayed in {TransferProgressFragment}
*/
class FileListAdapter(private val fileItems: List<FileItem>) :
RecyclerView.Adapter<FileViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FileViewHolder =
FileViewHolder(
ItemTransferListBinding.inflate(
LayoutInflater.from(parent.context),
parent,
false
),
this
)
override fun onBindViewHolder(holder: FileViewHolder, position: Int) {
holder.bind(fileItems[position])
}
override fun getItemCount(): Int = fileItems.size
inner class FileViewHolder(
private val itemTransferListBinding: ItemTransferListBinding,
val fileListAdapter: FileListAdapter
) :
BaseViewHolder<FileItem>(itemTransferListBinding.root) {
override fun bind(item: FileItem) {
itemTransferListBinding.textViewFileItemName.text = item.fileName
itemTransferListBinding.imageViewFileTransferred.isVisible = item.fileStatus != SENDING
itemTransferListBinding.progressBarTransferringFile.isVisible = item.fileStatus == SENDING
if (item.fileStatus != FileItem.FileStatus.TO_BE_SENT) {
// Icon for TO_BE_SENT is assigned by default in the item layout
itemTransferListBinding.progressBarTransferringFile.visibility = View.GONE
when (item.fileStatus) {
SENDING -> itemTransferListBinding.progressBarTransferringFile.visibility = View.VISIBLE
SENT -> {
itemTransferListBinding.imageViewFileTransferred.setImageResource(
R.drawable.ic_baseline_check_24px
)
itemTransferListBinding.progressBarTransferringFile.visibility = View.GONE
}
ERROR -> {
itemTransferListBinding.imageViewFileTransferred.setImageResource(
R.drawable.ic_baseline_error_24px
)
itemTransferListBinding.progressBarTransferringFile.visibility = View.GONE
}
else -> {
}
}
}
}
}
}

View File

@ -1,41 +0,0 @@
/*
* Kiwix Android
* Copyright (c) 2020 Kiwix <android.kiwix.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.localFileTransfer.adapter
import android.net.wifi.p2p.WifiP2pDevice
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import org.kiwix.kiwixmobile.core.base.adapter.AdapterDelegate
import org.kiwix.kiwixmobile.core.extensions.ViewGroupExtensions.viewBinding
import org.kiwix.kiwixmobile.databinding.RowPeerDeviceBinding
class WifiP2pDelegate(private val onItemClickAction: (WifiP2pDevice) -> Unit) :
AdapterDelegate<WifiP2pDevice> {
override fun createViewHolder(parent: ViewGroup): ViewHolder =
WifiP2pViewHolder(
parent.viewBinding(RowPeerDeviceBinding::inflate, false),
onItemClickAction
)
override fun bind(viewHolder: ViewHolder, itemToBind: WifiP2pDevice) {
(viewHolder as WifiP2pViewHolder).bind(itemToBind)
}
override fun isFor(item: WifiP2pDevice) = true
}

View File

@ -1,35 +0,0 @@
/*
* Kiwix Android
* Copyright (c) 2020 Kiwix <android.kiwix.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.localFileTransfer.adapter
import android.net.wifi.p2p.WifiP2pDevice
import org.kiwix.kiwixmobile.core.base.adapter.BaseViewHolder
import org.kiwix.kiwixmobile.databinding.RowPeerDeviceBinding
class WifiP2pViewHolder(
private val rowPeerDeviceBinding: RowPeerDeviceBinding,
private val onItemClickAction: (WifiP2pDevice) -> Unit
) : BaseViewHolder<WifiP2pDevice>(rowPeerDeviceBinding.root) {
override fun bind(item: WifiP2pDevice) {
rowPeerDeviceBinding.rowDeviceName.text = item.deviceName
containerView.setOnClickListener {
onItemClickAction.invoke(item)
}
}
}

View File

@ -1,26 +0,0 @@
/*
* Kiwix Android
* Copyright (c) 2020 Kiwix <android.kiwix.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.localFileTransfer.adapter
import android.net.wifi.p2p.WifiP2pDevice
import org.kiwix.kiwixmobile.core.base.adapter.BaseDelegateAdapter
internal class WifiPeerListAdapter(wifiP2pDelegate: WifiP2pDelegate) :
BaseDelegateAdapter<WifiP2pDevice>(wifiP2pDelegate) {
override fun getIdFor(item: WifiP2pDevice) = item.deviceAddress.hashCode().toLong()
}

View File

@ -184,7 +184,8 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
): View? {
fragmentDestinationDownloadBinding =
FragmentDestinationDownloadBinding.inflate(inflater, container, false)
val toolbar = fragmentDestinationDownloadBinding?.root?.findViewById<Toolbar>(R.id.toolbar)
val toolbar =
fragmentDestinationDownloadBinding?.root?.findViewById<Toolbar>(org.kiwix.kiwixmobile.core.R.id.toolbar)
val activity = activity as CoreMainActivity
activity.setSupportActionBar(toolbar)
activity.supportActionBar?.apply {

View File

@ -1,172 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
tools:context="org.kiwix.kiwixmobile.localFileTransfer.LocalFileTransferFragment">
<include layout="@layout/layout_toolbar" />
<TextView
android:id="@+id/text_view_your_device"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:background="@android:color/transparent"
android:paddingStart="5dp"
android:paddingTop="5dp"
android:paddingEnd="5dp"
android:paddingBottom="1dp"
android:text="@string/your_device"
android:textSize="13sp"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar" />
<TextView
android:id="@+id/text_view_device_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:background="@android:color/transparent"
android:contentDescription="@string/device_name"
android:gravity="start|center"
android:minHeight="@dimen/material_minimum_height_and_width"
android:paddingStart="5dp"
android:paddingEnd="5dp"
android:paddingBottom="5dp"
android:textIsSelectable="true"
android:textSize="17sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_view_your_device"
tools:hint="@string/device_name" />
<View
android:id="@+id/view_device_list_boundary"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:background="@color/dodger_blue"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_view_device_name" />
<TextView
android:id="@+id/text_view_available_device"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:gravity="center"
android:paddingTop="5dp"
android:text="@string/nearby_devices"
android:textSize="16sp"
app:fontFamily="monospace"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/view_device_list_boundary" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_peer_devices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:clipToPadding="false"
android:visibility="invisible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_view_available_device"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/text_view_empty_peer_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="50dp"
android:background="@android:color/transparent"
android:gravity="center"
android:text="@string/no_devices_found"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_view_available_device" />
<View
android:id="@+id/nearby_device_show_case_view"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_margin="50dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_view_available_device" />
<ProgressBar
android:id="@+id/progress_bar_searching_peers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="50dp"
android:background="@android:color/transparent"
android:indeterminate="true"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_view_available_device" />
<View
android:id="@+id/view_file_list_boundary"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="5dp"
android:layout_marginTop="201dp"
android:layout_marginEnd="5dp"
android:background="@color/dodger_blue"
app:layout_constraintBottom_toTopOf="@+id/text_view_files_for_transfer"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_view_available_device" />
<TextView
android:id="@+id/text_view_files_for_transfer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:gravity="center"
android:paddingTop="10dp"
android:text="@string/files_for_transfer"
android:textSize="16sp"
app:fontFamily="monospace"
app:layout_constraintBottom_toTopOf="@id/recycler_view_transfer_files"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/view_file_list_boundary" />
<View
android:id="@+id/file_transfer_show_case_view"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_margin="50dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_view_files_for_transfer" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_transfer_files"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@android:color/transparent"
android:clipToPadding="false"
android:contentDescription="@string/files_for_transfer"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_view_files_for_transfer"
tools:listitem="@layout/item_transfer_list" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,66 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="64dp">
<CheckBox
android:id="@+id/item_language_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/item_language_name"
style="@style/list_item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:alpha="0.90"
app:layout_constraintBottom_toTopOf="@id/item_language_localized_name"
app:layout_constraintStart_toEndOf="@id/item_language_checkbox"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
tools:text="English" />
<TextView
android:id="@+id/item_language_localized_name"
style="@style/list_item_body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.63"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@id/item_language_name"
app:layout_constraintTop_toBottomOf="@id/item_language_name"
tools:text="English" />
<TextView
android:id="@+id/item_language_books_count"
style="@style/list_item_body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:alpha="0.63"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="9 books" />
<View
android:id="@+id/item_language_clickable_area"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="?selectableItemBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,61 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="@+id/text_view_file_item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:gravity="center_vertical"
android:paddingStart="5dp"
android:paddingTop="1dp"
android:paddingEnd="5dp"
android:paddingBottom="1dp"
android:textIsSelectable="true"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:hint="File name" />
<ProgressBar
android:id="@+id/progress_bar_transferring_file"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:background="@android:color/transparent"
android:paddingStart="5dp"
android:paddingTop="1dp"
android:paddingEnd="5dp"
android:paddingBottom="1dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@id/text_view_file_item_name"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/image_view_file_transferred"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginEnd="12dp"
android:background="@android:color/transparent"
android:contentDescription="@string/status"
android:paddingStart="5dp"
android:paddingTop="1dp"
android:paddingEnd="5dp"
android:paddingBottom="1dp"
android:src="@drawable/ic_baseline_wait_24px"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@id/text_view_file_item_name"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp">
<TextView
android:id="@+id/row_device_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:background="@android:color/transparent"
android:gravity="center_horizontal"
android:paddingStart="5dp"
android:paddingTop="1dp"
android:paddingEnd="5dp"
android:paddingBottom="1dp"
android:textIsSelectable="false"
android:textSize="17sp"
android:textStyle="bold"
tools:hint="Device Name" />
</LinearLayout>