Update to 0.5.2
This commit is contained in:
parent
0eba1c301a
commit
663d4ea60f
28 changed files with 327 additions and 337 deletions
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="de.luhmer.owncloudnewsreader"
|
package="de.luhmer.owncloudnewsreader"
|
||||||
android:versionCode="35"
|
android:versionCode="36"
|
||||||
android:versionName="0.5.0" >
|
android:versionName="0.5.1" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="7"
|
android:minSdkVersion="7"
|
||||||
|
@ -12,6 +12,8 @@
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
|
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
|
||||||
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
||||||
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
|
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
|
||||||
|
@ -59,7 +61,9 @@
|
||||||
android:name="de.luhmer.owncloudnewsreader.SettingsActivity"
|
android:name="de.luhmer.owncloudnewsreader.SettingsActivity"
|
||||||
android:label="@string/title_activity_settings" >
|
android:label="@string/title_activity_settings" >
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".DownloadImagesActivity" />
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Sync Adapter and Service
|
* Sync Adapter and Service
|
||||||
|
|
|
@ -80,16 +80,20 @@ git clone https://github.com/owncloud/News-Android-App.git
|
||||||
|
|
||||||
Updates
|
Updates
|
||||||
==================================
|
==================================
|
||||||
0.5.1 (in development)
|
0.5.3 (in development)
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
0.5.2 (Google Play)
|
||||||
|
---------------------
|
||||||
|
- Improvement - Notification when background sync is enabled and new items are received
|
||||||
|
- Improvement - Fix high CPU-Load in Detail-View
|
||||||
|
|
||||||
0.5.0 (Google Play)
|
0.5.0 (Google Play)
|
||||||
---------------------
|
---------------------
|
||||||
- Improvement - <a href="https://github.com/owncloud/News-Android-App/issues/162">#162 New items available notification pops up when there really aren't</a>
|
- Improvement - <a href="https://github.com/owncloud/News-Android-App/issues/162">#162 New items available notification pops up when there really aren't</a>
|
||||||
- Improvement - <a href="https://github.com/owncloud/News-Android-App/issues/160">#160 Widget font size</a>
|
- Improvement - <a href="https://github.com/owncloud/News-Android-App/issues/160">#160 Widget font size</a>
|
||||||
- Improvement - <a href="https://github.com/owncloud/News-Android-App/issues/161">#161 'Send via' should be removed from sharing </a>
|
- Improvement - <a href="https://github.com/owncloud/News-Android-App/issues/161">#161 'Send via' should be removed from sharing </a>
|
||||||
|
|
||||||
|
|
||||||
0.4.11
|
0.4.11
|
||||||
---------------------
|
---------------------
|
||||||
- Critical Bug fix - <a href="https://github.com/owncloud/News-Android-App/issues/158">#158 0.4.10 instantly crashes when opening</a>
|
- Critical Bug fix - <a href="https://github.com/owncloud/News-Android-App/issues/158">#158 0.4.10 instantly crashes when opening</a>
|
||||||
|
|
|
@ -8,19 +8,30 @@
|
||||||
var images = document.getElementsByTagName('img');
|
var images = document.getElementsByTagName('img');
|
||||||
|
|
||||||
for (var i = 1; i < images.length; i++) {// i = 1 because of the feed image which has no caption
|
for (var i = 1; i < images.length; i++) {// i = 1 because of the feed image which has no caption
|
||||||
if(images[i].getAttribute('title') != "") {
|
if(images[i].getAttribute('title') != "" && images[i].getAttribute('title') != null) {
|
||||||
(function (image) {
|
(function (image) {
|
||||||
var timer;
|
var timer;
|
||||||
image.addEventListener('mouseup', function() {
|
image.addEventListener('mouseup', function() {
|
||||||
console.log("clear");
|
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
});
|
});
|
||||||
|
|
||||||
image.addEventListener('mousedown', function () {
|
image.addEventListener('mousedown', function (e) {
|
||||||
timer = window.setTimeout(function() {
|
timer = window.setTimeout(function() {
|
||||||
alert(image.getAttribute('title'));
|
e.preventDefault();
|
||||||
|
alert(image.getAttribute('title'));
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
image.addEventListener("touchstart", function(e){
|
||||||
|
timer = window.setTimeout(function() {
|
||||||
|
e.preventDefault();
|
||||||
|
alert(image.getAttribute('title'));
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
|
||||||
|
image.addEventListener('touchend', function() {
|
||||||
|
clearTimeout(timer);
|
||||||
|
});
|
||||||
})(images[i]);
|
})(images[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<!--<string name="non_sorted_articles">Nicht zugeordnete Artikel</string>-->
|
|
||||||
<!--EMAIL-->
|
|
||||||
<!--Action Bar Items-->
|
|
||||||
<!--Strings related to login-->
|
|
||||||
<!--<string name="pref_title_owncloudRootPath">ownCloud root address</string>-->
|
|
||||||
<!--<string name="pref_default_username">admin</string>-->
|
|
||||||
<!--Toast Messages-->
|
|
||||||
<!--Strings related to Settings-->
|
|
||||||
<!--General settings-->
|
|
||||||
<!--<string-array name="pref_general_sort_order_values">
|
|
||||||
<item>desc</item>
|
|
||||||
<item>asc</item>
|
|
||||||
</string-array>-->
|
|
||||||
<!--<string name="pref_title_social_recommendations">Enable social recommendations</string>
|
|
||||||
<string name="pref_description_social_recommendations">Recommendations for people to contact based on your message history</string>-->
|
|
||||||
<!--<string name="pref_title_AllowAllSSLCertificates">Allow all SSL Certificates</string>-->
|
|
||||||
<!--MemorizingTrustManager-->
|
|
||||||
<!--Settings for Display-->
|
|
||||||
<!--Login Dialog-->
|
|
||||||
<!--Data & Sync-->
|
|
||||||
<!--<string name="pref_title_data_sync_max_items">Max number of items to sync</string>-->
|
|
||||||
<!--<string name="pref_title_sync_frequency">Sync frequency</string>
|
|
||||||
|
|
||||||
<string-array name="pref_sync_frequency_titles">
|
|
||||||
<item>15 minutes</item>
|
|
||||||
<item>30 minutes</item>
|
|
||||||
<item>1 hour</item>
|
|
||||||
<item>3 hours</item>
|
|
||||||
<item>6 hours</item>
|
|
||||||
<item>Never</item>
|
|
||||||
</string-array>
|
|
||||||
<string-array name="pref_sync_frequency_values">
|
|
||||||
<item>15</item>
|
|
||||||
<item>30</item>
|
|
||||||
<item>60</item>
|
|
||||||
<item>180</item>
|
|
||||||
<item>360</item>
|
|
||||||
<item>-1</item>
|
|
||||||
</string-array>-->
|
|
||||||
<!--<string name="pref_title_system_sync_settings">System sync settings</string>-->
|
|
||||||
<!--Example settings for Notifications-->
|
|
||||||
<!--<string name="pref_header_notifications">Notifications</string>
|
|
||||||
<string name="pref_title_new_message_notifications">New message notifications</string>
|
|
||||||
<string name="pref_title_ringtone">Ringtone</string>
|
|
||||||
<string name="pref_ringtone_silent">Silent</string>
|
|
||||||
<string name="pref_title_vibrate">Vibrate</string>-->
|
|
||||||
</resources>
|
|
|
@ -1,49 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<!--<string name="non_sorted_articles">Nicht zugeordnete Artikel</string>-->
|
|
||||||
<!--EMAIL-->
|
|
||||||
<!--Action Bar Items-->
|
|
||||||
<!--Strings related to login-->
|
|
||||||
<!--<string name="pref_title_owncloudRootPath">ownCloud root address</string>-->
|
|
||||||
<!--<string name="pref_default_username">admin</string>-->
|
|
||||||
<!--Toast Messages-->
|
|
||||||
<!--Strings related to Settings-->
|
|
||||||
<!--General settings-->
|
|
||||||
<!--<string-array name="pref_general_sort_order_values">
|
|
||||||
<item>desc</item>
|
|
||||||
<item>asc</item>
|
|
||||||
</string-array>-->
|
|
||||||
<!--<string name="pref_title_social_recommendations">Enable social recommendations</string>
|
|
||||||
<string name="pref_description_social_recommendations">Recommendations for people to contact based on your message history</string>-->
|
|
||||||
<!--<string name="pref_title_AllowAllSSLCertificates">Allow all SSL Certificates</string>-->
|
|
||||||
<!--MemorizingTrustManager-->
|
|
||||||
<!--Settings for Display-->
|
|
||||||
<!--Login Dialog-->
|
|
||||||
<!--Data & Sync-->
|
|
||||||
<!--<string name="pref_title_data_sync_max_items">Max number of items to sync</string>-->
|
|
||||||
<!--<string name="pref_title_sync_frequency">Sync frequency</string>
|
|
||||||
|
|
||||||
<string-array name="pref_sync_frequency_titles">
|
|
||||||
<item>15 minutes</item>
|
|
||||||
<item>30 minutes</item>
|
|
||||||
<item>1 hour</item>
|
|
||||||
<item>3 hours</item>
|
|
||||||
<item>6 hours</item>
|
|
||||||
<item>Never</item>
|
|
||||||
</string-array>
|
|
||||||
<string-array name="pref_sync_frequency_values">
|
|
||||||
<item>15</item>
|
|
||||||
<item>30</item>
|
|
||||||
<item>60</item>
|
|
||||||
<item>180</item>
|
|
||||||
<item>360</item>
|
|
||||||
<item>-1</item>
|
|
||||||
</string-array>-->
|
|
||||||
<!--<string name="pref_title_system_sync_settings">System sync settings</string>-->
|
|
||||||
<!--Example settings for Notifications-->
|
|
||||||
<!--<string name="pref_header_notifications">Notifications</string>
|
|
||||||
<string name="pref_title_new_message_notifications">New message notifications</string>
|
|
||||||
<string name="pref_title_ringtone">Ringtone</string>
|
|
||||||
<string name="pref_ringtone_silent">Silent</string>
|
|
||||||
<string name="pref_title_vibrate">Vibrate</string>-->
|
|
||||||
</resources>
|
|
|
@ -1,50 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<!--<string name="non_sorted_articles">Nicht zugeordnete Artikel</string>-->
|
|
||||||
<!--EMAIL-->
|
|
||||||
<!--Action Bar Items-->
|
|
||||||
<!--Strings related to login-->
|
|
||||||
<string name="pref_title_password">Secret Code</string>
|
|
||||||
<!--<string name="pref_title_owncloudRootPath">ownCloud root address</string>-->
|
|
||||||
<!--<string name="pref_default_username">admin</string>-->
|
|
||||||
<!--Toast Messages-->
|
|
||||||
<!--Strings related to Settings-->
|
|
||||||
<!--General settings-->
|
|
||||||
<!--<string-array name="pref_general_sort_order_values">
|
|
||||||
<item>desc</item>
|
|
||||||
<item>asc</item>
|
|
||||||
</string-array>-->
|
|
||||||
<!--<string name="pref_title_social_recommendations">Enable social recommendations</string>
|
|
||||||
<string name="pref_description_social_recommendations">Recommendations for people to contact based on your message history</string>-->
|
|
||||||
<!--<string name="pref_title_AllowAllSSLCertificates">Allow all SSL Certificates</string>-->
|
|
||||||
<!--MemorizingTrustManager-->
|
|
||||||
<!--Settings for Display-->
|
|
||||||
<!--Login Dialog-->
|
|
||||||
<!--Data & Sync-->
|
|
||||||
<!--<string name="pref_title_data_sync_max_items">Max number of items to sync</string>-->
|
|
||||||
<!--<string name="pref_title_sync_frequency">Sync frequency</string>
|
|
||||||
|
|
||||||
<string-array name="pref_sync_frequency_titles">
|
|
||||||
<item>15 minutes</item>
|
|
||||||
<item>30 minutes</item>
|
|
||||||
<item>1 hour</item>
|
|
||||||
<item>3 hours</item>
|
|
||||||
<item>6 hours</item>
|
|
||||||
<item>Never</item>
|
|
||||||
</string-array>
|
|
||||||
<string-array name="pref_sync_frequency_values">
|
|
||||||
<item>15</item>
|
|
||||||
<item>30</item>
|
|
||||||
<item>60</item>
|
|
||||||
<item>180</item>
|
|
||||||
<item>360</item>
|
|
||||||
<item>-1</item>
|
|
||||||
</string-array>-->
|
|
||||||
<!--<string name="pref_title_system_sync_settings">System sync settings</string>-->
|
|
||||||
<!--Example settings for Notifications-->
|
|
||||||
<!--<string name="pref_header_notifications">Notifications</string>
|
|
||||||
<string name="pref_title_new_message_notifications">New message notifications</string>
|
|
||||||
<string name="pref_title_ringtone">Ringtone</string>
|
|
||||||
<string name="pref_ringtone_silent">Silent</string>
|
|
||||||
<string name="pref_title_vibrate">Vibrate</string>-->
|
|
||||||
</resources>
|
|
|
@ -1,49 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<!--<string name="non_sorted_articles">Nicht zugeordnete Artikel</string>-->
|
|
||||||
<!--EMAIL-->
|
|
||||||
<!--Action Bar Items-->
|
|
||||||
<!--Strings related to login-->
|
|
||||||
<!--<string name="pref_title_owncloudRootPath">ownCloud root address</string>-->
|
|
||||||
<!--<string name="pref_default_username">admin</string>-->
|
|
||||||
<!--Toast Messages-->
|
|
||||||
<!--Strings related to Settings-->
|
|
||||||
<!--General settings-->
|
|
||||||
<!--<string-array name="pref_general_sort_order_values">
|
|
||||||
<item>desc</item>
|
|
||||||
<item>asc</item>
|
|
||||||
</string-array>-->
|
|
||||||
<!--<string name="pref_title_social_recommendations">Enable social recommendations</string>
|
|
||||||
<string name="pref_description_social_recommendations">Recommendations for people to contact based on your message history</string>-->
|
|
||||||
<!--<string name="pref_title_AllowAllSSLCertificates">Allow all SSL Certificates</string>-->
|
|
||||||
<!--MemorizingTrustManager-->
|
|
||||||
<!--Settings for Display-->
|
|
||||||
<!--Login Dialog-->
|
|
||||||
<!--Data & Sync-->
|
|
||||||
<!--<string name="pref_title_data_sync_max_items">Max number of items to sync</string>-->
|
|
||||||
<!--<string name="pref_title_sync_frequency">Sync frequency</string>
|
|
||||||
|
|
||||||
<string-array name="pref_sync_frequency_titles">
|
|
||||||
<item>15 minutes</item>
|
|
||||||
<item>30 minutes</item>
|
|
||||||
<item>1 hour</item>
|
|
||||||
<item>3 hours</item>
|
|
||||||
<item>6 hours</item>
|
|
||||||
<item>Never</item>
|
|
||||||
</string-array>
|
|
||||||
<string-array name="pref_sync_frequency_values">
|
|
||||||
<item>15</item>
|
|
||||||
<item>30</item>
|
|
||||||
<item>60</item>
|
|
||||||
<item>180</item>
|
|
||||||
<item>360</item>
|
|
||||||
<item>-1</item>
|
|
||||||
</string-array>-->
|
|
||||||
<!--<string name="pref_title_system_sync_settings">System sync settings</string>-->
|
|
||||||
<!--Example settings for Notifications-->
|
|
||||||
<!--<string name="pref_header_notifications">Notifications</string>
|
|
||||||
<string name="pref_title_new_message_notifications">New message notifications</string>
|
|
||||||
<string name="pref_title_ringtone">Ringtone</string>
|
|
||||||
<string name="pref_ringtone_silent">Silent</string>
|
|
||||||
<string name="pref_title_vibrate">Vibrate</string>-->
|
|
||||||
</resources>
|
|
|
@ -1,49 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<!--<string name="non_sorted_articles">Nicht zugeordnete Artikel</string>-->
|
|
||||||
<!--EMAIL-->
|
|
||||||
<!--Action Bar Items-->
|
|
||||||
<!--Strings related to login-->
|
|
||||||
<!--<string name="pref_title_owncloudRootPath">ownCloud root address</string>-->
|
|
||||||
<!--<string name="pref_default_username">admin</string>-->
|
|
||||||
<!--Toast Messages-->
|
|
||||||
<!--Strings related to Settings-->
|
|
||||||
<!--General settings-->
|
|
||||||
<!--<string-array name="pref_general_sort_order_values">
|
|
||||||
<item>desc</item>
|
|
||||||
<item>asc</item>
|
|
||||||
</string-array>-->
|
|
||||||
<!--<string name="pref_title_social_recommendations">Enable social recommendations</string>
|
|
||||||
<string name="pref_description_social_recommendations">Recommendations for people to contact based on your message history</string>-->
|
|
||||||
<!--<string name="pref_title_AllowAllSSLCertificates">Allow all SSL Certificates</string>-->
|
|
||||||
<!--MemorizingTrustManager-->
|
|
||||||
<!--Settings for Display-->
|
|
||||||
<!--Login Dialog-->
|
|
||||||
<!--Data & Sync-->
|
|
||||||
<!--<string name="pref_title_data_sync_max_items">Max number of items to sync</string>-->
|
|
||||||
<!--<string name="pref_title_sync_frequency">Sync frequency</string>
|
|
||||||
|
|
||||||
<string-array name="pref_sync_frequency_titles">
|
|
||||||
<item>15 minutes</item>
|
|
||||||
<item>30 minutes</item>
|
|
||||||
<item>1 hour</item>
|
|
||||||
<item>3 hours</item>
|
|
||||||
<item>6 hours</item>
|
|
||||||
<item>Never</item>
|
|
||||||
</string-array>
|
|
||||||
<string-array name="pref_sync_frequency_values">
|
|
||||||
<item>15</item>
|
|
||||||
<item>30</item>
|
|
||||||
<item>60</item>
|
|
||||||
<item>180</item>
|
|
||||||
<item>360</item>
|
|
||||||
<item>-1</item>
|
|
||||||
</string-array>-->
|
|
||||||
<!--<string name="pref_title_system_sync_settings">System sync settings</string>-->
|
|
||||||
<!--Example settings for Notifications-->
|
|
||||||
<!--<string name="pref_header_notifications">Notifications</string>
|
|
||||||
<string name="pref_title_new_message_notifications">New message notifications</string>
|
|
||||||
<string name="pref_title_ringtone">Ringtone</string>
|
|
||||||
<string name="pref_ringtone_silent">Silent</string>
|
|
||||||
<string name="pref_title_vibrate">Vibrate</string>-->
|
|
||||||
</resources>
|
|
|
@ -53,7 +53,8 @@
|
||||||
<string name="action_login">Server Settings</string>
|
<string name="action_login">Server Settings</string>
|
||||||
|
|
||||||
|
|
||||||
|
<string name="notification_new_items_ticker">You have X new unread items</string>
|
||||||
|
<string name="notification_new_items_text">X new unread items available</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Strings related to login -->
|
<!-- Strings related to login -->
|
||||||
|
|
44
src/de/luhmer/owncloudnewsreader/DownloadImagesActivity.java
Normal file
44
src/de/luhmer/owncloudnewsreader/DownloadImagesActivity.java
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
package de.luhmer.owncloudnewsreader;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import de.luhmer.owncloudnewsreader.reader.owncloud.AsyncTask_GetItems;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by david on 14.10.13.
|
||||||
|
*/
|
||||||
|
public class DownloadImagesActivity extends Activity {
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
final long highestItemIdBeforeSync = getIntent().getLongExtra("highestItemIdBeforeSync", 0);
|
||||||
|
|
||||||
|
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
|
||||||
|
|
||||||
|
// set title
|
||||||
|
alertDialogBuilder.setTitle(getString(R.string.no_wifi_available));
|
||||||
|
|
||||||
|
// set dialog message
|
||||||
|
alertDialogBuilder
|
||||||
|
.setMessage(getString(R.string.do_you_want_to_download_without_wifi))
|
||||||
|
.setCancelable(true)
|
||||||
|
.setPositiveButton(getString(android.R.string.yes) ,new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog,int id) {
|
||||||
|
AsyncTask_GetItems.StartDownloadingImages(DownloadImagesActivity.this, highestItemIdBeforeSync);
|
||||||
|
DownloadImagesActivity.this.finish();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
DownloadImagesActivity.this.finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||||
|
|
||||||
|
alertDialog.show();
|
||||||
|
}
|
||||||
|
}
|
|
@ -277,7 +277,7 @@ public class NewsDetailActivity extends SherlockFragmentActivity {
|
||||||
{
|
{
|
||||||
NewsDetailFragment fragment = (NewsDetailFragment) getSupportFragmentManager().findFragmentByTag("android:switcher:" + R.id.pager + ":" + currentPosition);
|
NewsDetailFragment fragment = (NewsDetailFragment) getSupportFragmentManager().findFragmentByTag("android:switcher:" + R.id.pager + ":" + currentPosition);
|
||||||
if(fragment != null) // could be null if not instantiated yet
|
if(fragment != null) // could be null if not instantiated yet
|
||||||
fragment.ResumeVideoPlayers();
|
fragment.ResumCurrentPage();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ public class NewsDetailActivity extends SherlockFragmentActivity {
|
||||||
{
|
{
|
||||||
NewsDetailFragment fragment = (NewsDetailFragment) getSupportFragmentManager().findFragmentByTag("android:switcher:" + R.id.pager + ":" + currentPosition);
|
NewsDetailFragment fragment = (NewsDetailFragment) getSupportFragmentManager().findFragmentByTag("android:switcher:" + R.id.pager + ":" + currentPosition);
|
||||||
if(fragment != null) // could be null if not instantiated yet
|
if(fragment != null) // could be null if not instantiated yet
|
||||||
fragment.StopVideoPlayers();
|
fragment.PauseCurrentPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateActionBarIcons()
|
public void UpdateActionBarIcons()
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class NewsDetailFragment extends SherlockFragment {
|
||||||
private ProgressBar progressbar_webview;
|
private ProgressBar progressbar_webview;
|
||||||
private int section_number;
|
private int section_number;
|
||||||
|
|
||||||
public NewsDetailFragment() {
|
public NewsDetailFragment() {
|
||||||
//setRetainInstance(true);
|
//setRetainInstance(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,44 +72,57 @@ public class NewsDetailFragment extends SherlockFragment {
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
webview.saveState(outState);
|
webview.saveState(outState);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
@Override
|
||||||
@Override
|
public void onResume() {
|
||||||
public void onPause() {
|
super.onResume();
|
||||||
super.onPause();
|
ResumCurrentPage();
|
||||||
StopVideoPlayers();
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
PauseCurrentPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopVideoPlayers()
|
@Override
|
||||||
{
|
public void onDestroy() {
|
||||||
try {
|
super.onDestroy();
|
||||||
|
if(webview != null) {
|
||||||
|
webview.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
|
||||||
|
public void PauseCurrentPage()
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
Class.forName("android.webkit.WebView")
|
Class.forName("android.webkit.WebView")
|
||||||
.getMethod("onPause", (Class[]) null)
|
.getMethod("onPause", (Class[]) null)
|
||||||
.invoke(webview, (Object[]) null);
|
.invoke(webview, (Object[]) null);
|
||||||
*/
|
*/
|
||||||
if(webview != null)
|
if(webview != null) {
|
||||||
webview.onPause();
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
|
||||||
} catch(Exception ex) {
|
webview.onPause();
|
||||||
ex.printStackTrace();
|
webview.pauseTimers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
|
||||||
public void ResumeVideoPlayers()
|
public void ResumCurrentPage()
|
||||||
{
|
{
|
||||||
try {
|
|
||||||
/*
|
/*
|
||||||
Class.forName("android.webkit.WebView")
|
Class.forName("android.webkit.WebView")
|
||||||
.getMethod("onResume", (Class[]) null)
|
.getMethod("onResume", (Class[]) null)
|
||||||
.invoke(webview, (Object[]) null);
|
.invoke(webview, (Object[]) null);
|
||||||
*/
|
*/
|
||||||
if(webview != null)
|
if(webview != null) {
|
||||||
webview.onResume();
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
|
||||||
} catch(Exception ex) {
|
webview.onResume();
|
||||||
ex.printStackTrace();
|
webview.resumeTimers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
|
@ -313,6 +313,9 @@ public class NewsReaderDetailFragment extends SherlockListFragment implements IO
|
||||||
onlyStarredItems = true;
|
onlyStarredItems = true;
|
||||||
|
|
||||||
DatabaseConnection dbConn = new DatabaseConnection(context);
|
DatabaseConnection dbConn = new DatabaseConnection(context);
|
||||||
|
|
||||||
|
dbConn.clearDatabaseOverSize();
|
||||||
|
|
||||||
String sqlSelectStatement = null;
|
String sqlSelectStatement = null;
|
||||||
if(idFeed != null)
|
if(idFeed != null)
|
||||||
sqlSelectStatement = dbConn.getAllItemsIdsForFeedSQL(idFeed, onlyUnreadItems, onlyStarredItems, getSortDirection(context));
|
sqlSelectStatement = dbConn.getAllItemsIdsForFeedSQL(idFeed, onlyUnreadItems, onlyStarredItems, getSortDirection(context));
|
||||||
|
|
|
@ -48,6 +48,7 @@ import org.codechimp.apprater.AppRater;
|
||||||
import de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter;
|
import de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter;
|
||||||
import de.luhmer.owncloudnewsreader.LoginDialogFragment.LoginSuccessfullListener;
|
import de.luhmer.owncloudnewsreader.LoginDialogFragment.LoginSuccessfullListener;
|
||||||
import de.luhmer.owncloudnewsreader.authentication.AccountGeneral;
|
import de.luhmer.owncloudnewsreader.authentication.AccountGeneral;
|
||||||
|
import de.luhmer.owncloudnewsreader.cursor.NewsListCursorAdapter;
|
||||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||||
import de.luhmer.owncloudnewsreader.helper.MenuUtilsSherlockFragmentActivity;
|
import de.luhmer.owncloudnewsreader.helper.MenuUtilsSherlockFragmentActivity;
|
||||||
import de.luhmer.owncloudnewsreader.helper.ThemeChooser;
|
import de.luhmer.owncloudnewsreader.helper.ThemeChooser;
|
||||||
|
@ -498,7 +499,8 @@ public class NewsReaderListActivity extends MenuUtilsSherlockFragmentActivity im
|
||||||
{
|
{
|
||||||
NewsReaderDetailFragment nrD = (NewsReaderDetailFragment) getSupportFragmentManager().findFragmentById(R.id.content_frame);
|
NewsReaderDetailFragment nrD = (NewsReaderDetailFragment) getSupportFragmentManager().findFragmentById(R.id.content_frame);
|
||||||
if(nrD != null)
|
if(nrD != null)
|
||||||
nrD.UpdateCursor();
|
((NewsListCursorAdapter)nrD.getListAdapter()).notifyDataSetChanged();
|
||||||
|
//nrD.UpdateCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ public class NewsReaderListFragment extends SherlockFragment implements OnCreate
|
||||||
int newItemsCount = mPrefs.getInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING, 0);
|
int newItemsCount = mPrefs.getInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING, 0);
|
||||||
if(newItemsCount > 0) {
|
if(newItemsCount > 0) {
|
||||||
MessageBar messageBar = new MessageBar(getActivity(), true);
|
MessageBar messageBar = new MessageBar(getActivity(), true);
|
||||||
TextMessage textMessage = new TextMessage(getString(R.string.message_bar_new_articles_available), getString(R.string.message_bar_reload), R.drawable.ic_menu_refresh);
|
TextMessage textMessage = new TextMessage( newItemsCount + " " + getString(R.string.message_bar_new_articles_available), getString(R.string.message_bar_reload), R.drawable.ic_menu_refresh);
|
||||||
textMessage.setClickListener(mListener);
|
textMessage.setClickListener(mListener);
|
||||||
messageBar.show(textMessage);
|
messageBar.show(textMessage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -810,9 +810,9 @@ public class DatabaseConnection {
|
||||||
return database.update(SUBSCRIPTION_TABLE, contentValues, SUBSCRIPTION_ID + "= ?", new String[] { subscription_id });
|
return database.update(SUBSCRIPTION_TABLE, contentValues, SUBSCRIPTION_ID + "= ?", new String[] { subscription_id });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertNewItem (String Titel, String link, String description, Boolean isRead, String ID_SUBSCRIPTION, String ID_RSSITEM, Date timestamp, Boolean isStarred, String guid, String guidHash, String lastModified, String author) {
|
public void insertNewItem (String title, String link, String description, Boolean isRead, String ID_SUBSCRIPTION, String ID_RSSITEM, Date timestamp, Boolean isStarred, String guid, String guidHash, String lastModified, String author, boolean insertItem) {
|
||||||
ContentValues contentValues = new ContentValues();
|
ContentValues contentValues = new ContentValues();
|
||||||
contentValues.put(RSS_ITEM_TITLE, Titel);
|
contentValues.put(RSS_ITEM_TITLE, title);
|
||||||
contentValues.put(RSS_ITEM_LINK, link);
|
contentValues.put(RSS_ITEM_LINK, link);
|
||||||
contentValues.put(RSS_ITEM_BODY, description);
|
contentValues.put(RSS_ITEM_BODY, description);
|
||||||
contentValues.put(RSS_ITEM_READ, isRead);
|
contentValues.put(RSS_ITEM_READ, isRead);
|
||||||
|
@ -828,7 +828,12 @@ public class DatabaseConnection {
|
||||||
contentValues.put(RSS_ITEM_READ_TEMP, isRead);
|
contentValues.put(RSS_ITEM_READ_TEMP, isRead);
|
||||||
contentValues.put(RSS_ITEM_STARRED_TEMP, isStarred);
|
contentValues.put(RSS_ITEM_STARRED_TEMP, isStarred);
|
||||||
|
|
||||||
long result = database.insert(RSS_ITEM_TABLE, null, contentValues);
|
long result = 0;
|
||||||
|
if(insertItem)
|
||||||
|
result = database.insert(RSS_ITEM_TABLE, null, contentValues);
|
||||||
|
else
|
||||||
|
result = database.update(RSS_ITEM_TABLE, contentValues, RSS_ITEM_RSSITEM_ID + "=?", new String[] { ID_RSSITEM });
|
||||||
|
|
||||||
Log.d("DatabaseConnection", "Inserted Rows: " + result);
|
Log.d("DatabaseConnection", "Inserted Rows: " + result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
package de.luhmer.owncloudnewsreader.helper;
|
||||||
|
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
|
||||||
|
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
|
||||||
|
import de.luhmer.owncloudnewsreader.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by david on 29.10.13.
|
||||||
|
*/
|
||||||
|
public class NotificationManagerNewsReader {
|
||||||
|
private static NotificationManagerNewsReader instance;
|
||||||
|
private final int NOTIFICATION_ID = 0;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
public static NotificationManagerNewsReader getInstance(Context context)
|
||||||
|
{
|
||||||
|
if(instance == null)
|
||||||
|
instance = new NotificationManagerNewsReader(context);
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificationManagerNewsReader(Context context)
|
||||||
|
{
|
||||||
|
this.context = context;
|
||||||
|
//NOTIFICATION_ID = new Random().nextInt();
|
||||||
|
//NOTIFICATION_ID = new Random().nextInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void ShowMessage(String title, String tickerMessage, String message)
|
||||||
|
{
|
||||||
|
NotificationCompat.Builder builder =
|
||||||
|
new NotificationCompat.Builder(context)
|
||||||
|
.setSmallIcon(R.drawable.ic_launcher)
|
||||||
|
.setTicker(tickerMessage)
|
||||||
|
.setContentTitle(title)
|
||||||
|
//.setDefaults(Notification.DEFAULT_ALL)
|
||||||
|
.setAutoCancel(true)
|
||||||
|
.setContentText(message);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
myNotification = new NotificationCompat.Builder(context)
|
||||||
|
.setContentTitle("Exercise of Notification!")
|
||||||
|
.setContentText("http://android-er.blogspot.com/")
|
||||||
|
.setTicker("Notification!")
|
||||||
|
.setWhen(System.currentTimeMillis())
|
||||||
|
.setContentIntent(pendingIntent)
|
||||||
|
.setDefaults(Notification.DEFAULT_SOUND)
|
||||||
|
.setAutoCancel(true)
|
||||||
|
.setSmallIcon(R.drawable.ic_launcher)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
Intent notificationIntent = new Intent(context, NewsReaderListActivity.class);
|
||||||
|
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
builder.setContentIntent(contentIntent);
|
||||||
|
|
||||||
|
// Add as notification
|
||||||
|
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
manager.notify(NOTIFICATION_ID, builder.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove notification
|
||||||
|
public void RemoveNotification() {
|
||||||
|
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
manager.cancel(NOTIFICATION_ID);
|
||||||
|
}
|
||||||
|
}
|
|
@ -165,17 +165,20 @@ public class InsertIntoDatabase {
|
||||||
dbConn.closeDatabase();
|
dbConn.closeDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InsertSingleFeedItemIntoDatabase(RssFile rssFile, DatabaseConnection dbConn)
|
public static boolean InsertSingleFeedItemIntoDatabase(RssFile rssFile, DatabaseConnection dbConn)
|
||||||
{
|
{
|
||||||
|
boolean newItem = false;
|
||||||
|
|
||||||
if(rssFile != null)
|
if(rssFile != null)
|
||||||
{
|
{
|
||||||
Boolean isFeedAlreadyInDatabase = dbConn.doesRssItemAlreadyExsists(rssFile.getItem_Id());
|
Boolean isFeedAlreadyInDatabase = dbConn.doesRssItemAlreadyExsists(rssFile.getItem_Id());
|
||||||
|
|
||||||
|
/*
|
||||||
if(isFeedAlreadyInDatabase)
|
if(isFeedAlreadyInDatabase)
|
||||||
{
|
{
|
||||||
int result = dbConn.removeItemByItemId(rssFile.getItem_Id());
|
int result = dbConn.removeItemByItemId(rssFile.getItem_Id());
|
||||||
Log.d(TAG, "Delete Item: " + result);
|
Log.d(TAG, "Delete Item: " + result);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
String FeedId_Db = dbConn.getRowIdBySubscriptionID(String.valueOf(rssFile.getFeedID()));
|
String FeedId_Db = dbConn.getRowIdBySubscriptionID(String.valueOf(rssFile.getFeedID()));
|
||||||
//String IdSubscription = dbConn.getIdSubscriptionByStreamID(rssFile.getFeedID());
|
//String IdSubscription = dbConn.getIdSubscriptionByStreamID(rssFile.getFeedID());
|
||||||
|
@ -194,10 +197,15 @@ public class InsertIntoDatabase {
|
||||||
rssFile.getGuid(),
|
rssFile.getGuid(),
|
||||||
rssFile.getGuidHash(),
|
rssFile.getGuidHash(),
|
||||||
rssFile.getLastModified(),
|
rssFile.getLastModified(),
|
||||||
rssFile.getAuthor());
|
rssFile.getAuthor(),
|
||||||
|
!isFeedAlreadyInDatabase);
|
||||||
|
|
||||||
|
|
||||||
//dbConn.clearDatabaseOverSize();
|
//dbConn.clearDatabaseOverSize();
|
||||||
|
|
||||||
|
newItem = !rssFile.getRead();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return newItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ public abstract class API {
|
||||||
return mPrefs.getString(SettingsActivity.EDT_PASSWORD_STRING, null);
|
return mPrefs.getString(SettingsActivity.EDT_PASSWORD_STRING, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetFeeds(Context cont, API api) throws Exception {
|
public int[] GetFeeds(Context cont, API api) throws Exception {
|
||||||
return OwnCloudReaderMethods.GetFeeds(cont, api);
|
return OwnCloudReaderMethods.GetFeeds(cont, api);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ public abstract class API {
|
||||||
return OwnCloudReaderMethods.GetItems(tag, cont, offset, getRead, id, type, api);
|
return OwnCloudReaderMethods.GetItems(tag, cont, offset, getRead, id, type, api);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetUpdatedItems(TAGS tag, Context cont, long lastSync, API api) throws Exception {
|
public int[] GetUpdatedItems(TAGS tag, Context cont, long lastSync, API api) throws Exception {
|
||||||
return OwnCloudReaderMethods.GetUpdatedItems(tag, cont, lastSync, api);
|
return OwnCloudReaderMethods.GetUpdatedItems(tag, cont, lastSync, api);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,21 @@
|
||||||
package de.luhmer.owncloudnewsreader.reader.owncloud;
|
package de.luhmer.owncloudnewsreader.reader.owncloud;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
import android.test.RenamingDelegatingContext;
|
||||||
|
|
||||||
import de.luhmer.owncloudnewsreader.Constants;
|
import de.luhmer.owncloudnewsreader.Constants;
|
||||||
|
import de.luhmer.owncloudnewsreader.DownloadImagesActivity;
|
||||||
import de.luhmer.owncloudnewsreader.R;
|
import de.luhmer.owncloudnewsreader.R;
|
||||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||||
|
@ -55,7 +64,7 @@ public class AsyncTask_GetItems extends AsyncTask_Reader {
|
||||||
//int maxItemsInDatabase = Integer.parseInt(mPrefs.getString(SettingsActivity.SP_MAX_ITEMS_SYNC, "200"));
|
//int maxItemsInDatabase = Integer.parseInt(mPrefs.getString(SettingsActivity.SP_MAX_ITEMS_SYNC, "200"));
|
||||||
|
|
||||||
long lastModified = dbConn.getLastModified();
|
long lastModified = dbConn.getLastModified();
|
||||||
dbConn.clearDatabaseOverSize();
|
//dbConn.clearDatabaseOverSize();
|
||||||
|
|
||||||
//List<RssFile> files;
|
//List<RssFile> files;
|
||||||
long offset = dbConn.getLowestItemId(false);
|
long offset = dbConn.getLowestItemId(false);
|
||||||
|
@ -64,21 +73,23 @@ public class AsyncTask_GetItems extends AsyncTask_Reader {
|
||||||
int maxSyncSize = Integer.parseInt(OwnCloudReaderMethods.maxSizePerSync);
|
int maxSyncSize = Integer.parseInt(OwnCloudReaderMethods.maxSizePerSync);
|
||||||
|
|
||||||
highestItemIdBeforeSync = dbConn.getHighestItemId();
|
highestItemIdBeforeSync = dbConn.getHighestItemId();
|
||||||
int totalCount = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
if(lastModified == 0)
|
if(lastModified == 0)
|
||||||
{
|
{
|
||||||
int maxItemsInDatabase = Constants.maxItemsCount;
|
int maxItemsInDatabase = Constants.maxItemsCount;
|
||||||
|
int totalCount = 0;
|
||||||
do {
|
do {
|
||||||
requestCount = api.GetItems(TAGS.ALL, context, String.valueOf(offset), false, "0", "3", api);
|
requestCount = api.GetItems(TAGS.ALL, context, String.valueOf(offset), false, "0", "3", api);
|
||||||
if(requestCount > 0)
|
if(requestCount > 0)
|
||||||
offset = dbConn.getLowestItemId(false);
|
offset = dbConn.getLowestItemId(false);
|
||||||
totalCount += requestCount;
|
totalCount += requestCount;
|
||||||
} while(requestCount == maxSyncSize);
|
} while(requestCount == maxSyncSize);
|
||||||
|
|
||||||
|
mPrefs.edit().putInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING, totalCount).commit();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
offset = dbConn.getLowestItemId(true);
|
offset = dbConn.getLowestItemId(true);
|
||||||
requestCount = api.GetItems(TAGS.ALL_STARRED, context, String.valueOf(offset), true, "0", "2", api);
|
requestCount = api.GetItems(TAGS.ALL_STARRED, context, String.valueOf(offset), true, "0", "2", api);
|
||||||
|
@ -89,12 +100,11 @@ public class AsyncTask_GetItems extends AsyncTask_Reader {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
totalCount = api.GetUpdatedItems(TAGS.ALL, context, lastModified + 1, api);
|
int[] result = api.GetUpdatedItems(TAGS.ALL, context, lastModified + 1, api);
|
||||||
|
mPrefs.edit().putInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING, result[1]).commit();
|
||||||
|
|
||||||
//OwnCloudReaderMethods.GetUpdatedItems(TAGS.ALL, context, lastModified, api);
|
//OwnCloudReaderMethods.GetUpdatedItems(TAGS.ALL, context, lastModified, api);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
||||||
mPrefs.edit().putInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING, totalCount).commit();
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
return ex;
|
return ex;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -116,14 +126,14 @@ public class AsyncTask_GetItems extends AsyncTask_Reader {
|
||||||
if(!NetworkConnection.isWLANConnected(context) && NetworkConnection.isNetworkAvailable(context))
|
if(!NetworkConnection.isWLANConnected(context) && NetworkConnection.isNetworkAvailable(context))
|
||||||
ShowDownloadImageWithoutWifiQuestion();
|
ShowDownloadImageWithoutWifiQuestion();
|
||||||
else if(NetworkConnection.isNetworkAvailable(context))
|
else if(NetworkConnection.isNetworkAvailable(context))
|
||||||
StartDownloadingImages(context);
|
StartDownloadingImages(context, highestItemIdBeforeSync);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
detach();
|
detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartDownloadingImages(Context context)
|
public static void StartDownloadingImages(Context context, long highestItemIdBeforeSync)
|
||||||
{
|
{
|
||||||
DatabaseConnection dbConn = new DatabaseConnection(context);
|
DatabaseConnection dbConn = new DatabaseConnection(context);
|
||||||
try {
|
try {
|
||||||
|
@ -138,8 +148,31 @@ public class AsyncTask_GetItems extends AsyncTask_Reader {
|
||||||
|
|
||||||
private void ShowDownloadImageWithoutWifiQuestion()
|
private void ShowDownloadImageWithoutWifiQuestion()
|
||||||
{
|
{
|
||||||
final Context contextDownloadImage = this.context;
|
Bitmap bm = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher);
|
||||||
|
|
||||||
|
Intent intent = new Intent(context, DownloadImagesActivity.class);
|
||||||
|
intent.putExtra("highestItemIdBeforeSync", highestItemIdBeforeSync);
|
||||||
|
PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, 0);
|
||||||
|
|
||||||
|
Notification notification = new NotificationCompat.Builder(context)
|
||||||
|
.setContentTitle(context.getString(R.string.no_wifi_available))
|
||||||
|
.setContentText(context.getString(R.string.do_you_want_to_download_without_wifi))
|
||||||
|
.setSmallIcon(R.drawable.ic_launcher)
|
||||||
|
.setLargeIcon(bm)
|
||||||
|
.setContentIntent(pIntent)
|
||||||
|
.setAutoCancel(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
|
||||||
|
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
// hide the notification after its selected
|
||||||
|
notification.flags |= Notification.FLAG_AUTO_CANCEL;
|
||||||
|
|
||||||
|
notificationManager.notify(0, notification);
|
||||||
|
|
||||||
|
//final Context contextDownloadImage = this.context;
|
||||||
|
|
||||||
|
/*
|
||||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
|
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
|
||||||
|
|
||||||
// set title
|
// set title
|
||||||
|
@ -161,6 +194,7 @@ public class AsyncTask_GetItems extends AsyncTask_Reader {
|
||||||
|
|
||||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||||
|
|
||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,13 +23,14 @@ package de.luhmer.owncloudnewsreader.reader.owncloud;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public class GetVersion_v1 implements IHandleJsonObject {
|
public class GetVersion_v1 implements IHandleJsonObject {
|
||||||
|
|
||||||
String version;
|
String version;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void performAction(JSONObject jObj) {
|
public boolean performAction(JSONObject jObj) {
|
||||||
this.version = jObj.optJSONObject("ocs").optJSONObject("data").optString("version");
|
this.version = jObj.optJSONObject("ocs").optJSONObject("data").optString("version");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,8 +28,9 @@ public class GetVersion_v2 implements IHandleJsonObject {
|
||||||
String version;
|
String version;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void performAction(JSONObject jObj) {
|
public boolean performAction(JSONObject jObj) {
|
||||||
this.version = jObj.optString("version");
|
this.version = jObj.optString("version");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,5 +24,5 @@ package de.luhmer.owncloudnewsreader.reader.owncloud;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public interface IHandleJsonObject {
|
public interface IHandleJsonObject {
|
||||||
public void performAction(JSONObject jObj);
|
public boolean performAction(JSONObject jObj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,9 +49,10 @@ public class InsertFeedIntoDatabase implements IHandleJsonObject{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void performAction(JSONObject jObj) {
|
public boolean performAction(JSONObject jObj) {
|
||||||
ConcreteFeedItem rssFeed = parseFeed(jObj);
|
ConcreteFeedItem rssFeed = parseFeed(jObj);
|
||||||
feeds.add(rssFeed);
|
feeds.add(rssFeed);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteAllToDatabaseNow() {
|
public void WriteAllToDatabaseNow() {
|
||||||
|
|
|
@ -43,8 +43,9 @@ public class InsertFolderIntoDatabase implements IHandleJsonObject{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void performAction(JSONObject jObj) {
|
public boolean performAction(JSONObject jObj) {
|
||||||
folders.add(parseFolder(jObj));
|
folders.add(parseFolder(jObj));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteAllToDatabaseNow() {
|
public void WriteAllToDatabaseNow() {
|
||||||
|
|
|
@ -59,8 +59,8 @@ public class InsertItemIntoDatabase implements IHandleJsonObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void performAction(JSONObject jObj) {
|
public boolean performAction(JSONObject jObj) {
|
||||||
RssFile rssFile = parseItem(jObj);
|
RssFile rssFile = parseItem(jObj);
|
||||||
InsertIntoDatabase.InsertSingleFeedItemIntoDatabase(rssFile, dbConn);
|
return InsertIntoDatabase.InsertSingleFeedItemIntoDatabase(rssFile, dbConn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class OwnCloudReaderMethods {
|
||||||
//private static final String TAG = "OwnCloudReaderMethods";
|
//private static final String TAG = "OwnCloudReaderMethods";
|
||||||
public static String maxSizePerSync = "200";
|
public static String maxSizePerSync = "200";
|
||||||
|
|
||||||
public static int GetUpdatedItems(TAGS tag, Context cont, long lastSync, API api) throws Exception
|
public static int[] GetUpdatedItems(TAGS tag, Context cont, long lastSync, API api) throws Exception
|
||||||
{
|
{
|
||||||
List<NameValuePair> nVPairs = new ArrayList<NameValuePair>();
|
List<NameValuePair> nVPairs = new ArrayList<NameValuePair>();
|
||||||
//nVPairs.add(new BasicNameValuePair("batchSize", maxSizePerSync));
|
//nVPairs.add(new BasicNameValuePair("batchSize", maxSizePerSync));
|
||||||
|
@ -83,7 +83,7 @@ public class OwnCloudReaderMethods {
|
||||||
dbConn.closeDatabase();
|
dbConn.closeDatabase();
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
return 0;
|
return new int[] { 0, 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
//"type": 1, // the type of the query (Feed: 0, Folder: 1, Starred: 2, All: 3)
|
//"type": 1, // the type of the query (Feed: 0, Folder: 1, Starred: 2, All: 3)
|
||||||
|
@ -114,9 +114,9 @@ public class OwnCloudReaderMethods {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(api instanceof APIv1)
|
if(api instanceof APIv1)
|
||||||
return readJsonStreamV1(is, new InsertItemIntoDatabase(dbConn));
|
return readJsonStreamV1(is, new InsertItemIntoDatabase(dbConn))[0];
|
||||||
else if(api instanceof APIv2)
|
else if(api instanceof APIv2)
|
||||||
return readJsonStreamV2(is, new InsertItemIntoDatabase(dbConn));
|
return readJsonStreamV2(is, new InsertItemIntoDatabase(dbConn))[0];
|
||||||
} finally {
|
} finally {
|
||||||
dbConn.closeDatabase();
|
dbConn.closeDatabase();
|
||||||
is.close();
|
is.close();
|
||||||
|
@ -129,7 +129,7 @@ public class OwnCloudReaderMethods {
|
||||||
{
|
{
|
||||||
InputStream is = HttpJsonRequest.PerformJsonRequest(api.getFolderUrl(), null, api.getUsername(), api.getPassword(), cont);
|
InputStream is = HttpJsonRequest.PerformJsonRequest(api.getFolderUrl(), null, api.getUsername(), api.getPassword(), cont);
|
||||||
DatabaseConnection dbConn = new DatabaseConnection(cont);
|
DatabaseConnection dbConn = new DatabaseConnection(cont);
|
||||||
int result = 0;
|
int[] result = new int[2];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
InsertFolderIntoDatabase ifid = new InsertFolderIntoDatabase(dbConn);
|
InsertFolderIntoDatabase ifid = new InsertFolderIntoDatabase(dbConn);
|
||||||
|
@ -145,15 +145,15 @@ public class OwnCloudReaderMethods {
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetFeeds(Context cont, API api) throws Exception
|
public static int[] GetFeeds(Context cont, API api) throws Exception
|
||||||
{
|
{
|
||||||
InputStream inputStream = HttpJsonRequest.PerformJsonRequest(api.getFeedUrl() , null, api.getUsername(), api.getPassword(), cont);
|
InputStream inputStream = HttpJsonRequest.PerformJsonRequest(api.getFeedUrl() , null, api.getUsername(), api.getPassword(), cont);
|
||||||
|
|
||||||
DatabaseConnection dbConn = new DatabaseConnection(cont);
|
DatabaseConnection dbConn = new DatabaseConnection(cont);
|
||||||
int result = 0;
|
int result[] = new int[2];
|
||||||
try {
|
try {
|
||||||
InsertFeedIntoDatabase ifid = new InsertFeedIntoDatabase(dbConn);
|
InsertFeedIntoDatabase ifid = new InsertFeedIntoDatabase(dbConn);
|
||||||
|
|
||||||
|
@ -174,12 +174,13 @@ public class OwnCloudReaderMethods {
|
||||||
* can parse json like {"items":[{"id":6782}]}
|
* can parse json like {"items":[{"id":6782}]}
|
||||||
* @param in
|
* @param in
|
||||||
* @param iJoBj
|
* @param iJoBj
|
||||||
* @return
|
* @return count all, count new items
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
public static int readJsonStreamV2(InputStream in, IHandleJsonObject iJoBj) throws IOException, JSONException {
|
public static int[] readJsonStreamV2(InputStream in, IHandleJsonObject iJoBj) throws IOException, JSONException {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
int newItemsCount = 0;
|
||||||
JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));
|
JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));
|
||||||
reader.beginObject();
|
reader.beginObject();
|
||||||
reader.nextName();
|
reader.nextName();
|
||||||
|
@ -189,8 +190,8 @@ public class OwnCloudReaderMethods {
|
||||||
|
|
||||||
JSONObject e = getJSONObjectFromReader(reader);
|
JSONObject e = getJSONObjectFromReader(reader);
|
||||||
|
|
||||||
iJoBj.performAction(e);
|
if(iJoBj.performAction(e))
|
||||||
|
newItemsCount++;
|
||||||
//reader.endObject();
|
//reader.endObject();
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
@ -198,7 +199,7 @@ public class OwnCloudReaderMethods {
|
||||||
//reader.endObject();
|
//reader.endObject();
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
return count;
|
return new int[] { count, newItemsCount };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -209,8 +210,9 @@ public class OwnCloudReaderMethods {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
public static int readJsonStreamV1(InputStream in, IHandleJsonObject iJoBj) throws IOException, JSONException {
|
public static int[] readJsonStreamV1(InputStream in, IHandleJsonObject iJoBj) throws IOException, JSONException {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
int newItemsCount = 0;
|
||||||
JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));
|
JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));
|
||||||
reader.beginObject();//{
|
reader.beginObject();//{
|
||||||
reader.nextName();//"ocs"
|
reader.nextName();//"ocs"
|
||||||
|
@ -229,7 +231,8 @@ public class OwnCloudReaderMethods {
|
||||||
|
|
||||||
JSONObject e = getJSONObjectFromReader(reader);
|
JSONObject e = getJSONObjectFromReader(reader);
|
||||||
|
|
||||||
iJoBj.performAction(e);
|
if(iJoBj.performAction(e))
|
||||||
|
newItemsCount++;
|
||||||
|
|
||||||
//reader.endObject();
|
//reader.endObject();
|
||||||
count++;
|
count++;
|
||||||
|
@ -238,7 +241,7 @@ public class OwnCloudReaderMethods {
|
||||||
//reader.endObject();
|
//reader.endObject();
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
return count;
|
return new int[] { count, newItemsCount };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -450,6 +453,7 @@ public class OwnCloudReaderMethods {
|
||||||
//Try APIv2
|
//Try APIv2
|
||||||
try {
|
try {
|
||||||
String requestUrl = oc_root_path + OwnCloudConstants.ROOT_PATH_APIv2 + OwnCloudConstants.VERSION_PATH;
|
String requestUrl = oc_root_path + OwnCloudConstants.ROOT_PATH_APIv2 + OwnCloudConstants.VERSION_PATH;
|
||||||
|
requestUrl = API.validateURL(requestUrl);
|
||||||
InputStream is = HttpJsonRequest.PerformJsonRequest(requestUrl, null, username, password, cont);
|
InputStream is = HttpJsonRequest.PerformJsonRequest(requestUrl, null, username, password, cont);
|
||||||
try {
|
try {
|
||||||
GetVersion_v2 gv = new GetVersion_v2();
|
GetVersion_v2 gv = new GetVersion_v2();
|
||||||
|
@ -463,6 +467,7 @@ public class OwnCloudReaderMethods {
|
||||||
throw ex;
|
throw ex;
|
||||||
} catch(Exception ex) { //TODO GET HERE THE RIGHT EXCEPTION
|
} catch(Exception ex) { //TODO GET HERE THE RIGHT EXCEPTION
|
||||||
String requestUrl = oc_root_path + OwnCloudConstants.ROOT_PATH_APIv1 + OwnCloudConstants.VERSION_PATH + OwnCloudConstants.JSON_FORMAT;
|
String requestUrl = oc_root_path + OwnCloudConstants.ROOT_PATH_APIv1 + OwnCloudConstants.VERSION_PATH + OwnCloudConstants.JSON_FORMAT;
|
||||||
|
requestUrl = API.validateURL(requestUrl);
|
||||||
InputStream is = HttpJsonRequest.PerformJsonRequest(requestUrl, null, username, password, cont);
|
InputStream is = HttpJsonRequest.PerformJsonRequest(requestUrl, null, username, password, cont);
|
||||||
try {
|
try {
|
||||||
GetVersion_v1 gv = new GetVersion_v1();
|
GetVersion_v1 gv = new GetVersion_v1();
|
||||||
|
|
|
@ -24,7 +24,9 @@ package de.luhmer.owncloudnewsreader.services;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
@ -34,8 +36,10 @@ import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import de.luhmer.owncloudnewsreader.Constants;
|
import de.luhmer.owncloudnewsreader.Constants;
|
||||||
import de.luhmer.owncloudnewsreader.Constants.SYNC_TYPES;
|
import de.luhmer.owncloudnewsreader.Constants.SYNC_TYPES;
|
||||||
|
import de.luhmer.owncloudnewsreader.R;
|
||||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||||
import de.luhmer.owncloudnewsreader.helper.AidlException;
|
import de.luhmer.owncloudnewsreader.helper.AidlException;
|
||||||
|
import de.luhmer.owncloudnewsreader.helper.NotificationManagerNewsReader;
|
||||||
import de.luhmer.owncloudnewsreader.reader.FeedItemTags.TAGS;
|
import de.luhmer.owncloudnewsreader.reader.FeedItemTags.TAGS;
|
||||||
import de.luhmer.owncloudnewsreader.reader.IReader;
|
import de.luhmer.owncloudnewsreader.reader.IReader;
|
||||||
import de.luhmer.owncloudnewsreader.reader.OnAsyncTaskCompletedListener;
|
import de.luhmer.owncloudnewsreader.reader.OnAsyncTaskCompletedListener;
|
||||||
|
@ -182,7 +186,24 @@ public class OwnCloudSyncService extends Service {
|
||||||
|
|
||||||
if(task_result != null)
|
if(task_result != null)
|
||||||
ThrowException((Exception) task_result);
|
ThrowException((Exception) task_result);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
|
||||||
|
List<ActivityManager.RunningTaskInfo> runningTaskInfo = am.getRunningTasks(1);
|
||||||
|
|
||||||
|
ComponentName componentInfo = runningTaskInfo.get(0).topActivity;
|
||||||
|
if(!componentInfo.getPackageName().equals("de.luhmer.owncloudnewsreader")) {
|
||||||
|
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(OwnCloudSyncService.this);
|
||||||
|
int newItemsCount = mPrefs.getInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING, 0);
|
||||||
|
if(newItemsCount > 0) {
|
||||||
|
String tickerText = getString(R.string.notification_new_items_ticker).replace("X", String.valueOf(newItemsCount));
|
||||||
|
String contentText = getString(R.string.notification_new_items_text).replace("X", String.valueOf(newItemsCount));
|
||||||
|
String title = getString(R.string.app_name);
|
||||||
|
NotificationManagerNewsReader.getInstance(OwnCloudSyncService.this).ShowMessage(title, tickerText, contentText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Log.d(TAG, "onAsyncTask_GetItems Finished");
|
Log.d(TAG, "onAsyncTask_GetItems Finished");
|
||||||
//fireUpdateFinishedClicked();
|
//fireUpdateFinishedClicked();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue