Index: mobile/android/thirdparty/org/adblockplus/browser/StartPane.java |
=================================================================== |
--- a/mobile/android/thirdparty/org/adblockplus/browser/StartPane.java |
+++ b/mobile/android/thirdparty/org/adblockplus/browser/StartPane.java |
@@ -21,16 +21,17 @@ import java.io.File; |
import java.io.FileOutputStream; |
import java.io.IOException; |
import java.io.InputStream; |
import java.util.ArrayList; |
import java.util.HashMap; |
import java.util.List; |
import java.util.Map; |
+import org.mozilla.gecko.AppConstants; |
import org.mozilla.gecko.R; |
import android.content.Context; |
import android.content.DialogInterface; |
import android.content.DialogInterface.OnKeyListener; |
import android.graphics.Typeface; |
import android.os.Bundle; |
import android.support.v4.app.DialogFragment; |
@@ -45,38 +46,33 @@ import android.view.Window; |
import android.widget.Button; |
import android.widget.LinearLayout; |
import android.widget.TextView; |
public class StartPane extends DialogFragment implements OnClickListener, OnKeyListener |
{ |
private static final String TAG = "AdblockBrowser.StartPane"; |
private int currentStep = 0; |
- // For now we disable the beta community page, |
- // see https://issues.adblockplus.org/ticket/2937 for a follow-up issue |
- // for detecting whether we are on the beta channel or not |
- private static final boolean SKIP_BETA_COMMUNITY_PAGE = true; |
private static final HashMap<String, Integer> FONTS = new HashMap<String, Integer>(); |
private HashMap<String, Typeface> loadedFonts = new HashMap<String, Typeface>(); |
private static final int[] BETA_RESOURCE_LIST = |
{ |
R.layout.abb_start_pane_step_1, R.string.abb_frp_button_1, |
R.layout.abb_start_pane_step_2, R.string.abb_frp_button_2, |
R.layout.abb_start_pane_step_3, R.string.abb_frp_button_3 |
}; |
private static final int[] RELEASE_RESOURCE_LIST = |
{ |
R.layout.abb_start_pane_step_1, R.string.abb_frp_button_2, |
R.layout.abb_start_pane_step_2, R.string.abb_frp_button_3 |
}; |
- private static final int[] PAGES_RESOURCE_LIST = SKIP_BETA_COMMUNITY_PAGE ? |
- RELEASE_RESOURCE_LIST : BETA_RESOURCE_LIST; |
+ private int[] pagesResourceList; |
static |
{ |
FONTS.put("ttf_opensans_light", R.raw.opensans_light); |
FONTS.put("ttf_opensans_semibold", R.raw.opensans_semibold); |
} |
static Typeface typefaceFromResource(final Context context, final int resId) |
@@ -119,20 +115,28 @@ public class StartPane extends DialogFra |
final Typeface t = typefaceFromResource(context, e.getValue().intValue()); |
if (t != null) |
{ |
this.loadedFonts.put(e.getKey(), t); |
} |
} |
} |
+ private void loadPagesResources() |
+ { |
+ final boolean useBetaResourceList = !AppConstants.ABB_RELEASE_BUILD && BrowserAppUtils.wasInstalledFromPlayStore(getContext()); |
+ this.pagesResourceList = useBetaResourceList ? BETA_RESOURCE_LIST : RELEASE_RESOURCE_LIST; |
+ } |
+ |
@Override |
public void onCreate(Bundle savedInstanceState) |
{ |
super.onCreate(savedInstanceState); |
+ |
+ this.loadPagesResources(); |
this.setStyle(DialogFragment.STYLE_NO_TITLE, 0); |
this.loadTypefaces(); |
} |
@Override |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) |
{ |
final View view = inflater.inflate(R.layout.abb_start_pane, container, false); |
@@ -153,17 +157,17 @@ public class StartPane extends DialogFra |
window.setBackgroundDrawable(null); |
window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
} |
@Override |
public void onClick(View v) |
{ |
final int nextStep = this.currentStep + 1; |
- if (nextStep * 2 < PAGES_RESOURCE_LIST.length) |
+ if (nextStep * 2 < this.pagesResourceList.length) |
{ |
this.currentStep = nextStep; |
this.updateContents(this.getView()); |
} |
else |
{ |
this.dismissAllowingStateLoss(); |
} |
@@ -207,18 +211,18 @@ public class StartPane extends DialogFra |
private void updateContents(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(PAGES_RESOURCE_LIST[this.currentStep * 2], ll, true); |
- this.setButtonText(view, R.id.abb_frp_button, PAGES_RESOURCE_LIST[this.currentStep * 2 + 1]); |
+ inflater.inflate(this.pagesResourceList[this.currentStep * 2], ll, true); |
+ this.setButtonText(view, R.id.abb_frp_button, this.pagesResourceList[this.currentStep * 2 + 1]); |
final List<View> views = listViews(view); |
for (View v : views) |
{ |
final Object tag = v.getTag(); |
if (tag != null) |
{ |
Typeface t = this.loadedFonts.get(tag.toString()); |