| Index: mobile/android/thirdparty/org/adblockplus/browser/StartPane.java |
| diff --git a/mobile/android/thirdparty/org/adblockplus/browser/StartPane.java b/mobile/android/thirdparty/org/adblockplus/browser/StartPane.java |
| index dfab255130af311784956e8fd8f7e05a1fbe6a5e..b8fafcfe204dc68c1ae8d47697a464936f032492 100644 |
| --- a/mobile/android/thirdparty/org/adblockplus/browser/StartPane.java |
| +++ b/mobile/android/thirdparty/org/adblockplus/browser/StartPane.java |
| @@ -17,9 +17,6 @@ |
| package org.adblockplus.browser; |
| -import java.io.BufferedReader; |
| -import java.io.InputStreamReader; |
| - |
| import org.mozilla.gecko.R; |
| import android.content.Context; |
| @@ -28,7 +25,6 @@ import android.content.DialogInterface.OnKeyListener; |
| import android.os.Bundle; |
| import android.support.v4.app.DialogFragment; |
| import android.text.Html; |
| -import android.util.Log; |
| import android.view.KeyEvent; |
| import android.view.LayoutInflater; |
| import android.view.View; |
| @@ -44,6 +40,7 @@ public class StartPane extends DialogFragment implements OnClickListener, OnKeyL |
| { |
| private static final String TAG = "AdblockBrowser.StartPane"; |
| private int currentStep = 1; |
| + private static final int NUMBER_OF_STEPS = 3; |
| @Override |
| public void onCreate(Bundle savedInstanceState) |
| @@ -78,7 +75,7 @@ public class StartPane extends DialogFragment implements OnClickListener, OnKeyL |
| @Override |
| public void onClick(View v) |
| { |
| - if (this.currentStep < 2) |
| + if (this.currentStep < NUMBER_OF_STEPS) |
| { |
| this.currentStep++; |
| this.updateContents(this.getView()); |
| @@ -94,7 +91,7 @@ public class StartPane extends DialogFragment implements OnClickListener, OnKeyL |
| { |
| if (keyCode == KeyEvent.KEYCODE_BACK) |
| { |
| - if (this.currentStep > 1) |
| + if (event.getAction() == KeyEvent.ACTION_DOWN && this.currentStep > 1) |
| { |
| this.currentStep--; |
| this.updateContents(this.getView()); |
| @@ -106,46 +103,20 @@ public class StartPane extends DialogFragment implements OnClickListener, OnKeyL |
| private void updateContents(final View view) |
| { |
| - switch (this.currentStep) |
| - { |
| - default: |
| - case 1: |
| - this.createStepOneContents(view); |
| - break; |
| - case 2: |
| - this.createStepTwoContents(view); |
| - break; |
| - } |
| - } |
| - |
| - private void createStepOneContents(final View view) |
| - { |
| final LinearLayout ll = (LinearLayout) view.findViewById(R.id.abb_main_content); |
| ll.removeAllViews(); |
| final LayoutInflater inflater = (LayoutInflater) this.getActivity() |
| .getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| - inflater.inflate(R.layout.abb_start_pane_step_one, ll, true); |
| - |
| - setTextViewTextHtml(view, R.id.abb_frp_main_text, |
| - this.readRawTextFile(R.raw.abb_frp_acceptable_ads)); |
| - |
| - this.setButtonText(view, R.id.abb_frp_button, R.string.abb_frp_button_next); |
| - } |
| - |
| - private void createStepTwoContents(final View view) |
| - { |
| - final LinearLayout ll = (LinearLayout) view.findViewById(R.id.abb_main_content); |
| - ll.removeAllViews(); |
| - |
| - final LayoutInflater inflater = (LayoutInflater) this.getActivity() |
| - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| - inflater.inflate(R.layout.abb_start_pane_step_two, ll, true); |
| - |
| - setTextViewTextHtml(view, R.id.abb_frp_main_text, |
| - this.readRawTextFile(R.raw.abb_frp_bug_reports)); |
| - |
| - this.setButtonText(view, R.id.abb_frp_button, R.string.abb_frp_button_finish); |
| + inflater.inflate( |
| + this.getResources().getIdentifier("abb_start_pane_step_" + this.currentStep, |
| + "layout", |
| + this.getActivity().getPackageName()), ll, true); |
| + |
| + this.setButtonText(view, R.id.abb_frp_button, |
| + this.getResources().getIdentifier("abb_frp_button_" + this.currentStep, |
| + "string", |
| + this.getActivity().getPackageName())); |
| } |
| private void setTextViewTextHtml(final View view, final int viewId, final String text) |
| @@ -159,34 +130,4 @@ public class StartPane extends DialogFragment implements OnClickListener, OnKeyL |
| final Button button = (Button) view.findViewById(viewId); |
| button.setText(this.getString(resId)); |
| } |
| - |
| - private String readRawTextFile(final int id) |
| - { |
| - final StringBuilder text = new StringBuilder(); |
| - try |
| - { |
| - final BufferedReader buf = new BufferedReader(new InputStreamReader(this.getResources() |
| - .openRawResource(id))); |
| - |
| - try |
| - { |
| - String line; |
| - while ((line = buf.readLine()) != null) |
| - { |
| - text.append(line); |
| - text.append('\n'); |
| - } |
| - } |
| - finally |
| - { |
| - buf.close(); |
| - } |
| - } |
| - catch (final Exception e) |
| - { |
| - Log.e(TAG, "Failed loading raw resource " + id + ": " + e.getMessage(), e); |
| - } |
| - return text.toString(); |
| - } |
| } |
| - |