Android Open Source - device-frame-generator Device






From Project

Back to project page device-frame-generator.

License

The source code is released under:

Apache License

If you think the Android project device-frame-generator listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright 2014 Prateek Srivastava (@f2prateek)
 *//from  w w  w  . ja va2s.  c  o  m
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.f2prateek.dfg.model;

import android.auto.value.AutoValue;
import android.os.Parcelable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@AutoValue
public abstract class Device implements Parcelable {

  // Unique identifier for each device, also used to identify resources.
  public abstract String id();

  // Device name to display
  public abstract String name();

  // Device product URL
  public abstract String url();

  // Physical size of device, just for displaying to user
  public abstract float physicalSize();

  // DPI; just for displaying to user
  public abstract String density();

  // offset of screenshot from edges when in landscape
  public abstract Bounds landOffset();

  // offset of screenshot from edges when in portrait
  public abstract Bounds portOffset();

  // Screen resolution in portrait
  public abstract Bounds portSize();

  // Screen resolution in portrait, that will be displayed to the user.
  // This may or may not be same as portSize
  public abstract Bounds realSize();

  // A list of product ids that match {@link android.os.Build#PRODUCT} for this device
  public abstract List<String> productIds();

  private static Device create(String id, String name, String url, float physicalSize,
      String density, Bounds landOffset, Bounds portOffset, Bounds portSize, Bounds realSize,
      List<String> productIds) {
    return new AutoValue_Device(id, name, url, physicalSize, density, landOffset, portOffset,
        portSize, realSize, productIds);
  }

  // Get the name of the shadow resource
  public String getShadowStringResourceName(String orientation) {
    return id() + "_" + orientation + "_shadow";
  }

  // Get the name of the glare resource
  public String getGlareStringResourceName(String orientation) {
    return id() + "_" + orientation + "_glare";
  }

  // Get the name of the background resource
  public String getBackgroundStringResourceName(String orientation) {
    return id() + "_" + orientation + "_back";
  }

  // Get the name of the thumbnail resource
  public String getThumbnailResourceName() {
    return id() + "_thumb";
  }

  // Put all relevant values into the given container object and return it
  public void into(Map<String, Object> container) {
    container.put("device_id", id());
    container.put("device_name", name());
    container.put("device_bounds_x", portSize().x());
    container.put("device_bounds_y", portSize().y());
  }

  public static class Builder {
    private String id;
    private String name;
    private String url;
    private float physicalSize;
    private String density;
    private Bounds landOffset;
    private Bounds portOffset;
    private Bounds portSize;
    private Bounds realSize;
    private List<String> productIds = new ArrayList<>();

    public Builder setId(String id) {
      this.id = id;
      return this;
    }

    public Builder setName(String name) {
      this.name = name;
      return this;
    }

    public Builder setUrl(String url) {
      this.url = url;
      return this;
    }

    public Builder setPhysicalSize(float physicalSize) {
      this.physicalSize = physicalSize;
      return this;
    }

    public Builder setDensity(String density) {
      this.density = density;
      return this;
    }

    public Builder setLandOffset(int landOffsetX, int landOffsetY) {
      this.landOffset = Bounds.create(landOffsetX, landOffsetY);
      return this;
    }

    public Builder setPortOffset(int portOffsetX, int portOffsetY) {
      this.portOffset = Bounds.create(portOffsetX, portOffsetY);
      return this;
    }

    public Builder setPortSize(int portSizeX, int portSizeY) {
      this.portSize = Bounds.create(portSizeX, portSizeY);
      return this;
    }

    public Builder setRealSize(int realSizeX, int realSizeY) {
      this.realSize = Bounds.create(realSizeX, realSizeY);
      return this;
    }

    public Builder addProductId(String id) {
      productIds.add(id);
      return this;
    }

    public Device build() {
      return create(id, name, url, physicalSize, density, landOffset, portOffset, portSize,
          realSize, productIds);
    }
  }
}




Java Source Code List

com.f2prateek.dfg.AnalyticsKey.java
com.f2prateek.dfg.AppConstants.java
com.f2prateek.dfg.CrashlyticsLn.java
com.f2prateek.dfg.DFGApplicationModule.java
com.f2prateek.dfg.DFGApplication.java
com.f2prateek.dfg.DebugDFGApplicationModule.java
com.f2prateek.dfg.DeviceModule.java
com.f2prateek.dfg.DeviceProvider.java
com.f2prateek.dfg.Events.java
com.f2prateek.dfg.ForApplication.java
com.f2prateek.dfg.Modules.java
com.f2prateek.dfg.Modules.java
com.f2prateek.dfg.Utils.java
com.f2prateek.dfg.core.AbstractGenerateFrameService.java
com.f2prateek.dfg.core.DeviceFrameGenerator.java
com.f2prateek.dfg.core.GenerateFrameService.java
com.f2prateek.dfg.core.GenerateMultipleFramesService.java
com.f2prateek.dfg.model.Bounds.java
com.f2prateek.dfg.model.Device.java
com.f2prateek.dfg.model.Orientation.java
com.f2prateek.dfg.prefs.DebugPreferencesModule.java
com.f2prateek.dfg.prefs.DefaultDevice.java
com.f2prateek.dfg.prefs.FirstRun.java
com.f2prateek.dfg.prefs.GlareEnabled.java
com.f2prateek.dfg.prefs.PreferencesModule.java
com.f2prateek.dfg.prefs.ShadowEnabled.java
com.f2prateek.dfg.prefs.debug.AnimationSpeed.java
com.f2prateek.dfg.prefs.debug.PicassoDebugging.java
com.f2prateek.dfg.prefs.debug.PixelGridEnabled.java
com.f2prateek.dfg.prefs.debug.PixelRatioEnabled.java
com.f2prateek.dfg.prefs.debug.ScalpelEnabled.java
com.f2prateek.dfg.prefs.debug.ScalpelWireframeEnabled.java
com.f2prateek.dfg.prefs.debug.SeenDebugDrawer.java
com.f2prateek.dfg.prefs.model.BooleanPreference.java
com.f2prateek.dfg.prefs.model.IntPreference.java
com.f2prateek.dfg.prefs.model.StringPreference.java
com.f2prateek.dfg.ui.ActivityHierarchyServer.java
com.f2prateek.dfg.ui.AppContainer.java
com.f2prateek.dfg.ui.BindableAdapter.java
com.f2prateek.dfg.ui.DebugUiModule.java
com.f2prateek.dfg.ui.DeviceFragmentPagerAdapter.java
com.f2prateek.dfg.ui.SocketActivityHierarchyServer.java
com.f2prateek.dfg.ui.UiModule.java
com.f2prateek.dfg.ui.activities.BaseActivity.java
com.f2prateek.dfg.ui.activities.MainActivity.java
com.f2prateek.dfg.ui.activities.ReceiverActivity.java
com.f2prateek.dfg.ui.debug.AnimationSpeedAdapter.java
com.f2prateek.dfg.ui.debug.ContextualDebugActions.java
com.f2prateek.dfg.ui.debug.DebugAppContainer.java
com.f2prateek.dfg.ui.debug.HierarchyTreeChangeListener.java
com.f2prateek.dfg.ui.fragments.AboutFragment.java
com.f2prateek.dfg.ui.fragments.BaseFragment.java
com.f2prateek.dfg.ui.fragments.DeviceFragment.java
com.f2prateek.dfg.ui.widgets.ForegroundImageView.java