summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-03 21:03:28 +0000
committerlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-03 21:03:28 +0000
commit905b2785847d3dc97ca8da217066732b710d1a98 (patch)
tree02a114efc9f7128c5e9c461ac86ae1e14f9ac56a /remoting
parent5db62b5980814438e4bc2960f12245db6cc3f4da (diff)
downloadchromium_src-905b2785847d3dc97ca8da217066732b710d1a98.zip
chromium_src-905b2785847d3dc97ca8da217066732b710d1a98.tar.gz
chromium_src-905b2785847d3dc97ca8da217066732b710d1a98.tar.bz2
Show dialog if the Android device has no Google accounts
Since the Chromoting app is unusable without a Google account, show a dialog in this case, with an option to add a Google account. R=jamiewalch@chromium.org Review URL: https://codereview.chromium.org/178583011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254557 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/Chromoting.java41
-rw-r--r--remoting/resources/remoting_strings.grd17
2 files changed, 53 insertions, 5 deletions
diff --git a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
index 15879c8..9632de2 100644
--- a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
+++ b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
@@ -12,6 +12,7 @@ import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.app.ActionBar;
import android.app.Activity;
+import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
@@ -19,6 +20,7 @@ import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
+import android.provider.Settings;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@@ -84,6 +86,40 @@ public class Chromoting extends Activity implements JniInterface.ConnectionListe
*/
boolean mTriedNewAuthToken;
+ /** Shows a warning explaining that a Google account is required, then closes the activity. */
+ private void showNoAccountsDialog() {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage(R.string.noaccounts_message);
+ builder.setPositiveButton(R.string.noaccounts_add_account,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ Intent intent = new Intent(Settings.ACTION_ADD_ACCOUNT);
+ intent.putExtra(Settings.EXTRA_ACCOUNT_TYPES,
+ new String[] { ACCOUNT_TYPE });
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+ finish();
+ }
+ });
+ builder.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ finish();
+ }
+ });
+ builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ finish();
+ }
+ });
+
+ AlertDialog dialog = builder.create();
+ dialog.show();
+ }
+
/**
* Called when the activity is first created. Loads the native library and requests an
* authentication token from the system.
@@ -105,10 +141,7 @@ public class Chromoting extends Activity implements JniInterface.ConnectionListe
mAccounts = AccountManager.get(this).getAccountsByType(ACCOUNT_TYPE);
if (mAccounts.length == 0) {
- // TODO(lambroslambrou): Show a dialog with message: "To use <App Name>, you'll need
- // to add a Google Account to your device." and two buttons: "Close", "Add account".
- // The "Add account" button should navigate to the system "Add a Google Account"
- // screen.
+ showNoAccountsDialog();
return;
}
diff --git a/remoting/resources/remoting_strings.grd b/remoting/resources/remoting_strings.grd
index 9b1bc3d..8526bca 100644
--- a/remoting/resources/remoting_strings.grd
+++ b/remoting/resources/remoting_strings.grd
@@ -186,6 +186,12 @@
<release allow_pseudo="false" seq="1">
<messages fallback_to_english="true">
<if expr="_google_chrome">
+ <if expr="is_android">
+ <message desc="Message shown in popup dialog on Android when there are no Google accounts on the device" name="IDS_NOACCOUNTS_MESSAGE" formatter_data="android_java">
+ To use Chrome Remote Desktop, you'll need to add a Google Account to your device.
+ </message>
+ </if>
+
<message desc="Message shown when the Chrome Remote Desktop client tab is closed while a connection is active." name="IDS_CLOSE_PROMPT">
Leaving this page will end your Chrome Remote Desktop session.
</message>
@@ -282,6 +288,12 @@
</if>
<if expr="not _google_chrome">
+ <if expr="is_android">
+ <message desc="Message shown in popup dialog on Android when there are no Google accounts on the device" name="IDS_NOACCOUNTS_MESSAGE" formatter_data="android_java">
+ To use Chromoting, you'll need to add a Google Account to your device.
+ </message>
+ </if>
+
<message desc="Message shown when the Chromoting client tab is closed while a connection is active." name="IDS_CLOSE_PROMPT">
Leaving this page will end your Chromoting session.
</message>
@@ -390,6 +402,9 @@
<message desc="Android action-bar menu item for viewing the Play Store page for the application" name="IDS_ACTIONBAR_PLAY_STORE" formatter_data="android_java">
View in Google Play Store
</message>
+ <message desc="Label for the button on the Android popup dialog that is shown when there are no Google accounts on the device. Pressing this button launches the Android system screen for adding a new Google account to the device." name="IDS_NOACCOUNTS_ADD_ACCOUNT" formatter_data="android_java">
+ Add account
+ </message>
</if>
<message desc="Label for the access code entry box. This is where the client user enters the code that permits access to the host." name="IDS_ACCESS_CODE">
@@ -413,7 +428,7 @@
<message desc="In the connection history dialog, clicking this button will delete the connection history." name="IDS_CLEAR_HISTORY">
Clear history
</message>
- <message desc="Label for general-purpose Close buttons." name="IDS_CLOSE">
+ <message desc="Label for general-purpose Close buttons." name="IDS_CLOSE" formatter_data="android_java">
Close
</message>
<message desc="Label for the connect button. Clicking this button will start the Chrome Remote Desktop session if the access code is correct." name="IDS_CONNECT_BUTTON">