Java Code Examples for org.videolan.libvlc.util.AndroidUtil#isFroyoOrLater()

The following examples show how to use org.videolan.libvlc.util.AndroidUtil#isFroyoOrLater() . 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: MainActivity.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
/** Create menu from XML
 */
@TargetApi(Build.VERSION_CODES.FROYO)
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    mMenu = menu;
    /* Note: on Android 3.0+ with an action bar this method
     * is called while the view is created. This can happen
     * any time after onCreate.
     */
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.media_library, menu);

    if (AndroidUtil.isFroyoOrLater()) {
        SearchManager searchManager =
                (SearchManager) VLCApplication.getAppContext().getSystemService(Context.SEARCH_SERVICE);
        mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.ml_menu_search));
        mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        mSearchView.setQueryHint(getString(R.string.search_hint));
        SearchSuggestionsAdapter searchSuggestionsAdapter = new SearchSuggestionsAdapter(this, null);
        searchSuggestionsAdapter.setFilterQueryProvider(this);
        mSearchView.setSuggestionsAdapter(searchSuggestionsAdapter);
    } else
        menu.findItem(R.id.ml_menu_search).setVisible(false);
    return super.onCreateOptionsMenu(menu);
}
 
Example 2
Source File: AudioUtil.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
@SuppressLint("NewApi")
public static void prepareCacheFolder(Context context) {
    try {
        if (AndroidUtil.isFroyoOrLater() && AndroidDevices.hasExternalStorage() && context.getExternalCacheDir() != null)
            CACHE_DIR = context.getExternalCacheDir().getPath();
        else
            CACHE_DIR = AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY + "/Android/data/" + BuildConfig.APPLICATION_ID + "/cache";
    } catch (Exception e) { // catch NPE thrown by getExternalCacheDir()
        CACHE_DIR = AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY + "/Android/data/" + BuildConfig.APPLICATION_ID + "/cache";
    }
    ART_DIR = CACHE_DIR + "/art/";
    COVER_DIR = CACHE_DIR + "/covers/";
    PLAYLIST_DIR = CACHE_DIR + "/playlists/";

    for(String path : Arrays.asList(ART_DIR, COVER_DIR)) {
        File file = new File(path);
        if (!file.exists())
            file.mkdirs();
    }
}
 
Example 3
Source File: VideoPlayerActivity.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
@TargetApi(android.os.Build.VERSION_CODES.FROYO)
private void initBrightnessTouch() {
    float brightnesstemp = 0.6f;
    // Initialize the layoutParams screen brightness
    try {
        if (AndroidUtil.isFroyoOrLater() &&
                Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
            Settings.System.putInt(getContentResolver(),
                    Settings.System.SCREEN_BRIGHTNESS_MODE,
                    Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
            mRestoreAutoBrightness = android.provider.Settings.System.getInt(getContentResolver(),
                    android.provider.Settings.System.SCREEN_BRIGHTNESS) / 255.0f;
        } else {
            brightnesstemp = android.provider.Settings.System.getInt(getContentResolver(),
                android.provider.Settings.System.SCREEN_BRIGHTNESS) / 255.0f;
        }
    } catch (SettingNotFoundException e) {
        e.printStackTrace();
    }
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.screenBrightness = brightnesstemp;
    getWindow().setAttributes(lp);
    mIsFirstBrightnessGesture = false;
}
 
Example 4
Source File: PlaybackService.java    From VCL-Android with Apache License 2.0 4 votes vote down vote up
private static boolean readPhoneState() {
    return !AndroidUtil.isFroyoOrLater();
}
 
Example 5
Source File: PlaybackService.java    From VCL-Android with Apache License 2.0 4 votes vote down vote up
private void changeAudioFocus(boolean acquire) {
    if (AndroidUtil.isFroyoOrLater())
        changeAudioFocusFroyoOrLater(acquire);
}