Search in sources :

Example 6 with MainActivity

use of org.videolan.vlc.gui.MainActivity in project vlc-android by GeoffreyMetais.

the class VideoPlayerActivity method switchToAudioMode.

public void switchToAudioMode(boolean showUI) {
    if (mService == null)
        return;
    mSwitchingView = true;
    // Show the MainActivity if it is not in background.
    if (showUI) {
        Intent i = new Intent(this, VLCApplication.showTvUi() ? AudioPlayerActivity.class : MainActivity.class);
        startActivity(i);
    } else
        mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, true).apply();
    exitOK();
}
Also used : Intent(android.content.Intent) MainActivity(org.videolan.vlc.gui.MainActivity) AudioPlayerActivity(org.videolan.vlc.gui.tv.audioplayer.AudioPlayerActivity)

Example 7 with MainActivity

use of org.videolan.vlc.gui.MainActivity in project vlc-android by GeoffreyMetais.

the class BaseBrowserFragment method goBack.

public boolean goBack() {
    final FragmentActivity activity = getActivity();
    if (activity == null)
        return false;
    if (!mRoot) {
        final FragmentManager fm = activity.getSupportFragmentManager();
        final String tag = fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName();
        if (!activity.getSupportFragmentManager().popBackStackImmediate() && activity instanceof MainActivity)
            ((MainActivity) activity).getNavigator().showFragment(this instanceof NetworkBrowserFragment ? R.id.nav_network : R.id.nav_directories);
        final Fragment current = fm.findFragmentByTag(tag);
        final View view = current != null ? current.getView() : null;
        if (view != null)
            view.setVisibility(View.VISIBLE);
    }
    return !mRoot;
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) FragmentActivity(android.support.v4.app.FragmentActivity) MainActivity(org.videolan.vlc.gui.MainActivity) Fragment(android.support.v4.app.Fragment) View(android.view.View) ContextMenuRecyclerView(org.videolan.vlc.gui.view.ContextMenuRecyclerView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView)

Example 8 with MainActivity

use of org.videolan.vlc.gui.MainActivity in project vlc-android by GeoffreyMetais.

the class ExtensionsManager method updateAvailableExtensions.

private List<ExtensionListing> updateAvailableExtensions(Context context) {
    androidAutoInstalled = isAndroidAutoInstalled(context);
    PackageManager pm = context.getPackageManager();
    List<ResolveInfo> resolveInfos = pm.queryIntentServices(new Intent(ACTION_EXTENSION), PackageManager.GET_META_DATA);
    List<ExtensionListing> extensions = new ArrayList<>();
    for (ResolveInfo resolveInfo : resolveInfos) {
        ExtensionListing extension = new ExtensionListing();
        extension.componentName(new ComponentName(resolveInfo.serviceInfo.packageName, resolveInfo.serviceInfo.name));
        Bundle metaData = resolveInfo.serviceInfo.metaData;
        if (metaData != null) {
            extension.compatible(metaData.getInt(KEY_PROTOCOL_VERSION) == PROTOCOLE_VERSION);
            if (!extension.compatible())
                continue;
            String title = metaData.getString(KEY_LISTING_TITLE);
            extension.title(title != null ? title : resolveInfo.loadLabel(pm).toString());
            extension.description(metaData.getString(KEY_DESCRIPTION));
            String settingsActivity = metaData.getString(KEY_SETTINGS_ACTIVITY);
            if (!TextUtils.isEmpty(settingsActivity)) {
                extension.settingsActivity(ComponentName.unflattenFromString(resolveInfo.serviceInfo.packageName + "/" + settingsActivity));
            }
            extension.androidAutoEnabled(metaData.getBoolean(KEY_ANDROID_AUTO_ENABLED, false));
            extension.menuIcon(metaData.getInt(KEY_MENU_ICON, 0));
            extensions.add(extension);
        }
    }
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    deleteUnusedExtensionPreferences(extensions, settings);
    if (context instanceof MainActivity && ((MainActivity) context).getNavigator().currentIdIsExtension()) {
        if (previousExtensionIsEnabled(context)) {
            String lastExtensionTitle = settings.getString("current_extension_name", null);
            for (int i = 0; i < extensions.size(); ++i) {
                if (TextUtils.equals(extensions.get(i).title(), lastExtensionTitle)) {
                    ((MainActivity) context).getNavigator().setCurrentFragmentId(i);
                    settings.edit().putInt("fragment_id", i).apply();
                    break;
                }
            }
        } else {
            ((MainActivity) context).getNavigator().setCurrentFragmentId(-1);
            settings.edit().putInt("fragment_id", -1).apply();
        }
    }
    synchronized (mExtensions) {
        mExtensions.clear();
        mExtensions.addAll(extensions);
    }
    return extensions;
}
Also used : SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) Intent(android.content.Intent) MainActivity(org.videolan.vlc.gui.MainActivity) ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) ComponentName(android.content.ComponentName)

Aggregations

MainActivity (org.videolan.vlc.gui.MainActivity)8 Intent (android.content.Intent)4 SharedPreferences (android.content.SharedPreferences)4 ArrayList (java.util.ArrayList)4 Activity (android.app.Activity)2 ComponentName (android.content.ComponentName)2 PackageManager (android.content.pm.PackageManager)2 ResolveInfo (android.content.pm.ResolveInfo)2 Bundle (android.os.Bundle)2 Fragment (android.support.v4.app.Fragment)2 FragmentActivity (android.support.v4.app.FragmentActivity)2 FragmentManager (android.support.v4.app.FragmentManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 TextView (android.widget.TextView)2 MediaWrapper (org.videolan.medialibrary.media.MediaWrapper)2 SecondaryActivity (org.videolan.vlc.gui.SecondaryActivity)2 AudioPlayerActivity (org.videolan.vlc.gui.tv.audioplayer.AudioPlayerActivity)2 ContextMenuRecyclerView (org.videolan.vlc.gui.view.ContextMenuRecyclerView)2 MediaGroup (org.videolan.vlc.media.MediaGroup)2