-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from emreesen27/v1.0.0-beta4
V1.0.0 beta4
Showing
24 changed files
with
342 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ package com.sn.snfilemanager.job | |
enum class JobType { | ||
COPY, | ||
DELETE, | ||
CREATE, | ||
} |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/sn/snfilemanager/job/file/CreateDirectory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.sn.snfilemanager.job.file | ||
|
||
import com.sn.snfilemanager.core.base.BaseJob | ||
import com.sn.snfilemanager.job.JobCompletedCallback | ||
import com.sn.snfilemanager.job.JobType | ||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
|
||
class CreateDirectory( | ||
private val targetPath: Path, | ||
private val completed: JobCompletedCallback, | ||
) : BaseJob() { | ||
private val directory: MutableList<Path> = mutableListOf() | ||
|
||
override fun run() { | ||
val dir = Files.createDirectories(targetPath) | ||
directory.add(dir) | ||
} | ||
|
||
override fun onCompleted() { | ||
completed.jobOnCompleted(JobType.CREATE, directory) | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
app/src/main/java/com/sn/snfilemanager/view/dialog/CreateDirectoryDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.sn.snfilemanager.view.dialog | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import androidx.core.widget.addTextChangedListener | ||
import androidx.fragment.app.DialogFragment | ||
import com.sn.snfilemanager.R | ||
import com.sn.snfilemanager.core.extensions.click | ||
import com.sn.snfilemanager.databinding.DialogCreateDirectoryBinding | ||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
|
||
class CreateDirectoryDialog( | ||
private val path: String, | ||
private val onCreate: ((Path) -> Unit)? = null, | ||
) : | ||
DialogFragment() { | ||
private val binding: DialogCreateDirectoryBinding by lazy { | ||
DialogCreateDirectoryBinding.inflate(layoutInflater) | ||
} | ||
|
||
companion object { | ||
const val TAG = "CREATE_DIRECTORY_DIALOG" | ||
} | ||
|
||
override fun onStart() { | ||
super.onStart() | ||
dialog?.window?.setLayout( | ||
ConstraintLayout.LayoutParams.MATCH_PARENT, | ||
ConstraintLayout.LayoutParams.WRAP_CONTENT, | ||
) | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle?, | ||
): View { | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated( | ||
view: View, | ||
savedInstanceState: Bundle?, | ||
) { | ||
super.onViewCreated(view, savedInstanceState) | ||
binding.etFolderName.requestFocus() | ||
binding.btnCancel.click { dismiss() } | ||
binding.btnCreate.click { | ||
val name = binding.etFolderName.text.toString() | ||
if (checkNameExists(name)) { | ||
binding.inputLayout.error = getString(R.string.folder_exists_warning) | ||
} else { | ||
onCreate?.invoke(Paths.get(path).resolve(name)) | ||
dismiss() | ||
} | ||
} | ||
binding.etFolderName.addTextChangedListener { text -> | ||
binding.btnCreate.isEnabled = !text.isNullOrEmpty() | ||
binding.inputLayout.error = null | ||
} | ||
} | ||
|
||
private fun checkNameExists(name: String): Boolean { | ||
val targetPath = Paths.get(path).resolve(name) | ||
return Files.exists(targetPath) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:alpha="1" android:color="@color/main_color" android:state_focused="true" /> | ||
<item android:alpha="1" android:color="@color/main_color" android:state_hovered="true" /> | ||
<item android:alpha="1" android:color="@color/main_color" android:state_enabled="false" /> | ||
<item android:alpha="1" android:color="@color/main_color" /> | ||
</selector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?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" | ||
android:id="@+id/container" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<com.google.android.material.textview.MaterialTextView | ||
android:id="@+id/tv_title" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:fontFamily="@font/adamina" | ||
android:padding="@dimen/_10sdp" | ||
android:text="@string/create_folder" | ||
android:textColor="@color/first_text_color" | ||
android:textSize="@dimen/_13ssp" | ||
app:layout_constraintEnd_toEndOf="@+id/container" | ||
app:layout_constraintStart_toStartOf="@+id/container" | ||
app:layout_constraintTop_toTopOf="@id/container" /> | ||
|
||
<com.google.android.material.textfield.TextInputLayout | ||
android:id="@+id/input_layout" | ||
style="@style/TextInputLayoutStyle" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:padding="@dimen/_10sdp" | ||
app:layout_constraintEnd_toEndOf="@+id/container" | ||
app:layout_constraintStart_toStartOf="@+id/container" | ||
app:layout_constraintTop_toBottomOf="@+id/tv_title"> | ||
|
||
<com.google.android.material.textfield.TextInputEditText | ||
android:id="@+id/et_folder_name" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:fontFamily="@font/adamina" | ||
android:hint="@string/folder_name" | ||
android:padding="@dimen/_8sdp" | ||
android:textColorHint="@color/first_text_color" /> | ||
|
||
</com.google.android.material.textfield.TextInputLayout> | ||
|
||
|
||
<LinearLayout | ||
android:id="@+id/center_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/_10sdp" | ||
android:gravity="center" | ||
android:orientation="horizontal" | ||
app:layout_constraintEnd_toEndOf="@+id/container" | ||
app:layout_constraintStart_toStartOf="@+id/container" | ||
app:layout_constraintTop_toBottomOf="@+id/input_layout"> | ||
|
||
<com.google.android.material.textview.MaterialTextView | ||
android:id="@+id/btn_cancel" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/_10sdp" | ||
android:fontFamily="@font/adamina" | ||
android:padding="@dimen/_5sdp" | ||
android:text="@string/cancel" | ||
android:textColor="@color/app_buton_state_list" | ||
android:textSize="@dimen/_13ssp" /> | ||
|
||
<View | ||
android:layout_width="1dp" | ||
android:layout_height="@dimen/_40sdp" | ||
android:background="@color/divider_color" /> | ||
|
||
<com.google.android.material.textview.MaterialTextView | ||
android:id="@+id/btn_create" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/_10sdp" | ||
android:enabled="false" | ||
android:fontFamily="@font/adamina" | ||
android:padding="@dimen/_5sdp" | ||
android:text="@string/create" | ||
android:textColor="@color/app_buton_state_list" | ||
android:textSize="@dimen/_13ssp" /> | ||
|
||
</LinearLayout> | ||
|
||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu 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"> | ||
|
||
<item | ||
android:id="@+id/action_search" | ||
android:icon="@drawable/ic_search" | ||
android:title="@string/search" | ||
app:actionViewClass="androidx.appcompat.widget.SearchView" | ||
app:showAsAction="always|collapseActionView" | ||
tools:ignore="AlwaysShowAction" /> | ||
|
||
<item | ||
android:id="@+id/create_folder" | ||
android:title="@string/create_folder" | ||
app:showAsAction="never" /> | ||
|
||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters