diff options
Diffstat (limited to 'XeroxPrintServiceRecommendationPlugin/app/src')
22 files changed, 753 insertions, 0 deletions
diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/androidTest/java/com/xerox/printservicerecommendationplugin/ApplicationTest.java b/XeroxPrintServiceRecommendationPlugin/app/src/androidTest/java/com/xerox/printservicerecommendationplugin/ApplicationTest.java new file mode 100755 index 0000000..30c969b --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/androidTest/java/com/xerox/printservicerecommendationplugin/ApplicationTest.java @@ -0,0 +1,29 @@ +/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.xerox.printservicerecommendationplugin;
+
+import android.app.Application;
+import android.test.ApplicationTestCase;
+
+/**
+ * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
+ */
+public class ApplicationTest extends ApplicationTestCase<Application> {
+ public ApplicationTest() {
+ super(Application.class);
+
+ }
+}
\ No newline at end of file diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/AndroidManifest.xml b/XeroxPrintServiceRecommendationPlugin/app/src/main/AndroidManifest.xml new file mode 100755 index 0000000..c965bcb --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.xerox.printservicerecommendationplugin" >
+
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <application
+ android:allowBackup="true"
+ android:icon="@mipmap/ic_launcher"
+ android:label="@string/app_name"
+ android:supportsRtl="true"
+ android:theme="@style/AppTheme" >
+ <activity android:name=".RecommendationPluginInitActivity" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
\ No newline at end of file diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/MDnsUtils.java b/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/MDnsUtils.java new file mode 100755 index 0000000..a6b490e --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/MDnsUtils.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.xerox.printservicerecommendationplugin; + +import android.net.nsd.NsdServiceInfo; +import android.text.TextUtils; + +import java.nio.charset.StandardCharsets; +import java.util.Locale; +import java.util.Map; + +public class MDnsUtils { + public static final String ATTRIBUTE__TY = "ty"; + public static final String ATTRIBUTE__PRODUCT = "product"; + public static final String ATTRIBUTE__USB_MFG = "usb_MFG"; + public static final String ATTRIBUTE__USB_MDL = "usb_MDL"; + public static final String ATTRIBUTE__MFG = "mfg"; + public static final String EXCLUDE_FUJI = "fuji"; + public static final String PDL_ATTRIBUTE = "pdl"; + + public static boolean isVendorPrinter(NsdServiceInfo networkDevice, String[] vendorValues) { + + Map<String, byte[]> attributes = networkDevice.getAttributes(); + String product = getString(attributes.get(ATTRIBUTE__PRODUCT)); + String ty = getString(attributes.get(ATTRIBUTE__TY)); + String usbMfg = getString(attributes.get(ATTRIBUTE__USB_MFG)); + String usbMdl = getString(attributes.get(ATTRIBUTE__USB_MDL)); + String mfg = getString(attributes.get(ATTRIBUTE__MFG)); + return containsVendor(product, vendorValues) || containsVendor(ty, vendorValues) || containsVendor(usbMfg, vendorValues) || containsVendor(mfg, vendorValues) && !(containsString(ty, EXCLUDE_FUJI) || containsString(product, EXCLUDE_FUJI) || containsString(usbMdl, EXCLUDE_FUJI)); + + } + + public static String getVendor(NsdServiceInfo networkDevice) { + String vendor; + + Map<String, byte[]> attributes = networkDevice.getAttributes(); + vendor = getString(attributes.get(ATTRIBUTE__MFG)); + if (!TextUtils.isEmpty(vendor)) return vendor; + vendor = getString(attributes.get(ATTRIBUTE__USB_MFG)); + if (!TextUtils.isEmpty(vendor)) return vendor; + + return null; + } + + public static boolean checkPDLSupport(NsdServiceInfo networkDevice, String[] pdlFormats) { + if (pdlFormats == null) return false; + + String pdls = MDnsUtils.getString(networkDevice.getAttributes().get(PDL_ATTRIBUTE)); + if (pdls != null) { + for (String pdl : pdlFormats) { + if (pdls.contains(pdl)) { + return true; + } + } + } + return false; + } + + private static boolean containsVendor(String container, String[] vendorValues) { + if ((container == null) || (vendorValues == null)) return false; + for (String value : vendorValues) { + if (containsString(container, value) + || containsString(container.toLowerCase(Locale.US), value.toLowerCase(Locale.US)) + || containsString(container.toUpperCase(Locale.US), value.toUpperCase(Locale.US))) + return true; + } + return false; + } + + private static String getString(byte[] value) { + if (value != null) return new String(value, StandardCharsets.UTF_8); + return null; + } + + private static boolean containsString(String container, String contained) { + return (container != null) && (contained != null) && (container.equalsIgnoreCase(contained) || container.contains(contained + " ")); + } +}
\ No newline at end of file diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/PrintServicePlugin.java b/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/PrintServicePlugin.java new file mode 100755 index 0000000..31a6a78 --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/PrintServicePlugin.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.xerox.printservicerecommendationplugin; + +import android.support.annotation.IntRange; +import android.support.annotation.NonNull; +import android.support.annotation.StringRes; + +/** + * Interface to be implemented by each print service plugin. + * <p/> + * A print service plugin is a minimal version of a real {@link android.printservice.PrintService + * print service}. You cannot print using the plugin. The only functionality in the plugin is to + * report the number of printers that the real service would discover. + */ +public interface PrintServicePlugin { + /** + * Call back used by the print service plugins. + */ + interface PrinterDiscoveryCallback { + /** + * Announce that something changed and the UI for this plugin should be updated. + * + * @param numDiscoveredPrinters The number of printers discovered. + */ + void onChanged(@IntRange(from = 0) int numDiscoveredPrinters); + } + /** + * Get the name (a string reference) of the {@link android.printservice.PrintService print + * service} with the {@link #getPackageName specified package name}. This is read once, hence + * returning different data at different times is not allowed. + * + * @return The name of the print service as a string reference. The localization is handled + * outside of the plugin. + */ + @StringRes int getName(); + /** + * The package name of the full print service. + * + * @return The package name + */ + @NonNull CharSequence getPackageName(); + /** + * Start the discovery plugin. + * + * @param callback Callbacks used by this plugin. + * + * @throws Exception If anything went wrong when starting the plugin + */ + void start(@NonNull PrinterDiscoveryCallback callback) throws Exception; + /** + * Stop the plugin. This can only return once the plugin is completely finished and cleaned up. + * + * @throws Exception If anything went wrong while stopping plugin + */ + void stop() throws Exception; +} diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/PrinterHashMap.java b/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/PrinterHashMap.java new file mode 100755 index 0000000..3b94d47 --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/PrinterHashMap.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.xerox.printservicerecommendationplugin; + +import android.net.nsd.NsdServiceInfo; + +import java.util.HashMap; + +public final class PrinterHashMap extends HashMap<String, NsdServiceInfo> { + public static String getKey(NsdServiceInfo serviceInfo) { + return serviceInfo.getServiceName(); + } + + public NsdServiceInfo addPrinter(NsdServiceInfo device) { + return put(getKey(device), device); + } + + public NsdServiceInfo removePrinter(NsdServiceInfo device) { + return remove(getKey(device)); + } +} diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/RecommendationPluginInitActivity.java b/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/RecommendationPluginInitActivity.java new file mode 100755 index 0000000..c042a71 --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/RecommendationPluginInitActivity.java @@ -0,0 +1,68 @@ +/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.xerox.printservicerecommendationplugin;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.TextView;
+
+public class RecommendationPluginInitActivity extends Activity implements PrintServicePlugin.PrinterDiscoveryCallback{
+
+ XeroxPrintServiceRecommendationPlugin mXeroxRecommendation;
+ String TAG = RecommendationPluginInitActivity.class.getSimpleName();
+ TextView tvCount;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_xerox_discovery);
+ tvCount = (TextView) findViewById(R.id.printer_count);
+ mXeroxRecommendation = new XeroxPrintServiceRecommendationPlugin(this);
+ }
+
+ @Override
+ public void onPause(){
+ super.onPause();
+ try {
+ mXeroxRecommendation.stop();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onResume(){
+ super.onResume();
+ try {
+ mXeroxRecommendation.start(RecommendationPluginInitActivity.this);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onChanged(final int numDiscoveredPrinters) {
+ Log.d(TAG,"xerox printer count:"+numDiscoveredPrinters);
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ tvCount.setText(String.valueOf(numDiscoveredPrinters));
+ }
+ });
+
+ }
+}
diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/ServiceResolver.java b/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/ServiceResolver.java new file mode 100755 index 0000000..922ee73 --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/ServiceResolver.java @@ -0,0 +1,195 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.xerox.printservicerecommendationplugin; + +import android.content.Context; +import android.net.nsd.NsdManager; +import android.net.nsd.NsdServiceInfo; +import android.text.TextUtils; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +public class ServiceResolver { + + private final NsdManager mNSDManager; + private final String[] mServiceType; + private final Observer mObserver; + private final VendorInfo mVendorInfo; + private final String[] mPDLs; + private final PrinterHashMap mPrinterHashMap = new PrinterHashMap(); + private final List<NsdManager.DiscoveryListener> mListeners = new ArrayList<>(); + + public interface Observer { + void dataSetChanged(); + } + + public ServiceResolver(Context context, Observer observer, VendorInfo vendorInfo, String[] serviceTypes, String[] pdls) { + mObserver = observer; + mServiceType = serviceTypes; + mNSDManager = (NsdManager) context.getSystemService(Context.NSD_SERVICE); + mVendorInfo = vendorInfo; + mPDLs = pdls; + } + + public void start() { + stop(); + for (final String service : mServiceType) { + NsdManager.DiscoveryListener listener = new NsdManager.DiscoveryListener() { + @Override + public void onStartDiscoveryFailed(String s, int i) { + + } + + @Override + public void onStopDiscoveryFailed(String s, int i) { + + } + + @Override + public void onDiscoveryStarted(String s) { + + } + + @Override + public void onDiscoveryStopped(String s) { + + } + + @Override + public void onServiceFound(NsdServiceInfo nsdServiceInfo) { + queueRequest(nsdServiceInfo); + } + + @Override + public void onServiceLost(NsdServiceInfo nsdServiceInfo) { + removeRequest(nsdServiceInfo); + printerRemoved(nsdServiceInfo); + } + }; + mNSDManager.discoverServices(service, NsdManager.PROTOCOL_DNS_SD, listener); + mListeners.add(listener); + } + } + + public void stop() { + for (NsdManager.DiscoveryListener listener : mListeners) { + mNSDManager.stopServiceDiscovery(listener); + } + mListeners.clear(); + clearRequests(); + } + + //Resolving nsd services + private final LinkedList<NsdServiceInfo> mQueue = new LinkedList<>(); + private final Object mLock = new Object(); + private NsdServiceInfo mCurrentRequest = null; + + private void queueRequest(NsdServiceInfo serviceInfo) { + synchronized (mLock) { + if (mQueue.contains(serviceInfo)) return; + mQueue.add(serviceInfo); + makeNextRequest(); + } + } + + private void removeRequest(NsdServiceInfo serviceInfo) { + synchronized (mLock) { + mQueue.remove(serviceInfo); + if ((mCurrentRequest != null) && serviceInfo.equals(mCurrentRequest)) + mCurrentRequest = null; + } + } + + private void clearRequests() { + synchronized (mLock) { + mQueue.clear(); + } + } + + private void makeNextRequest() { + synchronized (mLock) { + if (mCurrentRequest != null) return; + if (mQueue.isEmpty()) return; + mCurrentRequest = mQueue.removeFirst(); + mNSDManager.resolveService(mCurrentRequest, new NsdManager.ResolveListener() { + @Override + public void onResolveFailed(NsdServiceInfo nsdServiceInfo, int i) { + synchronized (mLock) { + if (mCurrentRequest != null) mQueue.add(mCurrentRequest); + makeNextRequest(); + } + } + + @Override + public void onServiceResolved(NsdServiceInfo nsdServiceInfo) { + synchronized (mLock) { + if (mCurrentRequest != null) { + printerFound(nsdServiceInfo); + mCurrentRequest = null; + } + makeNextRequest(); + } + } + }); + + } + } + + private void printerFound(NsdServiceInfo nsdServiceInfo) { + if (nsdServiceInfo == null) return; + if (TextUtils.isEmpty(PrinterHashMap.getKey(nsdServiceInfo))) return; + String vendor = MDnsUtils.getVendor(nsdServiceInfo); + if (vendor == null) vendor = ""; + + for (String vendorValues : mVendorInfo.mDNSValues) { + if (vendor.equalsIgnoreCase(vendorValues)) { + vendor = mVendorInfo.mVendorID; + break; + } + } + + if ((vendor != mVendorInfo.mVendorID) && + MDnsUtils.isVendorPrinter(nsdServiceInfo, mVendorInfo.mDNSValues)) { + vendor = mVendorInfo.mVendorID; + } + + if (!(vendor == mVendorInfo.mVendorID)) { + return; + } + + if (!MDnsUtils.checkPDLSupport(nsdServiceInfo, mPDLs)) { + return; + } + + if ((mPrinterHashMap.addPrinter(nsdServiceInfo) == null)) { + mObserver.dataSetChanged(); + } + + } + + private void printerRemoved(NsdServiceInfo nsdServiceInfo) { + if ((mPrinterHashMap.removePrinter(nsdServiceInfo) != null)) { + mObserver.dataSetChanged(); + } + } + + public int getCount() { + return mPrinterHashMap.size(); + } + +}
\ No newline at end of file diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/VendorInfo.java b/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/VendorInfo.java new file mode 100755 index 0000000..39523ae --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/VendorInfo.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.xerox.printservicerecommendationplugin; + +import android.content.res.Resources; + +import java.util.Arrays; + +public final class VendorInfo { + + public final String mPackageName; + public final String mVendorID; + public final String[] mDNSValues; + public final int mID; + + public VendorInfo(Resources resources, int vendor_info_id) { + mID = vendor_info_id; + String[] data = resources.getStringArray(vendor_info_id); + if ((data == null) || (data.length < 2)) { + data = new String[]{null, null}; + } + mPackageName = data[0]; + mVendorID = data[1]; + mDNSValues = (data.length > 2) ? Arrays.copyOfRange(data, 2, data.length) : new String[]{}; + } +} diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/XeroxPrintServiceRecommendationPlugin.java b/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/XeroxPrintServiceRecommendationPlugin.java new file mode 100755 index 0000000..9e42031 --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/java/com/xerox/printservicerecommendationplugin/XeroxPrintServiceRecommendationPlugin.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.xerox.printservicerecommendationplugin; + +import android.content.Context; +import android.net.nsd.NsdManager; +import android.support.annotation.NonNull; + +public class XeroxPrintServiceRecommendationPlugin implements PrintServicePlugin, ServiceResolver.Observer { + + protected final Object mLock = new Object(); + protected PrinterDiscoveryCallback mDiscoveryCallback = null; + protected final ServiceResolver mServiceResolver; + protected final NsdManager mNSDManager; + protected final VendorInfo mVendorInfo; + private final int mVendorStringID = R.string.plugin_vendor_xerox; + private final String PDL__PDF = "application/pdf"; + private final String[] mServices = new String[]{"_ipp._tcp"}; + + public XeroxPrintServiceRecommendationPlugin(Context context) { + mNSDManager = (NsdManager) context.getSystemService(Context.NSD_SERVICE); + mVendorInfo = new VendorInfo(context.getResources(), R.array.known_print_vendor_info_for_xerox); + mServiceResolver = new ServiceResolver(context, this, mVendorInfo, mServices, new String[]{PDL__PDF}); + } + + @Override + public int getName() { + return mVendorStringID; + } + + @NonNull + @Override + public CharSequence getPackageName() { + return mVendorInfo.mPackageName; + } + + @Override + public void start(@NonNull PrinterDiscoveryCallback callback) throws Exception { + synchronized (mLock) { + mDiscoveryCallback = callback; + mServiceResolver.start(); + } + } + + @Override + public void stop() throws Exception { + synchronized (mLock) { + mDiscoveryCallback = null; + mServiceResolver.stop(); + } + } + + @Override + public void dataSetChanged() { + synchronized (mLock) { + if (mDiscoveryCallback != null) mDiscoveryCallback.onChanged(getCount()); + } + } + + public int getCount() { + return mServiceResolver.getCount(); + } +} diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/res/layout/activity_xerox_discovery.xml b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/layout/activity_xerox_discovery.xml new file mode 100755 index 0000000..d438079 --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/layout/activity_xerox_discovery.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:orientation="horizontal"
+ tools:context=".RecommendationPluginInitActivity">
+
+ <TextView
+ android:text="@string/vendor"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+ <TextView
+ android:id="@+id/printer_count"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+</LinearLayout>
diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/res/mipmap-hdpi/ic_launcher.png b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differnew file mode 100755 index 0000000..cde69bc --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/res/mipmap-mdpi/ic_launcher.png b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differnew file mode 100755 index 0000000..c133a0c --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differnew file mode 100755 index 0000000..bfa42f0 --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differnew file mode 100755 index 0000000..324e72c --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differnew file mode 100755 index 0000000..aee44e1 --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values-w820dp/dimens.xml b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values-w820dp/dimens.xml new file mode 100755 index 0000000..62df187 --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ +<resources>
+ <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+ (such as screen margins) for screens with more than 820dp of available width. This
+ would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+ <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values/colors.xml b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values/colors.xml new file mode 100755 index 0000000..f4ae6a7 --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values/colors.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<resources>
+ <color name="colorPrimary">#3F51B5</color>
+ <color name="colorPrimaryDark">#303F9F</color>
+ <color name="colorAccent">#FF4081</color>
+</resources>
diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values/dimens.xml b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values/dimens.xml new file mode 100755 index 0000000..295b5a9 --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ +<resources>
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+</resources>
diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values/donottranslate.xml b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values/donottranslate.xml new file mode 100755 index 0000000..43dbb9d --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values/donottranslate.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> +<resources xmlns:tools="http://schemas.android.com/tools"> + <string-array name="known_print_vendor_info_for_xerox" translatable="false"> + <item>com.xerox.printservice</item> + <item>Xerox</item> + <item>Xerox</item> + </string-array> +</resources>
\ No newline at end of file diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values/strings.xml b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values/strings.xml new file mode 100755 index 0000000..d0dad8b --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values/strings.xml @@ -0,0 +1,6 @@ +<resources>
+ <string name="app_name">XeroxDiscovery</string>
+ <string name="vendor">Xerox :</string>
+ <string name="action_settings">Settings</string>
+ <string name="plugin_vendor_xerox">Xerox</string>
+</resources>
diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values/styles.xml b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values/styles.xml new file mode 100755 index 0000000..6f19b47 --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ +<resources>
+
+ <!-- Base application theme. -->
+ <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+ <!-- Customize your theme here. -->
+ <item name="colorPrimary">@color/colorPrimary</item>
+ <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+ <item name="colorAccent">@color/colorAccent</item>
+ </style>
+
+</resources>
diff --git a/XeroxPrintServiceRecommendationPlugin/app/src/test/java/com/xerox/androidndiscovery/ExampleUnitTest.java b/XeroxPrintServiceRecommendationPlugin/app/src/test/java/com/xerox/androidndiscovery/ExampleUnitTest.java new file mode 100755 index 0000000..6385208 --- /dev/null +++ b/XeroxPrintServiceRecommendationPlugin/app/src/test/java/com/xerox/androidndiscovery/ExampleUnitTest.java @@ -0,0 +1,15 @@ +package com.xerox.printservicerecommendationplugin;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * To work on unit tests, switch the Test Artifact in the Build Variants view.
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() throws Exception {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file |