BearND has uploaded a new change for review. https://gerrit.wikimedia.org/r/146693
Change subject: Checkstyle: various Categories + remove unused code ...................................................................... Checkstyle: various Categories + remove unused code Change-Id: Ie8d634b683e4c1959f967d068d9774b7ee1cc0f1 --- M wikipedia/res/layout/fragment_search.xml M wikipedia/src/main/java/org/wikipedia/WikipediaApp.java M wikipedia/src/main/java/org/wikipedia/history/HistoryActivity.java M wikipedia/src/main/java/org/wikipedia/history/HistoryEntryContentProvider.java M wikipedia/src/main/java/org/wikipedia/page/BackStackItem.java M wikipedia/src/main/java/org/wikipedia/page/PageFragmentAdapter.java M wikipedia/src/main/java/org/wikipedia/page/ToCHandler.java M wikipedia/src/main/java/org/wikipedia/savedpages/SavedPageContentProvider.java M wikipedia/src/main/java/org/wikipedia/savedpages/SavedPagesActivity.java M wikipedia/src/main/java/org/wikipedia/search/SearchArticlesFragment.java M wikipedia/src/main/java/org/wikipedia/views/FlowLayout.java 11 files changed, 39 insertions(+), 65 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia refs/changes/93/146693/1 diff --git a/wikipedia/res/layout/fragment_search.xml b/wikipedia/res/layout/fragment_search.xml index 99fa61b..b7cff42 100644 --- a/wikipedia/res/layout/fragment_search.xml +++ b/wikipedia/res/layout/fragment_search.xml @@ -1,14 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/search_bar_container" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="48dp" android:background="?attr/search_background_color" > <LinearLayout - android:id="@+id/navbar" android:orientation="horizontal" android:layout_height="match_parent" android:layout_width="match_parent" @@ -124,4 +122,4 @@ <!-- Android has no easy way to give us a light border --> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/border" /> -</LinearLayout> \ No newline at end of file +</LinearLayout> diff --git a/wikipedia/src/main/java/org/wikipedia/WikipediaApp.java b/wikipedia/src/main/java/org/wikipedia/WikipediaApp.java index c523eca..1c050d1 100644 --- a/wikipedia/src/main/java/org/wikipedia/WikipediaApp.java +++ b/wikipedia/src/main/java/org/wikipedia/WikipediaApp.java @@ -70,13 +70,17 @@ public static String PREFERENCE_COLOR_THEME; public static float SCREEN_DENSITY; + // Reload in onCreate to override public static String PROTOCOL = "https"; + public static boolean FALLBACK = false; + public static int FAILS = 0; + public static String APP_VERSION_STRING; - public static int THEME_LIGHT; - public static int THEME_DARK; + public static final int THEME_LIGHT = R.style.Theme_WikiLight; + public static final int THEME_DARK = R.style.Theme_WikiDark; public static final int FONT_SIZE_MULTIPLIER_MIN = -5; public static final int FONT_SIZE_MULTIPLIER_MAX = 8; @@ -91,8 +95,6 @@ private int currentTheme = 0; private ConnectionChangeReceiver connChangeReceiver; - public static boolean FALLBACK = false; - public static int FAILS = 0; public WikipediaApp() { INSTANCE = this; @@ -132,9 +134,6 @@ PREFERENCE_ONBOARD = getString(R.string.preference_onboard); PREFERENCE_TEXT_SIZE_MULTIPLIER = getString(R.string.preference_text_size_multiplier); PREFERENCE_COLOR_THEME = getString(R.string.preference_color_theme); - - THEME_LIGHT = R.style.Theme_WikiLight; - THEME_DARK = R.style.Theme_WikiDark; PROTOCOL = "https"; // Move this to a preference or something later on diff --git a/wikipedia/src/main/java/org/wikipedia/history/HistoryActivity.java b/wikipedia/src/main/java/org/wikipedia/history/HistoryActivity.java index c6d1755..a0ea720 100644 --- a/wikipedia/src/main/java/org/wikipedia/history/HistoryActivity.java +++ b/wikipedia/src/main/java/org/wikipedia/history/HistoryActivity.java @@ -188,12 +188,12 @@ view.setTag(entry); Picasso.with(HistoryActivity.this) - .load(cursor.getString(5)) + .load(cursor.getString(HistoryEntryContentProvider.COL_INDEX_IMAGE)) .placeholder(R.drawable.ic_pageimage_placeholder) .error(R.drawable.ic_pageimage_placeholder) .into(thumbnail); - // Check the previous item, see if the times differe enough + // Check the previous item, see if the times differ enough // If they do, display the section header. // Always do it this is the first item. String curTime, prevTime = ""; @@ -210,7 +210,6 @@ } else { sectionHeader.setVisibility(View.GONE); } - } } diff --git a/wikipedia/src/main/java/org/wikipedia/history/HistoryEntryContentProvider.java b/wikipedia/src/main/java/org/wikipedia/history/HistoryEntryContentProvider.java index 4401187..aea22d0 100644 --- a/wikipedia/src/main/java/org/wikipedia/history/HistoryEntryContentProvider.java +++ b/wikipedia/src/main/java/org/wikipedia/history/HistoryEntryContentProvider.java @@ -12,6 +12,9 @@ public class HistoryEntryContentProvider extends SQLiteContentProvider<HistoryEntry> { private static final int MATCH_WITH_PAGEIMAGES = 64; + /** column index of pageimages.imageName in the MATCH_WITH_PAGEIMAGES case */ + public static final int COL_INDEX_IMAGE = 5; + public HistoryEntryContentProvider() { super(HistoryEntry.PERSISTANCE_HELPER); } diff --git a/wikipedia/src/main/java/org/wikipedia/page/BackStackItem.java b/wikipedia/src/main/java/org/wikipedia/page/BackStackItem.java index 13f5827..1cb6dcb 100644 --- a/wikipedia/src/main/java/org/wikipedia/page/BackStackItem.java +++ b/wikipedia/src/main/java/org/wikipedia/page/BackStackItem.java @@ -6,9 +6,9 @@ import org.wikipedia.history.HistoryEntry; public class BackStackItem implements Parcelable { - final PageTitle title; - final HistoryEntry historyEntry; - final int scrollPosition; + private final PageTitle title; + private final HistoryEntry historyEntry; + private final int scrollPosition; public BackStackItem(PageTitle title, HistoryEntry historyEntry, int scrollPosition) { this.title = title; @@ -44,4 +44,12 @@ return new BackStackItem[size]; } }; + + public PageTitle getTitle() { + return title; + } + + public HistoryEntry getHistoryEntry() { + return historyEntry; + } } diff --git a/wikipedia/src/main/java/org/wikipedia/page/PageFragmentAdapter.java b/wikipedia/src/main/java/org/wikipedia/page/PageFragmentAdapter.java index 45dc2f8..709f1fc 100644 --- a/wikipedia/src/main/java/org/wikipedia/page/PageFragmentAdapter.java +++ b/wikipedia/src/main/java/org/wikipedia/page/PageFragmentAdapter.java @@ -25,8 +25,8 @@ PageViewFragment f = fragmentArray.get(position); if (f == null) { f = new PageViewFragment(position, - backStack.getStack().get(position).title, - backStack.getStack().get(position).historyEntry, + backStack.getStack().get(position).getTitle(), + backStack.getStack().get(position).getHistoryEntry(), R.id.search_fragment); fragmentArray.put(position, f); diff --git a/wikipedia/src/main/java/org/wikipedia/page/ToCHandler.java b/wikipedia/src/main/java/org/wikipedia/page/ToCHandler.java index f3705a4..ea46b10 100644 --- a/wikipedia/src/main/java/org/wikipedia/page/ToCHandler.java +++ b/wikipedia/src/main/java/org/wikipedia/page/ToCHandler.java @@ -27,6 +27,8 @@ import java.util.ArrayList; public class ToCHandler { + private static final int MAX_LEVELS = 3; + private static final int INDENTATION_WIDTH_DP = 16; private final ListView tocList; private final ProgressBar tocProgress; private final CommunicationBridge bridge; @@ -162,7 +164,7 @@ private ToCAdapter(Page page) { sections = new ArrayList<Section>(); for (Section s : page.getSections()) { - if (s.getLevel() < 3 && !s.isLead()) { + if (s.getLevel() < MAX_LEVELS && !s.isLead()) { sections.add(s); } } @@ -193,7 +195,7 @@ View sectionFiller = convertView.findViewById(R.id.page_toc_filler); LinearLayout.LayoutParams indentLayoutParameters = new LinearLayout.LayoutParams(sectionFiller.getLayoutParams()); - indentLayoutParameters.width = (section.getLevel() - 1) * (int)(16 * WikipediaApp.SCREEN_DENSITY); + indentLayoutParameters.width = (section.getLevel() - 1) * (int) (INDENTATION_WIDTH_DP * WikipediaApp.SCREEN_DENSITY); sectionFiller.setLayoutParams(indentLayoutParameters); sectionHeading.setText(Html.fromHtml(section.getHeading())); diff --git a/wikipedia/src/main/java/org/wikipedia/savedpages/SavedPageContentProvider.java b/wikipedia/src/main/java/org/wikipedia/savedpages/SavedPageContentProvider.java index f65a923..fc446af 100644 --- a/wikipedia/src/main/java/org/wikipedia/savedpages/SavedPageContentProvider.java +++ b/wikipedia/src/main/java/org/wikipedia/savedpages/SavedPageContentProvider.java @@ -12,6 +12,9 @@ public class SavedPageContentProvider extends SQLiteContentProvider<SavedPage> { private static final int MATCH_WITH_PAGEIMAGES = 64; + /** column index of pageimages.imageName in the MATCH_WITH_PAGEIMAGES case */ + public static final int COL_INDEX_IMAGE = 4; + public SavedPageContentProvider() { super(SavedPage.PERSISTANCE_HELPER); } @@ -41,7 +44,6 @@ SQLiteDatabase db = getDbOpenHelper().getReadableDatabase(); Cursor cursor; - switch (uriType) { case MATCH_WITH_PAGEIMAGES: diff --git a/wikipedia/src/main/java/org/wikipedia/savedpages/SavedPagesActivity.java b/wikipedia/src/main/java/org/wikipedia/savedpages/SavedPagesActivity.java index 0ece511..447ecfb 100644 --- a/wikipedia/src/main/java/org/wikipedia/savedpages/SavedPagesActivity.java +++ b/wikipedia/src/main/java/org/wikipedia/savedpages/SavedPagesActivity.java @@ -28,9 +28,7 @@ import org.wikipedia.page.PageActivity; import org.wikipedia.pageimages.PageImage; -import java.text.DateFormat; import java.util.ArrayList; -import java.util.Date; public class SavedPagesActivity extends ThemedActionBarActivity implements LoaderManager.LoaderCallbacks<Cursor> { public static final int ACTIVITY_RESULT_SAVEDPAGE_SELECT = 1; @@ -161,7 +159,7 @@ savedPagesList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { - // We shouldn't do anything if the user is multiselecting things + // We shouldn't do anything if the user is multi-selecting things if (actionMode == null) { SavedPage savedPage = (SavedPage) view.getTag(); HistoryEntry newEntry = new HistoryEntry(savedPage.getTitle(), HistoryEntry.SOURCE_SAVED_PAGE); @@ -211,10 +209,6 @@ } private class SavedPagesAdapter extends CursorAdapter { - - /** see SavedPageContentProvider.query() MATCH_WITH_PAGEIMAGES */ - private static final int COL_INDEX_IMAGE_NAME = 4; - public SavedPagesAdapter(Context context, Cursor c, boolean autoRequery) { super(context, c, autoRequery); } @@ -222,10 +216,6 @@ @Override public View newView(Context context, Cursor cursor, ViewGroup viewGroup) { return getLayoutInflater().inflate(R.layout.item_saved_page_entry, viewGroup, false); - } - - private String getDateString(Date date) { - return DateFormat.getDateInstance().format(date); } @Override @@ -237,7 +227,7 @@ view.setTag(entry); Picasso.with(SavedPagesActivity.this) - .load(cursor.getString(COL_INDEX_IMAGE_NAME)) + .load(cursor.getString(SavedPageContentProvider.COL_INDEX_IMAGE)) .placeholder(R.drawable.ic_pageimage_placeholder) .error(R.drawable.ic_pageimage_placeholder) .into(thumbnail); diff --git a/wikipedia/src/main/java/org/wikipedia/search/SearchArticlesFragment.java b/wikipedia/src/main/java/org/wikipedia/search/SearchArticlesFragment.java index 2e0c301..5f2ea27 100644 --- a/wikipedia/src/main/java/org/wikipedia/search/SearchArticlesFragment.java +++ b/wikipedia/src/main/java/org/wikipedia/search/SearchArticlesFragment.java @@ -1,8 +1,6 @@ package org.wikipedia.search; import android.content.Context; -import android.graphics.Color; -import android.graphics.drawable.ColorDrawable; import android.os.Build; import android.os.Bundle; import android.os.Handler; @@ -56,9 +54,6 @@ private WikipediaApp app; - private LinearLayout searchBarContainer; - private LinearLayout navbar; - private View searchBarIcon; private EditText searchTermText; private ListView searchResultsList; private ProgressBar searchProgress; @@ -67,11 +62,6 @@ private ImageView searchBarMenuButton; private ImageView searchBarTocButton; private ImageView drawerIndicator; - private ImageView wikipediaIcon; - - private int navbarColor; - private int searchTermTextColor; - private int searchTermHintTextColor; private SearchResultAdapter adapter; @@ -157,31 +147,15 @@ pausedStateOfZero = savedInstanceState.getBoolean("pausedStateOfZero"); } - searchBarContainer = (LinearLayout) parentLayout.findViewById(R.id.search_bar_container); - navbar = (LinearLayout) parentLayout.findViewById(R.id.navbar); searchTermText = (EditText) parentLayout.findViewById(R.id.search_term_text); - try { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - navbarColor = ((ColorDrawable) (searchBarContainer.getBackground())).getColor(); - } else { - navbarColor = Color.WHITE; - } - searchTermTextColor = searchTermText.getCurrentTextColor(); - searchTermHintTextColor = searchTermText.getCurrentHintTextColor(); - } catch (Exception e) { - // just in case something in the layout changes out from underneath this code - navbarColor = Color.WHITE; - searchTermTextColor = Color.BLACK; - searchTermHintTextColor = Color.GRAY; - } searchResultsList = (ListView) parentLayout.findViewById(R.id.search_results_list); searchProgress = (ProgressBar) parentLayout.findViewById(R.id.search_progress); - searchBarIcon = parentLayout.findViewById(R.id.search_bar_icon); + View searchBarIcon = parentLayout.findViewById(R.id.search_bar_icon); searchNetworkError = parentLayout.findViewById(R.id.search_network_error); searchBarMenuButton = (ImageView)parentLayout.findViewById(R.id.search_bar_show_menu); searchBarTocButton = (ImageView)parentLayout.findViewById(R.id.search_bar_show_toc); drawerIndicator = (ImageView)parentLayout.findViewById(R.id.search_drawer_indicator); - wikipediaIcon = (ImageView)parentLayout.findViewById(R.id.wikipedia_icon); + ImageView wikipediaIcon = (ImageView) parentLayout.findViewById(R.id.wikipedia_icon); searchNoResults = parentLayout.findViewById(R.id.search_results_empty); app.adjustDrawableToTheme(wikipediaIcon.getDrawable()); diff --git a/wikipedia/src/main/java/org/wikipedia/views/FlowLayout.java b/wikipedia/src/main/java/org/wikipedia/views/FlowLayout.java index d3c8c8a..6019fb6 100644 --- a/wikipedia/src/main/java/org/wikipedia/views/FlowLayout.java +++ b/wikipedia/src/main/java/org/wikipedia/views/FlowLayout.java @@ -15,13 +15,12 @@ * to overflow onto multiple "lines". */ public class FlowLayout extends ViewGroup { - - Resources resources; - private List<Integer> lineHeights = new ArrayList<Integer>(); - private static final int HORIZONTAL_SPACING = 8; private static final int VERTICAL_SPACING = 8; + private Resources resources; + private List<Integer> lineHeights = new ArrayList<Integer>(); + public FlowLayout(Context context) { super(context); resources = context.getResources(); -- To view, visit https://gerrit.wikimedia.org/r/146693 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie8d634b683e4c1959f967d068d9774b7ee1cc0f1 Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: BearND <bsitzm...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits