Commit f8d35b46 authored by mattreynolds's avatar mattreynolds Committed by Commit bot

Add Physical Web opt-in dialog

Display a dialog describing the Physical Web and inviting the user to
enable or decline the feature.

BUG=529962

Review URL: https://codereview.chromium.org/1526323003

Cr-Commit-Position: refs/heads/master@{#367027}
parent 102a658b
......@@ -406,6 +406,14 @@ by a child template that "extends" this file.
android:exported="false">
</activity>
<!-- Opt-in activity for Physical Web -->
<activity android:name="org.chromium.chrome.browser.physicalweb.PhysicalWebOptInActivity"
android:label="@string/physical_web_list_urls_activity_title"
android:theme="@style/PhysicalWebOptInStyle"
android:autoRemoveFromRecents="true"
android:exported="false">
</activity>
<!-- Providers for chrome data. -->
<provider android:name="org.chromium.chrome.browser.ChromeBrowserProvider"
android:authorities="{{ manifest_package }}.ChromeBrowserProvider;{{ manifest_package }}.browser;{{ manifest_package }}"
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<merge
xmlns:android="http://schemas.android.com/apk/res/android" >
<ScrollView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_marginBottom="57dp"
android:fillViewport="true"
android:scrollbarStyle="outsideOverlay" >
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:paddingStart="40dp"
android:paddingEnd="40dp"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:layout_height="140dp"
android:layout_width="140dp"
android:src="@drawable/physical_web_logo"
android:contentDescription="@null" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="20dp"
android:text="@string/physical_web_optin_title"
android:textSize="24sp"
android:textColor="@android:color/black" />
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/physical_web_optin_description"
android:textSize="16sp"
android:textColor="@color/light_normal_color" />
</LinearLayout>
</ScrollView>
<View
style="@style/ButtonBarTopDivider"
android:layout_gravity="bottom"
android:layout_marginBottom="56dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_gravity="bottom"
android:orientation="horizontal" >
<!--suppress ButtonStyle -->
<Button
android:id="@+id/physical_web_decline"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/listChoiceBackgroundIndicator"
android:gravity="start|center_vertical"
android:textDirection="locale"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:text="@string/no_thanks"
android:textAllCaps="true"
android:textColor="@color/light_normal_color"
android:textSize="14sp" />
<!--suppress ButtonStyle -->
<Button
android:id="@+id/physical_web_enable"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/listChoiceBackgroundIndicator"
android:gravity="end|center_vertical"
android:textDirection="locale"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:text="@string/enable"
android:textAllCaps="true"
android:textColor="@color/light_active_color"
android:textSize="14sp" />
</LinearLayout>
</merge>
\ No newline at end of file
......@@ -446,6 +446,12 @@
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
</style>
<style name="PhysicalWebOptInStyle" parent="Theme.AppCompat.Light">
<item name="android:windowBackground">@android:color/white</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowContentOverlay">@null</item>
</style>
<!-- Misc styles -->
<style name="SnackbarAnimation">
......
......@@ -34,6 +34,7 @@ import java.util.HashSet;
public class ListUrlsActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {
public static final String REFERER_KEY = "referer";
public static final int NOTIFICATION_REFERER = 1;
public static final int OPTIN_REFERER = 2;
private static final String TAG = "PhysicalWeb";
private static final long SCAN_TIMEOUT_MILLIS = 5000; // 5 seconds
private NearbyUrlsAdapter mAdapter;
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.physicalweb;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager;
/**
* This activity invites the user to opt-in to the Physical Web feature.
*/
public class PhysicalWebOptInActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.physical_web_optin);
Button declineButton = (Button) findViewById(R.id.physical_web_decline);
declineButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PrivacyPreferencesManager privacyPrefManager =
PrivacyPreferencesManager.getInstance(PhysicalWebOptInActivity.this);
privacyPrefManager.setPhysicalWebEnabled(false);
finish();
}
});
Button enableButton = (Button) findViewById(R.id.physical_web_enable);
enableButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PrivacyPreferencesManager privacyPrefManager =
PrivacyPreferencesManager.getInstance(PhysicalWebOptInActivity.this);
privacyPrefManager.setPhysicalWebEnabled(true);
startActivity(createListUrlsIntent(PhysicalWebOptInActivity.this));
finish();
}
});
}
private static Intent createListUrlsIntent(Context context) {
Intent intent = new Intent(context, ListUrlsActivity.class);
intent.putExtra(ListUrlsActivity.REFERER_KEY,
ListUrlsActivity.OPTIN_REFERER);
return intent;
}
}
\ No newline at end of file
......@@ -245,8 +245,7 @@ class UrlManager {
}
private PendingIntent createOptInIntent() {
// TODO(mattreynolds): navigate to PhysicalWebOptInActivity
Intent intent = new Intent(mContext, ListUrlsActivity.class);
Intent intent = new Intent(mContext, PhysicalWebOptInActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0);
return pendingIntent;
}
......
......@@ -161,6 +161,9 @@ CHAR-LIMIT guidelines:
<message name="IDS_NO_THANKS" desc="Generic label to say no thanks for a feature. [CHAR-LIMIT=32]">
No Thanks
</message>
<message name="IDS_ENABLE" desc="Generic label to enable a feature. [CHAR-LIMIT=32]">
Enable
</message>
<message name="IDS_NEXT" desc="Generic label for a button to advance to the next item. [CHAR-LIMIT=20]">
Next
</message>
......@@ -2303,6 +2306,14 @@ However, you aren’t invisible. Going incognito doesn’t hide your browsing fr
Discover web pages sent by nearby objects. Chrome gathers web pages associated with objects around you, sends them anonymously to a Google service to find the ones most useful to you, then displays them.
You must have Bluetooth and Location turned on in order to use the Physical Web.
</message>
<message name="IDS_PHYSICAL_WEB_OPTIN_TITLE" desc="The title for a dialog inviting the user to opt-in to the Physical Web.">
The Physical Web
</message>
<message name="IDS_PHYSICAL_WEB_OPTIN_DESCRIPTION" desc="Description of the Physical Web displayed in the opt-in dialog">
Discover web pages sent by nearby objects.
Chrome will scan for nearby pages when your device is unlocked. These pages will go through a Google service to improve the quality of page results.
</message>
<message name="IDS_PHYSICAL_WEB_LIST_URLS_ACTIVITY_TITLE" desc="The title for a dialog that shows a list of URLs broadcasted from nearby devices.">
The Physical Web
......
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