android.service.wallpaper.WallpaperService Java Examples

The following examples show how to use android.service.wallpaper.WallpaperService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LiveWallpaperListAdapter.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public LiveWallpaperListAdapter(Context context) {
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mPackageManager = context.getPackageManager();

    List<ResolveInfo> list = mPackageManager.queryIntentServices(
            new Intent(WallpaperService.SERVICE_INTERFACE),
            PackageManager.GET_META_DATA);

    mWallpapers = new ArrayList<LiveWallpaperTile>();

    new LiveWallpaperEnumerator(context).execute(list);
}
 
Example #2
Source File: Drawer.java    From meter with Apache License 2.0 5 votes vote down vote up
@Override
public void onSensorChanged(SensorEvent event) {
    if (event.sensor == mAccelerometer) {
        System.arraycopy(event.values, 0, mLastAccelerometer, 0, event.values.length);
        mLastAccelerometerSet = true;
    } else if (event.sensor == mMagnetometer) {
        System.arraycopy(event.values, 0, mLastMagnetometer, 0, event.values.length);
        mLastMagnetometerSet = true;
    }
    if (mLastAccelerometerSet && mLastMagnetometerSet) {
        SensorManager.getRotationMatrix(mR, null, mLastAccelerometer, mLastMagnetometer);

        try {
            mDisplay = ((WindowManager) ((WallpaperService) context).getApplication().getSystemService(Service.WINDOW_SERVICE))
                    .getDefaultDisplay();
        } catch (Exception ignored){}


        int rotation = Surface.ROTATION_0;
        if(mDisplay != null) {
            rotation = mDisplay.getRotation();
        }

        float[] mRremap = mR.clone();
        if(rotation == Surface.ROTATION_90){
            SensorManager.remapCoordinateSystem(mR, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, mRremap);
        }
        if(rotation == Surface.ROTATION_270){
            SensorManager.remapCoordinateSystem(mR, SensorManager.AXIS_MINUS_Y, SensorManager.AXIS_X, mRremap);
        }
        if(rotation == Surface.ROTATION_180){
            SensorManager.remapCoordinateSystem(mR, SensorManager.AXIS_MINUS_X, SensorManager.AXIS_MINUS_Y, mRremap);
        }

        SensorManager.getOrientation(mRremap, mOrientation);
    }
}
 
Example #3
Source File: LiveWallpaperListAdapter.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public LiveWallpaperListAdapter(Context context) {
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mPackageManager = context.getPackageManager();

    List<ResolveInfo> list = mPackageManager.queryIntentServices(
            new Intent(WallpaperService.SERVICE_INTERFACE),
            PackageManager.GET_META_DATA);

    mWallpapers = new ArrayList<LiveWallpaperTile>();

    new LiveWallpaperEnumerator(context).execute(list);
}
 
Example #4
Source File: LiveWallpaperListAdapter.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public LiveWallpaperListAdapter(Context context) {
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mPackageManager = context.getPackageManager();

    List<ResolveInfo> list = mPackageManager.queryIntentServices(
            new Intent(WallpaperService.SERVICE_INTERFACE),
            PackageManager.GET_META_DATA);

    mWallpapers = new ArrayList<LiveWallpaperTile>();

    new LiveWallpaperEnumerator(context).execute(list);
}
 
Example #5
Source File: WallpaperInfo.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor.
 * 
 * @param context The Context in which we are parsing the wallpaper.
 * @param service The ResolveInfo returned from the package manager about
 * this wallpaper's component.
 */
public WallpaperInfo(Context context, ResolveInfo service)
        throws XmlPullParserException, IOException {
    mService = service;
    ServiceInfo si = service.serviceInfo;
    
    final PackageManager pm = context.getPackageManager();
    XmlResourceParser parser = null;
    try {
        parser = si.loadXmlMetaData(pm, WallpaperService.SERVICE_META_DATA);
        if (parser == null) {
            throw new XmlPullParserException("No "
                    + WallpaperService.SERVICE_META_DATA + " meta-data");
        }
    
        Resources res = pm.getResourcesForApplication(si.applicationInfo);
        
        AttributeSet attrs = Xml.asAttributeSet(parser);
        
        int type;
        while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
                && type != XmlPullParser.START_TAG) {
        }
        
        String nodeName = parser.getName();
        if (!"wallpaper".equals(nodeName)) {
            throw new XmlPullParserException(
                    "Meta-data does not start with wallpaper tag");
        }
        
        TypedArray sa = res.obtainAttributes(attrs,
                com.android.internal.R.styleable.Wallpaper);
        mSettingsActivityName = sa.getString(
                com.android.internal.R.styleable.Wallpaper_settingsActivity);

        mThumbnailResource = sa.getResourceId(
                com.android.internal.R.styleable.Wallpaper_thumbnail,
                -1);
        mAuthorResource = sa.getResourceId(
                com.android.internal.R.styleable.Wallpaper_author,
                -1);
        mDescriptionResource = sa.getResourceId(
                com.android.internal.R.styleable.Wallpaper_description,
                -1);
        mContextUriResource = sa.getResourceId(
                com.android.internal.R.styleable.Wallpaper_contextUri,
                -1);
        mContextDescriptionResource = sa.getResourceId(
                com.android.internal.R.styleable.Wallpaper_contextDescription,
                -1);
        mShowMetadataInPreview = sa.getBoolean(
                com.android.internal.R.styleable.Wallpaper_showMetadataInPreview,
                false);
        mSupportsAmbientMode = sa.getBoolean(
                com.android.internal.R.styleable.Wallpaper_supportsAmbientMode,
                false);

        sa.recycle();
    } catch (NameNotFoundException e) {
        throw new XmlPullParserException(
                "Unable to create context for: " + si.packageName);
    } finally {
        if (parser != null) parser.close();
    }
}
 
Example #6
Source File: nicoWallpaper.java    From styT with Apache License 2.0 4 votes vote down vote up
public CubeEngine(WallpaperService w) {
    ww = w;
}
 
Example #7
Source File: nicoWallpaper.java    From styT with Apache License 2.0 4 votes vote down vote up
MVer(WallpaperService myWallpaperService, SurfaceHolder surfaceHolder) {
    this.m = myWallpaperService;
    this.surfaceHolder = surfaceHolder;
}