aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip P. Moltmann <moltmann@google.com>2016-10-11 15:25:57 -0700
committerPhilip P. Moltmann <moltmann@google.com>2016-10-13 15:53:38 -0700
commit0dcca641aefb59e6e6aa1f9ae37c2972b6559fe8 (patch)
treee0d7a764bc75fc0ee4f1ba027b3eeb63ac732665
parent8752b6579fa2cc0659ed20b8e9e0ac606cdce2ed (diff)
downloadexperimental-0dcca641aefb59e6e6aa1f9ae37c2972b6559fe8.tar.gz
Support for selecting printers from info activity
Test: Selected printers via info activity and canceled activity. Checked if extra was there when called from settings. Change-Id: I5d60f4c0ecf2f1d16cca1b0371b037f7f3df5278
-rw-r--r--PrintService/AndroidManifest.xml3
-rw-r--r--PrintService/res/layout/activity_info.xml25
-rw-r--r--PrintService/res/values/strings.xml1
-rw-r--r--PrintService/src/foo/bar/printservice/InfoActivity.java19
4 files changed, 37 insertions, 11 deletions
diff --git a/PrintService/AndroidManifest.xml b/PrintService/AndroidManifest.xml
index 09b86fd..e1e45d1 100644
--- a/PrintService/AndroidManifest.xml
+++ b/PrintService/AndroidManifest.xml
@@ -1,8 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="foo.bar.printservice" >
- <uses-sdk android:minSdkVersion="19"
- android:targetSdkVersion="24" />
+ <uses-sdk android:minSdkVersion="19" />
<application
android:icon="@drawable/ic_launcher"
diff --git a/PrintService/res/layout/activity_info.xml b/PrintService/res/layout/activity_info.xml
index 70ef63e..2453a1b 100644
--- a/PrintService/res/layout/activity_info.xml
+++ b/PrintService/res/layout/activity_info.xml
@@ -17,14 +17,23 @@
*/
-->
-<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" >
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:gravity="center">
<TextView
- android:id="@+id/info"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- </TextView>
+ android:id="@+id/info"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="16dp" />
+
+ <Button
+ android:id="@+id/select_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/select_printer"
+ android:visibility="gone" />
</LinearLayout>
diff --git a/PrintService/res/values/strings.xml b/PrintService/res/values/strings.xml
index f30f58b..e623111 100644
--- a/PrintService/res/values/strings.xml
+++ b/PrintService/res/values/strings.xml
@@ -5,6 +5,7 @@
on print sends an email to svetoslavganov@google.com</string>
<string name="settings">This is an activitiy with some print service settings.</string>
<string name="info">More info about %1$s.</string>
+ <string name="select_printer">Select printer</string>
<string name="settings_activity_label">Settings activity</string>
<string name="add_pritners_activity_label">Add printers activity</string>
diff --git a/PrintService/src/foo/bar/printservice/InfoActivity.java b/PrintService/src/foo/bar/printservice/InfoActivity.java
index b07069b..e64b0c8 100644
--- a/PrintService/src/foo/bar/printservice/InfoActivity.java
+++ b/PrintService/src/foo/bar/printservice/InfoActivity.java
@@ -17,11 +17,15 @@
package foo.bar.printservice;
import android.app.Activity;
+import android.content.Intent;
import android.os.Bundle;
+import android.printservice.PrintService;
+import android.view.View;
+import android.widget.Button;
import android.widget.TextView;
/**
- * Dummy activity showing more information about a printer
+ * Dummy activity showing more information about a printer
*/
public class InfoActivity extends Activity {
/** Intent-extra-key used for the name of the printer */
@@ -36,5 +40,18 @@ public class InfoActivity extends Activity {
text.setText(getResources().getString(R.string.info,
getIntent().getStringExtra(PRINTER_NAME)));
+
+ if (getIntent().getBooleanExtra(PrintService.EXTRA_CAN_SELECT_PRINTER,
+ false)) {
+ Button selectButton = (Button) findViewById(R.id.select_button);
+
+ selectButton.setVisibility(View.VISIBLE);
+ selectButton.setOnClickListener(v -> {
+ setResult(Activity.RESULT_OK,
+ (new Intent()).putExtra(PrintService.EXTRA_SELECT_PRINTER, true));
+ finish();
+ }
+ );
+ }
}
}