@Test public void testMeetsMinimumVersion() throws Exception { assertThat( Utils.meetsMinimumVersion( "b6ae90c071", 0.28f ) ).isEqualTo( false ); assertThat( Utils.meetsMinimumVersion( "Unknown", 0.28f ) ).isEqualTo( false ); assertThat( Utils.meetsMinimumVersion( "v0.27.6", 0.28f ) ).isEqualTo( false ); assertThat( Utils.meetsMinimumVersion( "v0.27", 0.28f ) ).isEqualTo( false ); assertThat( Utils.meetsMinimumVersion( "0.27", 0.28f ) ).isEqualTo( false ); assertThat( Utils.meetsMinimumVersion( "v0.27-xyz", 0.28f ) ).isEqualTo( false ); assertThat( Utils.meetsMinimumVersion( "v0.26", 0.28f ) ).isEqualTo( false ); assertThat( Utils.meetsMinimumVersion( "0.26", 0.28f ) ).isEqualTo( false ); assertThat( Utils.meetsMinimumVersion( "v0.26-xyz", 0.28f ) ).isEqualTo( false ); assertThat( Utils.meetsMinimumVersion( "v0.28", 0.28f ) ).isEqualTo( true ); assertThat( Utils.meetsMinimumVersion( "0.28", 0.28f ) ).isEqualTo( true ); assertThat( Utils.meetsMinimumVersion( "v0.28-xyz", 0.28f ) ).isEqualTo( true ); assertThat( Utils.meetsMinimumVersion( "v28.0", 0.28f ) ).isEqualTo( true ); assertThat( Utils.meetsMinimumVersion( "v0.29", 0.28f ) ).isEqualTo( true ); assertThat( Utils.meetsMinimumVersion( "0.29", 0.28f ) ).isEqualTo( true ); assertThat( Utils.meetsMinimumVersion( "v0.29-xyz", 0.28f ) ).isEqualTo( true ); assertThat( Utils.meetsMinimumVersion( "v29.0", 0.28f ) ).isEqualTo( true ); assertThat( Utils.meetsMinimumVersion( "v0.28.1-21-ge26a33c", 0.28f ) ).isEqualTo( true ); }
public static boolean meetsMinimumVersion( String version, float minimumVersion ) { if( "Unknown".equals( version ) || version.matches( "\\b[0-9a-f]{5,40}\\b" ) ) { return false; } String cleanVersion = version; if( cleanVersion.startsWith( "v" ) ) { cleanVersion = cleanVersion.substring( 1 ); } if( cleanVersion.contains( "-" ) ) { cleanVersion = cleanVersion.substring( 0, cleanVersion.indexOf( '-' ) ); } if( cleanVersion.length() > 4 ) { cleanVersion = cleanVersion.substring( 0, 4 ); } try { Float.parseFloat( cleanVersion ); } catch( NumberFormatException e ) { return false; } float extractedVersion = Float.parseFloat( cleanVersion ); if( !cleanVersion.startsWith( "0" ) ) { extractedVersion *= 100; } return ( extractedVersion >= minimumVersion ); }
Utils { public static boolean meetsMinimumVersion( String version, float minimumVersion ) { if( "Unknown".equals( version ) || version.matches( "\\b[0-9a-f]{5,40}\\b" ) ) { return false; } String cleanVersion = version; if( cleanVersion.startsWith( "v" ) ) { cleanVersion = cleanVersion.substring( 1 ); } if( cleanVersion.contains( "-" ) ) { cleanVersion = cleanVersion.substring( 0, cleanVersion.indexOf( '-' ) ); } if( cleanVersion.length() > 4 ) { cleanVersion = cleanVersion.substring( 0, 4 ); } try { Float.parseFloat( cleanVersion ); } catch( NumberFormatException e ) { return false; } float extractedVersion = Float.parseFloat( cleanVersion ); if( !cleanVersion.startsWith( "0" ) ) { extractedVersion *= 100; } return ( extractedVersion >= minimumVersion ); } }
Utils { public static boolean meetsMinimumVersion( String version, float minimumVersion ) { if( "Unknown".equals( version ) || version.matches( "\\b[0-9a-f]{5,40}\\b" ) ) { return false; } String cleanVersion = version; if( cleanVersion.startsWith( "v" ) ) { cleanVersion = cleanVersion.substring( 1 ); } if( cleanVersion.contains( "-" ) ) { cleanVersion = cleanVersion.substring( 0, cleanVersion.indexOf( '-' ) ); } if( cleanVersion.length() > 4 ) { cleanVersion = cleanVersion.substring( 0, 4 ); } try { Float.parseFloat( cleanVersion ); } catch( NumberFormatException e ) { return false; } float extractedVersion = Float.parseFloat( cleanVersion ); if( !cleanVersion.startsWith( "0" ) ) { extractedVersion *= 100; } return ( extractedVersion >= minimumVersion ); } private  Utils(); }
Utils { public static boolean meetsMinimumVersion( String version, float minimumVersion ) { if( "Unknown".equals( version ) || version.matches( "\\b[0-9a-f]{5,40}\\b" ) ) { return false; } String cleanVersion = version; if( cleanVersion.startsWith( "v" ) ) { cleanVersion = cleanVersion.substring( 1 ); } if( cleanVersion.contains( "-" ) ) { cleanVersion = cleanVersion.substring( 0, cleanVersion.indexOf( '-' ) ); } if( cleanVersion.length() > 4 ) { cleanVersion = cleanVersion.substring( 0, 4 ); } try { Float.parseFloat( cleanVersion ); } catch( NumberFormatException e ) { return false; } float extractedVersion = Float.parseFloat( cleanVersion ); if( !cleanVersion.startsWith( "0" ) ) { extractedVersion *= 100; } return ( extractedVersion >= minimumVersion ); } private  Utils(); static Point getDisplaySize( Context context ); static boolean isOrientationPortrait( Context context ); static void showErrorDialog( Context context, String errorString ); static int convertDpToPixel( Context ctx, int dp ); static String formatMillis( int millis ); static long getDuration( String videoUrl ); static boolean meetsMinimumVersion( String version, float minimumVersion ); }
Utils { public static boolean meetsMinimumVersion( String version, float minimumVersion ) { if( "Unknown".equals( version ) || version.matches( "\\b[0-9a-f]{5,40}\\b" ) ) { return false; } String cleanVersion = version; if( cleanVersion.startsWith( "v" ) ) { cleanVersion = cleanVersion.substring( 1 ); } if( cleanVersion.contains( "-" ) ) { cleanVersion = cleanVersion.substring( 0, cleanVersion.indexOf( '-' ) ); } if( cleanVersion.length() > 4 ) { cleanVersion = cleanVersion.substring( 0, 4 ); } try { Float.parseFloat( cleanVersion ); } catch( NumberFormatException e ) { return false; } float extractedVersion = Float.parseFloat( cleanVersion ); if( !cleanVersion.startsWith( "0" ) ) { extractedVersion *= 100; } return ( extractedVersion >= minimumVersion ); } private  Utils(); static Point getDisplaySize( Context context ); static boolean isOrientationPortrait( Context context ); static void showErrorDialog( Context context, String errorString ); static int convertDpToPixel( Context ctx, int dp ); static String formatMillis( int millis ); static long getDuration( String videoUrl ); static boolean meetsMinimumVersion( String version, float minimumVersion );  }