Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(823)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/bandwidth/DataReductionPromoScreen.java

Issue 1011363006: Data Saver promo changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/bandwidth/DataReductionPromoScreen.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/bandwidth/DataReductionPromoScreen.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/bandwidth/DataReductionPromoScreen.java
index a3b3e753c78f5745a296f47fee3ca23c4c73a384..9e73a733dd0105883a8abe110283ff26886af485 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/bandwidth/DataReductionPromoScreen.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/bandwidth/DataReductionPromoScreen.java
@@ -9,12 +9,18 @@ import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
+import android.text.TextPaint;
+import android.text.method.LinkMovementMethod;
+import android.text.style.ClickableSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
+import android.widget.TextView;
+import android.widget.Toast;
import org.chromium.base.ApplicationStatus;
import org.chromium.chrome.R;
@@ -22,6 +28,8 @@ import org.chromium.chrome.browser.ChromiumApplication;
import org.chromium.chrome.browser.metrics.UmaBridge;
import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings;
import org.chromium.chrome.browser.preferences.PreferencesLauncher;
+import org.chromium.ui.text.SpanApplier;
+import org.chromium.ui.text.SpanApplier.SpanInfo;
/**
* The promo screen encouraging users to enable Data Saver.
@@ -32,7 +40,8 @@ public class DataReductionPromoScreen extends Dialog implements View.OnClickList
// DataReductionProxyPromoAction in tools/metrics/histograms/histograms.xml.
private static final int ACTION_DISMISSED_FIRST_SCREEN = 0;
private static final int ACTION_ENABLED_FIRST_SCREEN = 2;
- public static final int ACTION_INDEX_BOUNDARY = 4;
+ private static final int ACTION_SETTINGS_LINK = 4;
+ public static final int ACTION_INDEX_BOUNDARY = 5;
public static final String FROM_PROMO = "FromPromo";
private static final String SHARED_PREF_DISPLAYED_PROMO = "displayed_data_reduction_promo";
@@ -87,6 +96,7 @@ public class DataReductionPromoScreen extends Dialog implements View.OnClickList
getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
addListenerOnButton();
+ addClickableSpan();
mState = ACTION_DISMISSED_FIRST_SCREEN;
UmaBridge.dataReductionProxyPromoDisplayed();
@@ -104,6 +114,33 @@ public class DataReductionPromoScreen extends Dialog implements View.OnClickList
}
}
+ private void addClickableSpan() {
+ TextView settings_link = (TextView) findViewById(R.id.data_reduction_title_2_link);
+ ClickableSpan clickableSettingsSpan = new ClickableSpan() {
+ @Override
+ public void onClick(View view) {
+ Context context = getContext();
+ if (context == null) return;
+ Intent intent = PreferencesLauncher.createIntentForSettingsPage(
+ context, BandwidthReductionPreferences.class.getName());
+ intent.putExtra(FROM_PROMO, true);
+ context.startActivity(intent);
+ mState = ACTION_SETTINGS_LINK;
+ dismiss();
+ }
+
+ @Override
+ public void updateDrawState(TextPaint textPaint) {
+ textPaint.setColor(Color.parseColor("#27b4e7"));
newt (away) 2015/03/24 21:08:26 Don't use Color.parseColor(). Instead: textPa
megjablon 2015/03/24 21:23:11 Done.
+ textPaint.setUnderlineText(false);
+ }
+ };
+ settings_link.setMovementMethod(LinkMovementMethod.getInstance());
+ settings_link.setText(SpanApplier.applySpans(
+ getContext().getString(R.string.data_reduction_title_2),
+ new SpanInfo("<link>", "</link>", clickableSettingsSpan)));
+ }
+
@Override
public void onClick(View v) {
int id = v.getId();
@@ -126,13 +163,12 @@ public class DataReductionPromoScreen extends Dialog implements View.OnClickList
}
private void handleEnableButtonPressed() {
- Context context = getContext();
- if (context == null) return;
- Intent intent = PreferencesLauncher.createIntentForSettingsPage(context,
- BandwidthReductionPreferences.class.getName());
- intent.putExtra(FROM_PROMO, true);
- context.startActivity(intent);
+ DataReductionProxySettings.getInstance().setDataReductionProxyEnabled(
+ getContext(), true);
+ UmaBridge.dataReductionProxyTurnedOnFromPromo();
dismiss();
+ Toast.makeText(getContext(), getContext().getString(R.string.data_reduction_enabled_toast),
+ Toast.LENGTH_LONG).show();
}
private void handleCloseButtonPressed() {

Powered by Google App Engine
This is Rietveld 408576698