Java Code Examples for org.springframework.mobile.device.Device#isTablet()

The following examples show how to use org.springframework.mobile.device.Device#isTablet() . 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: LoginAction.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public String execute()
    throws Exception
{
    Device device = deviceResolver.resolveDevice( ServletActionContext.getRequest() );

    ServletActionContext.getResponse().addHeader( "Login-Page", "true" );

    if ( device.isMobile() || device.isTablet() )
    {
        return "mobile";
    }

    availableLocales = new ArrayList<>( resourceBundleManager.getAvailableLocales() );

    return "standard";
}
 
Example 2
Source File: JwtTokenUtil.java    From spring-security-mybatis-demo with Apache License 2.0 5 votes vote down vote up
private String generateAudience(Device device) {
    String audience = AUDIENCE_UNKNOWN;
    if (device.isNormal()) {
        audience = AUDIENCE_WEB;
    } else if (device.isTablet()) {
        audience = AUDIENCE_TABLET;
    } else if (device.isMobile()) {
        audience = AUDIENCE_MOBILE;
    }
    return audience;
}
 
Example 3
Source File: JwtTokenUtil.java    From xmanager with Apache License 2.0 5 votes vote down vote up
private String generateAudience(Device device) {
    String audience = AUDIENCE_UNKNOWN;
    if (device.isNormal()) {
        audience = AUDIENCE_WEB;
    } else if (device.isTablet()) {
        audience = AUDIENCE_TABLET;
    } else if (device.isMobile()) {
        audience = AUDIENCE_MOBILE;
    }
    return audience;
}
 
Example 4
Source File: _JwtTokenUtil.java    From generator-spring-rest-jwt with MIT License 5 votes vote down vote up
private String generateAudience(Device device) {
    String audience = AUDIENCE_UNKNOWN;
    if (device.isNormal()) {
        audience = AUDIENCE_WEB;
    } else if (device.isTablet()) {
        audience = AUDIENCE_TABLET;
    } else if (device.isMobile()) {
        audience = AUDIENCE_MOBILE;
    }
    return audience;
}
 
Example 5
Source File: JwtTokenUtil.java    From microservices-sample-project with Apache License 2.0 5 votes vote down vote up
private String generateAudience(Device device) {
    String audience = AUDIENCE_UNKNOWN;
    if (device.isNormal()) {
        audience = AUDIENCE_WEB;
    } else if (device.isTablet()) {
        audience = AUDIENCE_TABLET;
    } else if (device.isMobile()) {
        audience = AUDIENCE_MOBILE;
    }
    return audience;
}
 
Example 6
Source File: JwtTokenUtil.java    From tour-of-heros-api-security-zerhusen with MIT License 5 votes vote down vote up
private String generateAudience(Device device) {
    String audience = AUDIENCE_UNKNOWN;
    if (device.isNormal()) {
        audience = AUDIENCE_WEB;
    } else if (device.isTablet()) {
        audience = AUDIENCE_TABLET;
    } else if (device.isMobile()) {
        audience = AUDIENCE_MOBILE;
    }
    return audience;
}
 
Example 7
Source File: TokenHelper.java    From springboot-jwt-starter with MIT License 5 votes vote down vote up
private String generateAudience(Device device) {
    String audience = AUDIENCE_UNKNOWN;
    if (device.isNormal()) {
        audience = AUDIENCE_WEB;
    } else if (device.isTablet()) {
        audience = AUDIENCE_TABLET;
    } else if (device.isMobile()) {
        audience = AUDIENCE_MOBILE;
    }
    return audience;
}
 
Example 8
Source File: TokenUtils.java    From Cerberus with MIT License 5 votes vote down vote up
private String generateAudience(Device device) {
  String audience = this.AUDIENCE_UNKNOWN;
  if (device.isNormal()) {
    audience = this.AUDIENCE_WEB;
  } else if (device.isTablet()) {
    audience = AUDIENCE_TABLET;
  } else if (device.isMobile()) {
    audience = AUDIENCE_MOBILE;
  }
  return audience;
}
 
Example 9
Source File: IndexController.java    From tutorials with MIT License 5 votes vote down vote up
@GetMapping("/")
public String greeting(Device device) {

	String deviceType = "browser";
	String platform = "browser";
	String viewName = "index";

	if (device.isNormal()) {
		deviceType = "browser";
	} else if (device.isMobile()) {
		deviceType = "mobile";
		viewName = "mobile/index";
	} else if (device.isTablet()) {
		deviceType = "tablet";
		viewName = "tablet/index";
	}

	platform = device.getDevicePlatform().name();

	if (platform.equalsIgnoreCase("UNKNOWN")) {
		platform = "browser";
	}

	LOGGER.info("Client Device Type: " + deviceType + ", Platform: " + platform);

	return viewName;
}
 
Example 10
Source File: TokenHelper.java    From springboot-jwt-starter with MIT License 4 votes vote down vote up
private Date generateExpirationDate(Device device) {
    long expiresIn = device.isTablet() || device.isMobile() ? MOBILE_EXPIRES_IN : EXPIRES_IN;
    return new Date(timeProvider.now().getTime() + expiresIn * 1000);
}
 
Example 11
Source File: TokenHelper.java    From springboot-jwt-starter with MIT License 4 votes vote down vote up
public int getExpiredIn(Device device) {
    return device.isMobile() || device.isTablet() ? MOBILE_EXPIRES_IN : EXPIRES_IN;
}
 
Example 12
Source File: MappedRedirectStrategy.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void sendRedirect( HttpServletRequest request, HttpServletResponse response, String url )
    throws IOException
{
    // ---------------------------------------------------------------------
    // Check if redirect should be skipped - for cookie authentication only
    // ---------------------------------------------------------------------

    String authOnly = (String) request.getAttribute( PARAM_AUTH_ONLY );

    if ( "true".equals( authOnly ) )
    {
        return;
    }

    // ---------------------------------------------------------------------
    // Ignore certain ajax requests
    // ---------------------------------------------------------------------

    for ( String key : redirectMap.keySet() )
    {
        if ( url.contains(key) )
        {
            url = url.replaceFirst( key, redirectMap.get( key ) );
        }
    }

    // ---------------------------------------------------------------------
    // Redirect to mobile start pages
    // ---------------------------------------------------------------------

    Device device = deviceResolver.resolveDevice( request );

    if ( (device.isMobile() || device.isTablet()) )
    {
        url = getRootPath( request ) + "/";
    }

    log.debug( "Redirecting to " + url );

    super.sendRedirect( request, response, url );
}