Skip to content

Commit

Permalink
Merge pull request #41 from justin-cotarla/dev
Browse files Browse the repository at this point in the history
[Release 1] dev into master
  • Loading branch information
chriskfwoo committed Feb 12, 2019
2 parents 3adf5c6 + 59eacd5 commit 9838aeb
Show file tree
Hide file tree
Showing 42 changed files with 906 additions and 29 deletions.
41 changes: 41 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
language: android

before_cache:
-rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
-rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
-$HOME/.gradle/caches/
-$HOME/.gradle/wrapper/
-$HOME/.android/build-cache


env:
global:
- ANDROID_API=28
- ANDROID_BUILD_TOOLS=28.0.3
- ADB_INSTALL_TIMEOUT=5

android:
components:
- tools
- platform-tools
- build-tools-$ANDROID_BUILD_TOOLS
- android-$ANDROID_API

- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository

licenses:
- android-sdk-preview-license-.+
- android-sdk-license-.+
- google-gdk-license-.+

before_script:
- chmod +x gradlew

script:
- ./gradlew clean assembleDebug
- ./gradlew checkstyle
- ./gradlew testDevDebug
6 changes: 5 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ dependencies {
implementation "com.android.support:recyclerview-v7:$supportVersion"
implementation "com.android.support:palette-v7:$supportVersion"
implementation "com.android.support:preference-v14:$supportVersion"
implementation "com.android.support:exifinterface:$supportVersion"

implementation ('com.github.michael-rapp:chrome-like-tab-switcher:0.3.7') {
// TODO: remove when this component updates its own dependency on Support 28.0.0
Expand All @@ -240,6 +241,10 @@ dependencies {
implementation 'org.apache.commons:commons-lang3:3.8.1'
implementation 'org.jsoup:jsoup:1.11.3'

implementation 'com.google.api-client:google-api-client-android:1.22.0' exclude module: 'httpclient'
implementation 'com.google.http-client:google-http-client-gson:1.20.0' exclude module: 'httpclient'
implementation 'com.google.apis:google-api-services-vision:v1-rev2-1.21.0'

annotationProcessor "com.jakewharton:butterknife-compiler:$butterKnifeVersion"

android.productFlavors.each { flavor ->
Expand Down Expand Up @@ -269,7 +274,6 @@ dependencies {
androidTestImplementation "com.android.support.test:runner:$testingSupportVersion" // Android JUnit Runner
androidTestImplementation "com.android.support.test.espresso:espresso-core:$espressoVersion"
androidTestImplementation "com.android.support.test.espresso:espresso-contrib:$espressoVersion"

}

private setSigningConfigKey(config, Properties props) {
Expand Down
3 changes: 2 additions & 1 deletion app/proguard-rules-debug.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# --- Prevent crashes when getting SearchView from ActionMode --
# TODO: remove this file if no longer be able to reproduce this issue.
-keep class android.support.v7.widget.SearchView { *; }
# --- /Prevent crashes when getting SearchView from ActionMode --
# --- /Prevent crashes when getting SearchView from ActionMode --
-ignorewarnings
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
-->
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />

<!-- For image search -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera2" android:required="false" />

<application
android:allowBackup="true"
android:fullBackupContent="@xml/full_backup_rules"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ bridge.registerListener( "getTextSelection", function( payload ) {
if (text.length < 2 && payload.purpose === "share") {
text = getLeadParagraph();
}
if (text.length > 250) {
if (text.length > 250 && payload.purpose !== "hear") {
text = text.substring(0, 249);
}
if (payload.purpose === "edit_here") {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/org/wikipedia/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public final class Constants {
public static final int ACTIVITY_REQUEST_RESET_PASSWORD = 43;
public static final int ACTIVITY_REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION = 44;
public static final int ACTIVITY_REQUEST_VOICE_SEARCH = 45;
public static final int ACTIVITY_REQUEST_IMAGE_SEARCH = 46;
public static final int ACTIVITY_REQUEST_CAMERA_PERMISSION = 47;
public static final int ACTIVITY_REQUEST_READ_EXTERNAL_STORAGE_PERMISSION = 48;
public static final int ACTIVITY_REQUEST_LANGLINKS = 50;
public static final int ACTIVITY_REQUEST_EDIT_SECTION = 51;
public static final int ACTIVITY_REQUEST_GALLERY = 52;
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/org/wikipedia/feed/FeedFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class FeedFragment extends Fragment implements BackPressedHandler {
public interface Callback {
void onFeedSearchRequested();
void onFeedVoiceSearchRequested();
void onFeedImageSearchRequested();
void onFeedSelectPage(HistoryEntry entry);
void onFeedSelectPageFromExistingTab(HistoryEntry entry);
void onFeedAddPageToList(HistoryEntry entry);
Expand Down Expand Up @@ -399,6 +400,13 @@ public void onVoiceSearchRequested() {
}
}

@Override
public void onImageSearchRequested() {
if (getCallback() != null) {
getCallback().onFeedImageSearchRequested();
}
}

@Override
public boolean onRequestDismissCard(@NonNull Card card) {
int position = coordinator.dismissCard(card);
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/org/wikipedia/feed/searchbar/SearchCardView.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.wikipedia.feed.searchbar;

import android.content.Context;
import android.content.pm.PackageManager;

import org.wikipedia.R;
import org.wikipedia.feed.view.DefaultFeedCardView;
Expand All @@ -14,6 +15,7 @@ public class SearchCardView extends DefaultFeedCardView<SearchCard> {
public interface Callback {
void onSearchRequested();
void onVoiceSearchRequested();
void onImageSearchRequested();
}

public SearchCardView(Context context) {
Expand All @@ -22,6 +24,11 @@ public SearchCardView(Context context) {
setCardBackgroundColor(ResourceUtil.getThemedColor(context, R.attr.searchItemBackground));
ButterKnife.bind(this);
FeedbackUtil.setToolbarButtonLongPressToast(findViewById(R.id.voice_search_button));
FeedbackUtil.setToolbarButtonLongPressToast(findViewById(R.id.camera_search_button));

if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)) {
findViewById(R.id.camera_search_button).setVisibility(GONE);
}
}

@OnClick(R.id.search_container) void onSearchClick() {
Expand All @@ -35,4 +42,10 @@ public SearchCardView(Context context) {
getCallback().onVoiceSearchRequested();
}
}

@OnClick(R.id.camera_search_button) void onImageSearchClick() {
if (getCallback() != null) {
getCallback().onImageSearchRequested();
}
}
}
26 changes: 22 additions & 4 deletions app/src/main/java/org/wikipedia/history/HistoryFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public interface Callback {
private Unbinder unbinder;
@BindView(R.id.history_list) RecyclerView historyList;
@BindView(R.id.history_empty_container) View historyEmptyView;
@BindView(R.id.no_history_container) View noHistoryView;
@BindView(R.id.search_empty_view) SearchEmptyView searchEmptyView;

private WikipediaApp app;
Expand Down Expand Up @@ -100,7 +101,6 @@ public void onCreate(Bundle savedInstanceState) {
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_history, container, false);
unbinder = ButterKnife.bind(this, view);

searchEmptyView.setEmptyText(R.string.search_history_no_results);

ItemTouchHelper.Callback touchCallback = new SwipeableItemTouchHelperCallback(requireContext());
Expand Down Expand Up @@ -132,6 +132,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
public void onResume() {
super.onResume();
updateEmptyState();
updateNoHistoryViewState();
}

@Override
Expand Down Expand Up @@ -168,14 +169,25 @@ private void updateEmptyState() {
}

private void updateEmptyState(@Nullable String searchQuery) {
if (TextUtils.isEmpty(searchQuery)) {
if (Prefs.isHistoryTurnedOff()) {
searchEmptyView.setVisibility(View.GONE);
setEmptyContainerVisibility(false);
} else if (TextUtils.isEmpty(searchQuery)) {
searchEmptyView.setVisibility(View.GONE);
setEmptyContainerVisibility(adapter.isEmpty());
} else {
searchEmptyView.setVisibility(adapter.isEmpty() ? View.VISIBLE : View.GONE);
setEmptyContainerVisibility(false);
}
historyList.setVisibility(adapter.isEmpty() ? View.GONE : View.VISIBLE);
historyList.setVisibility(adapter.isEmpty() || Prefs.isHistoryTurnedOff() ? View.GONE : View.VISIBLE);
}

private void updateNoHistoryViewState() {
if (Prefs.isHistoryTurnedOff()) {
noHistoryView.setVisibility(View.VISIBLE);
} else {
noHistoryView.setVisibility(View.GONE);
}
}

private void setEmptyContainerVisibility(boolean visible) {
Expand All @@ -202,10 +214,16 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
boolean isHistoryAvailable = !adapter.isEmpty();

boolean isHistoryTurnedOff = Prefs.isHistoryTurnedOff();
boolean isHistoryAvailable = !adapter.isEmpty() && !isHistoryTurnedOff;
menu.findItem(R.id.menu_clear_all_history)
.setVisible(isHistoryAvailable)
.setEnabled(isHistoryAvailable);

menu.findItem(R.id.menu_search_history)
.setVisible(!isHistoryTurnedOff)
.setEnabled(!isHistoryTurnedOff);
}

@Override
Expand Down
15 changes: 9 additions & 6 deletions app/src/main/java/org/wikipedia/history/UpdateHistoryTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.wikipedia.WikipediaApp;
import org.wikipedia.database.DatabaseClient;
import org.wikipedia.database.contract.PageHistoryContract;
import org.wikipedia.settings.Prefs;

import io.reactivex.functions.Action;

Expand All @@ -21,12 +22,14 @@ public UpdateHistoryTask(HistoryEntry entry) {

@Override
public void run() throws Exception {
DatabaseClient<HistoryEntry> client = WikipediaApp.getInstance().getDatabaseClient(HistoryEntry.class);
client.upsert(new HistoryEntry(entry.getTitle(),
entry.getTimestamp(),
entry.getSource(),
entry.getTimeSpentSec() + getPreviousTimeSpent(client)),
PageHistoryContract.Page.SELECTION);
if (!Prefs.isHistoryTurnedOff()) {
DatabaseClient<HistoryEntry> client = WikipediaApp.getInstance().getDatabaseClient(HistoryEntry.class);
client.upsert(new HistoryEntry(entry.getTitle(),
entry.getTimestamp(),
entry.getSource(),
entry.getTimeSpentSec() + getPreviousTimeSpent(client)),
PageHistoryContract.Page.SELECTION);
}
}

private int getPreviousTimeSpent(@NonNull DatabaseClient<HistoryEntry> client) {
Expand Down
Loading

0 comments on commit 9838aeb

Please sign in to comment.