fix #129, allow creating folder shortcuts
This commit is contained in:
parent
d08165e78d
commit
ffa691eb4c
|
@ -51,7 +51,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.12.10'
|
implementation 'com.simplemobiletools:commons:5.12.11'
|
||||||
implementation 'com.github.Stericson:RootTools:df729dcb13'
|
implementation 'com.github.Stericson:RootTools:df729dcb13'
|
||||||
implementation 'com.github.Stericson:RootShell:1.6'
|
implementation 'com.github.Stericson:RootShell:1.6'
|
||||||
implementation 'com.alexvasilkov:gesture-views:2.5.2'
|
implementation 'com.alexvasilkov:gesture-views:2.5.2'
|
||||||
|
|
|
@ -7,7 +7,15 @@ class SplashActivity : BaseSplashActivity() {
|
||||||
override fun getAppPackageName() = packageName
|
override fun getAppPackageName() = packageName
|
||||||
|
|
||||||
override fun initActivity() {
|
override fun initActivity() {
|
||||||
startActivity(Intent(this, MainActivity::class.java))
|
if (intent.action == Intent.ACTION_VIEW && intent.data != null) {
|
||||||
|
Intent(this, MainActivity::class.java).apply {
|
||||||
|
action = Intent.ACTION_VIEW
|
||||||
|
data = intent.data
|
||||||
|
startActivity(this)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
startActivity(Intent(this, MainActivity::class.java))
|
||||||
|
}
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
package com.simplemobiletools.filemanager.pro.adapters
|
package com.simplemobiletools.filemanager.pro.adapters
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.app.PendingIntent
|
||||||
import android.content.ClipData
|
import android.content.ClipData
|
||||||
import android.content.ClipboardManager
|
import android.content.ClipboardManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
|
import android.content.pm.ShortcutInfo
|
||||||
|
import android.content.pm.ShortcutManager
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.graphics.drawable.Icon
|
||||||
|
import android.graphics.drawable.LayerDrawable
|
||||||
|
import android.net.Uri
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -17,12 +25,14 @@ import com.simplemobiletools.commons.dialogs.*
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.CONFLICT_OVERWRITE
|
import com.simplemobiletools.commons.helpers.CONFLICT_OVERWRITE
|
||||||
import com.simplemobiletools.commons.helpers.CONFLICT_SKIP
|
import com.simplemobiletools.commons.helpers.CONFLICT_SKIP
|
||||||
|
import com.simplemobiletools.commons.helpers.isNougatMR1Plus
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.commons.views.FastScroller
|
import com.simplemobiletools.commons.views.FastScroller
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.filemanager.pro.activities.SplashActivity
|
||||||
import com.simplemobiletools.filemanager.pro.dialogs.CompressAsDialog
|
import com.simplemobiletools.filemanager.pro.dialogs.CompressAsDialog
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.*
|
import com.simplemobiletools.filemanager.pro.extensions.*
|
||||||
import com.simplemobiletools.filemanager.pro.helpers.*
|
import com.simplemobiletools.filemanager.pro.helpers.*
|
||||||
|
@ -67,6 +77,7 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
||||||
findItem(R.id.cab_open_with).isVisible = isOneFileSelected()
|
findItem(R.id.cab_open_with).isVisible = isOneFileSelected()
|
||||||
findItem(R.id.cab_open_as).isVisible = isOneFileSelected()
|
findItem(R.id.cab_open_as).isVisible = isOneFileSelected()
|
||||||
findItem(R.id.cab_set_as).isVisible = isOneFileSelected()
|
findItem(R.id.cab_set_as).isVisible = isOneFileSelected()
|
||||||
|
findItem(R.id.cab_create_shortcut).isVisible = isNougatMR1Plus() && isOneItemSelected() && File(getFirstSelectedItemPath()).isDirectory
|
||||||
|
|
||||||
checkHideBtnVisibility(this)
|
checkHideBtnVisibility(this)
|
||||||
}
|
}
|
||||||
|
@ -84,6 +95,7 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
||||||
R.id.cab_share -> shareFiles()
|
R.id.cab_share -> shareFiles()
|
||||||
R.id.cab_hide -> toggleFileVisibility(true)
|
R.id.cab_hide -> toggleFileVisibility(true)
|
||||||
R.id.cab_unhide -> toggleFileVisibility(false)
|
R.id.cab_unhide -> toggleFileVisibility(false)
|
||||||
|
R.id.cab_create_shortcut -> createShortcut()
|
||||||
R.id.cab_copy_path -> copyPath()
|
R.id.cab_copy_path -> copyPath()
|
||||||
R.id.cab_set_as -> setAs()
|
R.id.cab_set_as -> setAs()
|
||||||
R.id.cab_open_with -> openWith()
|
R.id.cab_open_with -> openWith()
|
||||||
|
@ -216,6 +228,37 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NewApi")
|
||||||
|
private fun createShortcut() {
|
||||||
|
val manager = activity.getSystemService(ShortcutManager::class.java)
|
||||||
|
if (manager.isRequestPinShortcutSupported) {
|
||||||
|
val path = getFirstSelectedItemPath()
|
||||||
|
|
||||||
|
val appIconColor = baseConfig.appIconColor
|
||||||
|
val drawable = resources.getDrawable(R.drawable.shortcut_folder)
|
||||||
|
(drawable as LayerDrawable).findDrawableByLayerId(R.id.shortcut_folder_background).applyColorFilter(appIconColor)
|
||||||
|
val bmp = drawable.convertToBitmap()
|
||||||
|
|
||||||
|
val intent = Intent(activity, SplashActivity::class.java)
|
||||||
|
intent.action = Intent.ACTION_VIEW
|
||||||
|
intent.data = Uri.fromFile(File(path))
|
||||||
|
|
||||||
|
val shortcut = ShortcutInfo.Builder(activity, path)
|
||||||
|
.setShortLabel(path.getFilenameFromPath())
|
||||||
|
.setIcon(Icon.createWithBitmap(bmp))
|
||||||
|
.setIntent(intent)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
manager.dynamicShortcuts = Arrays.asList(shortcut)
|
||||||
|
|
||||||
|
val pinShortcutInfo = ShortcutInfo.Builder(activity, path).build()
|
||||||
|
val pinnedShortcutCallbackIntent = manager.createShortcutResultIntent(pinShortcutInfo)
|
||||||
|
|
||||||
|
val successCallback = PendingIntent.getBroadcast(activity, 0, pinnedShortcutCallbackIntent, 0)
|
||||||
|
manager.requestPinShortcut(pinShortcutInfo, successCallback.intentSender)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun addFileUris(path: String, paths: ArrayList<String>) {
|
private fun addFileUris(path: String, paths: ArrayList<String>) {
|
||||||
if (File(path).isDirectory) {
|
if (File(path).isDirectory) {
|
||||||
val shouldShowHidden = activity.config.shouldShowHidden
|
val shouldShowHidden = activity.config.shouldShowHidden
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 179 B |
Binary file not shown.
After Width: | Height: | Size: 243 B |
Binary file not shown.
After Width: | Height: | Size: 267 B |
Binary file not shown.
After Width: | Height: | Size: 457 B |
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:id="@+id/shortcut_folder_background">
|
||||||
|
<shape android:shape="oval">
|
||||||
|
<solid android:color="@color/color_primary"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/shortcut_folder_image"
|
||||||
|
android:bottom="@dimen/medium_margin"
|
||||||
|
android:drawable="@drawable/ic_folder_big"
|
||||||
|
android:left="@dimen/medium_margin"
|
||||||
|
android:right="@dimen/medium_margin"
|
||||||
|
android:top="@dimen/medium_margin"/>
|
||||||
|
|
||||||
|
</layer-list>
|
|
@ -31,6 +31,10 @@
|
||||||
android:icon="@drawable/ic_unhide"
|
android:icon="@drawable/ic_unhide"
|
||||||
android:title="@string/unhide"
|
android:title="@string/unhide"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/cab_create_shortcut"
|
||||||
|
android:title="@string/create_shortcut"
|
||||||
|
app:showAsAction="never"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/cab_copy_path"
|
android:id="@+id/cab_copy_path"
|
||||||
android:title="@string/copy_path"
|
android:title="@string/copy_path"
|
||||||
|
|
Loading…
Reference in New Issue