Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
MobileManager
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Wang Xu
MobileManager
Commits
effbc9af
Commit
effbc9af
authored
Aug 12, 2019
by
Wang Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更改壁纸
parent
58b98f28
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
211 additions
and
122 deletions
+211
-122
Launcher.java
Launcher3/src/com/android/launcher3/Launcher.java
+42
-2
SettingActivity.java
...3/src/com/android/launcher3/settings/SettingActivity.java
+31
-0
FileUtil.java
...src/main/java/com/secspace/lib/common/utils/FileUtil.java
+138
-120
No files found.
Launcher3/src/com/android/launcher3/Launcher.java
View file @
effbc9af
...
@@ -41,10 +41,15 @@ import android.content.SharedPreferences;
...
@@ -41,10 +41,15 @@ import android.content.SharedPreferences;
import
android.content.SharedPreferences.OnSharedPreferenceChangeListener
;
import
android.content.SharedPreferences.OnSharedPreferenceChangeListener
;
import
android.content.pm.ActivityInfo
;
import
android.content.pm.ActivityInfo
;
import
android.content.pm.PackageManager
;
import
android.content.pm.PackageManager
;
import
android.content.res.Resources
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Point
;
import
android.graphics.Point
;
import
android.graphics.Rect
;
import
android.graphics.Rect
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.graphics.drawable.Drawable
;
import
android.graphics.drawable.Drawable
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.os.AsyncTask
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
...
@@ -136,12 +141,14 @@ import com.android.launcher3.widget.WidgetHostViewLoader;
...
@@ -136,12 +141,14 @@ import com.android.launcher3.widget.WidgetHostViewLoader;
import
com.android.launcher3.widget.WidgetsContainerView
;
import
com.android.launcher3.widget.WidgetsContainerView
;
import
com.secspace.lib.common.event.RefreshWorkSpaceEvent
;
import
com.secspace.lib.common.event.RefreshWorkSpaceEvent
;
import
com.secspace.lib.common.utils.DpmHelper
;
import
com.secspace.lib.common.utils.DpmHelper
;
import
com.secspace.lib.common.utils.FileUtil
;
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
;
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
;
import
org.greenrobot.eventbus.EventBus
;
import
org.greenrobot.eventbus.EventBus
;
import
org.greenrobot.eventbus.Subscribe
;
import
org.greenrobot.eventbus.Subscribe
;
import
org.greenrobot.eventbus.ThreadMode
;
import
org.greenrobot.eventbus.ThreadMode
;
import
java.io.File
;
import
java.io.FileDescriptor
;
import
java.io.FileDescriptor
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -161,6 +168,7 @@ public class Launcher extends BaseActivity
...
@@ -161,6 +168,7 @@ public class Launcher extends BaseActivity
LauncherModel
.
Callbacks
,
View
.
OnTouchListener
,
LauncherProviderChangeListener
,
LauncherModel
.
Callbacks
,
View
.
OnTouchListener
,
LauncherProviderChangeListener
,
AccessibilityManager
.
AccessibilityStateChangeListener
{
AccessibilityManager
.
AccessibilityStateChangeListener
{
public
static
final
String
TAG
=
"Launcher"
;
public
static
final
String
TAG
=
"Launcher"
;
private
static
final
String
ACTION_CHANGE_WALLPAPER
=
"action_change_wallpaper"
;
static
final
boolean
LOGD
=
false
;
static
final
boolean
LOGD
=
false
;
static
final
boolean
DEBUG_WIDGETS
=
false
;
static
final
boolean
DEBUG_WIDGETS
=
false
;
...
@@ -178,6 +186,8 @@ public class Launcher extends BaseActivity
...
@@ -178,6 +186,8 @@ public class Launcher extends BaseActivity
private
static
final
int
REQUEST_PERMISSION_CALL_PHONE
=
13
;
private
static
final
int
REQUEST_PERMISSION_CALL_PHONE
=
13
;
private
static
final
int
CHANGE_WALLPAPER
=
14
;
private
static
final
float
BOUNCE_ANIMATION_TENSION
=
1.3f
;
private
static
final
float
BOUNCE_ANIMATION_TENSION
=
1.3f
;
/**
/**
...
@@ -206,6 +216,8 @@ public class Launcher extends BaseActivity
...
@@ -206,6 +216,8 @@ public class Launcher extends BaseActivity
static
final
String
APPS_VIEW_SHOWN
=
"launcher.apps_view_shown"
;
static
final
String
APPS_VIEW_SHOWN
=
"launcher.apps_view_shown"
;
static
final
String
WALLPAPER_NAME
=
"wallpaper"
;
/**
/**
* The different states that Launcher can be in.
* The different states that Launcher can be in.
*/
*/
...
@@ -361,6 +373,8 @@ public class Launcher extends BaseActivity
...
@@ -361,6 +373,8 @@ public class Launcher extends BaseActivity
private
RotationPrefChangeHandler
mRotationPrefChangeHandler
;
private
RotationPrefChangeHandler
mRotationPrefChangeHandler
;
private
String
mWallpaperPath
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
if
(
DEBUG_STRICT_MODE
)
{
if
(
DEBUG_STRICT_MODE
)
{
...
@@ -377,6 +391,7 @@ public class Launcher extends BaseActivity
...
@@ -377,6 +391,7 @@ public class Launcher extends BaseActivity
.
penaltyDeath
()
.
penaltyDeath
()
.
build
());
.
build
());
}
}
mWallpaperPath
=
getFilesDir
().
getAbsolutePath
()
+
File
.
separator
+
WALLPAPER_NAME
;
if
(
LauncherAppState
.
PROFILE_STARTUP
)
{
if
(
LauncherAppState
.
PROFILE_STARTUP
)
{
Trace
.
beginSection
(
"Launcher-onCreate"
);
Trace
.
beginSection
(
"Launcher-onCreate"
);
}
}
...
@@ -483,6 +498,22 @@ public class Launcher extends BaseActivity
...
@@ -483,6 +498,22 @@ public class Launcher extends BaseActivity
mLauncherCallbacks
.
onCreate
(
savedInstanceState
);
mLauncherCallbacks
.
onCreate
(
savedInstanceState
);
}
}
EventBus
.
getDefault
().
register
(
this
);
EventBus
.
getDefault
().
register
(
this
);
if
(
mWallpaperPath
!=
null
)
{
Bitmap
bitmap
=
BitmapFactory
.
decodeFile
(
mWallpaperPath
);
View
launcher
=
findViewById
(
R
.
id
.
launcher
);
launcher
.
setBackground
(
new
BitmapDrawable
(
getResources
(),
bitmap
));
}
if
(
ACTION_CHANGE_WALLPAPER
.
equals
(
getIntent
().
getAction
()))
{
Uri
selectedImage
=
getIntent
().
getParcelableExtra
(
"uri"
);
String
path
=
FileUtil
.
getPath
(
this
,
selectedImage
);
FileUtil
.
copyFile
(
this
,
path
,
WALLPAPER_NAME
);
Bitmap
bitmap
=
BitmapFactory
.
decodeFile
(
mWallpaperPath
);
View
launcher
=
findViewById
(
R
.
id
.
launcher
);
launcher
.
setBackground
(
new
BitmapDrawable
(
getResources
(),
bitmap
));
}
}
}
@Override
@Override
...
@@ -1781,11 +1812,11 @@ public class Launcher extends BaseActivity
...
@@ -1781,11 +1812,11 @@ public class Launcher extends BaseActivity
@Override
@Override
protected
void
onNewIntent
(
Intent
intent
)
{
protected
void
onNewIntent
(
Intent
intent
)
{
long
startTime
=
0
;
long
startTime
=
0
;
if
(
DEBUG_RESUME_TIME
)
{
if
(
DEBUG_RESUME_TIME
)
{
startTime
=
System
.
currentTimeMillis
();
startTime
=
System
.
currentTimeMillis
();
}
}
super
.
onNewIntent
(
intent
);
super
.
onNewIntent
(
intent
);
boolean
alreadyOnHome
=
mHasFocus
&&
((
intent
.
getFlags
()
&
boolean
alreadyOnHome
=
mHasFocus
&&
((
intent
.
getFlags
()
&
Intent
.
FLAG_ACTIVITY_BROUGHT_TO_FRONT
)
Intent
.
FLAG_ACTIVITY_BROUGHT_TO_FRONT
)
!=
Intent
.
FLAG_ACTIVITY_BROUGHT_TO_FRONT
);
!=
Intent
.
FLAG_ACTIVITY_BROUGHT_TO_FRONT
);
...
@@ -1853,6 +1884,16 @@ public class Launcher extends BaseActivity
...
@@ -1853,6 +1884,16 @@ public class Launcher extends BaseActivity
mLauncherCallbacks
.
onHomeIntent
();
mLauncherCallbacks
.
onHomeIntent
();
}
}
}
}
if
(
ACTION_CHANGE_WALLPAPER
.
equals
(
intent
.
getAction
()))
{
Uri
selectedImage
=
intent
.
getParcelableExtra
(
"uri"
);
String
path
=
FileUtil
.
getPath
(
this
,
selectedImage
);
FileUtil
.
copyFile
(
this
,
path
,
WALLPAPER_NAME
);
Bitmap
bitmap
=
BitmapFactory
.
decodeFile
(
mWallpaperPath
);
View
launcher
=
findViewById
(
R
.
id
.
launcher
);
launcher
.
setBackground
(
new
BitmapDrawable
(
getResources
(),
bitmap
));
}
PinItemDragListener
.
handleDragRequest
(
this
,
intent
);
PinItemDragListener
.
handleDragRequest
(
this
,
intent
);
if
(
mLauncherCallbacks
!=
null
)
{
if
(
mLauncherCallbacks
!=
null
)
{
...
@@ -1881,7 +1922,6 @@ public class Launcher extends BaseActivity
...
@@ -1881,7 +1922,6 @@ public class Launcher extends BaseActivity
});
});
}
}
}
}
if
(
DEBUG_RESUME_TIME
)
{
if
(
DEBUG_RESUME_TIME
)
{
Log
.
d
(
TAG
,
"Time spent in onNewIntent: "
+
(
System
.
currentTimeMillis
()
-
startTime
));
Log
.
d
(
TAG
,
"Time spent in onNewIntent: "
+
(
System
.
currentTimeMillis
()
-
startTime
));
}
}
...
...
Launcher3/src/com/android/launcher3/settings/SettingActivity.java
View file @
effbc9af
...
@@ -4,19 +4,28 @@ import android.app.AlertDialog;
...
@@ -4,19 +4,28 @@ import android.app.AlertDialog;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.net.Uri
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.Button
;
import
android.widget.LinearLayout
;
import
android.widget.LinearLayout
;
import
com.android.launcher3.BuildConfig
;
import
com.android.launcher3.BuildConfig
;
import
com.android.launcher3.Launcher
;
import
com.android.launcher3.R
;
import
com.android.launcher3.R
;
import
com.android.launcher3.mdm.MdmUtils
;
import
com.android.launcher3.mdm.MdmUtils
;
import
com.android.launcher3.settings.wifi.WifiWhiteListActivity
;
import
com.android.launcher3.settings.wifi.WifiWhiteListActivity
;
import
com.secspace.lib.common.utils.FileUtil
;
public
class
SettingActivity
extends
AppCompatActivity
implements
View
.
OnClickListener
{
public
class
SettingActivity
extends
AppCompatActivity
implements
View
.
OnClickListener
{
private
static
final
int
REQUEST_PICK_WALLPAPER
=
10
;
private
static
final
String
ACTION_CHANGE_WALLPAPER
=
"action_change_wallpaper"
;
private
Button
mBtnVsrsion
;
private
Button
mBtnVsrsion
;
private
Button
mBtnChangeWallPaper
;
private
Button
mBtnChangeWallPaper
;
private
Button
mBtnChangePwd
;
private
Button
mBtnChangePwd
;
...
@@ -139,6 +148,28 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
...
@@ -139,6 +148,28 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
case
R
.
id
.
btn_wifi_whitelist
:
case
R
.
id
.
btn_wifi_whitelist
:
startActivity
(
new
Intent
(
this
,
WifiWhiteListActivity
.
class
));
startActivity
(
new
Intent
(
this
,
WifiWhiteListActivity
.
class
));
break
;
break
;
case
R
.
id
.
btn_change_wallpaper
:
Intent
intent
=
new
Intent
(
Intent
.
ACTION_PICK
,
android
.
provider
.
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
);
startActivityForResult
(
intent
,
REQUEST_PICK_WALLPAPER
);
break
;
}
}
@Override
protected
void
onActivityResult
(
final
int
requestCode
,
final
int
resultCode
,
final
Intent
data
)
{
if
(
requestCode
==
REQUEST_PICK_WALLPAPER
)
{
if
(
resultCode
==
RESULT_OK
)
{
Log
.
e
(
"WWWW"
,
"AAAAA"
);
Uri
selectedImage
=
data
.
getData
();
Intent
intent
=
new
Intent
();
intent
.
setPackage
(
getPackageName
());
intent
.
setAction
(
ACTION_CHANGE_WALLPAPER
);
intent
.
setClass
(
this
,
Launcher
.
class
);
intent
.
putExtra
(
"uri"
,
selectedImage
);
startActivity
(
intent
);
finish
();
}
}
}
}
}
}
}
lib_common/src/main/java/com/secspace/lib/common/utils/FileUtil.java
View file @
effbc9af
package
com
.
secspace
.
lib
.
common
.
utils
;
package
com
.
secspace
.
lib
.
common
.
utils
;
import
android.content.ContentUris
;
import
android.content.Context
;
import
android.content.Context
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Environment
;
import
android.provider.DocumentsContract
;
import
android.provider.MediaStore
;
import
android.util.Log
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
...
@@ -16,134 +24,28 @@ import java.text.DecimalFormat;
...
@@ -16,134 +24,28 @@ import java.text.DecimalFormat;
public
class
FileUtil
{
public
class
FileUtil
{
private
static
final
String
TAG
=
"FileUtil"
;
private
static
final
String
TAG
=
"FileUtil"
;
/**
public
static
void
copyFile
(
Context
context
,
String
oldPath
,
String
newPath
)
{
* 复制单个文件,如果目标文件存在,则不覆盖
*/
public
static
boolean
copyFile
(
String
srcFileName
,
String
descFileName
)
{
return
FileUtil
.
copyFileCover
(
srcFileName
,
descFileName
,
false
);
}
/**
* 复制单个文件
*/
public
static
boolean
copyFileCover
(
String
srcFileName
,
String
descFileName
,
boolean
coverlay
)
{
File
srcFile
=
new
File
(
srcFileName
);
if
(!
srcFile
.
exists
())
{
return
false
;
}
else
if
(!
srcFile
.
isFile
())
{
return
false
;
}
File
descFile
=
new
File
(
descFileName
);
if
(
descFile
.
exists
())
{
if
(
coverlay
)
{
if
(!
deleteFile
(
descFileName
))
{
return
false
;
}
}
else
{
return
false
;
}
}
else
{
if
(!
descFile
.
getParentFile
().
exists
())
{
if
(!
descFile
.
getParentFile
().
mkdirs
())
{
return
false
;
}
}
}
int
readByte
=
0
;
InputStream
ins
=
null
;
OutputStream
outs
=
null
;
try
{
descFile
.
createNewFile
();
ins
=
new
FileInputStream
(
srcFile
);
outs
=
new
FileOutputStream
(
descFile
);
byte
[]
buf
=
new
byte
[
1024
];
while
((
readByte
=
ins
.
read
(
buf
))
!=
-
1
)
{
outs
.
write
(
buf
,
0
,
readByte
);
}
return
true
;
}
catch
(
Exception
e
)
{
return
false
;
}
finally
{
if
(
outs
!=
null
)
{
try
{
try
{
outs
.
close
();
int
bytesum
=
0
;
}
catch
(
IOException
oute
)
{
int
byteread
=
0
;
oute
.
printStackTrace
();
File
oldfile
=
new
File
(
oldPath
);
}
FileOutputStream
fos
=
context
.
openFileOutput
(
newPath
,
Context
.
MODE_PRIVATE
);
}
if
(
oldfile
.
exists
())
{
if
(
ins
!=
null
)
{
InputStream
inStream
=
new
FileInputStream
(
oldPath
);
try
{
byte
[]
buffer
=
new
byte
[
1024
];
ins
.
close
();
while
(
(
byteread
=
inStream
.
read
(
buffer
))
!=
-
1
)
{
}
catch
(
IOException
ine
)
{
bytesum
+=
byteread
;
ine
.
printStackTrace
();
fos
.
write
(
buffer
,
0
,
byteread
);
}
}
}
inStream
.
close
();
}
}
}
}
catch
(
Exception
e
)
{
/**
e
.
printStackTrace
();
* 复制整个目录的内容,如果目标目录存在,则不覆盖
*/
public
static
boolean
copyDirectory
(
String
srcDirName
,
String
descDirName
)
{
return
FileUtil
.
copyDirectoryCover
(
srcDirName
,
descDirName
,
false
);
}
/**
* 复制整个目录的内容
*/
public
static
boolean
copyDirectoryCover
(
String
srcDirName
,
String
descDirName
,
boolean
coverlay
)
{
File
srcDir
=
new
File
(
srcDirName
);
if
(!
srcDir
.
exists
())
{
return
false
;
}
else
if
(!
srcDir
.
isDirectory
())
{
return
false
;
}
if
(!
descDirName
.
endsWith
(
File
.
separator
))
{
descDirName
=
descDirName
+
File
.
separator
;
}
File
descDir
=
new
File
(
descDirName
);
if
(
descDir
.
exists
())
{
if
(
coverlay
)
{
if
(!
deleteFile
(
descDirName
))
{
return
false
;
}
}
else
{
return
false
;
}
}
else
{
if
(!
descDir
.
mkdirs
())
{
return
false
;
}
}
boolean
flag
=
true
;
File
[]
files
=
srcDir
.
listFiles
();
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
if
(
files
[
i
].
isFile
())
{
flag
=
FileUtil
.
copyFile
(
files
[
i
].
getAbsolutePath
(),
descDirName
+
files
[
i
].
getName
());
if
(!
flag
)
{
break
;
}
}
if
(
files
[
i
].
isDirectory
())
{
flag
=
FileUtil
.
copyDirectory
(
files
[
i
].
getAbsolutePath
(),
descDirName
+
files
[
i
].
getName
());
if
(!
flag
)
{
break
;
}
}
}
}
if
(!
flag
)
{
return
false
;
}
}
return
true
;
}
/**
/**
* 删除文件,可以删除单个文件或文件夹
* 删除文件,可以删除单个文件或文件夹
...
@@ -351,4 +253,119 @@ public class FileUtil {
...
@@ -351,4 +253,119 @@ public class FileUtil {
return
null
;
return
null
;
}
}
}
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is ExternalStorageProvider.
*/
public
static
boolean
isExternalStorageDocument
(
Uri
uri
)
{
return
"com.android.externalstorage.documents"
.
equals
(
uri
.
getAuthority
());
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is DownloadsProvider.
*/
public
static
boolean
isDownloadsDocument
(
Uri
uri
)
{
return
"com.android.providers.downloads.documents"
.
equals
(
uri
.
getAuthority
());
}
/**
* Get the value of the data column for this Uri. This is useful for
* MediaStore Uris, and other file-based ContentProviders.
*
* @param context The context.
* @param uri The Uri to query.
* @param selection (Optional) Filter used in the query.
* @param selectionArgs (Optional) Selection arguments used in the query.
* @return The value of the _data column, which is typically a file path.
*/
public
static
String
getDataColumn
(
Context
context
,
Uri
uri
,
String
selection
,
String
[]
selectionArgs
)
{
Cursor
cursor
=
null
;
final
String
column
=
MediaStore
.
Images
.
Media
.
DATA
;
final
String
[]
projection
=
{
column
};
try
{
cursor
=
context
.
getContentResolver
().
query
(
uri
,
null
,
selection
,
selectionArgs
,
null
);
if
(
cursor
!=
null
&&
cursor
.
moveToFirst
())
{
final
int
column_index
=
cursor
.
getColumnIndexOrThrow
(
column
);
return
cursor
.
getString
(
column_index
);
}
}
finally
{
if
(
cursor
!=
null
)
cursor
.
close
();
}
return
null
;
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is MediaProvider.
*/
public
static
boolean
isMediaDocument
(
Uri
uri
)
{
return
"com.android.providers.media.documents"
.
equals
(
uri
.
getAuthority
());
}
public
static
String
getPath
(
final
Context
context
,
final
Uri
uri
)
{
final
boolean
isKitKat
=
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
;
// DocumentProvider
if
(
isKitKat
&&
DocumentsContract
.
isDocumentUri
(
context
,
uri
))
{
// ExternalStorageProvider
if
(
isExternalStorageDocument
(
uri
))
{
final
String
docId
=
DocumentsContract
.
getDocumentId
(
uri
);
final
String
[]
split
=
docId
.
split
(
":"
);
final
String
type
=
split
[
0
];
if
(
"primary"
.
equalsIgnoreCase
(
type
))
{
return
Environment
.
getExternalStorageDirectory
()
+
"/"
+
split
[
1
];
}
}
// DownloadsProvider
else
if
(
isDownloadsDocument
(
uri
))
{
final
String
id
=
DocumentsContract
.
getDocumentId
(
uri
);
final
Uri
contentUri
=
ContentUris
.
withAppendedId
(
Uri
.
parse
(
"content://downloads/public_downloads"
),
Long
.
valueOf
(
id
));
return
getDataColumn
(
context
,
contentUri
,
null
,
null
);
}
// MediaProvider
else
if
(
isMediaDocument
(
uri
))
{
final
String
docId
=
DocumentsContract
.
getDocumentId
(
uri
);
final
String
[]
split
=
docId
.
split
(
":"
);
final
String
type
=
split
[
0
];
Uri
contentUri
=
null
;
if
(
"image"
.
equals
(
type
))
{
contentUri
=
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
;
}
else
if
(
"video"
.
equals
(
type
))
{
contentUri
=
MediaStore
.
Video
.
Media
.
EXTERNAL_CONTENT_URI
;
}
else
if
(
"audio"
.
equals
(
type
))
{
contentUri
=
MediaStore
.
Audio
.
Media
.
EXTERNAL_CONTENT_URI
;
}
final
String
selection
=
"_id=?"
;
final
String
[]
selectionArgs
=
new
String
[]{
split
[
1
]};
return
getDataColumn
(
context
,
contentUri
,
selection
,
selectionArgs
);
}
}
// MediaStore (and general)
else
if
(
"content"
.
equalsIgnoreCase
(
uri
.
getScheme
()))
{
return
getDataColumn
(
context
,
uri
,
null
,
null
);
}
// File
else
if
(
"file"
.
equalsIgnoreCase
(
uri
.
getScheme
()))
{
return
uri
.
getPath
();
}
return
null
;
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment