Commit dff91820 authored by Geoffrey Métais's avatar Geoffrey Métais

Rename plugin to extensions everywhere

parent 140709c9
......@@ -21,7 +21,7 @@
* ***************************************************************************
*/
package org.videolan.vlc.plugin.api;
package org.videolan.vlc.extensions.api;
import android.app.Application;
import android.test.ApplicationTestCase;
......
package org.videolan.vlc.plugin.api;
package org.videolan.vlc.extensions.api;
import org.videolan.vlc.plugin.api.VLCExtensionItem;
import org.videolan.vlc.extensions.api.VLCExtensionItem;
import android.net.Uri;
interface IExtensionHost {
......
package org.videolan.vlc.plugin.api;
package org.videolan.vlc.extensions.api;
import org.videolan.vlc.plugin.api.IExtensionHost;
import org.videolan.vlc.plugin.api.VLCExtensionItem;
import org.videolan.vlc.extensions.api.IExtensionHost;
import org.videolan.vlc.extensions.api.VLCExtensionItem;
interface IExtensionService {
// Protocol version 1
......
......@@ -21,7 +21,7 @@
* ***************************************************************************
*/
package org.videolan.vlc.plugin.api;
package org.videolan.vlc.extensions.api;
import android.os.Parcel;
import android.os.Parcelable;
......
package org.videolan.vlc.plugin.api;
package org.videolan.vlc.extensions.api;
import android.app.Service;
import android.content.ComponentName;
......
......@@ -21,7 +21,7 @@
* ***************************************************************************
*/
package org.videolan.vlc.plugin.api;
package org.videolan.vlc.extensions.api;
import org.junit.Test;
......
......@@ -429,7 +429,7 @@
</intent-filter>
</activity>
<service android:name=".plugin.PluginService" />
<service android:name=".extensions.ExtensionManagerService" />
<service android:name=".PlaybackService" />
<receiver
android:name=".widget.VLCAppWidgetProviderWhite"
......
......@@ -7,7 +7,7 @@
type="org.videolan.vlc.gui.browser.ExtensionAdapter.ViewHolder"/>
<variable
name="item"
type="org.videolan.vlc.plugin.api.VLCExtensionItem"/>
type="org.videolan.vlc.extensions.api.VLCExtensionItem"/>
<variable
name="image"
type="android.graphics.drawable.BitmapDrawable"/>
......
......@@ -21,7 +21,7 @@
* ***************************************************************************
*/
package org.videolan.vlc.plugin;
package org.videolan.vlc.extensions;
import android.content.ComponentName;
import android.os.Parcel;
......@@ -38,7 +38,7 @@ public class ExtensionListing implements Parcelable {
private String mDescription;
private ComponentName mSettingsActivity;
private PluginService.Connection connection;
private ExtensionManagerService.Connection connection;
public ExtensionListing(){}
......@@ -63,7 +63,7 @@ public class ExtensionListing implements Parcelable {
}
/**
* Returns the version of the {@link org.videolan.vlc.plugin.api.VLCExtensionService}
* Returns the version of the {@link org.videolan.vlc.extensions.api.VLCExtensionService}
* protocol used by the extension.
*/
public int protocolVersion() {
......@@ -71,7 +71,7 @@ public class ExtensionListing implements Parcelable {
}
/**
* Sets the version of the {@link org.videolan.vlc.plugin.api.VLCExtensionService}
* Sets the version of the {@link org.videolan.vlc.extensions.api.VLCExtensionService}
* protocol used by the extension.
*/
public ExtensionListing protocolVersion(int protocolVersion) {
......@@ -81,7 +81,7 @@ public class ExtensionListing implements Parcelable {
/**
* Returns whether this extension is compatible to the host application; that is whether
* the version of the {@link org.videolan.vlc.plugin.api.VLCExtensionService}
* the version of the {@link org.videolan.vlc.extensions.api.VLCExtensionService}
* protocol used by the extension matches what is used by the host application.
*/
public boolean compatible() {
......@@ -143,11 +143,11 @@ public class ExtensionListing implements Parcelable {
return this;
}
public PluginService.Connection getConnection() {
public ExtensionManagerService.Connection getConnection() {
return connection;
}
public void setConnection(PluginService.Connection connection) {
public void setConnection(ExtensionManagerService.Connection connection) {
this.connection = connection;
}
......
......@@ -21,7 +21,7 @@
* ***************************************************************************
*/
package org.videolan.vlc.plugin;
package org.videolan.vlc.extensions;
import android.app.Service;
import android.content.ComponentName;
......@@ -43,16 +43,21 @@ import android.util.Log;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.plugin.api.IExtensionHost;
import org.videolan.vlc.plugin.api.IExtensionService;
import org.videolan.vlc.plugin.api.VLCExtensionItem;
import org.videolan.vlc.extensions.api.IExtensionHost;
import org.videolan.vlc.extensions.api.IExtensionService;
import org.videolan.vlc.extensions.api.VLCExtensionItem;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
public class PluginService extends Service {
public class ExtensionManagerService extends Service {
private static final String TAG = "VLC/PluginService";
private static final String TAG = "VLC/ExtensionManagerService";
private static final String KEY_PROTOCOL_VERSION = "protocolVersion";
private static final String KEY_LISTING_TITLE = "title";
private static final String KEY_DESCRIPTION = "description";
private static final String KEY_SETTINGS_ACTIVITY = "settingsActivity";
public static final String ACTION_EXTENSION = "org.videolan.vlc.Extension";
public static final int PROTOCOLE_VERSION = 1;
......@@ -60,6 +65,9 @@ public class PluginService extends Service {
private final IBinder mBinder = new LocalBinder();
private ExtensionManagerActivity mExtensionManagerActivity;
private List<ExtensionListing> mExtensions = new ArrayList<>();
int mCurrentIndex = -1;
public interface ExtensionManagerActivity {
void displayExtensionItems(String title, List<VLCExtensionItem> items, boolean showParams);
}
......@@ -71,7 +79,6 @@ public class PluginService extends Service {
@Override
public void onCreate() {
super.onCreate();
getAvailableExtensions();
}
@Override
......@@ -92,42 +99,45 @@ public class PluginService extends Service {
}
public class LocalBinder extends Binder {
public PluginService getService() {
return PluginService.this;
public ExtensionManagerService getService() {
return ExtensionManagerService.this;
}
}
public List<ExtensionListing> getAvailableExtensions() {
public List<ExtensionListing> updateAvailableExtensions() {
PackageManager pm = VLCApplication.getAppContext().getPackageManager();
List<ResolveInfo> resolveInfos = pm.queryIntentServices(
new Intent(ACTION_EXTENSION), PackageManager.GET_META_DATA);
mPlugins.clear();
ArrayList<ExtensionListing> extensions = new ArrayList<>();
for (ResolveInfo resolveInfo : resolveInfos) {
ExtensionListing info = new ExtensionListing();
info.componentName(new ComponentName(resolveInfo.serviceInfo.packageName,
resolveInfo.serviceInfo.name));
info.title(resolveInfo.loadLabel(pm).toString());
Bundle metaData = resolveInfo.serviceInfo.metaData;
if (metaData != null) {
info.compatible(metaData.getInt("protocolVersion") == PROTOCOLE_VERSION);
info.compatible(metaData.getInt(KEY_PROTOCOL_VERSION) == PROTOCOLE_VERSION);
if (!info.compatible())
continue;
info.description(metaData.getString("description"));
String settingsActivity = metaData.getString("settingsActivity");
String title = metaData.getString(KEY_LISTING_TITLE);
info.title(title != null ? title : resolveInfo.loadLabel(pm).toString());
info.description(metaData.getString(KEY_DESCRIPTION));
String settingsActivity = metaData.getString(KEY_SETTINGS_ACTIVITY);
if (!TextUtils.isEmpty(settingsActivity)) {
info.settingsActivity(ComponentName.unflattenFromString(
resolveInfo.serviceInfo.packageName + "/" + settingsActivity));
}
mPlugins.add(info);
extensions.add(info);
}
}
return mPlugins;
synchronized (mExtensions) {
mExtensions.clear();
mExtensions.addAll(extensions);
}
return extensions;
}
private List<ExtensionListing> mPlugins = new LinkedList<>();
int mCurrentIndex = -1;
public void openExtension(int index) {
if (index == mCurrentIndex)
browse(0, null);
......@@ -136,12 +146,12 @@ public class PluginService extends Service {
}
public ExtensionListing getCurrentPlugin() {
return mPlugins.get(mCurrentIndex);
public ExtensionListing getCurrentExtension() {
return mExtensions.get(mCurrentIndex);
}
public void connectService(final int index) {
ExtensionListing info = mPlugins.get(index);
ExtensionListing info = mExtensions.get(index);
if (mCurrentIndex != -1) {
disconnect();
......@@ -187,10 +197,10 @@ public class PluginService extends Service {
public void refresh() {
try {
ExtensionListing plugin = mPlugins.get(mCurrentIndex);
if (plugin == null)
ExtensionListing extension = mExtensions.get(mCurrentIndex);
if (extension == null)
return;
IExtensionService service = plugin.getConnection().binder;
IExtensionService service = extension.getConnection().binder;
if (service == null)
return;
service.refresh();
......@@ -199,10 +209,10 @@ public class PluginService extends Service {
public void browse(int intId, String stringId) {
try {
ExtensionListing plugin = mPlugins.get(mCurrentIndex);
if (plugin == null)
ExtensionListing extension = mExtensions.get(mCurrentIndex);
if (extension == null)
return;
IExtensionService service = plugin.getConnection().binder;
IExtensionService service = extension.getConnection().binder;
if (service == null)
return;
service.browse(intId, stringId);
......@@ -212,14 +222,14 @@ public class PluginService extends Service {
public void disconnect() {
if (mCurrentIndex == -1)
return;
ExtensionListing plugin = getCurrentPlugin();
Connection conn = plugin.getConnection();
ExtensionListing extension = getCurrentExtension();
Connection conn = extension.getConnection();
if (conn != null) {
try {
unbindService(conn.serviceConnection);
} catch (Exception e) {} // In case of extension service crashed
}
plugin.setConnection(null);
extension.setConnection(null);
}
private IExtensionHost makeHostInterface() {
......@@ -243,7 +253,7 @@ public class PluginService extends Service {
mHandler.post(new Runnable() {
@Override
public void run() {
MediaUtils.openMediaNoUi(PluginService.this, media);
MediaUtils.openMediaNoUi(ExtensionManagerService.this, media);
}
});
}
......
package org.videolan.vlc.plugin;
package org.videolan.vlc.extensions;
import android.net.Uri;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.plugin.api.VLCExtensionItem;
import org.videolan.vlc.extensions.api.VLCExtensionItem;
public class Utils {
......
......@@ -82,9 +82,9 @@ import org.videolan.vlc.interfaces.ISortable;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaLibrary;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.plugin.ExtensionListing;
import org.videolan.vlc.plugin.PluginService;
import org.videolan.vlc.plugin.api.VLCExtensionItem;
import org.videolan.vlc.extensions.ExtensionListing;
import org.videolan.vlc.extensions.ExtensionManagerService;
import org.videolan.vlc.extensions.api.VLCExtensionItem;
import org.videolan.vlc.util.Permissions;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
......@@ -93,7 +93,7 @@ import org.videolan.vlc.util.WeakHandler;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AudioPlayerContainerActivity implements SearchSuggestionsAdapter.SuggestionDisplay, FilterQueryProvider, NavigationView.OnNavigationItemSelectedListener, PluginService.ExtensionManagerActivity {
public class MainActivity extends AudioPlayerContainerActivity implements SearchSuggestionsAdapter.SuggestionDisplay, FilterQueryProvider, NavigationView.OnNavigationItemSelectedListener, ExtensionManagerService.ExtensionManagerActivity {
public final static String TAG = "VLC/MainActivity";
private static final String PREF_FIRST_RUN = "first_run";
......@@ -129,7 +129,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements Search
private SearchView mSearchView;
// Plugins management
private PluginService mPluginService;
private ExtensionManagerService mExtensionManagerService;
private static final int PLUGIN_NAVIGATION_GROUP = 2;
@Override
......@@ -223,7 +223,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements Search
// Bind service which discoverves au connects toplugins
if (!bindService(new Intent(MainActivity.this,
PluginService.class), mPluginServiceConnection, Context.BIND_AUTO_CREATE))
ExtensionManagerService.class), mPluginServiceConnection, Context.BIND_AUTO_CREATE))
mPluginServiceConnection = null;
}
......@@ -284,11 +284,11 @@ public class MainActivity extends AudioPlayerContainerActivity implements Search
}
private void loadPlugins() {
List<ExtensionListing> plugins = mPluginService.getAvailableExtensions();
List<ExtensionListing> plugins = mExtensionManagerService.updateAvailableExtensions();
if (plugins.isEmpty()) {
unbindService(mPluginServiceConnection);
mPluginServiceConnection = null;
mPluginService.stopSelf();
mExtensionManagerService.stopSelf();
return;
}
PackageManager pm = getPackageManager();
......@@ -310,8 +310,8 @@ public class MainActivity extends AudioPlayerContainerActivity implements Search
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mPluginService = ((PluginService.LocalBinder)service).getService();
mPluginService.setExtensionManagerActivity(MainActivity.this);
mExtensionManagerService = ((ExtensionManagerService.LocalBinder)service).getService();
mExtensionManagerService.setExtensionManagerActivity(MainActivity.this);
loadPlugins();
}
......@@ -448,7 +448,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements Search
args.putBoolean(ExtensionBrowser.KEY_SHOW_FAB, showParams);
args.putString(ExtensionBrowser.KEY_TITLE, title);
fragment.setArguments(args);
fragment.setPluginService(mPluginService);
fragment.setExtensionService(mExtensionManagerService);
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
......@@ -862,11 +862,11 @@ public class MainActivity extends AudioPlayerContainerActivity implements Search
return false;
if (item.getGroupId() == PLUGIN_NAVIGATION_GROUP) {
mPluginService.openExtension(id);
mExtensionManagerService.openExtension(id);
mCurrentFragmentId = id;
} else {
if (mPluginServiceConnection != null)
mPluginService.disconnect();
mExtensionManagerService.disconnect();
if(current == null || (item != null && mCurrentFragmentId == id)) { /* Already selected */
if (mFocusedPrior != 0)
......
......@@ -18,10 +18,10 @@ import org.videolan.vlc.BR;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.databinding.ExtensionItemViewBinding;
import org.videolan.vlc.extensions.api.VLCExtensionItem;
import org.videolan.vlc.gui.helpers.AsyncImageLoader;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.plugin.api.VLCExtensionItem;
import java.io.BufferedInputStream;
import java.io.IOException;
......
......@@ -21,10 +21,10 @@ import org.videolan.vlc.gui.view.DividerItemDecoration;
import org.videolan.vlc.gui.view.SwipeRefreshLayout;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.plugin.ExtensionListing;
import org.videolan.vlc.plugin.PluginService;
import org.videolan.vlc.plugin.Utils;
import org.videolan.vlc.plugin.api.VLCExtensionItem;
import org.videolan.vlc.extensions.ExtensionListing;
import org.videolan.vlc.extensions.ExtensionManagerService;
import org.videolan.vlc.extensions.Utils;
import org.videolan.vlc.extensions.api.VLCExtensionItem;
import java.util.ArrayList;
......@@ -42,11 +42,11 @@ public class ExtensionBrowser extends Fragment implements View.OnClickListener,
protected TextView mEmptyView;
protected SwipeRefreshLayout mSwipeRefreshLayout;
PluginService mPluginService;
ExtensionManagerService mExtensionManagerService;
private boolean showSettings = false;
public void setPluginService(PluginService service) {
mPluginService = service;
public void setExtensionService(ExtensionManagerService service) {
mExtensionManagerService = service;
}
public ExtensionBrowser() {
......@@ -118,24 +118,24 @@ public class ExtensionBrowser extends Fragment implements View.OnClickListener,
}
public void browseItem(VLCExtensionItem item) {
mPluginService.browse(item.intId, item.stringId);
mExtensionManagerService.browse(item.intId, item.stringId);
}
@Override
public void onClick(View v) {
if (v.getId() == mAddDirectoryFAB.getId()){
ExtensionListing plugin = mPluginService.getCurrentPlugin();
if (plugin == null)
ExtensionListing extension = mExtensionManagerService.getCurrentExtension();
if (extension == null)
return;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setComponent(plugin.settingsActivity());
intent.setComponent(extension.settingsActivity());
startActivity(intent);
}
}
@Override
public void onRefresh() {
mPluginService.refresh();
mExtensionManagerService.refresh();
}
RecyclerView.OnScrollListener mScrollListener = new RecyclerView.OnScrollListener() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment