misc fixes

This commit is contained in:
tibbi 2017-03-11 11:30:42 +01:00
parent 179763ebe6
commit a0e4205777
11 changed files with 31 additions and 70 deletions

View file

@ -4,6 +4,7 @@ import android.Manifest
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.os.Handler
import android.os.Parcelable
import android.support.v4.app.ActivityCompat
import android.view.Menu
@ -23,6 +24,7 @@ import com.simplemobiletools.filemanager.R
import com.simplemobiletools.filemanager.SCROLL_STATE
import com.simplemobiletools.filemanager.extensions.config
import com.simplemobiletools.filemanager.fragments.ItemsFragment
import kotlinx.android.synthetic.main.activity_main.*
import java.io.File
import java.util.*
@ -41,7 +43,7 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//breadcrumbs.setListener(this)
breadcrumbs.setListener(this)
tryInitFileManager()
storeStoragePaths()
}
@ -64,7 +66,7 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
}
private fun openPath(path: String) {
//breadcrumbs.setBreadcrumb(path)
breadcrumbs.setBreadcrumb(path)
val bundle = Bundle()
bundle.putString(PATH, path)
@ -78,7 +80,7 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
latestFragment = ItemsFragment()
latestFragment!!.arguments = bundle
latestFragment!!.setListener(this)
latestFragment!!.setListener(this@MainActivity)
supportFragmentManager.beginTransaction().replace(R.id.fragment_holder, latestFragment).addToBackStack(path).commitAllowingStateLoss()
}
@ -100,7 +102,7 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_MULTISELECT, BuildConfig.VERSION_NAME)
}
/*override fun onBackPressed() {
override fun onBackPressed() {
if (breadcrumbs.childCount <= 1) {
if (!mWasBackJustPressed) {
mWasBackJustPressed = true
@ -114,7 +116,7 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
val item = breadcrumbs.lastItem
openPath(item.path)
}
}*/
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
@ -139,8 +141,8 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
changePath(it)
}
} else {
/*val item = breadcrumbs.getChildAt(id).tag as FileDirItem
openPath(item.path)*/
val item = breadcrumbs.getChildAt(id).tag as FileDirItem
openPath(item.path)
}
}

View file

@ -17,7 +17,6 @@ import com.simplemobiletools.commons.extensions.formatSize
import com.simplemobiletools.commons.extensions.isGif
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.models.FileDirItem
import com.simplemobiletools.filemanager.Config
import com.simplemobiletools.filemanager.R
import com.simplemobiletools.filemanager.activities.SimpleActivity
import com.simplemobiletools.filemanager.dialogs.CopyDialog
@ -51,29 +50,15 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: List<FileDirItem>,
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
return when (item.itemId) {
R.id.cab_rename -> {
displayRenameDialog()
true
}
R.id.cab_properties -> {
showProperties()
true
}
R.id.cab_share -> {
shareFiles()
true
}
R.id.cab_copy_move -> {
displayCopyDialog()
true
}
R.id.cab_delete -> {
askConfirmDelete()
true
}
else -> false
when (item.itemId) {
R.id.cab_rename -> displayRenameDialog()
R.id.cab_properties -> showProperties()
R.id.cab_share -> shareFiles()
R.id.cab_copy_move -> displayCopyDialog()
R.id.cab_delete -> askConfirmDelete()
else -> return false
}
return true
}
override fun onCreateActionMode(actionMode: ActionMode?, menu: Menu?): Boolean {

View file

@ -7,7 +7,7 @@ import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.filemanager.R
import com.simplemobiletools.filemanager.activities.SimpleActivity
import com.simplemobiletools.filemanager.extensions.config
import kotlinx.android.synthetic.main.copy_item.view.*
import kotlinx.android.synthetic.main.dialog_copy_item.view.*
import java.io.File
import java.util.*
@ -15,7 +15,7 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val c
init {
val context = activity
val view = activity.layoutInflater.inflate(R.layout.copy_item, null)
val view = activity.layoutInflater.inflate(R.layout.dialog_copy_item, null)
val sourcePath = files[0].parent.trimEnd('/')
var destinationPath = ""
view.source.text = "${context.humanizePath(sourcePath)}/"

View file

@ -7,13 +7,13 @@ import android.view.WindowManager
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.filemanager.R
import com.simplemobiletools.filemanager.extensions.config
import kotlinx.android.synthetic.main.create_new.view.*
import kotlinx.android.synthetic.main.dialog_create_new.view.*
import java.io.File
import java.io.IOException
class CreateNewItemDialog(val activity: Activity, val path: String, val callback: () -> Unit) {
init {
val view = activity.layoutInflater.inflate(R.layout.create_new, null)
val view = activity.layoutInflater.inflate(R.layout.dialog_create_new, null)
AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, null)

View file

@ -7,13 +7,13 @@ import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.models.FileDirItem
import com.simplemobiletools.filemanager.R
import com.simplemobiletools.filemanager.extensions.config
import kotlinx.android.synthetic.main.rename_item.view.*
import kotlinx.android.synthetic.main.dialog_rename_item.view.*
import java.io.File
class RenameItemDialog(val activity: Activity, val item: FileDirItem, val callback: () -> Unit) {
init {
val view = activity.layoutInflater.inflate(R.layout.rename_item, null)
val view = activity.layoutInflater.inflate(R.layout.dialog_rename_item, null)
view.item_name.setText(item.name)
val path = File(item.path).parent

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:id="@+id/breadcrumb_text"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

View file

@ -9,14 +9,14 @@
android:paddingRight="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin">
<TextView
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/source_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/source"
android:textSize="@dimen/smaller_text_size"/>
<TextView
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/source"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -26,14 +26,14 @@
android:paddingTop="@dimen/small_margin"
android:text="source"/>
<TextView
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/destination_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/destination"
android:textSize="@dimen/smaller_text_size"/>
<TextView
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/destination"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -50,14 +50,14 @@
android:layout_height="wrap_content"
android:checkedButton="@+id/dialog_radio_copy">
<RadioButton
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/dialog_radio_copy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/medium_margin"
android:text="@string/copy"/>
<RadioButton
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/dialog_radio_move"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/directory_picker_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.simplemobiletools.commons.views.Breadcrumbs
android:id="@+id/directory_picker_breadcrumbs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/activity_margin"/>
<ListView
android:id="@+id/directory_picker_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

View file

@ -21,7 +21,7 @@
android:paddingTop="@dimen/medium_margin"
android:src="@drawable/ic_folder"/>
<com.simplemobiletools.commons.views.MyTextView
<TextView
android:id="@+id/item_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -33,7 +33,7 @@
android:paddingTop="@dimen/small_margin"
android:text="Directory"/>
<com.simplemobiletools.commons.views.MyTextView
<TextView
android:id="@+id/item_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"