/***
  Copyright (c) 2013 CommonsWare, LLC
  
  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.commonsware.cwac.camera;

import android.os.Build;

public class DeviceProfile {
  private static volatile DeviceProfile SINGLETON=null;

  synchronized public static DeviceProfile getInstance() {
    if (SINGLETON == null) {
      if ("samsung".equalsIgnoreCase(Build.MANUFACTURER)
          && !("crespo".equals(Build.DEVICE))) {
        SINGLETON=new SamsungDeviceProfile();
      }
      else if ("motorola".equalsIgnoreCase(Build.MANUFACTURER)) {
        SINGLETON=new MotorolaDeviceProfile();
      }
      else {
        SINGLETON=new DeviceProfile();
      }
    }

    return(SINGLETON);
  }

  private DeviceProfile() {
  }

  public boolean useTextureView() {
    return(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN);
  }

  public boolean encodesRotationToExif() {
    return(false);
  }

  private static class SamsungDeviceProfile extends DeviceProfile {
    @Override
    public boolean encodesRotationToExif() {
      return(true);
    }
  }

  private static class MotorolaDeviceProfile extends DeviceProfile {
    @Override
    public boolean encodesRotationToExif() {
      return(true);
    }
  }
}

@@ -880,54 +880,8 @@
 RER)
-%0A          && !(%22crespo%22.equals(Build.DEVICE))
 ) %7B%0A
@@ -1352,32 +1352,95 @@
 rn(false);%0A  %7D%0A%0A
+  public boolean rotateBasedOnExif() %7B%0A    return(false);%0A  %7D%0A%0A
   private static
@@ -1446,23 +1446,29 @@
 c class 
-Samsung
+FullExifFixup
 DevicePr
@@ -1577,24 +1577,106 @@
 true);%0A    %7D
+%0A%0A    @Override%0A    public boolean rotateBasedOnExif() %7B%0A      return(true);%0A    %7D
 %0A  %7D%0A%0A  priv
@@ -1692,24 +1692,23 @@
 c class 
-Motorola
+Samsung
 DevicePr
@@ -1724,109 +1724,136 @@
 ends
- DeviceProfile %7B%0A    @Override%0A    public boolean encodesRotationToExif() %7B%0A      return(true);%0A    %7D
+%0A      FullExifFixupDeviceProfile %7B%0A  %7D%0A%0A  private static class MotorolaDeviceProfile extends%0A      FullExifFixupDeviceProfile %7B
 %0A  %7D

fix for issue #16