forked from SlimRoms/packages_apps_Settings
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LockscreenWallpaper: Use FB's WallpaperCropper
Thanks to OmniROM for these following commits: * https://gerrit.omnirom.org/#/c/14299/ * https://gerrit.omnirom.org/#/c/14345/ * https://gerrit.omnirom.org/#/c/14354/ FB part: SlimSaber/frameworks_base@9e55ef6 Change-Id: I4c70f3ca58afbbf9ddc542bd331bedb4a5cd63df
- Loading branch information
1 parent
c633e1b
commit c347ba1
Showing
9 changed files
with
180 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright (C) 2015 The OmniROM Project | ||
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 2 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/>. | ||
--> | ||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"> | ||
|
||
<PreferenceCategory | ||
android:key="lockscreen_wallpaper" | ||
android:title="@string/lockscreen_wallpaper_title" > | ||
|
||
<Preference | ||
android:key="lockscreen_wallpaper_set" | ||
android:title="@string/lockscreen_wallpaper_set_title" | ||
android:persistent="false"/> | ||
|
||
<Preference | ||
android:key="lockscreen_wallpaper_clear" | ||
android:title="@string/lockscreen_wallpaper_clear_title" | ||
android:persistent="false"/> | ||
|
||
</PreferenceCategory> | ||
</PreferenceScreen> |
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright (C) 2015 The OmniROM Project | ||
* | ||
* 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 2 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 com.android.settings.slim; | ||
|
||
import android.app.Activity; | ||
import android.app.WallpaperManager; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.preference.Preference; | ||
import android.preference.PreferenceScreen; | ||
import android.widget.Toast; | ||
|
||
import com.android.settings.R; | ||
import com.android.settings.SettingsPreferenceFragment; | ||
|
||
public class LockscreenWallpaper extends SettingsPreferenceFragment { | ||
public static final int IMAGE_PICK = 1; | ||
|
||
private static final String KEY_WALLPAPER_SET = "lockscreen_wallpaper_set"; | ||
private static final String KEY_WALLPAPER_CLEAR = "lockscreen_wallpaper_clear"; | ||
|
||
private Preference mSetWallpaper; | ||
private Preference mClearWallpaper; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
addPreferencesFromResource(R.xml.lockscreen_wallpaper); | ||
|
||
mSetWallpaper = (Preference) findPreference(KEY_WALLPAPER_SET); | ||
mClearWallpaper = (Preference) findPreference(KEY_WALLPAPER_CLEAR); | ||
} | ||
|
||
@Override | ||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { | ||
if (preference == mSetWallpaper) { | ||
setKeyguardWallpaper(); | ||
return true; | ||
} else if (preference == mClearWallpaper) { | ||
clearKeyguardWallpaper(); | ||
Toast.makeText(getView().getContext(), getString(R.string.reset_lockscreen_wallpaper), | ||
Toast.LENGTH_LONG).show(); | ||
return true; | ||
} | ||
return super.onPreferenceTreeClick(preferenceScreen, preference); | ||
} | ||
|
||
@Override | ||
public void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
if (requestCode == IMAGE_PICK && resultCode == Activity.RESULT_OK) { | ||
if (data != null && data.getData() != null) { | ||
Uri uri = data.getData(); | ||
Intent intent = new Intent(); | ||
intent.setClassName("com.android.wallpapercropper", "com.android.wallpapercropper.WallpaperCropActivity"); | ||
intent.putExtra("keyguardMode", "1"); | ||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | ||
intent.setData(uri); | ||
startActivity(intent); | ||
} | ||
} | ||
} | ||
|
||
private void setKeyguardWallpaper() { | ||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); | ||
intent.setType("image/*"); | ||
startActivityForResult(intent, IMAGE_PICK); | ||
} | ||
|
||
private void clearKeyguardWallpaper() { | ||
WallpaperManager wallpaperManager = null; | ||
wallpaperManager = WallpaperManager.getInstance(getActivity()); | ||
wallpaperManager.clearKeyguardWallpaper(); | ||
} | ||
} |