Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	News-Android-App/build.gradle
#	News-Android-App/src/main/AndroidManifest.xml
#	News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsDetailActivity.java
#	News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsDetailFragment.java
#	News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java
#	News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/NewsListRecyclerAdapter.java
#	gradle/wrapper/gradle-wrapper.properties
  • Loading branch information
David-Development committed May 11, 2019
2 parents 5b420ec + 97334cc commit b6c7788
Show file tree
Hide file tree
Showing 33 changed files with 665 additions and 283 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Expand Up @@ -48,6 +48,9 @@ jobs:
- run:
name: Run unit tests
command: ./gradlew test
- run:
name: Run Lint Tests
command: ./gradlew lint test
- store_artifacts:
path: News-Android-App/build/reports
destination: reports
Expand Down
33 changes: 17 additions & 16 deletions News-Android-App/build.gradle
Expand Up @@ -118,7 +118,10 @@ repositories {
maven { url "https://dl.bintray.com/lukaville/maven" } //Needed for com.nbsp:library:1.02 in Material File Picker
}

final DAGGER_VERSION = '2.22.1'
final OKHTTP_VERSION = '3.12.2'
final MOCKITO_VERSION = '2.27.0'
final RETROFIT_VERSION = '2.5.0'

dependencies {
// core android studio module
Expand All @@ -141,7 +144,7 @@ dependencies {
implementation "com.google.android.material:material:1.1.0-alpha06"
//implementation "com.google.android.material:material:1.0.0"
implementation "androidx.palette:palette:1.0.0"
implementation "androidx.recyclerview:recyclerview:1.1.0-alpha3"
implementation "androidx.recyclerview:recyclerview:1.1.0-alpha05"
implementation "androidx.browser:browser:1.0.0"
implementation "androidx.cardview:cardview:1.0.0"
//implementation 'de.mrmaffen:holocircularprogressbar:1.0.1'
Expand All @@ -151,9 +154,6 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'

compileOnly 'com.google.auto.value:auto-value:1.1'
annotationProcessor 'com.google.auto.value:auto-value:1.1'

implementation 'com.sothree.slidinguppanel:library:3.2.1'

implementation 'org.greenrobot:eventbus:3.1.1'
Expand All @@ -165,21 +165,22 @@ dependencies {
//implementation 'org.apache.commons:commons-lang3:3.4'
implementation 'com.github.gabrielemariotti.changeloglib:changelog:2.1.0'
implementation 'org.jsoup:jsoup:1.11.3'
implementation ('net.rdrei.android.dirchooser:library:3.0@aar') { transitive = true }

implementation ('net.rdrei.android.dirchooser:library:3.0@aar') {
exclude group: 'com.google.auto.value', module: 'auto-value'
transitive = true
}

implementation 'com.google.dagger:dagger:2.22.1'
annotationProcessor "com.google.dagger:dagger-compiler:2.16"
compileOnly 'javax.annotation:jsr250-api:1.0'
implementation "com.google.dagger:dagger:${DAGGER_VERSION}"
annotationProcessor "com.google.dagger:dagger-compiler:${DAGGER_VERSION}"

implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
implementation 'io.reactivex.rxjava2:rxjava:2.1.4'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation "com.squareup.retrofit2:adapter-rxjava2:$RETROFIT_VERSION"

implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
implementation "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
implementation "com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}"
implementation "com.squareup.okhttp3:logging-interceptor:${OKHTTP_VERSION}"

Expand All @@ -189,23 +190,23 @@ dependencies {


testImplementation 'junit:junit:4.12'
testImplementation("org.mockito:mockito-core:1.10.19") {
testImplementation("org.mockito:mockito-core:$MOCKITO_VERSION") {
exclude group: 'org.hamcrest'
}
testImplementation 'com.google.dexmaker:dexmaker:1.2'
testImplementation 'com.google.dexmaker:dexmaker-mockito:1.2'
testImplementation "com.squareup.okhttp3:mockwebserver:${OKHTTP_VERSION}"


androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:2.16"
androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:${DAGGER_VERSION}"

// https://mvnrepository.com/artifact/com.squareup.okhttp3/mockwebserver
//androidTestImplementation "com.squareup.okhttp3:mockwebserver:${OKHTTP_VERSION}"


androidTestImplementation 'tools.fastlane:screengrab:1.2.0'
//androidTestImplementation 'org.mockito:mockito-core:2.25.1'
androidTestImplementation 'org.mockito:mockito-android:2.18.3'
//androidTestImplementation "org.mockito:mockito-core:MOCKITO_VERSION"
androidTestImplementation "org.mockito:mockito-android:$MOCKITO_VERSION"


//androidTestImplementation 'com.google.dexmaker:dexmaker:1.2'
Expand Down
3 changes: 1 addition & 2 deletions News-Android-App/src/main/AndroidManifest.xml
Expand Up @@ -21,7 +21,7 @@
<!-- Required for TwilightManager -->
<!-- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
android:name=".NewsReaderApplication"
android:allowBackup="true"
Expand Down Expand Up @@ -50,7 +50,6 @@

<activity
android:name=".NewsDetailActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/title_activity_news_detail" />

<activity android:name=".PiPVideoPlaybackActivity"
Expand Down
Expand Up @@ -36,13 +36,6 @@
import android.view.ViewGroup;
import android.widget.ProgressBar;

import java.lang.ref.WeakReference;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.inject.Inject;

import androidx.appcompat.widget.Toolbar;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.core.content.ContextCompat;
Expand All @@ -52,6 +45,14 @@
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;

import java.lang.ref.WeakReference;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import de.luhmer.owncloudnewsreader.database.DatabaseConnectionOrm;
Expand Down Expand Up @@ -141,8 +142,9 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setTitle(rssItem.getTitle());
break;
}
else
else {
item_id++;
}
}
}

Expand All @@ -159,7 +161,10 @@ protected void onCreate(Bundle savedInstanceState) {

try {
mViewPager.setCurrentItem(item_id, true);
pageChanged(item_id);
if(savedInstanceState == null) {
// Only do that when activity is started for the first time. Not on orientation changes etc..
pageChanged(item_id);
}
} catch(Exception ex) {
ex.printStackTrace();
}
Expand Down Expand Up @@ -244,23 +249,25 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {

private void pageChanged(int position)
{
StopVideoOnCurrentPage();
stopVideoOnCurrentPage();
currentPosition = position;
ResumeVideoPlayersOnCurrentPage();
resumeVideoPlayersOnCurrentPage();
progressIndicator.setProgress(position + 1);

getSupportActionBar().setTitle(rssItems.get(position).getTitle());

if(!rssItems.get(position).getRead_temp())
{
markItemAsReadUnread(rssItems.get(position), true);
RssItem rssItem = rssItems.get(position);
if(!rssItem.getRead_temp()) {
if (!NewsReaderListActivity.stayUnreadItems.contains(rssItem.getId())) {
markItemAsReadOrUnread(rssItems.get(position), true);
}

mPostDelayHandler.delayTimer();
mPostDelayHandler.delayTimer();

Log.v("PAGE CHANGED", "PAGE: " + position + " - IDFEED: " + rssItems.get(position).getId());
}
else { //Only in else because the function markItemAsReas updates the ActionBar items as well
UpdateActionBarIcons();
Log.v("PAGE CHANGED", "PAGE: " + position + " - IDFEED: " + rssItems.get(position).getId());
}
else {
updateActionBarIcons();
}
}

Expand All @@ -271,33 +278,30 @@ private NewsDetailFragment getNewsDetailFragmentAtPosition(int position) {
return null;
}

private void ResumeVideoPlayersOnCurrentPage()
{
private void resumeVideoPlayersOnCurrentPage() {
NewsDetailFragment fragment = getNewsDetailFragmentAtPosition(currentPosition);
if(fragment != null) // could be null if not instantiated yet
fragment.resumeCurrentPage();
if(fragment != null) { // could be null if not instantiated yet
fragment.resumeCurrentPage();
}

}

private void StopVideoOnCurrentPage()
{
private void stopVideoOnCurrentPage() {
NewsDetailFragment fragment = getNewsDetailFragmentAtPosition(currentPosition);
if(fragment != null) // could be null if not instantiated yet
fragment.pauseCurrentPage();
if(fragment != null) { // could be null if not instantiated yet
fragment.pauseCurrentPage();
}
}

public void UpdateActionBarIcons()
{
public void updateActionBarIcons() {
RssItem rssItem = rssItems.get(currentPosition);

boolean isStarred = rssItem.getStarred_temp();
boolean isRead = rssItem.getRead_temp();


PodcastItem podcastItem = DatabaseConnectionOrm.ParsePodcastItemFromRssItem(this, rssItem);
boolean podcastAvailable = !"".equals(podcastItem.link);


if(menuItem_PlayPodcast != null)
menuItem_PlayPodcast.setVisible(podcastAvailable);

Expand All @@ -307,8 +311,6 @@ public void UpdateActionBarIcons()
else if(menuItem_Starred != null)
menuItem_Starred.setIcon(R.drawable.ic_action_star_border_dark);



if(isRead && menuItem_Read != null) {
menuItem_Read.setIcon(R.drawable.ic_check_box_white);
menuItem_Read.setChecked(true);
Expand Down Expand Up @@ -354,7 +356,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
}
}

UpdateActionBarIcons();
updateActionBarIcons();

return true;
}
Expand All @@ -369,11 +371,12 @@ public boolean onOptionsItemSelected(MenuItem item) {
return true;

case R.id.action_read:
markItemAsReadUnread(rssItem, !menuItem_Read.isChecked());
UpdateActionBarIcons();
markItemAsReadOrUnread(rssItem, !menuItem_Read.isChecked());
updateActionBarIcons();
mPostDelayHandler.delayTimer();
break;


case R.id.action_starred:
toggleRssItemStarredState();
break;
Expand Down Expand Up @@ -478,7 +481,7 @@ public void toggleRssItemStarredState() {
rssItem.setStarred_temp(!curState);
dbConn.updateRssItem(rssItem);

UpdateActionBarIcons();
updateActionBarIcons();

mPostDelayHandler.delayTimer();
}
Expand All @@ -491,10 +494,12 @@ private boolean isChromeDefaultBrowser() {
return (resolveInfo.loadLabel(getPackageManager()).toString().contains("Chrome"));
}

private void markItemAsReadUnread(RssItem item, boolean read) {
private void markItemAsReadOrUnread(RssItem item, boolean read) {
NewsReaderListActivity.stayUnreadItems.add(item.getId());

item.setRead_temp(read);
dbConn.updateRssItem(item);
UpdateActionBarIcons();
dbConn.updateRssItem(item);
updateActionBarIcons();
}

@Override
Expand All @@ -512,20 +517,19 @@ public void finish() {
//public class SectionsPagerAdapter extends FragmentPagerAdapter {
public class SectionsPagerAdapter extends FragmentStatePagerAdapter {

SparseArray<WeakReference<NewsDetailFragment>> items = new SparseArray<>();
SparseArray<WeakReference<NewsDetailFragment>> items = new SparseArray<>();

public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);

if(fm.getFragments() != null) {
for (Fragment fragment : fm.getFragments()) {
if (fragment instanceof NewsDetailFragment) {
int id = ((NewsDetailFragment) fragment).getSectionNumber();
items.put(id, new WeakReference<>((NewsDetailFragment) fragment));
}
}
}
}
for (Fragment fragment : fm.getFragments()) {
if (fragment instanceof NewsDetailFragment) {
int id = ((NewsDetailFragment) fragment).getSectionNumber();
Log.v(TAG, "Retaining NewsDetailFragment with ID: " + id);
items.put(id, new WeakReference<>((NewsDetailFragment) fragment));
}
}
}

@Override
public Fragment getItem(int position) {
Expand All @@ -547,8 +551,7 @@ public Fragment getItem(int position) {
}

@Override
public void destroyItem(ViewGroup container, int position, Object object)
{
public void destroyItem(ViewGroup container, int position, Object object) {
items.remove(position);

super.destroyItem(container, position, object);
Expand Down

0 comments on commit b6c7788

Please sign in to comment.