Update project structure for gradle build system
This commit is contained in:
parent
6d17fdc097
commit
f61a3827ee
362 changed files with 7685 additions and 252237 deletions
1
Changeloglib
Submodule
1
Changeloglib
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit f06f0d5ffdd901c6feda1a6a8bf1c6e664840fd6
|
1
MessageBar
Submodule
1
MessageBar
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 6861fa9a17352f3ffc63761a3833b51c95588abd
|
|
@ -1,24 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="android" name="Android">
|
||||
<configuration />
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/build/classes/main" />
|
||||
<output-test url="file://$MODULE_DIR$/build/classes/test" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android 4.2.2 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="libs" level="project" />
|
||||
<orderEntry type="module" module-name="actionbarsherlock" />
|
||||
<orderEntry type="module" module-name="library" />
|
||||
<orderEntry type="module" module-name="AppRater" />
|
||||
<orderEntry type="module" module-name="main" />
|
||||
<orderEntry type="module" module-name="MessageBar" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
|
1
News-Android-App/.gitignore
vendored
Normal file
1
News-Android-App/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/build
|
83
News-Android-App/News-Android-App-News-Android-App.iml
Normal file
83
News-Android-App/News-Android-App-News-Android-App.iml
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="News-Android-App" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="android" name="Android">
|
||||
<configuration>
|
||||
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
|
||||
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
|
||||
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
|
||||
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
||||
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
|
||||
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
|
||||
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="android-gradle" name="Android-Gradle">
|
||||
<configuration>
|
||||
<option name="GRADLE_PROJECT_PATH" value=":News-Android-App" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/build/classes/debug" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/r/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/aidl/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/rs/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/res/rs/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/r/test/debug" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/aidl/test/debug" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/test/debug" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/rs/test/debug" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/res/rs/test/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/assets" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/resources" type="java-test-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/apk" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/bundles" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/dependency-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/incremental" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/symbols" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="MessageBar" exported="" />
|
||||
<orderEntry type="library" exported="" name="ComGithubChrisbanesActionbarpulltorefreshExtraAbs093.aar" level="project" />
|
||||
<orderEntry type="library" exported="" name="gson-2.2.4" level="project" />
|
||||
<orderEntry type="library" exported="" name="ComActionbarsherlockActionbarsherlock440.aar" level="project" />
|
||||
<orderEntry type="library" exported="" name="jsoup-1.7.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="ComGithubCastorflexSmoothprogressbarLibrary020.aar" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-19.0.1" level="project" />
|
||||
<orderEntry type="module" module-name="ChangeLogLibrary" exported="" />
|
||||
<orderEntry type="library" exported="" name="ComGithubChrisbanesActionbarpulltorefreshLibrary093.aar" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
33
News-Android-App/build.gradle
Normal file
33
News-Android-App/build.gradle
Normal file
|
@ -0,0 +1,33 @@
|
|||
apply plugin: 'android'
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion '19.0.0'
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 7
|
||||
targetSdkVersion 19
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
runProguard false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
aidl.srcDirs = ['src/main/java']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.android.support:support-v4:19.0.+'
|
||||
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
|
||||
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abs:+'
|
||||
compile files('src/main/libs/gson-2.2.4.jar')
|
||||
compile files('src/main/libs/jsoup-1.7.2.jar')
|
||||
compile project(':Changeloglib:ChangeLogLibrary')
|
||||
compile project(':MessageBar')
|
||||
}
|
27
News-Android-App/build.gradle~
Normal file
27
News-Android-App/build.gradle~
Normal file
|
@ -0,0 +1,27 @@
|
|||
apply plugin: 'android'
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion '19.0.0'
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 7
|
||||
targetSdkVersion 19
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
runProguard false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.android.support:support-v4:19.0.+'
|
||||
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
|
||||
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abs:+'
|
||||
compile files('src/main/libs/gson-2.2.4.jar')
|
||||
compile files('src/main/libs/jsoup-1.7.2.jar')
|
||||
}
|
|
@ -1,9 +1,6 @@
|
|||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# in /opt/android-studio/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
|
@ -17,4 +14,4 @@
|
|||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
#}
|
6
News-Android-App/remove_invalid_languages.sh
Executable file
6
News-Android-App/remove_invalid_languages.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
git rm -r res/values-ach/
|
||||
git rm -r res/values-ady/
|
||||
git rm -r res/values-en@pirate/
|
||||
git rm -r res/values-nds/
|
||||
git rm -r res/values-nqo/
|
||||
git rm -r res/values-tzm/
|
|
@ -1,123 +1,123 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="de.luhmer.owncloudnewsreader"
|
||||
android:versionCode="40"
|
||||
android:versionName="0.5.5" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="7"
|
||||
android:targetSdkVersion="17" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<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.USE_CREDENTIALS" />
|
||||
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
|
||||
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
|
||||
|
||||
|
||||
<application
|
||||
android:debuggable="false"
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name="de.luhmer.owncloudnewsreader.NewsReaderListActivity"
|
||||
android:label="@string/app_name"> <!-- android:configChanges="keyboardHidden|orientation|screenSize" -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="de.luhmer.owncloudnewsreader.NewsDetailActivity"
|
||||
android:label="@string/title_activity_news_detail"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" >
|
||||
</activity>
|
||||
|
||||
<service android:name="de.luhmer.owncloudnewsreader.services.DownloadImagesService" />
|
||||
<service android:name="de.luhmer.owncloudnewsreader.services.SyncItemStateService" />
|
||||
|
||||
<activity
|
||||
android:name="de.luhmer.owncloudnewsreader.SettingsActivity"
|
||||
android:label="@string/title_activity_settings" >
|
||||
</activity>
|
||||
|
||||
<activity android:name=".DownloadImagesActivity" />
|
||||
|
||||
<!--
|
||||
**********************************************************************
|
||||
* Sync Adapter and Service
|
||||
**********************************************************************
|
||||
-->
|
||||
|
||||
|
||||
<service
|
||||
android:name="de.luhmer.owncloudnewsreader.services.OwnCloudAuthenticatorService"
|
||||
android:exported="true" >
|
||||
<intent-filter>
|
||||
<action android:name="android.accounts.AccountAuthenticator" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.accounts.AccountAuthenticator"
|
||||
android:resource="@xml/authenticator" />
|
||||
</service>
|
||||
|
||||
<service android:name="de.luhmer.owncloudnewsreader.services.OwnCloudSyncService" />
|
||||
|
||||
<service
|
||||
android:name="de.luhmer.owncloudnewsreader.services.OwnCloudSettingsSyncService"
|
||||
android:exported="true" >
|
||||
<intent-filter>
|
||||
<action android:name="android.content.SyncAdapter" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.content.SyncAdapter"
|
||||
android:resource="@xml/syncadapter" />
|
||||
</service>
|
||||
|
||||
<provider
|
||||
android:name=".providers.OwnCloudSyncProvider"
|
||||
android:authorities="de.luhmer.owncloudnewsreader"
|
||||
android:label="@string/auto_sync_string"
|
||||
android:syncable="true">
|
||||
</provider>
|
||||
|
||||
<!--
|
||||
<activity
|
||||
android:name=".authentication.AuthenticatorActivity"
|
||||
android:label="@string/title_activity_settings"
|
||||
android:launchMode="singleTask" > -->
|
||||
<!-- android:theme="@style/Theme.Transparent" > --><!--
|
||||
</activity>
|
||||
-->
|
||||
|
||||
<!--
|
||||
**********************************************************************
|
||||
* Widget Provider Receiver
|
||||
**********************************************************************
|
||||
-->
|
||||
<receiver android:name="de.luhmer.owncloudnewsreader.widget.WidgetProvider" >
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.appwidget.provider"
|
||||
android:resource="@xml/widget_info" />
|
||||
</receiver>
|
||||
|
||||
<service
|
||||
android:name="de.luhmer.owncloudnewsreader.widget.WidgetService"
|
||||
android:exported="false"
|
||||
android:permission="android.permission.BIND_REMOTEVIEWS" />
|
||||
|
||||
</application>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="de.luhmer.owncloudnewsreader"
|
||||
android:versionCode="40"
|
||||
android:versionName="0.5.5" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="7"
|
||||
android:targetSdkVersion="17" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<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.USE_CREDENTIALS" />
|
||||
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
|
||||
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
|
||||
|
||||
|
||||
<application
|
||||
android:debuggable="true"
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name="de.luhmer.owncloudnewsreader.NewsReaderListActivity"
|
||||
android:label="@string/app_name"> <!-- android:configChanges="keyboardHidden|orientation|screenSize" -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="de.luhmer.owncloudnewsreader.NewsDetailActivity"
|
||||
android:label="@string/title_activity_news_detail"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" >
|
||||
</activity>
|
||||
|
||||
<service android:name="de.luhmer.owncloudnewsreader.services.DownloadImagesService" />
|
||||
<service android:name="de.luhmer.owncloudnewsreader.services.SyncItemStateService" />
|
||||
|
||||
<activity
|
||||
android:name="de.luhmer.owncloudnewsreader.SettingsActivity"
|
||||
android:label="@string/title_activity_settings" >
|
||||
</activity>
|
||||
|
||||
<activity android:name=".DownloadImagesActivity" />
|
||||
|
||||
<!--
|
||||
**********************************************************************
|
||||
* Sync Adapter and Service
|
||||
**********************************************************************
|
||||
-->
|
||||
|
||||
|
||||
<service
|
||||
android:name="de.luhmer.owncloudnewsreader.services.OwnCloudAuthenticatorService"
|
||||
android:exported="true" >
|
||||
<intent-filter>
|
||||
<action android:name="android.accounts.AccountAuthenticator" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.accounts.AccountAuthenticator"
|
||||
android:resource="@xml/authenticator" />
|
||||
</service>
|
||||
|
||||
<service android:name="de.luhmer.owncloudnewsreader.services.OwnCloudSyncService" />
|
||||
|
||||
<service
|
||||
android:name="de.luhmer.owncloudnewsreader.services.OwnCloudSettingsSyncService"
|
||||
android:exported="true" >
|
||||
<intent-filter>
|
||||
<action android:name="android.content.SyncAdapter" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.content.SyncAdapter"
|
||||
android:resource="@xml/syncadapter" />
|
||||
</service>
|
||||
|
||||
<provider
|
||||
android:name=".providers.OwnCloudSyncProvider"
|
||||
android:authorities="de.luhmer.owncloudnewsreader"
|
||||
android:label="@string/auto_sync_string"
|
||||
android:syncable="true">
|
||||
</provider>
|
||||
|
||||
<!--
|
||||
<activity
|
||||
android:name=".authentication.AuthenticatorActivity"
|
||||
android:label="@string/title_activity_settings"
|
||||
android:launchMode="singleTask" > -->
|
||||
<!-- android:theme="@style/Theme.Transparent" > --><!--
|
||||
</activity>
|
||||
-->
|
||||
|
||||
<!--
|
||||
**********************************************************************
|
||||
* Widget Provider Receiver
|
||||
**********************************************************************
|
||||
-->
|
||||
<receiver android:name="de.luhmer.owncloudnewsreader.widget.WidgetProvider" >
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.appwidget.provider"
|
||||
android:resource="@xml/widget_info" />
|
||||
</receiver>
|
||||
|
||||
<service
|
||||
android:name="de.luhmer.owncloudnewsreader.widget.WidgetService"
|
||||
android:exported="false"
|
||||
android:permission="android.permission.BIND_REMOTEVIEWS" />
|
||||
|
||||
</application>
|
||||
</manifest>
|
BIN
News-Android-App/src/main/ic_launcher-web.png
Normal file
BIN
News-Android-App/src/main/ic_launcher-web.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
|
@ -5,9 +5,11 @@ import android.content.res.TypedArray;
|
|||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
|
||||
import com.devspark.robototextview.RobotoTypefaceManager;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
|
||||
/**
|
||||
* Implementation of a {@link AutoCompleteTextView} with native support for all the Roboto fonts.
|
||||
*
|
|
@ -1,43 +1,43 @@
|
|||
package de.luhmer.owncloudnewsreader;
|
||||
|
||||
public class Constants {
|
||||
public static final Boolean DEBUG_MODE = true;
|
||||
public static final Boolean debugModeWidget = true;
|
||||
|
||||
|
||||
public static final String _TAG_LABEL_UNREAD = "stream/contents/user/-/state/com.google/reading-list?n=1000&r=n&xt=user/-/state/com.google/read";
|
||||
public static final String _TAG_LABEL_STARRED = "stream/contents/user/-/state/com.google/starred?n=20";
|
||||
|
||||
//public static final String LAST_SYNC = "LAST_SYNC";
|
||||
|
||||
public static final int maxItemsCount = 1000;
|
||||
|
||||
|
||||
public static final int TaskID_GetVersion = -10;
|
||||
public static final int TaskID_GetFolder = 1;
|
||||
public static final int TaskID_GetFeeds = 2;
|
||||
public static final int TaskID_GetItems = 3;
|
||||
public static final int TaskID_PerformStateChange = -1;
|
||||
|
||||
public enum SYNC_TYPES { SYNC_TYPE__ITEM_STATES,
|
||||
SYNC_TYPE__FOLDER,
|
||||
SYNC_TYPE__FEEDS,
|
||||
SYNC_TYPE__ITEMS,
|
||||
SYNC_TYPE__GET_API};
|
||||
|
||||
|
||||
public static final String LAST_UPDATE_NEW_ITEMS_COUNT_STRING = "LAST_UPDATE_NEW_ITEMS_COUNT_STRING";
|
||||
|
||||
/*
|
||||
private static final String _P_KEY_PART1 = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgNmCsMj6M4zkjpKRG8MG5+yIAyqSQE2etVkZsc3s";
|
||||
private static final String _P_KEY_PART2 = "V5zLoQ/NUOVC0fS2tj8IWk6UYqQGk9rmVold3sDGiTCvWGFecjwel3qxzz23hKLlemrv2+0WPrZ5KOqiaCEMi";
|
||||
private static final String _P_KEY_PART3 = "CeQ7zgpcytcQdD9Y/aeaHJ9P27ntn0ub6H1Bx3VDRHm4Jkg6LQnqmdIpEmeIztnoMFlLXTaVKapaFmqJGX9ar";
|
||||
private static final String _P_KEY_PART4 = "RizGd9kqtgAqIP7YnGGDV1vP/MqYpegJkOMOlxhuVvXUsg7t7hBLdGXsJ572DzUK/2/fbZ+PIcG7OF4RgJV7Yb";
|
||||
private static final String _P_KEY_PART5 = "/AVD0ssqydMlwuheOG82FCqhBtw2vShAz7mkWgL0l0u5HQIDAQAB";
|
||||
|
||||
public static String getBase64EncodedPublicKey()
|
||||
{
|
||||
return _P_KEY_PART1 + _P_KEY_PART2 + _P_KEY_PART3 + _P_KEY_PART4 + _P_KEY_PART5;
|
||||
}
|
||||
*/
|
||||
}
|
||||
package de.luhmer.owncloudnewsreader;
|
||||
|
||||
public class Constants {
|
||||
public static final Boolean DEBUG_MODE = true;
|
||||
public static final Boolean debugModeWidget = true;
|
||||
|
||||
|
||||
public static final String _TAG_LABEL_UNREAD = "stream/contents/user/-/state/com.google/reading-list?n=1000&r=n&xt=user/-/state/com.google/read";
|
||||
public static final String _TAG_LABEL_STARRED = "stream/contents/user/-/state/com.google/starred?n=20";
|
||||
|
||||
//public static final String LAST_SYNC = "LAST_SYNC";
|
||||
|
||||
public static final int maxItemsCount = 1000;
|
||||
|
||||
|
||||
public static final int TaskID_GetVersion = -10;
|
||||
public static final int TaskID_GetFolder = 1;
|
||||
public static final int TaskID_GetFeeds = 2;
|
||||
public static final int TaskID_GetItems = 3;
|
||||
public static final int TaskID_PerformStateChange = -1;
|
||||
|
||||
public enum SYNC_TYPES { SYNC_TYPE__ITEM_STATES,
|
||||
SYNC_TYPE__FOLDER,
|
||||
SYNC_TYPE__FEEDS,
|
||||
SYNC_TYPE__ITEMS,
|
||||
SYNC_TYPE__GET_API};
|
||||
|
||||
|
||||
public static final String LAST_UPDATE_NEW_ITEMS_COUNT_STRING = "LAST_UPDATE_NEW_ITEMS_COUNT_STRING";
|
||||
|
||||
/*
|
||||
private static final String _P_KEY_PART1 = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgNmCsMj6M4zkjpKRG8MG5+yIAyqSQE2etVkZsc3s";
|
||||
private static final String _P_KEY_PART2 = "V5zLoQ/NUOVC0fS2tj8IWk6UYqQGk9rmVold3sDGiTCvWGFecjwel3qxzz23hKLlemrv2+0WPrZ5KOqiaCEMi";
|
||||
private static final String _P_KEY_PART3 = "CeQ7zgpcytcQdD9Y/aeaHJ9P27ntn0ub6H1Bx3VDRHm4Jkg6LQnqmdIpEmeIztnoMFlLXTaVKapaFmqJGX9ar";
|
||||
private static final String _P_KEY_PART4 = "RizGd9kqtgAqIP7YnGGDV1vP/MqYpegJkOMOlxhuVvXUsg7t7hBLdGXsJ572DzUK/2/fbZ+PIcG7OF4RgJV7Yb";
|
||||
private static final String _P_KEY_PART5 = "/AVD0ssqydMlwuheOG82FCqhBtw2vShAz7mkWgL0l0u5HQIDAQAB";
|
||||
|
||||
public static String getBase64EncodedPublicKey()
|
||||
{
|
||||
return _P_KEY_PART1 + _P_KEY_PART2 + _P_KEY_PART3 + _P_KEY_PART4 + _P_KEY_PART5;
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package de.luhmer.owncloudnewsreader.ListView;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ExpandableListView;
|
||||
|
||||
public class BlockingExpandableListView extends ExpandableListView {
|
||||
|
||||
private boolean mBlockLayoutChildren;
|
||||
|
||||
public BlockingExpandableListView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public void setBlockLayoutChildren(boolean block) {
|
||||
mBlockLayoutChildren = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layoutChildren() {
|
||||
if (!mBlockLayoutChildren) {
|
||||
super.layoutChildren();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package de.luhmer.owncloudnewsreader.ListView;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ListView;
|
||||
|
||||
public class BlockingListView extends ListView {
|
||||
|
||||
private boolean mBlockLayoutChildren;
|
||||
|
||||
public BlockingListView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public void setBlockLayoutChildren(boolean block) {
|
||||
mBlockLayoutChildren = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layoutChildren() {
|
||||
if (!mBlockLayoutChildren) {
|
||||
super.layoutChildren();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,442 +1,443 @@
|
|||
/**
|
||||
* Android ownCloud News
|
||||
*
|
||||
* @author David Luhmer
|
||||
* @copyright 2013 David Luhmer david-dev@live.de
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.luhmer.owncloudnewsreader.ListView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseExpandableListAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||
import de.luhmer.owncloudnewsreader.async_tasks.FillTextForTextViewAsyncTask;
|
||||
import de.luhmer.owncloudnewsreader.async_tasks.IGetTextForTextViewAsyncTask;
|
||||
import de.luhmer.owncloudnewsreader.data.AbstractItem;
|
||||
import de.luhmer.owncloudnewsreader.data.ConcreteFeedItem;
|
||||
import de.luhmer.owncloudnewsreader.data.FolderSubscribtionItem;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.helper.BitmapDrawableLruCache;
|
||||
import de.luhmer.owncloudnewsreader.helper.FavIconHandler;
|
||||
import de.luhmer.owncloudnewsreader.helper.FontHelper;
|
||||
import de.luhmer.owncloudnewsreader.interfaces.ExpListTextClicked;
|
||||
|
||||
public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter {
|
||||
|
||||
BitmapDrawableLruCache favIconCache = null;
|
||||
|
||||
private Context mContext;
|
||||
private DatabaseConnection dbConn;
|
||||
FontHelper fHelper;
|
||||
|
||||
ExpListTextClicked eListTextClickHandler;
|
||||
|
||||
private ArrayList<FolderSubscribtionItem> mCategoriesArrayList;
|
||||
private SparseArray<SparseArray<ConcreteFeedItem>> mItemsArrayList;
|
||||
private boolean showOnlyUnread = false;
|
||||
|
||||
public static final String ALL_UNREAD_ITEMS = "-10";
|
||||
public static final String ALL_STARRED_ITEMS = "-11";
|
||||
public static final String ALL_ITEMS = "-12";
|
||||
public static final String ITEMS_WITHOUT_FOLDER = "-22";
|
||||
//private static final String TAG = "SubscriptionExpandableListAdapter";
|
||||
|
||||
|
||||
public SubscriptionExpandableListAdapter(Context mContext, DatabaseConnection dbConn)
|
||||
{
|
||||
this.mContext = mContext;
|
||||
this.dbConn = dbConn;
|
||||
|
||||
int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
|
||||
//Use 1/8 of the available memory for this memory cache
|
||||
int cachSize = maxMemory / 8;
|
||||
favIconCache = new BitmapDrawableLruCache(cachSize);
|
||||
|
||||
fHelper = new FontHelper(mContext);
|
||||
|
||||
ReloadAdapter();
|
||||
}
|
||||
|
||||
private void AddEverythingInCursorFolderToSubscriptions(Cursor itemsCursor)
|
||||
{
|
||||
while (itemsCursor.moveToNext()) {
|
||||
String header = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.FOLDER_LABEL));
|
||||
//String id_folder = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.FOLDER_LABEL_ID));
|
||||
long id = itemsCursor.getLong(0);
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(header, null, id));
|
||||
}
|
||||
itemsCursor.close();
|
||||
}
|
||||
|
||||
private void AddEverythingInCursorFeedsToSubscriptions(Cursor itemsCursor)
|
||||
{
|
||||
while (itemsCursor.moveToNext()) {
|
||||
String header = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_HEADERTEXT));
|
||||
//String id_folder = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_ID));
|
||||
long id = itemsCursor.getLong(0);
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(header, ITEMS_WITHOUT_FOLDER, id));
|
||||
}
|
||||
itemsCursor.close();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public Object getChild(int groupPosition, int childPosition) {
|
||||
int parent_id = (int)getGroupId(groupPosition);
|
||||
//Check if we are not in our current group now, or the current cached items are wrong - MUST BE RECACHED
|
||||
//if(mItemsArrayList.isEmpty() /*|| ((ConcreteSubscribtionItem)mItemsArrayList.get(0)).parent_id != parent_id */){
|
||||
if(mItemsArrayList.indexOfKey(groupPosition) < 0 /*|| (mItemsArrayList.get(groupPosition).size() <= childPosition)*/ /*|| ((ConcreteSubscribtionItem)mItemsArrayList.get(0)).parent_id != parent_id */){
|
||||
mItemsArrayList.append(groupPosition, new SparseArray<ConcreteFeedItem>());
|
||||
Cursor itemsCursor = dbConn.getAllSubscriptionForFolder(String.valueOf(parent_id), showOnlyUnread);
|
||||
itemsCursor.requery();
|
||||
//mItemsArrayList.clear();
|
||||
int childPosTemp = childPosition;
|
||||
if (itemsCursor.moveToFirst())
|
||||
do {
|
||||
long id_database = itemsCursor.getLong(0);
|
||||
String name = itemsCursor.getString(1);
|
||||
String subscription_id = itemsCursor.getString(2);
|
||||
String urlFavicon = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_FAVICON_URL));
|
||||
ConcreteFeedItem newItem = new ConcreteFeedItem(name, String.valueOf(parent_id), subscription_id, urlFavicon, id_database);
|
||||
mItemsArrayList.get(groupPosition).put(childPosTemp, newItem);
|
||||
childPosTemp++;
|
||||
} while (itemsCursor.moveToNext());
|
||||
itemsCursor.close();
|
||||
}
|
||||
return mItemsArrayList.get(groupPosition).get(childPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getChildId(int groupPosition, int childPosition) {
|
||||
return ((ConcreteFeedItem)(getChild(groupPosition, childPosition))).id_database;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getChildView(int groupPosition, int childPosition,
|
||||
boolean isLastChild, View convertView, ViewGroup parent) {
|
||||
LinearLayout view;
|
||||
ChildHolder viewHolder;
|
||||
ConcreteFeedItem item = (ConcreteFeedItem)getChild(groupPosition, childPosition);
|
||||
|
||||
|
||||
if (convertView == null) {
|
||||
view = new LinearLayout(mContext);
|
||||
String inflater = Context.LAYOUT_INFLATER_SERVICE;
|
||||
LayoutInflater vi = (LayoutInflater) mContext.getSystemService(inflater);
|
||||
vi.inflate(R.layout.subscription_list_sub_item, view, true);
|
||||
if(item != null)
|
||||
view.setTag(item.id_database);
|
||||
|
||||
FontHelper fHelper = new FontHelper(mContext);
|
||||
fHelper.setFontForAllChildren(view, fHelper.getFont());
|
||||
|
||||
viewHolder = new ChildHolder();
|
||||
viewHolder.tV_HeaderText = (TextView) view.findViewById(R.id.summary);
|
||||
viewHolder.tV_UnreadCount = (TextView) view.findViewById(R.id.tv_unreadCount);
|
||||
viewHolder.imgView_FavIcon = (ImageView) view.findViewById(R.id.iVFavicon);
|
||||
|
||||
view.setTag(viewHolder);
|
||||
} else {
|
||||
view = (LinearLayout) convertView;
|
||||
viewHolder = (ChildHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
if(item != null)
|
||||
{
|
||||
String headerText = (item.header != null) ? item.header : "";
|
||||
viewHolder.tV_HeaderText.setText(headerText);
|
||||
|
||||
boolean execludeStarredItems = (item.folder_id.equals(ALL_STARRED_ITEMS)) ? false : true;
|
||||
SetUnreadCountForFeed(viewHolder.tV_UnreadCount, String.valueOf(item.id_database), execludeStarredItems);
|
||||
GetFavIconForFeed(item.favIcon, viewHolder.imgView_FavIcon, String.valueOf(item.id_database));
|
||||
}
|
||||
else
|
||||
{
|
||||
viewHolder.tV_HeaderText.setText(mContext.getString(R.string.login_dialog_text_something_went_wrong));
|
||||
viewHolder.tV_UnreadCount.setText("0");
|
||||
viewHolder.imgView_FavIcon.setImageDrawable(null);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
static class ChildHolder {
|
||||
public TextView tV_HeaderText;
|
||||
public TextView tV_UnreadCount;
|
||||
public ImageView imgView_FavIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildrenCount(int groupPosition) {
|
||||
int count;
|
||||
if(mItemsArrayList.indexOfKey(groupPosition) < 0){
|
||||
Cursor itemsCursor = dbConn.getAllSubscriptionForFolder(String.valueOf(getGroupId(groupPosition)), showOnlyUnread);
|
||||
count = itemsCursor.getCount();
|
||||
itemsCursor.close();
|
||||
}
|
||||
else
|
||||
count = mItemsArrayList.get(groupPosition).size();
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGroup(int groupPosition) {
|
||||
return mCategoriesArrayList.get(groupPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupCount() {
|
||||
return mCategoriesArrayList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getGroupId(int groupPosition) {
|
||||
return ((AbstractItem)getGroup(groupPosition)).id_database;
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
@SuppressLint("CutPasteId")
|
||||
@Override
|
||||
public View getGroupView(int groupPosition, boolean isExpanded,
|
||||
View convertView, ViewGroup parent) {
|
||||
LinearLayout view;
|
||||
GroupHolder viewHolder;
|
||||
|
||||
final FolderSubscribtionItem group = (FolderSubscribtionItem)getGroup(groupPosition);
|
||||
|
||||
if (convertView == null) {
|
||||
view = new LinearLayout(mContext);
|
||||
String inflater = Context.LAYOUT_INFLATER_SERVICE;
|
||||
LayoutInflater vi = (LayoutInflater) mContext.getSystemService(inflater);
|
||||
vi.inflate(R.layout.subscription_list_item, view, true);
|
||||
|
||||
fHelper.setFontForAllChildren(view, fHelper.getFont());
|
||||
|
||||
viewHolder = new GroupHolder();
|
||||
viewHolder.imgView = (ImageView) view.findViewById(R.id.img_View_expandable_indicator);
|
||||
viewHolder.txt_Summary = (TextView) view.findViewById(R.id.summary);
|
||||
viewHolder.txt_UnreadCount = (TextView) view.findViewById(R.id.tV_feedsCount);
|
||||
|
||||
viewHolder.txt_Summary.setClickable(true);
|
||||
|
||||
view.setTag(viewHolder);
|
||||
|
||||
} else {
|
||||
view = (LinearLayout) convertView;
|
||||
viewHolder = (GroupHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
|
||||
viewHolder.txt_Summary.setText(group.headerFolder);
|
||||
viewHolder.txt_Summary.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
String val = String.valueOf(group.id_database);
|
||||
boolean skipFireEvent = false;
|
||||
if(group.idFolder != null)
|
||||
{
|
||||
if(group.idFolder.equals(ITEMS_WITHOUT_FOLDER))
|
||||
{
|
||||
fireListTextClicked(val, mContext, false, group.idFolder);
|
||||
skipFireEvent = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!skipFireEvent)
|
||||
fireListTextClicked(val, mContext, true, group.idFolder);
|
||||
}
|
||||
});
|
||||
|
||||
boolean skipGetUnread = false;
|
||||
if(group.idFolder != null)
|
||||
{
|
||||
if(group.idFolder.equals(ITEMS_WITHOUT_FOLDER))
|
||||
{
|
||||
SetUnreadCountForFeed(viewHolder.txt_UnreadCount, String.valueOf(group.id_database), true);
|
||||
skipGetUnread = true;
|
||||
}
|
||||
}
|
||||
if(!skipGetUnread)
|
||||
SetUnreadCountForFolder(viewHolder.txt_UnreadCount, String.valueOf(group.id_database));
|
||||
|
||||
|
||||
viewHolder.txt_UnreadCount.setText("");
|
||||
|
||||
//viewHolder.txt_UnreadCount.setText(group.unreadCount);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
viewHolder.imgView.setRotation(0);
|
||||
|
||||
if(group.idFolder != null)
|
||||
{
|
||||
if(group.idFolder.equals(ITEMS_WITHOUT_FOLDER))
|
||||
{
|
||||
Cursor cursor = dbConn.getFeedByDbID(String.valueOf(group.id_database));
|
||||
if(cursor != null)
|
||||
{
|
||||
if(cursor.getCount() > 0)
|
||||
{
|
||||
viewHolder.imgView.setImageDrawable(null);
|
||||
|
||||
cursor.moveToFirst();
|
||||
String favIconURL = cursor.getString(cursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_FAVICON_URL));
|
||||
GetFavIconForFeed(favIconURL, viewHolder.imgView, String.valueOf(group.id_database));
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(String.valueOf(group.id_database).equals(ALL_STARRED_ITEMS))
|
||||
{
|
||||
viewHolder.imgView.setVisibility( View.VISIBLE );
|
||||
viewHolder.imgView.setImageResource(R.drawable.btn_rating_star_off_normal_holo_light);
|
||||
} else if (getChildrenCount( groupPosition ) == 0 ) {
|
||||
viewHolder.imgView.setVisibility( View.INVISIBLE );
|
||||
}
|
||||
else {
|
||||
viewHolder.imgView.setVisibility( View.VISIBLE );
|
||||
viewHolder.imgView.setImageResource(R.drawable.ic_find_next_holo_dark);
|
||||
|
||||
if(isExpanded)
|
||||
{
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
viewHolder.imgView.setRotation(-90);
|
||||
else
|
||||
viewHolder.imgView.setImageResource(R.drawable.ic_find_previous_holo_dark);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
private void SetUnreadCountForFeed(TextView textView, String idDatabase, boolean execludeStarredItems)
|
||||
{
|
||||
IGetTextForTextViewAsyncTask iGetter = new UnreadFeedCount(mContext, idDatabase, execludeStarredItems);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
// Execute in parallel
|
||||
new FillTextForTextViewAsyncTask(textView, iGetter).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ((Void) null));
|
||||
else
|
||||
new FillTextForTextViewAsyncTask(textView, iGetter).execute((Void) null);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
private void SetUnreadCountForFolder(TextView textView, String idDatabase)
|
||||
{
|
||||
IGetTextForTextViewAsyncTask iGetter = new UnreadFolderCount(mContext, idDatabase);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
// Execute in parallel
|
||||
new FillTextForTextViewAsyncTask(textView, iGetter).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ((Void) null));
|
||||
else
|
||||
new FillTextForTextViewAsyncTask(textView, iGetter).execute((Void) null);
|
||||
|
||||
}
|
||||
|
||||
private void GetFavIconForFeed(String favIconURL, ImageView imgView, String feedID)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(favIconURL != null)
|
||||
{
|
||||
if(favIconURL.trim().length() > 0)
|
||||
new FavIconHandler().GetImageAsync(imgView, favIconURL, mContext, feedID, favIconCache);
|
||||
else
|
||||
imgView.setImageResource(FavIconHandler.getResourceIdForRightDefaultFeedIcon(mContext));
|
||||
}
|
||||
else
|
||||
imgView.setImageResource(FavIconHandler.getResourceIdForRightDefaultFeedIcon(mContext));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static class GroupHolder
|
||||
{
|
||||
TextView txt_Summary;
|
||||
TextView txt_UnreadCount;
|
||||
ImageView imgView;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasStableIds() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildSelectable(int groupPosition, int childPosition) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void ReloadAdapter()
|
||||
{
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
showOnlyUnread = mPrefs.getBoolean(SettingsActivity.CB_SHOWONLYUNREAD_STRING, false);
|
||||
|
||||
mCategoriesArrayList = new ArrayList<FolderSubscribtionItem>();
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(mContext.getString(R.string.allUnreadFeeds), null, Long.valueOf(ALL_UNREAD_ITEMS)));
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(mContext.getString(R.string.starredFeeds), null, Long.valueOf(ALL_STARRED_ITEMS)));
|
||||
|
||||
//mCategoriesArrayList.add(new FolderSubscribtionItem(mContext.getString(R.string.starredFeeds), -11, null, null));
|
||||
|
||||
AddEverythingInCursorFolderToSubscriptions(dbConn.getAllTopSubscriptions(showOnlyUnread));
|
||||
AddEverythingInCursorFeedsToSubscriptions(dbConn.getAllTopSubscriptionsWithoutFolder(showOnlyUnread));
|
||||
|
||||
//AddEverythingInCursorToSubscriptions(dbConn.getAllTopSubscriptionsWithUnreadFeeds());
|
||||
mItemsArrayList = new SparseArray<SparseArray<ConcreteFeedItem>>();
|
||||
|
||||
this.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
public void setHandlerListener(ExpListTextClicked listener)
|
||||
{
|
||||
eListTextClickHandler = listener;
|
||||
}
|
||||
protected void fireListTextClicked(String idSubscription, Context context, boolean isFolder, String optional_folder_id)
|
||||
{
|
||||
if(eListTextClickHandler != null)
|
||||
eListTextClickHandler.onTextClicked(idSubscription, context, isFolder, optional_folder_id);
|
||||
}
|
||||
/**
|
||||
* Android ownCloud News
|
||||
*
|
||||
* @author David Luhmer
|
||||
* @copyright 2013 David Luhmer david-dev@live.de
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.luhmer.owncloudnewsreader.ListView;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseExpandableListAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||
import de.luhmer.owncloudnewsreader.async_tasks.FillTextForTextViewAsyncTask;
|
||||
import de.luhmer.owncloudnewsreader.async_tasks.IGetTextForTextViewAsyncTask;
|
||||
import de.luhmer.owncloudnewsreader.data.AbstractItem;
|
||||
import de.luhmer.owncloudnewsreader.data.ConcreteFeedItem;
|
||||
import de.luhmer.owncloudnewsreader.data.FolderSubscribtionItem;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.helper.BitmapDrawableLruCache;
|
||||
import de.luhmer.owncloudnewsreader.helper.FavIconHandler;
|
||||
import de.luhmer.owncloudnewsreader.helper.FontHelper;
|
||||
import de.luhmer.owncloudnewsreader.interfaces.ExpListTextClicked;
|
||||
|
||||
public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter {
|
||||
|
||||
BitmapDrawableLruCache favIconCache = null;
|
||||
|
||||
private Context mContext;
|
||||
private DatabaseConnection dbConn;
|
||||
FontHelper fHelper;
|
||||
|
||||
ExpListTextClicked eListTextClickHandler;
|
||||
|
||||
private ArrayList<FolderSubscribtionItem> mCategoriesArrayList;
|
||||
private SparseArray<SparseArray<ConcreteFeedItem>> mItemsArrayList;
|
||||
private boolean showOnlyUnread = false;
|
||||
|
||||
public static final String ALL_UNREAD_ITEMS = "-10";
|
||||
public static final String ALL_STARRED_ITEMS = "-11";
|
||||
public static final String ALL_ITEMS = "-12";
|
||||
public static final String ITEMS_WITHOUT_FOLDER = "-22";
|
||||
//private static final String TAG = "SubscriptionExpandableListAdapter";
|
||||
|
||||
|
||||
public SubscriptionExpandableListAdapter(Context mContext, DatabaseConnection dbConn)
|
||||
{
|
||||
this.mContext = mContext;
|
||||
this.dbConn = dbConn;
|
||||
|
||||
int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
|
||||
//Use 1/8 of the available memory for this memory cache
|
||||
int cachSize = maxMemory / 8;
|
||||
favIconCache = new BitmapDrawableLruCache(cachSize);
|
||||
|
||||
fHelper = new FontHelper(mContext);
|
||||
|
||||
ReloadAdapter();
|
||||
}
|
||||
|
||||
private void AddEverythingInCursorFolderToSubscriptions(Cursor itemsCursor)
|
||||
{
|
||||
while (itemsCursor.moveToNext()) {
|
||||
String header = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.FOLDER_LABEL));
|
||||
//String id_folder = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.FOLDER_LABEL_ID));
|
||||
long id = itemsCursor.getLong(0);
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(header, null, id));
|
||||
}
|
||||
itemsCursor.close();
|
||||
}
|
||||
|
||||
private void AddEverythingInCursorFeedsToSubscriptions(Cursor itemsCursor)
|
||||
{
|
||||
while (itemsCursor.moveToNext()) {
|
||||
String header = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_HEADERTEXT));
|
||||
//String id_folder = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_ID));
|
||||
long id = itemsCursor.getLong(0);
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(header, ITEMS_WITHOUT_FOLDER, id));
|
||||
}
|
||||
itemsCursor.close();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public Object getChild(int groupPosition, int childPosition) {
|
||||
int parent_id = (int)getGroupId(groupPosition);
|
||||
//Check if we are not in our current group now, or the current cached items are wrong - MUST BE RECACHED
|
||||
//if(mItemsArrayList.isEmpty() /*|| ((ConcreteSubscribtionItem)mItemsArrayList.get(0)).parent_id != parent_id */){
|
||||
if(mItemsArrayList.indexOfKey(groupPosition) < 0 /*|| (mItemsArrayList.get(groupPosition).size() <= childPosition)*/ /*|| ((ConcreteSubscribtionItem)mItemsArrayList.get(0)).parent_id != parent_id */){
|
||||
mItemsArrayList.append(groupPosition, new SparseArray<ConcreteFeedItem>());
|
||||
Cursor itemsCursor = dbConn.getAllSubscriptionForFolder(String.valueOf(parent_id), showOnlyUnread);
|
||||
itemsCursor.requery();
|
||||
//mItemsArrayList.clear();
|
||||
int childPosTemp = childPosition;
|
||||
if (itemsCursor.moveToFirst())
|
||||
do {
|
||||
long id_database = itemsCursor.getLong(0);
|
||||
String name = itemsCursor.getString(1);
|
||||
String subscription_id = itemsCursor.getString(2);
|
||||
String urlFavicon = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_FAVICON_URL));
|
||||
ConcreteFeedItem newItem = new ConcreteFeedItem(name, String.valueOf(parent_id), subscription_id, urlFavicon, id_database);
|
||||
mItemsArrayList.get(groupPosition).put(childPosTemp, newItem);
|
||||
childPosTemp++;
|
||||
} while (itemsCursor.moveToNext());
|
||||
itemsCursor.close();
|
||||
}
|
||||
return mItemsArrayList.get(groupPosition).get(childPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getChildId(int groupPosition, int childPosition) {
|
||||
return ((ConcreteFeedItem)(getChild(groupPosition, childPosition))).id_database;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getChildView(int groupPosition, int childPosition,
|
||||
boolean isLastChild, View convertView, ViewGroup parent) {
|
||||
LinearLayout view;
|
||||
ChildHolder viewHolder;
|
||||
ConcreteFeedItem item = (ConcreteFeedItem)getChild(groupPosition, childPosition);
|
||||
|
||||
|
||||
if (convertView == null) {
|
||||
view = new LinearLayout(mContext);
|
||||
String inflater = Context.LAYOUT_INFLATER_SERVICE;
|
||||
LayoutInflater vi = (LayoutInflater) mContext.getSystemService(inflater);
|
||||
vi.inflate(R.layout.subscription_list_sub_item, view, true);
|
||||
if(item != null)
|
||||
view.setTag(item.id_database);
|
||||
|
||||
FontHelper fHelper = new FontHelper(mContext);
|
||||
fHelper.setFontForAllChildren(view, fHelper.getFont());
|
||||
|
||||
viewHolder = new ChildHolder();
|
||||
viewHolder.tV_HeaderText = (TextView) view.findViewById(R.id.summary);
|
||||
viewHolder.tV_UnreadCount = (TextView) view.findViewById(R.id.tv_unreadCount);
|
||||
viewHolder.imgView_FavIcon = (ImageView) view.findViewById(R.id.iVFavicon);
|
||||
|
||||
view.setTag(viewHolder);
|
||||
} else {
|
||||
view = (LinearLayout) convertView;
|
||||
viewHolder = (ChildHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
if(item != null)
|
||||
{
|
||||
String headerText = (item.header != null) ? item.header : "";
|
||||
viewHolder.tV_HeaderText.setText(headerText);
|
||||
|
||||
boolean execludeStarredItems = (item.folder_id.equals(ALL_STARRED_ITEMS)) ? false : true;
|
||||
SetUnreadCountForFeed(viewHolder.tV_UnreadCount, String.valueOf(item.id_database), execludeStarredItems);
|
||||
GetFavIconForFeed(item.favIcon, viewHolder.imgView_FavIcon, String.valueOf(item.id_database));
|
||||
}
|
||||
else
|
||||
{
|
||||
viewHolder.tV_HeaderText.setText(mContext.getString(R.string.login_dialog_text_something_went_wrong));
|
||||
viewHolder.tV_UnreadCount.setText("0");
|
||||
viewHolder.imgView_FavIcon.setImageDrawable(null);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
static class ChildHolder {
|
||||
public TextView tV_HeaderText;
|
||||
public TextView tV_UnreadCount;
|
||||
public ImageView imgView_FavIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildrenCount(int groupPosition) {
|
||||
int count;
|
||||
if(mItemsArrayList.indexOfKey(groupPosition) < 0){
|
||||
Cursor itemsCursor = dbConn.getAllSubscriptionForFolder(String.valueOf(getGroupId(groupPosition)), showOnlyUnread);
|
||||
count = itemsCursor.getCount();
|
||||
itemsCursor.close();
|
||||
}
|
||||
else
|
||||
count = mItemsArrayList.get(groupPosition).size();
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGroup(int groupPosition) {
|
||||
return mCategoriesArrayList.get(groupPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupCount() {
|
||||
return mCategoriesArrayList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getGroupId(int groupPosition) {
|
||||
return ((AbstractItem)getGroup(groupPosition)).id_database;
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
@SuppressLint("CutPasteId")
|
||||
@Override
|
||||
public View getGroupView(int groupPosition, boolean isExpanded,
|
||||
View convertView, ViewGroup parent) {
|
||||
LinearLayout view;
|
||||
GroupHolder viewHolder;
|
||||
|
||||
final FolderSubscribtionItem group = (FolderSubscribtionItem)getGroup(groupPosition);
|
||||
|
||||
if (convertView == null) {
|
||||
view = new LinearLayout(mContext);
|
||||
String inflater = Context.LAYOUT_INFLATER_SERVICE;
|
||||
LayoutInflater vi = (LayoutInflater) mContext.getSystemService(inflater);
|
||||
vi.inflate(R.layout.subscription_list_item, view, true);
|
||||
|
||||
fHelper.setFontForAllChildren(view, fHelper.getFont());
|
||||
|
||||
viewHolder = new GroupHolder();
|
||||
viewHolder.imgView = (ImageView) view.findViewById(R.id.img_View_expandable_indicator);
|
||||
viewHolder.txt_Summary = (TextView) view.findViewById(R.id.summary);
|
||||
viewHolder.txt_UnreadCount = (TextView) view.findViewById(R.id.tV_feedsCount);
|
||||
|
||||
viewHolder.txt_Summary.setClickable(true);
|
||||
|
||||
view.setTag(viewHolder);
|
||||
|
||||
} else {
|
||||
view = (LinearLayout) convertView;
|
||||
viewHolder = (GroupHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
|
||||
viewHolder.txt_Summary.setText(group.headerFolder);
|
||||
viewHolder.txt_Summary.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
String val = String.valueOf(group.id_database);
|
||||
boolean skipFireEvent = false;
|
||||
if(group.idFolder != null)
|
||||
{
|
||||
if(group.idFolder.equals(ITEMS_WITHOUT_FOLDER))
|
||||
{
|
||||
fireListTextClicked(val, mContext, false, group.idFolder);
|
||||
skipFireEvent = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!skipFireEvent)
|
||||
fireListTextClicked(val, mContext, true, group.idFolder);
|
||||
}
|
||||
});
|
||||
|
||||
boolean skipGetUnread = false;
|
||||
if(group.idFolder != null)
|
||||
{
|
||||
if(group.idFolder.equals(ITEMS_WITHOUT_FOLDER))
|
||||
{
|
||||
SetUnreadCountForFeed(viewHolder.txt_UnreadCount, String.valueOf(group.id_database), true);
|
||||
skipGetUnread = true;
|
||||
}
|
||||
}
|
||||
if(!skipGetUnread)
|
||||
SetUnreadCountForFolder(viewHolder.txt_UnreadCount, String.valueOf(group.id_database));
|
||||
|
||||
|
||||
viewHolder.txt_UnreadCount.setText("");
|
||||
|
||||
//viewHolder.txt_UnreadCount.setText(group.unreadCount);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
viewHolder.imgView.setRotation(0);
|
||||
|
||||
if(group.idFolder != null)
|
||||
{
|
||||
if(group.idFolder.equals(ITEMS_WITHOUT_FOLDER))
|
||||
{
|
||||
Cursor cursor = dbConn.getFeedByDbID(String.valueOf(group.id_database));
|
||||
if(cursor != null)
|
||||
{
|
||||
if(cursor.getCount() > 0)
|
||||
{
|
||||
viewHolder.imgView.setImageDrawable(null);
|
||||
|
||||
cursor.moveToFirst();
|
||||
String favIconURL = cursor.getString(cursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_FAVICON_URL));
|
||||
GetFavIconForFeed(favIconURL, viewHolder.imgView, String.valueOf(group.id_database));
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(String.valueOf(group.id_database).equals(ALL_STARRED_ITEMS))
|
||||
{
|
||||
viewHolder.imgView.setVisibility( View.VISIBLE );
|
||||
viewHolder.imgView.setImageResource(R.drawable.btn_rating_star_off_normal_holo_light);
|
||||
} else if (getChildrenCount( groupPosition ) == 0 ) {
|
||||
viewHolder.imgView.setVisibility( View.INVISIBLE );
|
||||
}
|
||||
else {
|
||||
viewHolder.imgView.setVisibility( View.VISIBLE );
|
||||
viewHolder.imgView.setImageResource(R.drawable.ic_find_next_holo_dark);
|
||||
|
||||
if(isExpanded)
|
||||
{
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
viewHolder.imgView.setRotation(-90);
|
||||
else
|
||||
viewHolder.imgView.setImageResource(R.drawable.ic_find_previous_holo_dark);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
private void SetUnreadCountForFeed(TextView textView, String idDatabase, boolean execludeStarredItems)
|
||||
{
|
||||
IGetTextForTextViewAsyncTask iGetter = new UnreadFeedCount(mContext, idDatabase, execludeStarredItems);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
// Execute in parallel
|
||||
new FillTextForTextViewAsyncTask(textView, iGetter).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ((Void) null));
|
||||
else
|
||||
new FillTextForTextViewAsyncTask(textView, iGetter).execute((Void) null);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
private void SetUnreadCountForFolder(TextView textView, String idDatabase)
|
||||
{
|
||||
IGetTextForTextViewAsyncTask iGetter = new UnreadFolderCount(mContext, idDatabase);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
// Execute in parallel
|
||||
new FillTextForTextViewAsyncTask(textView, iGetter).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ((Void) null));
|
||||
else
|
||||
new FillTextForTextViewAsyncTask(textView, iGetter).execute((Void) null);
|
||||
|
||||
}
|
||||
|
||||
private void GetFavIconForFeed(String favIconURL, ImageView imgView, String feedID)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(favIconURL != null)
|
||||
{
|
||||
if(favIconURL.trim().length() > 0)
|
||||
new FavIconHandler().GetImageAsync(imgView, favIconURL, mContext, feedID, favIconCache);
|
||||
else
|
||||
imgView.setImageResource(FavIconHandler.getResourceIdForRightDefaultFeedIcon(mContext));
|
||||
}
|
||||
else
|
||||
imgView.setImageResource(FavIconHandler.getResourceIdForRightDefaultFeedIcon(mContext));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static class GroupHolder
|
||||
{
|
||||
TextView txt_Summary;
|
||||
TextView txt_UnreadCount;
|
||||
ImageView imgView;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasStableIds() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildSelectable(int groupPosition, int childPosition) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void ReloadAdapter()
|
||||
{
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
showOnlyUnread = mPrefs.getBoolean(SettingsActivity.CB_SHOWONLYUNREAD_STRING, false);
|
||||
|
||||
mCategoriesArrayList = new ArrayList<FolderSubscribtionItem>();
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(mContext.getString(R.string.allUnreadFeeds), null, Long.valueOf(ALL_UNREAD_ITEMS)));
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(mContext.getString(R.string.starredFeeds), null, Long.valueOf(ALL_STARRED_ITEMS)));
|
||||
|
||||
//mCategoriesArrayList.add(new FolderSubscribtionItem(mContext.getString(R.string.starredFeeds), -11, null, null));
|
||||
|
||||
AddEverythingInCursorFolderToSubscriptions(dbConn.getAllTopSubscriptions(showOnlyUnread));
|
||||
AddEverythingInCursorFeedsToSubscriptions(dbConn.getAllTopSubscriptionsWithoutFolder(showOnlyUnread));
|
||||
|
||||
//AddEverythingInCursorToSubscriptions(dbConn.getAllTopSubscriptionsWithUnreadFeeds());
|
||||
mItemsArrayList = new SparseArray<SparseArray<ConcreteFeedItem>>();
|
||||
|
||||
this.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
public void setHandlerListener(ExpListTextClicked listener)
|
||||
{
|
||||
eListTextClickHandler = listener;
|
||||
}
|
||||
protected void fireListTextClicked(String idSubscription, Context context, boolean isFolder, String optional_folder_id)
|
||||
{
|
||||
if(eListTextClickHandler != null)
|
||||
eListTextClickHandler.onTextClicked(idSubscription, context, isFolder, optional_folder_id);
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@
|
|||
package de.luhmer.owncloudnewsreader.ListView;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.async_tasks.IGetTextForTextViewAsyncTask;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
|
|
@ -22,6 +22,7 @@
|
|||
package de.luhmer.owncloudnewsreader.ListView;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.async_tasks.IGetTextForTextViewAsyncTask;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
|
|
@ -21,9 +21,6 @@
|
|||
|
||||
package de.luhmer.owncloudnewsreader;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
|
@ -43,6 +40,9 @@ import android.widget.EditText;
|
|||
|
||||
import com.actionbarsherlock.app.SherlockDialogFragment;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.authentication.AuthenticatorActivity;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.helper.FontHelper;
|
File diff suppressed because it is too large
Load diff
|
@ -21,11 +21,6 @@
|
|||
|
||||
package de.luhmer.owncloudnewsreader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
|
@ -45,6 +40,11 @@ import android.widget.ProgressBar;
|
|||
|
||||
import com.actionbarsherlock.app.SherlockFragment;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.helper.FontHelper;
|
||||
import de.luhmer.owncloudnewsreader.helper.ImageHandler;
|
|
@ -1,404 +1,403 @@
|
|||
/**
|
||||
* Android ownCloud News
|
||||
*
|
||||
* @author David Luhmer
|
||||
* @copyright 2013 David Luhmer david-dev@live.de
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.luhmer.owncloudnewsreader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteCursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.actionbarsherlock.app.SherlockListFragment;
|
||||
import com.devspark.robototextview.widget.RobotoCheckBox;
|
||||
import com.devspark.robototextview.widget.RobotoTextView;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter;
|
||||
import de.luhmer.owncloudnewsreader.cursor.IOnStayUnread;
|
||||
import de.luhmer.owncloudnewsreader.cursor.NewsListCursorAdapter;
|
||||
import de.luhmer.owncloudnewsreader.cursor.SimpleCursorLoader;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection.SORT_DIRECTION;
|
||||
import de.luhmer.owncloudnewsreader.helper.MenuUtilsSherlockFragmentActivity;
|
||||
|
||||
/**
|
||||
* A fragment representing a single NewsReader detail screen. This fragment is
|
||||
* either contained in a {@link NewsReaderListActivity} in two-pane mode (on
|
||||
* tablets) or a {@link NewsReaderListActivity} on handsets.
|
||||
*/
|
||||
public class NewsReaderDetailFragment extends SherlockListFragment implements IOnStayUnread {
|
||||
/**
|
||||
* The fragment argument representing the item ID that this fragment
|
||||
* represents.
|
||||
*/
|
||||
public static final String ARG_ITEM_ID = "item_id";
|
||||
|
||||
protected static final String TAG = "NewsReaderDetailFragment";
|
||||
|
||||
//private DatabaseConnection dbConn;
|
||||
|
||||
//private boolean DialogShowedToMarkLastItemsAsRead = false;
|
||||
|
||||
/*
|
||||
private NewsListCursorAdapter lvAdapter;
|
||||
|
||||
public NewsListCursorAdapter getLvAdapter() {
|
||||
return lvAdapter;
|
||||
}*/
|
||||
|
||||
String idFeed;
|
||||
/**
|
||||
* @return the idFeed
|
||||
*/
|
||||
public String getIdFeed() {
|
||||
return idFeed;
|
||||
}
|
||||
|
||||
String idFolder;
|
||||
/**
|
||||
* @return the idFolder
|
||||
*/
|
||||
public String getIdFolder() {
|
||||
return idFolder;
|
||||
}
|
||||
|
||||
String titel;
|
||||
|
||||
/**
|
||||
* @return the titel
|
||||
*/
|
||||
public String getTitel() {
|
||||
return titel;
|
||||
}
|
||||
|
||||
/**
|
||||
* The current activated item position. Only used on tablets.
|
||||
*/
|
||||
private int mActivatedPosition = ListView.INVALID_POSITION;
|
||||
private int marginFromTop = ListView.INVALID_POSITION;
|
||||
|
||||
private boolean reloadCursorOnStartUp = false;
|
||||
|
||||
//private static ArrayList<Integer> databaseIdsOfItems;
|
||||
ArrayList<RobotoCheckBox> stayUnreadCheckboxes;
|
||||
|
||||
/**
|
||||
* Mandatory empty constructor for the fragment manager to instantiate the
|
||||
* fragment (e.g. upon screen orientation changes).
|
||||
*/
|
||||
public NewsReaderDetailFragment() {
|
||||
//databaseIdsOfItems = new ArrayList<Integer>();
|
||||
stayUnreadCheckboxes = new ArrayList<RobotoCheckBox>();
|
||||
}
|
||||
|
||||
public void setUpdateListViewOnStartUp(boolean reloadCursorOnStartUp) {
|
||||
this.reloadCursorOnStartUp = reloadCursorOnStartUp;
|
||||
}
|
||||
|
||||
public void setActivatedPosition(int position) {
|
||||
mActivatedPosition = position;
|
||||
}
|
||||
public void setMarginFromTop(int margin) {
|
||||
marginFromTop = margin;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//setRetainInstance(true);
|
||||
|
||||
//dbConn = new DatabaseConnection(getActivity());
|
||||
|
||||
if(getArguments() != null) {
|
||||
if (getArguments().containsKey(NewsReaderListActivity.SUBSCRIPTION_ID)) {
|
||||
idFeed = getArguments().getString(NewsReaderListActivity.SUBSCRIPTION_ID);
|
||||
}
|
||||
if (getArguments().containsKey(NewsReaderListActivity.TITEL)) {
|
||||
titel = getArguments().getString(NewsReaderListActivity.TITEL);
|
||||
}
|
||||
if (getArguments().containsKey(NewsReaderListActivity.FOLDER_ID)) {
|
||||
idFolder = getArguments().getString(NewsReaderListActivity.FOLDER_ID);
|
||||
}
|
||||
|
||||
((SherlockFragmentActivity) getActivity()).getSupportActionBar().setTitle(titel);
|
||||
|
||||
UpdateMenuItemsState();//Is called on Tablets and Smartphones but on Smartphones the menuItemDownloadMoreItems is null. So it will be ignored
|
||||
|
||||
//getListView().setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
|
||||
//lvAdapter = null;
|
||||
NewsListCursorAdapter lvAdapter = new NewsListCursorAdapter(getActivity(), null, this);
|
||||
setListAdapter(lvAdapter);
|
||||
|
||||
getActivity().getSupportLoaderManager().destroyLoader(0);
|
||||
|
||||
if(reloadCursorOnStartUp)
|
||||
UpdateCurrentRssView(getActivity());
|
||||
|
||||
UpdateCursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void UpdateMenuItemsState()
|
||||
{
|
||||
if(MenuUtilsSherlockFragmentActivity.getMenuItemDownloadMoreItems() != null)
|
||||
{
|
||||
if(idFolder != null) {
|
||||
if(idFolder.equals(SubscriptionExpandableListAdapter.ALL_UNREAD_ITEMS))
|
||||
MenuUtilsSherlockFragmentActivity.getMenuItemDownloadMoreItems().setEnabled(false);
|
||||
else
|
||||
MenuUtilsSherlockFragmentActivity.getMenuItemDownloadMoreItems().setEnabled(true);
|
||||
} else
|
||||
MenuUtilsSherlockFragmentActivity.getMenuItemDownloadMoreItems().setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see android.support.v4.app.ListFragment#onViewCreated(android.view.View, android.os.Bundle)
|
||||
*/
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
if(mPrefs.getBoolean(SettingsActivity.CB_MARK_AS_READ_WHILE_SCROLLING_STRING, false))
|
||||
{
|
||||
getListView().setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
|
||||
}
|
||||
|
||||
RobotoCheckBox lastViewedArticleCheckbox = null;
|
||||
public void onScroll(final AbsListView view, final int firstVisibleItem, final int visibleItemCount, int totalItemCount) {
|
||||
|
||||
if(lastViewedArticleCheckbox == null)
|
||||
lastViewedArticleCheckbox = getCheckBoxAtPosition(0, view);
|
||||
|
||||
RobotoCheckBox cb = getCheckBoxAtPosition(0, view);
|
||||
if(lastViewedArticleCheckbox != cb) {
|
||||
if(!stayUnreadCheckboxes.contains(lastViewedArticleCheckbox));
|
||||
NewsListCursorAdapter.ChangeCheckBoxState(lastViewedArticleCheckbox, true, getActivity());
|
||||
|
||||
lastViewedArticleCheckbox = cb;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private RobotoCheckBox getCheckBoxAtPosition(int pos, AbsListView viewLV)
|
||||
{
|
||||
ListView lv = (ListView) viewLV;
|
||||
View view = (View) lv.getChildAt(pos);
|
||||
if(view != null)
|
||||
return (RobotoCheckBox) view.findViewById(R.id.cb_lv_item_read);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
//if(lvAdapter != null)
|
||||
// lvAdapter.CloseDatabaseConnection();
|
||||
//if(lvAdapter != null)
|
||||
// lvAdapter.CloseDatabaseConnection();
|
||||
//if(dbConn != null)
|
||||
// dbConn.closeDatabase();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public void UpdateCursor()
|
||||
{
|
||||
try
|
||||
{
|
||||
LoaderManager loader = getActivity().getSupportLoaderManager();
|
||||
loader.initLoader(0, null, loaderCallbacks);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public LoaderCallbacks<Cursor> loaderCallbacks = new LoaderCallbacks<Cursor>() {
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
return new NewsDetailCursorLoader(getActivity(), idFolder, idFeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
|
||||
NewsListCursorAdapter nca = (NewsListCursorAdapter) getListAdapter();
|
||||
if(nca != null)
|
||||
nca.swapCursor(cursor);
|
||||
|
||||
if(cursor.getCount() <= 0) {
|
||||
getListView().setVisibility(View.GONE);
|
||||
getActivity().findViewById(R.id.tv_no_items_available).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
getListView().setVisibility(View.VISIBLE);
|
||||
getActivity().findViewById(R.id.tv_no_items_available).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
try {
|
||||
if(mActivatedPosition != ListView.INVALID_POSITION && marginFromTop != ListView.INVALID_POSITION)
|
||||
getListView().setSelectionFromTop(mActivatedPosition, marginFromTop);
|
||||
else if(mActivatedPosition != ListView.INVALID_POSITION)
|
||||
getListView().setSelection(mActivatedPosition);
|
||||
} catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
//((NewsListCursorAdapter) getListAdapter()).changeCursor(cursor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> loader) {
|
||||
NewsListCursorAdapter nca = (NewsListCursorAdapter) getListAdapter();
|
||||
if(nca != null)
|
||||
((NewsListCursorAdapter) getListAdapter()).swapCursor(null);
|
||||
}
|
||||
};
|
||||
|
||||
public void notifyDataSetChangedOnAdapter()
|
||||
{
|
||||
NewsListCursorAdapter nca = (NewsListCursorAdapter) getListAdapter();
|
||||
if(nca != null)
|
||||
((NewsListCursorAdapter) getListAdapter()).notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void UpdateCurrentRssView(Context context) {
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean onlyUnreadItems = mPrefs.getBoolean(SettingsActivity.CB_SHOWONLYUNREAD_STRING, false);
|
||||
boolean onlyStarredItems = false;
|
||||
if(idFolder != null)
|
||||
if(idFolder.equals(SubscriptionExpandableListAdapter.ALL_STARRED_ITEMS))
|
||||
onlyStarredItems = true;
|
||||
|
||||
DatabaseConnection dbConn = new DatabaseConnection(context);
|
||||
|
||||
dbConn.clearDatabaseOverSize();
|
||||
|
||||
String sqlSelectStatement = null;
|
||||
if(idFeed != null)
|
||||
sqlSelectStatement = dbConn.getAllItemsIdsForFeedSQL(idFeed, onlyUnreadItems, onlyStarredItems, getSortDirection(context));
|
||||
else if(idFolder != null)
|
||||
{
|
||||
if(idFolder.equals(SubscriptionExpandableListAdapter.ALL_STARRED_ITEMS))
|
||||
onlyUnreadItems = false;
|
||||
sqlSelectStatement = dbConn.getAllItemsIdsForFolderSQL(idFolder, onlyUnreadItems, getSortDirection(context));
|
||||
}
|
||||
if(sqlSelectStatement != null) {
|
||||
dbConn.insertIntoRssCurrentViewTable(sqlSelectStatement);
|
||||
}
|
||||
}
|
||||
|
||||
public static SORT_DIRECTION getSortDirection(Context context) {
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
SORT_DIRECTION sDirection = SORT_DIRECTION.asc;
|
||||
String sortDirection = mPrefs.getString(SettingsActivity.SP_SORT_ORDER, "1");
|
||||
if(sortDirection.equals("1"))
|
||||
sDirection = SORT_DIRECTION.desc;
|
||||
|
||||
return sDirection;
|
||||
}
|
||||
|
||||
public static Cursor getRightCusor(Context context /*, String idFolder, String idFeed */)
|
||||
{
|
||||
DatabaseConnection dbConn = new DatabaseConnection(context);
|
||||
return dbConn.getCurrentSelectedRssItems(getSortDirection(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_newsreader_detail, container, false);
|
||||
return rootView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class NewsDetailCursorLoader extends SimpleCursorLoader {
|
||||
String idFolder;
|
||||
String idFeed;
|
||||
|
||||
public NewsDetailCursorLoader(Context context, String idFolder, String idFeed) {
|
||||
super(context);
|
||||
this.idFolder = idFolder;
|
||||
this.idFeed = idFeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor loadInBackground() {
|
||||
return getRightCusor(getContext() /*, idFolder, idFeed */);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
if(mPrefs.getBoolean(SettingsActivity.CB_SKIP_DETAILVIEW_AND_OPEN_BROWSER_DIRECTLY_STRING, false)) {
|
||||
Cursor c = ((SQLiteCursor) l.getAdapter().getItem(position));
|
||||
String currentUrl = c.getString(c.getColumnIndex(DatabaseConnection.RSS_ITEM_LINK));
|
||||
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(currentUrl));
|
||||
startActivity(browserIntent);
|
||||
|
||||
((RobotoCheckBox) v.findViewById(R.id.cb_lv_item_read)).setChecked(true);
|
||||
} else {
|
||||
Intent intentNewsDetailAct = new Intent(getActivity(), NewsDetailActivity.class);
|
||||
|
||||
intentNewsDetailAct.putExtra(NewsReaderListActivity.ITEM_ID, position);
|
||||
intentNewsDetailAct.putExtra(NewsReaderListActivity.TITEL, titel);
|
||||
startActivityForResult(intentNewsDetailAct, Activity.RESULT_CANCELED);
|
||||
}
|
||||
super.onListItemClick(l, v, position, id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stayUnread(RobotoCheckBox cb) {
|
||||
stayUnreadCheckboxes.add(cb);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Android ownCloud News
|
||||
*
|
||||
* @author David Luhmer
|
||||
* @copyright 2013 David Luhmer david-dev@live.de
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.luhmer.owncloudnewsreader;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteCursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.actionbarsherlock.app.SherlockListFragment;
|
||||
import com.devspark.robototextview.widget.RobotoCheckBox;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter;
|
||||
import de.luhmer.owncloudnewsreader.cursor.IOnStayUnread;
|
||||
import de.luhmer.owncloudnewsreader.cursor.NewsListCursorAdapter;
|
||||
import de.luhmer.owncloudnewsreader.cursor.SimpleCursorLoader;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection.SORT_DIRECTION;
|
||||
import de.luhmer.owncloudnewsreader.helper.MenuUtilsSherlockFragmentActivity;
|
||||
|
||||
/**
|
||||
* A fragment representing a single NewsReader detail screen. This fragment is
|
||||
* either contained in a {@link NewsReaderListActivity} in two-pane mode (on
|
||||
* tablets) or a {@link NewsReaderListActivity} on handsets.
|
||||
*/
|
||||
public class NewsReaderDetailFragment extends SherlockListFragment implements IOnStayUnread {
|
||||
/**
|
||||
* The fragment argument representing the item ID that this fragment
|
||||
* represents.
|
||||
*/
|
||||
public static final String ARG_ITEM_ID = "item_id";
|
||||
|
||||
protected static final String TAG = "NewsReaderDetailFragment";
|
||||
|
||||
//private DatabaseConnection dbConn;
|
||||
|
||||
//private boolean DialogShowedToMarkLastItemsAsRead = false;
|
||||
|
||||
/*
|
||||
private NewsListCursorAdapter lvAdapter;
|
||||
|
||||
public NewsListCursorAdapter getLvAdapter() {
|
||||
return lvAdapter;
|
||||
}*/
|
||||
|
||||
String idFeed;
|
||||
/**
|
||||
* @return the idFeed
|
||||
*/
|
||||
public String getIdFeed() {
|
||||
return idFeed;
|
||||
}
|
||||
|
||||
String idFolder;
|
||||
/**
|
||||
* @return the idFolder
|
||||
*/
|
||||
public String getIdFolder() {
|
||||
return idFolder;
|
||||
}
|
||||
|
||||
String titel;
|
||||
|
||||
/**
|
||||
* @return the titel
|
||||
*/
|
||||
public String getTitel() {
|
||||
return titel;
|
||||
}
|
||||
|
||||
/**
|
||||
* The current activated item position. Only used on tablets.
|
||||
*/
|
||||
private int mActivatedPosition = ListView.INVALID_POSITION;
|
||||
private int marginFromTop = ListView.INVALID_POSITION;
|
||||
|
||||
private boolean reloadCursorOnStartUp = false;
|
||||
|
||||
//private static ArrayList<Integer> databaseIdsOfItems;
|
||||
ArrayList<RobotoCheckBox> stayUnreadCheckboxes;
|
||||
|
||||
/**
|
||||
* Mandatory empty constructor for the fragment manager to instantiate the
|
||||
* fragment (e.g. upon screen orientation changes).
|
||||
*/
|
||||
public NewsReaderDetailFragment() {
|
||||
//databaseIdsOfItems = new ArrayList<Integer>();
|
||||
stayUnreadCheckboxes = new ArrayList<RobotoCheckBox>();
|
||||
}
|
||||
|
||||
public void setUpdateListViewOnStartUp(boolean reloadCursorOnStartUp) {
|
||||
this.reloadCursorOnStartUp = reloadCursorOnStartUp;
|
||||
}
|
||||
|
||||
public void setActivatedPosition(int position) {
|
||||
mActivatedPosition = position;
|
||||
}
|
||||
public void setMarginFromTop(int margin) {
|
||||
marginFromTop = margin;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//setRetainInstance(true);
|
||||
|
||||
//dbConn = new DatabaseConnection(getActivity());
|
||||
|
||||
if(getArguments() != null) {
|
||||
if (getArguments().containsKey(NewsReaderListActivity.SUBSCRIPTION_ID)) {
|
||||
idFeed = getArguments().getString(NewsReaderListActivity.SUBSCRIPTION_ID);
|
||||
}
|
||||
if (getArguments().containsKey(NewsReaderListActivity.TITEL)) {
|
||||
titel = getArguments().getString(NewsReaderListActivity.TITEL);
|
||||
}
|
||||
if (getArguments().containsKey(NewsReaderListActivity.FOLDER_ID)) {
|
||||
idFolder = getArguments().getString(NewsReaderListActivity.FOLDER_ID);
|
||||
}
|
||||
|
||||
((SherlockFragmentActivity) getActivity()).getSupportActionBar().setTitle(titel);
|
||||
|
||||
UpdateMenuItemsState();//Is called on Tablets and Smartphones but on Smartphones the menuItemDownloadMoreItems is null. So it will be ignored
|
||||
|
||||
//getListView().setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
|
||||
//lvAdapter = null;
|
||||
NewsListCursorAdapter lvAdapter = new NewsListCursorAdapter(getActivity(), null, this);
|
||||
setListAdapter(lvAdapter);
|
||||
|
||||
getActivity().getSupportLoaderManager().destroyLoader(0);
|
||||
|
||||
if(reloadCursorOnStartUp)
|
||||
UpdateCurrentRssView(getActivity());
|
||||
|
||||
UpdateCursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void UpdateMenuItemsState()
|
||||
{
|
||||
if(MenuUtilsSherlockFragmentActivity.getMenuItemDownloadMoreItems() != null)
|
||||
{
|
||||
if(idFolder != null) {
|
||||
if(idFolder.equals(SubscriptionExpandableListAdapter.ALL_UNREAD_ITEMS))
|
||||
MenuUtilsSherlockFragmentActivity.getMenuItemDownloadMoreItems().setEnabled(false);
|
||||
else
|
||||
MenuUtilsSherlockFragmentActivity.getMenuItemDownloadMoreItems().setEnabled(true);
|
||||
} else
|
||||
MenuUtilsSherlockFragmentActivity.getMenuItemDownloadMoreItems().setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see android.support.v4.app.ListFragment#onViewCreated(android.view.View, android.os.Bundle)
|
||||
*/
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
if(mPrefs.getBoolean(SettingsActivity.CB_MARK_AS_READ_WHILE_SCROLLING_STRING, false))
|
||||
{
|
||||
getListView().setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
|
||||
}
|
||||
|
||||
RobotoCheckBox lastViewedArticleCheckbox = null;
|
||||
public void onScroll(final AbsListView view, final int firstVisibleItem, final int visibleItemCount, int totalItemCount) {
|
||||
|
||||
if(lastViewedArticleCheckbox == null)
|
||||
lastViewedArticleCheckbox = getCheckBoxAtPosition(0, view);
|
||||
|
||||
RobotoCheckBox cb = getCheckBoxAtPosition(0, view);
|
||||
if(lastViewedArticleCheckbox != cb) {
|
||||
if(!stayUnreadCheckboxes.contains(lastViewedArticleCheckbox));
|
||||
NewsListCursorAdapter.ChangeCheckBoxState(lastViewedArticleCheckbox, true, getActivity());
|
||||
|
||||
lastViewedArticleCheckbox = cb;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private RobotoCheckBox getCheckBoxAtPosition(int pos, AbsListView viewLV)
|
||||
{
|
||||
ListView lv = (ListView) viewLV;
|
||||
View view = (View) lv.getChildAt(pos);
|
||||
if(view != null)
|
||||
return (RobotoCheckBox) view.findViewById(R.id.cb_lv_item_read);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
//if(lvAdapter != null)
|
||||
// lvAdapter.CloseDatabaseConnection();
|
||||
//if(lvAdapter != null)
|
||||
// lvAdapter.CloseDatabaseConnection();
|
||||
//if(dbConn != null)
|
||||
// dbConn.closeDatabase();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public void UpdateCursor()
|
||||
{
|
||||
try
|
||||
{
|
||||
LoaderManager loader = getActivity().getSupportLoaderManager();
|
||||
loader.initLoader(0, null, loaderCallbacks);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public LoaderCallbacks<Cursor> loaderCallbacks = new LoaderCallbacks<Cursor>() {
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
return new NewsDetailCursorLoader(getActivity(), idFolder, idFeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
|
||||
NewsListCursorAdapter nca = (NewsListCursorAdapter) getListAdapter();
|
||||
if(nca != null)
|
||||
nca.swapCursor(cursor);
|
||||
|
||||
if(cursor.getCount() <= 0) {
|
||||
getListView().setVisibility(View.GONE);
|
||||
getActivity().findViewById(R.id.tv_no_items_available).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
getListView().setVisibility(View.VISIBLE);
|
||||
getActivity().findViewById(R.id.tv_no_items_available).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
try {
|
||||
if(mActivatedPosition != ListView.INVALID_POSITION && marginFromTop != ListView.INVALID_POSITION)
|
||||
getListView().setSelectionFromTop(mActivatedPosition, marginFromTop);
|
||||
else if(mActivatedPosition != ListView.INVALID_POSITION)
|
||||
getListView().setSelection(mActivatedPosition);
|
||||
} catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
//((NewsListCursorAdapter) getListAdapter()).changeCursor(cursor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> loader) {
|
||||
NewsListCursorAdapter nca = (NewsListCursorAdapter) getListAdapter();
|
||||
if(nca != null)
|
||||
((NewsListCursorAdapter) getListAdapter()).swapCursor(null);
|
||||
}
|
||||
};
|
||||
|
||||
public void notifyDataSetChangedOnAdapter()
|
||||
{
|
||||
NewsListCursorAdapter nca = (NewsListCursorAdapter) getListAdapter();
|
||||
if(nca != null)
|
||||
((NewsListCursorAdapter) getListAdapter()).notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void UpdateCurrentRssView(Context context) {
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean onlyUnreadItems = mPrefs.getBoolean(SettingsActivity.CB_SHOWONLYUNREAD_STRING, false);
|
||||
boolean onlyStarredItems = false;
|
||||
if(idFolder != null)
|
||||
if(idFolder.equals(SubscriptionExpandableListAdapter.ALL_STARRED_ITEMS))
|
||||
onlyStarredItems = true;
|
||||
|
||||
DatabaseConnection dbConn = new DatabaseConnection(context);
|
||||
|
||||
dbConn.clearDatabaseOverSize();
|
||||
|
||||
String sqlSelectStatement = null;
|
||||
if(idFeed != null)
|
||||
sqlSelectStatement = dbConn.getAllItemsIdsForFeedSQL(idFeed, onlyUnreadItems, onlyStarredItems, getSortDirection(context));
|
||||
else if(idFolder != null)
|
||||
{
|
||||
if(idFolder.equals(SubscriptionExpandableListAdapter.ALL_STARRED_ITEMS))
|
||||
onlyUnreadItems = false;
|
||||
sqlSelectStatement = dbConn.getAllItemsIdsForFolderSQL(idFolder, onlyUnreadItems, getSortDirection(context));
|
||||
}
|
||||
if(sqlSelectStatement != null) {
|
||||
dbConn.insertIntoRssCurrentViewTable(sqlSelectStatement);
|
||||
}
|
||||
}
|
||||
|
||||
public static SORT_DIRECTION getSortDirection(Context context) {
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
SORT_DIRECTION sDirection = SORT_DIRECTION.asc;
|
||||
String sortDirection = mPrefs.getString(SettingsActivity.SP_SORT_ORDER, "1");
|
||||
if(sortDirection.equals("1"))
|
||||
sDirection = SORT_DIRECTION.desc;
|
||||
|
||||
return sDirection;
|
||||
}
|
||||
|
||||
public static Cursor getRightCusor(Context context /*, String idFolder, String idFeed */)
|
||||
{
|
||||
DatabaseConnection dbConn = new DatabaseConnection(context);
|
||||
return dbConn.getCurrentSelectedRssItems(getSortDirection(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_newsreader_detail, container, false);
|
||||
return rootView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class NewsDetailCursorLoader extends SimpleCursorLoader {
|
||||
String idFolder;
|
||||
String idFeed;
|
||||
|
||||
public NewsDetailCursorLoader(Context context, String idFolder, String idFeed) {
|
||||
super(context);
|
||||
this.idFolder = idFolder;
|
||||
this.idFeed = idFeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor loadInBackground() {
|
||||
return getRightCusor(getContext() /*, idFolder, idFeed */);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
if(mPrefs.getBoolean(SettingsActivity.CB_SKIP_DETAILVIEW_AND_OPEN_BROWSER_DIRECTLY_STRING, false)) {
|
||||
Cursor c = ((SQLiteCursor) l.getAdapter().getItem(position));
|
||||
String currentUrl = c.getString(c.getColumnIndex(DatabaseConnection.RSS_ITEM_LINK));
|
||||
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(currentUrl));
|
||||
startActivity(browserIntent);
|
||||
|
||||
((RobotoCheckBox) v.findViewById(R.id.cb_lv_item_read)).setChecked(true);
|
||||
} else {
|
||||
Intent intentNewsDetailAct = new Intent(getActivity(), NewsDetailActivity.class);
|
||||
|
||||
intentNewsDetailAct.putExtra(NewsReaderListActivity.ITEM_ID, position);
|
||||
intentNewsDetailAct.putExtra(NewsReaderListActivity.TITEL, titel);
|
||||
startActivityForResult(intentNewsDetailAct, Activity.RESULT_CANCELED);
|
||||
}
|
||||
super.onListItemClick(l, v, position, id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stayUnread(RobotoCheckBox cb) {
|
||||
stayUnreadCheckboxes.add(cb);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -21,10 +21,6 @@
|
|||
|
||||
package de.luhmer.owncloudnewsreader;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
|
@ -50,6 +46,10 @@ import android.preference.PreferenceManager;
|
|||
import com.actionbarsherlock.app.SherlockPreferenceActivity;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.helper.ImageHandler;
|
||||
import de.luhmer.owncloudnewsreader.helper.PostDelayHandler;
|
|
@ -35,7 +35,6 @@ import android.widget.TextView;
|
|||
|
||||
import com.actionbarsherlock.app.SherlockDialogFragment;
|
||||
|
||||
import it.gmariotti.changelibs.library.internal.ChangeLog;
|
||||
import it.gmariotti.changelibs.library.view.ChangeLogListView;
|
||||
|
||||
/**
|
|
@ -21,11 +21,11 @@
|
|||
|
||||
package de.luhmer.owncloudnewsreader.async_tasks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import de.luhmer.owncloudnewsreader.async_tasks.GetImageAsyncTask;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.helper.ImageHandler;
|
||||
|
||||
public class AsyncTask_DownloadImages extends AsyncTask<Void, Void, Void>{
|
|
@ -21,12 +21,12 @@
|
|||
|
||||
package de.luhmer.owncloudnewsreader.async_tasks;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Process;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class FillTextForTextViewAsyncTask extends AsyncTask<Void, Void, String> {
|
||||
IGetTextForTextViewAsyncTask iGetter;
|
||||
WeakReference<TextView> textView;
|
|
@ -21,30 +21,22 @@
|
|||
|
||||
package de.luhmer.owncloudnewsreader.async_tasks;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import org.apache.http.util.ByteArrayBuffer;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.http.util.ByteArrayBuffer;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.preference.PreferenceManager;
|
||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||
import de.luhmer.owncloudnewsreader.helper.BitmapDrawableLruCache;
|
||||
import de.luhmer.owncloudnewsreader.helper.ImageDownloadFinished;
|
||||
import de.luhmer.owncloudnewsreader.helper.ImageHandler;
|
|
@ -1,6 +1,5 @@
|
|||
package de.luhmer.owncloudnewsreader.authentication;
|
||||
|
||||
import static android.accounts.AccountManager.KEY_BOOLEAN_RESULT;
|
||||
import android.accounts.AbstractAccountAuthenticator;
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountAuthenticatorResponse;
|
||||
|
@ -12,6 +11,8 @@ import android.os.Bundle;
|
|||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import static android.accounts.AccountManager.KEY_BOOLEAN_RESULT;
|
||||
|
||||
public class OwnCloudAccountAuthenticator extends AbstractAccountAuthenticator {
|
||||
|
||||
private String TAG = "UdinicAuthenticator";
|
|
@ -11,6 +11,7 @@ import android.content.SyncResult;
|
|||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.services.IOwnCloudSyncService;
|
||||
import de.luhmer.owncloudnewsreader.services.OwnCloudSyncService;
|
||||
|
|
@ -1,340 +1,340 @@
|
|||
/**
|
||||
* Android ownCloud News
|
||||
*
|
||||
* @author David Luhmer
|
||||
* @copyright 2013 David Luhmer david-dev@live.de
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.luhmer.owncloudnewsreader.cursor;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.widget.CursorAdapter;
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.format.DateUtils;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.devspark.robototextview.widget.RobotoCheckBox;
|
||||
import com.devspark.robototextview.widget.RobotoTextView;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.NewsDetailFragment;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.helper.FontHelper;
|
||||
import de.luhmer.owncloudnewsreader.helper.PostDelayHandler;
|
||||
import de.luhmer.owncloudnewsreader.helper.ThemeChooser;
|
||||
import de.luhmer.owncloudnewsreader.reader.IReader;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.OwnCloud_Reader;
|
||||
|
||||
public class NewsListCursorAdapter extends CursorAdapter {
|
||||
//private static final String TAG = "NewsListCursorAdapter";
|
||||
DatabaseConnection dbConn;
|
||||
IReader _Reader;
|
||||
//SimpleDateFormat simpleDateFormat;
|
||||
final int LengthBody = 300;
|
||||
ForegroundColorSpan bodyForegroundColor;
|
||||
IOnStayUnread onStayUnread;
|
||||
|
||||
PostDelayHandler pDelayHandler;
|
||||
|
||||
int selectedDesign = 0;
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
@SuppressWarnings("deprecation")
|
||||
public NewsListCursorAdapter(Context context, Cursor c, IOnStayUnread onStayUnread) {
|
||||
super(context, c);
|
||||
|
||||
this.onStayUnread = onStayUnread;
|
||||
|
||||
pDelayHandler = new PostDelayHandler(context);
|
||||
|
||||
//simpleDateFormat = new SimpleDateFormat("EEE, d. MMM HH:mm:ss");
|
||||
bodyForegroundColor = new ForegroundColorSpan(context.getResources().getColor(android.R.color.secondary_text_dark));
|
||||
|
||||
_Reader = new OwnCloud_Reader();
|
||||
dbConn = new DatabaseConnection(context);
|
||||
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
selectedDesign = Integer.valueOf(mPrefs.getString(SettingsActivity.SP_FEED_LIST_LAYOUT, "0"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindView(final View view, final Context context, Cursor cursor) {
|
||||
final String idItemDb = cursor.getString(0);
|
||||
|
||||
switch (selectedDesign) {
|
||||
case 0:
|
||||
setSimpleLayout(view, cursor);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
setExtendedLayout(view, cursor);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
setExtendedLayoutWebView(view, cursor);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
FontHelper fHelper = new FontHelper(context);
|
||||
fHelper.setFontForAllChildren(view, fHelper.getFont());
|
||||
|
||||
RobotoCheckBox cbStarred = (RobotoCheckBox) view.findViewById(R.id.cb_lv_item_starred);
|
||||
if(ThemeChooser.isDarkTheme(mContext))
|
||||
cbStarred.setBackgroundResource(R.drawable.checkbox_background_holo_dark);
|
||||
/*
|
||||
//The default is white so we don't need to set it here again..
|
||||
else
|
||||
cbStarred.setBackgroundResource(R.drawable.checkbox_background_holo_light);*/
|
||||
|
||||
cbStarred.setOnCheckedChangeListener(null);
|
||||
|
||||
Boolean isStarred = dbConn.isFeedUnreadStarred(cursor.getString(0), false);//false => starred will be checked
|
||||
//Log.d("ISSTARRED", "" + isStarred + " - Cursor: " + cursor.getString(0));
|
||||
cbStarred.setChecked(isStarred);
|
||||
cbStarred.setClickable(true);
|
||||
cbStarred.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
dbConn.updateIsStarredOfItem(idItemDb, isChecked);
|
||||
|
||||
if(isChecked)
|
||||
UpdateIsReadCheckBox(buttonView, idItemDb);
|
||||
|
||||
pDelayHandler.DelayTimer();
|
||||
}
|
||||
});
|
||||
|
||||
LinearLayout ll_cb_starred_wrapper = (LinearLayout) view.findViewById(R.id.ll_cb_starred_wrapper);
|
||||
if(ll_cb_starred_wrapper != null) {
|
||||
ll_cb_starred_wrapper.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
RobotoCheckBox cbStarred = (RobotoCheckBox) view.findViewById(R.id.cb_lv_item_starred);
|
||||
cbStarred.setChecked(!cbStarred.isChecked());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
RobotoCheckBox cbRead = (RobotoCheckBox) view.findViewById(R.id.cb_lv_item_read);
|
||||
cbRead.setTag(idItemDb);
|
||||
cbRead.setOnCheckedChangeListener(null);
|
||||
Boolean isChecked = dbConn.isFeedUnreadStarred(cursor.getString(0), true);
|
||||
//Log.d("ISREAD", "" + isChecked + " - Cursor: " + cursor.getString(0));
|
||||
cbRead.setChecked(isChecked);
|
||||
if(!isChecked) {
|
||||
RobotoTextView textView = (RobotoTextView) view.findViewById(R.id.summary);
|
||||
fHelper.setFontStyleForSingleView(textView, fHelper.getFontUnreadStyle());
|
||||
}
|
||||
|
||||
|
||||
cbRead.setClickable(true);
|
||||
cbRead.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
ChangeReadStateOfItem((RobotoCheckBox) buttonView, view, isChecked, context);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
String colorString = dbConn.getAvgColourOfFeedByDbId(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_SUBSCRIPTION_ID)));
|
||||
View viewColor = view.findViewById(R.id.color_line_feed);
|
||||
if(colorString != null)
|
||||
viewColor.setBackgroundColor(Integer.parseInt(colorString));
|
||||
}
|
||||
|
||||
public void ChangeReadStateOfItem(RobotoCheckBox checkBox, View parentView, boolean isChecked, Context context) {
|
||||
|
||||
dbConn.updateIsReadOfItem(checkBox.getTag().toString(), isChecked);
|
||||
UpdateListCursor(mContext);
|
||||
|
||||
pDelayHandler.DelayTimer();
|
||||
|
||||
RobotoTextView textView = (RobotoTextView) parentView.findViewById(R.id.summary);
|
||||
if(textView != null)
|
||||
{
|
||||
FontHelper fHelper = new FontHelper(context);
|
||||
if(isChecked)
|
||||
fHelper.setFontStyleForSingleView(textView, fHelper.getFont());
|
||||
//textView.setTextAppearance(mContext, R.style.RobotoFontStyle);
|
||||
else {
|
||||
fHelper.setFontStyleForSingleView(textView, fHelper.getFontUnreadStyle());
|
||||
onStayUnread.stayUnread(checkBox);
|
||||
}
|
||||
//textView.setTextAppearance(mContext, R.style.RobotoFontStyleBold);
|
||||
|
||||
textView.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSimpleLayout(View view, Cursor cursor)
|
||||
{
|
||||
TextView textViewSummary = (TextView) view.findViewById(R.id.summary);
|
||||
textViewSummary.setText(Html.fromHtml(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_TITLE))).toString());
|
||||
|
||||
TextView textViewItemDate = (TextView) view.findViewById(R.id.tv_item_date);
|
||||
long pubDate = cursor.getLong(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_PUBDATE));
|
||||
//textViewItemDate.setText(simpleDateFormat.format(new Date(pubDate)));
|
||||
String dateString = (String) DateUtils.getRelativeTimeSpanString(pubDate);
|
||||
textViewItemDate.setText(dateString);
|
||||
|
||||
TextView textViewTitle = (TextView) view.findViewById(R.id.tv_subscription);
|
||||
textViewTitle.setText(dbConn.getTitleOfSubscriptionByRowID(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_SUBSCRIPTION_ID))));
|
||||
textViewSummary.setTag(cursor.getString(0));
|
||||
}
|
||||
|
||||
public void setExtendedLayout(View view, Cursor cursor)
|
||||
{
|
||||
TextView textViewSummary = (TextView) view.findViewById(R.id.summary);
|
||||
textViewSummary.setText(Html.fromHtml(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_TITLE))).toString());
|
||||
|
||||
TextView textViewItemDate = (TextView) view.findViewById(R.id.tv_item_date);
|
||||
long pubDate = cursor.getLong(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_PUBDATE));
|
||||
//textViewItemDate.setText(simpleDateFormat.format(new Date(pubDate)));
|
||||
String dateString = (String) DateUtils.getRelativeTimeSpanString(pubDate);
|
||||
textViewItemDate.setText(dateString);
|
||||
|
||||
TextView textViewItemBody = (TextView) view.findViewById(R.id.body);
|
||||
String body = cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_BODY));
|
||||
textViewItemBody.setText(getBodyText(body));
|
||||
|
||||
TextView textViewTitle = (TextView) view.findViewById(R.id.tv_subscription);
|
||||
textViewTitle.setText(dbConn.getTitleOfSubscriptionByRowID(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_SUBSCRIPTION_ID))));
|
||||
textViewSummary.setTag(cursor.getString(0));
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
public void setExtendedLayoutWebView(View view, Cursor cursor)
|
||||
{
|
||||
WebView webViewContent = (WebView) view.findViewById(R.id.webView_body);
|
||||
webViewContent.setClickable(false);
|
||||
webViewContent.setFocusable(false);
|
||||
//if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
// webViewContent.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
|
||||
webViewContent.loadDataWithBaseURL("", NewsDetailFragment.getHtmlPage(mContext, dbConn , cursor.getInt(0)), "text/html", "UTF-8", "");
|
||||
}
|
||||
|
||||
public void CloseDatabaseConnection()
|
||||
{
|
||||
if(dbConn != null)
|
||||
dbConn.closeDatabase();
|
||||
}
|
||||
|
||||
private void UpdateIsReadCheckBox(View view, String idItemDb)
|
||||
{
|
||||
LinearLayout lLayout = (LinearLayout) view.getParent();
|
||||
Boolean isChecked = dbConn.isFeedUnreadStarred(idItemDb, true);
|
||||
RobotoCheckBox cbRead = (RobotoCheckBox) lLayout.findViewById(R.id.cb_lv_item_read);
|
||||
if(cbRead == null) {//In the default layout the star checkbox is nested two times.
|
||||
lLayout = (LinearLayout) lLayout.getParent();
|
||||
cbRead = (RobotoCheckBox) lLayout.findViewById(R.id.cb_lv_item_read);
|
||||
}
|
||||
cbRead.setChecked(isChecked);
|
||||
}
|
||||
|
||||
public static void ChangeCheckBoxState(RobotoCheckBox cb, boolean state, Context context)
|
||||
{
|
||||
if(cb != null)
|
||||
{
|
||||
if(cb.isChecked() != state)
|
||||
{
|
||||
cb.setChecked(state);
|
||||
|
||||
UpdateListCursor(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateListCursor(Context context)
|
||||
{
|
||||
SherlockFragmentActivity sfa = (SherlockFragmentActivity) context;
|
||||
|
||||
//if tablet view is enabled --> update the listview
|
||||
if(sfa instanceof NewsReaderListActivity)
|
||||
((NewsReaderListActivity) sfa).updateAdapter();
|
||||
}
|
||||
|
||||
|
||||
private String getBodyText(String body)
|
||||
{
|
||||
//if(body.length() > LengthBody)
|
||||
// body = body.substring(0, LengthBody);
|
||||
|
||||
body = body.replaceAll("<img[^>]*>", "");
|
||||
body = body.replaceAll("<video[^>]*>", "");
|
||||
|
||||
SpannableString bodyStringSpannable = new SpannableString(Html.fromHtml(body));
|
||||
bodyStringSpannable.setSpan(bodyForegroundColor, 0, bodyStringSpannable.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
|
||||
String bodyString = bodyStringSpannable.toString().trim();
|
||||
|
||||
if(bodyString.length() > LengthBody)
|
||||
bodyString = bodyString.substring(0, LengthBody);
|
||||
|
||||
return bodyString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View newView(Context cont, Cursor cursor, ViewGroup parent) {
|
||||
// when the view will be created for first time,
|
||||
// we need to tell the adapters, how each item will look
|
||||
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||
View retView = null;
|
||||
|
||||
switch (selectedDesign) {
|
||||
case 0:
|
||||
retView = inflater.inflate(R.layout.subscription_detail_list_item_simple, parent, false);
|
||||
break;
|
||||
case 1:
|
||||
retView = inflater.inflate(R.layout.subscription_detail_list_item_extended, parent, false);
|
||||
break;
|
||||
case 2:
|
||||
retView = inflater.inflate(R.layout.subscription_detail_list_item_extended_webview, parent, false);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(retView != null)
|
||||
retView.setTag(cursor.getString(0));
|
||||
|
||||
return retView;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Android ownCloud News
|
||||
*
|
||||
* @author David Luhmer
|
||||
* @copyright 2013 David Luhmer david-dev@live.de
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.luhmer.owncloudnewsreader.cursor;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.widget.CursorAdapter;
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.format.DateUtils;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.devspark.robototextview.widget.RobotoCheckBox;
|
||||
import com.devspark.robototextview.widget.RobotoTextView;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.NewsDetailFragment;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.helper.FontHelper;
|
||||
import de.luhmer.owncloudnewsreader.helper.PostDelayHandler;
|
||||
import de.luhmer.owncloudnewsreader.helper.ThemeChooser;
|
||||
import de.luhmer.owncloudnewsreader.reader.IReader;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.OwnCloud_Reader;
|
||||
|
||||
public class NewsListCursorAdapter extends CursorAdapter {
|
||||
//private static final String TAG = "NewsListCursorAdapter";
|
||||
DatabaseConnection dbConn;
|
||||
IReader _Reader;
|
||||
//SimpleDateFormat simpleDateFormat;
|
||||
final int LengthBody = 300;
|
||||
ForegroundColorSpan bodyForegroundColor;
|
||||
IOnStayUnread onStayUnread;
|
||||
|
||||
PostDelayHandler pDelayHandler;
|
||||
|
||||
int selectedDesign = 0;
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
@SuppressWarnings("deprecation")
|
||||
public NewsListCursorAdapter(Context context, Cursor c, IOnStayUnread onStayUnread) {
|
||||
super(context, c);
|
||||
|
||||
this.onStayUnread = onStayUnread;
|
||||
|
||||
pDelayHandler = new PostDelayHandler(context);
|
||||
|
||||
//simpleDateFormat = new SimpleDateFormat("EEE, d. MMM HH:mm:ss");
|
||||
bodyForegroundColor = new ForegroundColorSpan(context.getResources().getColor(android.R.color.secondary_text_dark));
|
||||
|
||||
_Reader = new OwnCloud_Reader();
|
||||
dbConn = new DatabaseConnection(context);
|
||||
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
selectedDesign = Integer.valueOf(mPrefs.getString(SettingsActivity.SP_FEED_LIST_LAYOUT, "0"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindView(final View view, final Context context, Cursor cursor) {
|
||||
final String idItemDb = cursor.getString(0);
|
||||
|
||||
switch (selectedDesign) {
|
||||
case 0:
|
||||
setSimpleLayout(view, cursor);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
setExtendedLayout(view, cursor);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
setExtendedLayoutWebView(view, cursor);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
FontHelper fHelper = new FontHelper(context);
|
||||
fHelper.setFontForAllChildren(view, fHelper.getFont());
|
||||
|
||||
RobotoCheckBox cbStarred = (RobotoCheckBox) view.findViewById(R.id.cb_lv_item_starred);
|
||||
if(ThemeChooser.isDarkTheme(mContext))
|
||||
cbStarred.setBackgroundResource(R.drawable.checkbox_background_holo_dark);
|
||||
/*
|
||||
//The default is white so we don't need to set it here again..
|
||||
else
|
||||
cbStarred.setBackgroundResource(R.drawable.checkbox_background_holo_light);*/
|
||||
|
||||
cbStarred.setOnCheckedChangeListener(null);
|
||||
|
||||
Boolean isStarred = dbConn.isFeedUnreadStarred(cursor.getString(0), false);//false => starred will be checked
|
||||
//Log.d("ISSTARRED", "" + isStarred + " - Cursor: " + cursor.getString(0));
|
||||
cbStarred.setChecked(isStarred);
|
||||
cbStarred.setClickable(true);
|
||||
cbStarred.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
dbConn.updateIsStarredOfItem(idItemDb, isChecked);
|
||||
|
||||
if(isChecked)
|
||||
UpdateIsReadCheckBox(buttonView, idItemDb);
|
||||
|
||||
pDelayHandler.DelayTimer();
|
||||
}
|
||||
});
|
||||
|
||||
LinearLayout ll_cb_starred_wrapper = (LinearLayout) view.findViewById(R.id.ll_cb_starred_wrapper);
|
||||
if(ll_cb_starred_wrapper != null) {
|
||||
ll_cb_starred_wrapper.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
RobotoCheckBox cbStarred = (RobotoCheckBox) view.findViewById(R.id.cb_lv_item_starred);
|
||||
cbStarred.setChecked(!cbStarred.isChecked());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
RobotoCheckBox cbRead = (RobotoCheckBox) view.findViewById(R.id.cb_lv_item_read);
|
||||
cbRead.setTag(idItemDb);
|
||||
cbRead.setOnCheckedChangeListener(null);
|
||||
Boolean isChecked = dbConn.isFeedUnreadStarred(cursor.getString(0), true);
|
||||
//Log.d("ISREAD", "" + isChecked + " - Cursor: " + cursor.getString(0));
|
||||
cbRead.setChecked(isChecked);
|
||||
if(!isChecked) {
|
||||
RobotoTextView textView = (RobotoTextView) view.findViewById(R.id.summary);
|
||||
fHelper.setFontStyleForSingleView(textView, fHelper.getFontUnreadStyle());
|
||||
}
|
||||
|
||||
|
||||
cbRead.setClickable(true);
|
||||
cbRead.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
ChangeReadStateOfItem((RobotoCheckBox) buttonView, view, isChecked, context);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
String colorString = dbConn.getAvgColourOfFeedByDbId(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_SUBSCRIPTION_ID)));
|
||||
View viewColor = view.findViewById(R.id.color_line_feed);
|
||||
if(colorString != null)
|
||||
viewColor.setBackgroundColor(Integer.parseInt(colorString));
|
||||
}
|
||||
|
||||
public void ChangeReadStateOfItem(RobotoCheckBox checkBox, View parentView, boolean isChecked, Context context) {
|
||||
|
||||
dbConn.updateIsReadOfItem(checkBox.getTag().toString(), isChecked);
|
||||
UpdateListCursor(mContext);
|
||||
|
||||
pDelayHandler.DelayTimer();
|
||||
|
||||
RobotoTextView textView = (RobotoTextView) parentView.findViewById(R.id.summary);
|
||||
if(textView != null)
|
||||
{
|
||||
FontHelper fHelper = new FontHelper(context);
|
||||
if(isChecked)
|
||||
fHelper.setFontStyleForSingleView(textView, fHelper.getFont());
|
||||
//textView.setTextAppearance(mContext, R.style.RobotoFontStyle);
|
||||
else {
|
||||
fHelper.setFontStyleForSingleView(textView, fHelper.getFontUnreadStyle());
|
||||
onStayUnread.stayUnread(checkBox);
|
||||
}
|
||||
//textView.setTextAppearance(mContext, R.style.RobotoFontStyleBold);
|
||||
|
||||
textView.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSimpleLayout(View view, Cursor cursor)
|
||||
{
|
||||
TextView textViewSummary = (TextView) view.findViewById(R.id.summary);
|
||||
textViewSummary.setText(Html.fromHtml(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_TITLE))).toString());
|
||||
|
||||
TextView textViewItemDate = (TextView) view.findViewById(R.id.tv_item_date);
|
||||
long pubDate = cursor.getLong(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_PUBDATE));
|
||||
//textViewItemDate.setText(simpleDateFormat.format(new Date(pubDate)));
|
||||
String dateString = (String) DateUtils.getRelativeTimeSpanString(pubDate);
|
||||
textViewItemDate.setText(dateString);
|
||||
|
||||
TextView textViewTitle = (TextView) view.findViewById(R.id.tv_subscription);
|
||||
textViewTitle.setText(dbConn.getTitleOfSubscriptionByRowID(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_SUBSCRIPTION_ID))));
|
||||
textViewSummary.setTag(cursor.getString(0));
|
||||
}
|
||||
|
||||
public void setExtendedLayout(View view, Cursor cursor)
|
||||
{
|
||||
TextView textViewSummary = (TextView) view.findViewById(R.id.summary);
|
||||
textViewSummary.setText(Html.fromHtml(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_TITLE))).toString());
|
||||
|
||||
TextView textViewItemDate = (TextView) view.findViewById(R.id.tv_item_date);
|
||||
long pubDate = cursor.getLong(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_PUBDATE));
|
||||
//textViewItemDate.setText(simpleDateFormat.format(new Date(pubDate)));
|
||||
String dateString = (String) DateUtils.getRelativeTimeSpanString(pubDate);
|
||||
textViewItemDate.setText(dateString);
|
||||
|
||||
TextView textViewItemBody = (TextView) view.findViewById(R.id.body);
|
||||
String body = cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_BODY));
|
||||
textViewItemBody.setText(getBodyText(body));
|
||||
|
||||
TextView textViewTitle = (TextView) view.findViewById(R.id.tv_subscription);
|
||||
textViewTitle.setText(dbConn.getTitleOfSubscriptionByRowID(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_SUBSCRIPTION_ID))));
|
||||
textViewSummary.setTag(cursor.getString(0));
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
public void setExtendedLayoutWebView(View view, Cursor cursor)
|
||||
{
|
||||
WebView webViewContent = (WebView) view.findViewById(R.id.webView_body);
|
||||
webViewContent.setClickable(false);
|
||||
webViewContent.setFocusable(false);
|
||||
//if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
// webViewContent.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
|
||||
webViewContent.loadDataWithBaseURL("", NewsDetailFragment.getHtmlPage(mContext, dbConn , cursor.getInt(0)), "text/html", "UTF-8", "");
|
||||
}
|
||||
|
||||
public void CloseDatabaseConnection()
|
||||
{
|
||||
if(dbConn != null)
|
||||
dbConn.closeDatabase();
|
||||
}
|
||||
|
||||
private void UpdateIsReadCheckBox(View view, String idItemDb)
|
||||
{
|
||||
LinearLayout lLayout = (LinearLayout) view.getParent();
|
||||
Boolean isChecked = dbConn.isFeedUnreadStarred(idItemDb, true);
|
||||
RobotoCheckBox cbRead = (RobotoCheckBox) lLayout.findViewById(R.id.cb_lv_item_read);
|
||||
if(cbRead == null) {//In the default layout the star checkbox is nested two times.
|
||||
lLayout = (LinearLayout) lLayout.getParent();
|
||||
cbRead = (RobotoCheckBox) lLayout.findViewById(R.id.cb_lv_item_read);
|
||||
}
|
||||
cbRead.setChecked(isChecked);
|
||||
}
|
||||
|
||||
public static void ChangeCheckBoxState(RobotoCheckBox cb, boolean state, Context context)
|
||||
{
|
||||
if(cb != null)
|
||||
{
|
||||
if(cb.isChecked() != state)
|
||||
{
|
||||
cb.setChecked(state);
|
||||
|
||||
UpdateListCursor(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateListCursor(Context context)
|
||||
{
|
||||
SherlockFragmentActivity sfa = (SherlockFragmentActivity) context;
|
||||
|
||||
//if tablet view is enabled --> update the listview
|
||||
if(sfa instanceof NewsReaderListActivity)
|
||||
((NewsReaderListActivity) sfa).updateAdapter();
|
||||
}
|
||||
|
||||
|
||||
private String getBodyText(String body)
|
||||
{
|
||||
//if(body.length() > LengthBody)
|
||||
// body = body.substring(0, LengthBody);
|
||||
|
||||
body = body.replaceAll("<img[^>]*>", "");
|
||||
body = body.replaceAll("<video[^>]*>", "");
|
||||
|
||||
SpannableString bodyStringSpannable = new SpannableString(Html.fromHtml(body));
|
||||
bodyStringSpannable.setSpan(bodyForegroundColor, 0, bodyStringSpannable.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
|
||||
String bodyString = bodyStringSpannable.toString().trim();
|
||||
|
||||
if(bodyString.length() > LengthBody)
|
||||
bodyString = bodyString.substring(0, LengthBody);
|
||||
|
||||
return bodyString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View newView(Context cont, Cursor cursor, ViewGroup parent) {
|
||||
// when the view will be created for first time,
|
||||
// we need to tell the adapters, how each item will look
|
||||
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||
View retView = null;
|
||||
|
||||
switch (selectedDesign) {
|
||||
case 0:
|
||||
retView = inflater.inflate(R.layout.subscription_detail_list_item_simple, parent, false);
|
||||
break;
|
||||
case 1:
|
||||
retView = inflater.inflate(R.layout.subscription_detail_list_item_extended, parent, false);
|
||||
break;
|
||||
case 2:
|
||||
retView = inflater.inflate(R.layout.subscription_detail_list_item_extended_webview, parent, false);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(retView != null)
|
||||
retView.setTag(cursor.getString(0));
|
||||
|
||||
return retView;
|
||||
}
|
||||
}
|
|
@ -1,40 +1,40 @@
|
|||
/**
|
||||
* Android ownCloud News
|
||||
*
|
||||
* @author David Luhmer
|
||||
* @copyright 2013 David Luhmer david-dev@live.de
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.luhmer.owncloudnewsreader.data;
|
||||
|
||||
public class ConcreteFeedItem {
|
||||
|
||||
public String folder_id;
|
||||
public String subscription_id;
|
||||
public String favIcon;
|
||||
public String header;
|
||||
public long id_database;
|
||||
|
||||
public ConcreteFeedItem(String header, String folder_id, String subscription_id, String favIcon, long id_database/*, String parent_title*/) {
|
||||
|
||||
this.header = header;
|
||||
this.folder_id = folder_id;
|
||||
this.subscription_id = subscription_id;
|
||||
this.favIcon = favIcon;
|
||||
this.id_database = id_database;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Android ownCloud News
|
||||
*
|
||||
* @author David Luhmer
|
||||
* @copyright 2013 David Luhmer david-dev@live.de
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.luhmer.owncloudnewsreader.data;
|
||||
|
||||
public class ConcreteFeedItem {
|
||||
|
||||
public String folder_id;
|
||||
public String subscription_id;
|
||||
public String favIcon;
|
||||
public String header;
|
||||
public long id_database;
|
||||
|
||||
public ConcreteFeedItem(String header, String folder_id, String subscription_id, String favIcon, long id_database/*, String parent_title*/) {
|
||||
|
||||
this.header = header;
|
||||
this.folder_id = folder_id;
|
||||
this.subscription_id = subscription_id;
|
||||
this.favIcon = favIcon;
|
||||
this.id_database = id_database;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -21,14 +21,6 @@
|
|||
|
||||
package de.luhmer.owncloudnewsreader.helper;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
|
@ -39,6 +31,14 @@ import android.os.Build;
|
|||
import android.util.Log;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/**
|
||||
* Created by David on 24.05.13.
|
||||
*/
|
|
@ -21,11 +21,12 @@
|
|||
|
||||
package de.luhmer.owncloudnewsreader.helper;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import android.content.Context;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseHelper;
|
||||
|
||||
public class DatabaseUtils {
|
|
@ -21,8 +21,6 @@
|
|||
|
||||
package de.luhmer.owncloudnewsreader.helper;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
|
@ -33,6 +31,10 @@ import android.os.AsyncTask;
|
|||
import android.os.Build;
|
||||
import android.util.SparseArray;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
import de.luhmer.owncloudnewsreader.async_tasks.GetImageAsyncTask;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
|
@ -21,6 +21,10 @@
|
|||
|
||||
package de.luhmer.owncloudnewsreader.helper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Environment;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
|
@ -33,10 +37,6 @@ import java.util.List;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Environment;
|
||||
|
||||
public class ImageHandler {
|
||||
//private static final String TAG = "DownloadImagesFromWeb";
|
||||
|
|
@ -1,226 +1,226 @@
|
|||
/**
|
||||
* Android ownCloud News
|
||||
*
|
||||
* @author David Luhmer
|
||||
* @copyright 2013 David Luhmer david-dev@live.de
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.luhmer.owncloudnewsreader.helper;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockDialogFragment;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.Constants;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderDetailFragment;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
import de.luhmer.owncloudnewsreader.VersionInfoDialogFragment;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.reader.IReader;
|
||||
import de.luhmer.owncloudnewsreader.reader.OnAsyncTaskCompletedListener;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.API;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.OwnCloud_Reader;
|
||||
|
||||
public class MenuUtilsSherlockFragmentActivity extends SherlockFragmentActivity {
|
||||
|
||||
protected static final String TAG = "MenuUtils";
|
||||
|
||||
static FragmentActivity activity;
|
||||
|
||||
static MenuItem menuItemSettings;
|
||||
static MenuItem menuItemLogin;
|
||||
static MenuItem menuItemStartImageCaching;
|
||||
|
||||
|
||||
private static MenuItem menuItemUpdater;
|
||||
private static MenuItem menuItemDownloadMoreItems;
|
||||
|
||||
static IReader _Reader;
|
||||
|
||||
/**
|
||||
* @return the menuItemUpdater
|
||||
*/
|
||||
public static MenuItem getMenuItemUpdater() {
|
||||
return menuItemUpdater;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the menuItemDownloadMoreItems
|
||||
*/
|
||||
public static MenuItem getMenuItemDownloadMoreItems() {
|
||||
return menuItemDownloadMoreItems;
|
||||
}
|
||||
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
@Override
|
||||
protected void onResume() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
|
||||
public static void onCreateOptionsMenu(Menu menu, MenuInflater inflater, FragmentActivity act) {
|
||||
inflater.inflate(R.menu.news_reader, menu);
|
||||
activity = act;
|
||||
|
||||
menuItemSettings = menu.findItem(R.id.action_settings);
|
||||
menuItemLogin = menu.findItem(R.id.action_login);
|
||||
menuItemStartImageCaching = menu.findItem(R.id.menu_StartImageCaching);
|
||||
|
||||
menuItemUpdater = menu.findItem(R.id.menu_update);
|
||||
//menuItemMarkAllAsRead = menu.findItem(R.id.menu_markAllAsRead);
|
||||
menuItemDownloadMoreItems = menu.findItem(R.id.menu_downloadMoreItems);
|
||||
|
||||
|
||||
//menuItemMarkAllAsRead.setEnabled(false);
|
||||
menuItemDownloadMoreItems.setEnabled(false);
|
||||
|
||||
NewsReaderDetailFragment ndf = ((NewsReaderDetailFragment) activity.getSupportFragmentManager().findFragmentById(R.id.content_frame));
|
||||
if(ndf != null)
|
||||
ndf.UpdateMenuItemsState();
|
||||
}
|
||||
|
||||
public static boolean onOptionsItemSelected(MenuItem item, FragmentActivity activity) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_About_Changelog:
|
||||
SherlockDialogFragment dialog = new VersionInfoDialogFragment();
|
||||
dialog.show(activity.getSupportFragmentManager(), "VersionChangelogDialogFragment");
|
||||
return true;
|
||||
|
||||
case R.id.menu_markAllAsRead:
|
||||
NewsReaderDetailFragment ndf = ((NewsReaderDetailFragment) activity.getSupportFragmentManager().findFragmentById(R.id.content_frame));
|
||||
if(ndf != null)
|
||||
{
|
||||
/*
|
||||
for(int i = 0; i < ndf.getListView().getChildCount(); i++)
|
||||
{
|
||||
View view = ndf.getListView().getChildAt(i);
|
||||
CheckBox cb = (CheckBox) view.findViewById(R.id.cb_lv_item_read);
|
||||
if(!cb.isChecked())
|
||||
cb.setChecked(true);
|
||||
}
|
||||
*/
|
||||
|
||||
DatabaseConnection dbConn = new DatabaseConnection(activity);
|
||||
try {
|
||||
/*
|
||||
//dbConn.markAllItemsAsRead(ndf.getDatabaseIdsOfItems());
|
||||
List<Integer> items = new ArrayList<Integer>();
|
||||
|
||||
|
||||
Cursor cursor = ncla.getLvAdapter().getCursor();
|
||||
cursor.moveToFirst();
|
||||
do {
|
||||
items.add(Integer.parseInt(cursor.getString(0)));
|
||||
} while (cursor.moveToNext());
|
||||
dbConn.markAllItemsAsRead(items);
|
||||
*/
|
||||
dbConn.markAllItemsAsReadForCurrentView();
|
||||
} finally {
|
||||
dbConn.closeDatabase();
|
||||
}
|
||||
ndf.UpdateCursor();
|
||||
|
||||
//If tablet view is enabled update the listview as well
|
||||
if(activity instanceof NewsReaderListActivity)
|
||||
((NewsReaderListActivity) activity).updateAdapter();
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
case R.id.menu_downloadMoreItems:
|
||||
DownloadMoreItems();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void DownloadMoreItems()
|
||||
{
|
||||
/*
|
||||
DatabaseConnection dbConn = new DatabaseConnection(activity);
|
||||
int count = dbConn.getCountFeedsForFolder(SubscriptionExpandableListAdapter.ALL_ITEMS, false);
|
||||
if(count >= Constants.maxItemsCount)
|
||||
{
|
||||
String text = activity.getString(R.string.max_items_count_reached);
|
||||
text = text.replace("XX", "" + Constants.maxItemsCount);
|
||||
new AlertDialog.Builder(activity)
|
||||
.setTitle(activity.getString(R.string.empty_view_header))
|
||||
.setMessage(text)
|
||||
.setPositiveButton(activity.getString(android.R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,int id) {
|
||||
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
//Toast.makeText(activity, text, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
else
|
||||
{*/
|
||||
String username = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext()).getString("edt_username", "");
|
||||
String password = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext()).getString("edt_password", "");
|
||||
|
||||
if(username != null) {
|
||||
_Reader = new OwnCloud_Reader();
|
||||
((OwnCloud_Reader)_Reader).Start_AsyncTask_GetVersion(Constants.TaskID_GetVersion, activity, onAsyncTaskGetVersionFinished, username, password);
|
||||
|
||||
Toast.makeText(activity, activity.getString(R.string.toast_GettingMoreItems), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
static OnAsyncTaskCompletedListener onAsyncTaskGetVersionFinished = new OnAsyncTaskCompletedListener() {
|
||||
|
||||
@Override
|
||||
public void onAsyncTaskCompleted(int task_id, Object task_result) {
|
||||
if(_Reader != null) {
|
||||
String appVersion = task_result.toString();
|
||||
API api = API.GetRightApiForVersion(appVersion, activity);
|
||||
((OwnCloud_Reader) _Reader).setApi(api);
|
||||
|
||||
NewsReaderDetailFragment ndf = ((NewsReaderDetailFragment) activity.getSupportFragmentManager().findFragmentById(R.id.content_frame));
|
||||
_Reader.Start_AsyncTask_GetOldItems(Constants.TaskID_GetItems, activity, onAsyncTaskComplete, ndf.getIdFeed(), ndf.getIdFolder());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static OnAsyncTaskCompletedListener onAsyncTaskComplete = new OnAsyncTaskCompletedListener() {
|
||||
@Override
|
||||
public void onAsyncTaskCompleted(int task_id, Object task_result) {
|
||||
NewsReaderDetailFragment ndf = ((NewsReaderDetailFragment) activity.getSupportFragmentManager().findFragmentById(R.id.content_frame));
|
||||
if(ndf != null)
|
||||
ndf.UpdateCursor();
|
||||
|
||||
Log.d(TAG, "Finished Download extra items..");
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Android ownCloud News
|
||||
*
|
||||
* @author David Luhmer
|
||||
* @copyright 2013 David Luhmer david-dev@live.de
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.luhmer.owncloudnewsreader.helper;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockDialogFragment;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.Constants;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderDetailFragment;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
import de.luhmer.owncloudnewsreader.VersionInfoDialogFragment;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.reader.IReader;
|
||||
import de.luhmer.owncloudnewsreader.reader.OnAsyncTaskCompletedListener;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.API;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.OwnCloud_Reader;
|
||||
|
||||
public class MenuUtilsSherlockFragmentActivity extends SherlockFragmentActivity {
|
||||
|
||||
protected static final String TAG = "MenuUtils";
|
||||
|
||||
static FragmentActivity activity;
|
||||
|
||||
static MenuItem menuItemSettings;
|
||||
static MenuItem menuItemLogin;
|
||||
static MenuItem menuItemStartImageCaching;
|
||||
|
||||
|
||||
private static MenuItem menuItemUpdater;
|
||||
private static MenuItem menuItemDownloadMoreItems;
|
||||
|
||||
static IReader _Reader;
|
||||
|
||||
/**
|
||||
* @return the menuItemUpdater
|
||||
*/
|
||||
public static MenuItem getMenuItemUpdater() {
|
||||
return menuItemUpdater;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the menuItemDownloadMoreItems
|
||||
*/
|
||||
public static MenuItem getMenuItemDownloadMoreItems() {
|
||||
return menuItemDownloadMoreItems;
|
||||
}
|
||||
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
@Override
|
||||
protected void onResume() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
|
||||
public static void onCreateOptionsMenu(Menu menu, MenuInflater inflater, FragmentActivity act) {
|
||||
inflater.inflate(R.menu.news_reader, menu);
|
||||
activity = act;
|
||||
|
||||
menuItemSettings = menu.findItem(R.id.action_settings);
|
||||
menuItemLogin = menu.findItem(R.id.action_login);
|
||||
menuItemStartImageCaching = menu.findItem(R.id.menu_StartImageCaching);
|
||||
|
||||
menuItemUpdater = menu.findItem(R.id.menu_update);
|
||||
//menuItemMarkAllAsRead = menu.findItem(R.id.menu_markAllAsRead);
|
||||
menuItemDownloadMoreItems = menu.findItem(R.id.menu_downloadMoreItems);
|
||||
|
||||
|
||||
//menuItemMarkAllAsRead.setEnabled(false);
|
||||
menuItemDownloadMoreItems.setEnabled(false);
|
||||
|
||||
NewsReaderDetailFragment ndf = ((NewsReaderDetailFragment) activity.getSupportFragmentManager().findFragmentById(R.id.content_frame));
|
||||
if(ndf != null)
|
||||
ndf.UpdateMenuItemsState();
|
||||
}
|
||||
|
||||
public static boolean onOptionsItemSelected(MenuItem item, FragmentActivity activity) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_About_Changelog:
|
||||
SherlockDialogFragment dialog = new VersionInfoDialogFragment();
|
||||
dialog.show(activity.getSupportFragmentManager(), "VersionChangelogDialogFragment");
|
||||
return true;
|
||||
|
||||
case R.id.menu_markAllAsRead:
|
||||
NewsReaderDetailFragment ndf = ((NewsReaderDetailFragment) activity.getSupportFragmentManager().findFragmentById(R.id.content_frame));
|
||||
if(ndf != null)
|
||||
{
|
||||
/*
|
||||
for(int i = 0; i < ndf.getListView().getChildCount(); i++)
|
||||
{
|
||||
View view = ndf.getListView().getChildAt(i);
|
||||
CheckBox cb = (CheckBox) view.findViewById(R.id.cb_lv_item_read);
|
||||
if(!cb.isChecked())
|
||||
cb.setChecked(true);
|
||||
}
|
||||
*/
|
||||
|
||||
DatabaseConnection dbConn = new DatabaseConnection(activity);
|
||||
try {
|
||||
/*
|
||||
//dbConn.markAllItemsAsRead(ndf.getDatabaseIdsOfItems());
|
||||
List<Integer> items = new ArrayList<Integer>();
|
||||
|
||||
|
||||
Cursor cursor = ncla.getLvAdapter().getCursor();
|
||||
cursor.moveToFirst();
|
||||
do {
|
||||
items.add(Integer.parseInt(cursor.getString(0)));
|
||||
} while (cursor.moveToNext());
|
||||
dbConn.markAllItemsAsRead(items);
|
||||
*/
|
||||
dbConn.markAllItemsAsReadForCurrentView();
|
||||
} finally {
|
||||
dbConn.closeDatabase();
|
||||
}
|
||||
ndf.UpdateCursor();
|
||||
|
||||
//If tablet view is enabled update the listview as well
|
||||
if(activity instanceof NewsReaderListActivity)
|
||||
((NewsReaderListActivity) activity).updateAdapter();
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
case R.id.menu_downloadMoreItems:
|
||||
DownloadMoreItems();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void DownloadMoreItems()
|
||||
{
|
||||
/*
|
||||
DatabaseConnection dbConn = new DatabaseConnection(activity);
|
||||
int count = dbConn.getCountFeedsForFolder(SubscriptionExpandableListAdapter.ALL_ITEMS, false);
|
||||
if(count >= Constants.maxItemsCount)
|
||||
{
|
||||
String text = activity.getString(R.string.max_items_count_reached);
|
||||
text = text.replace("XX", "" + Constants.maxItemsCount);
|
||||
new AlertDialog.Builder(activity)
|
||||
.setTitle(activity.getString(R.string.empty_view_header))
|
||||
.setMessage(text)
|
||||
.setPositiveButton(activity.getString(android.R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,int id) {
|
||||
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
//Toast.makeText(activity, text, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
else
|
||||
{*/
|
||||
String username = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext()).getString("edt_username", "");
|
||||
String password = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext()).getString("edt_password", "");
|
||||
|
||||
if(username != null) {
|
||||
_Reader = new OwnCloud_Reader();
|
||||
((OwnCloud_Reader)_Reader).Start_AsyncTask_GetVersion(Constants.TaskID_GetVersion, activity, onAsyncTaskGetVersionFinished, username, password);
|
||||
|
||||
Toast.makeText(activity, activity.getString(R.string.toast_GettingMoreItems), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
static OnAsyncTaskCompletedListener onAsyncTaskGetVersionFinished = new OnAsyncTaskCompletedListener() {
|
||||
|
||||
@Override
|
||||
public void onAsyncTaskCompleted(int task_id, Object task_result) {
|
||||
if(_Reader != null) {
|
||||
String appVersion = task_result.toString();
|
||||
API api = API.GetRightApiForVersion(appVersion, activity);
|
||||
((OwnCloud_Reader) _Reader).setApi(api);
|
||||
|
||||
NewsReaderDetailFragment ndf = ((NewsReaderDetailFragment) activity.getSupportFragmentManager().findFragmentById(R.id.content_frame));
|
||||
_Reader.Start_AsyncTask_GetOldItems(Constants.TaskID_GetItems, activity, onAsyncTaskComplete, ndf.getIdFeed(), ndf.getIdFolder());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static OnAsyncTaskCompletedListener onAsyncTaskComplete = new OnAsyncTaskCompletedListener() {
|
||||
@Override
|
||||
public void onAsyncTaskCompleted(int task_id, Object task_result) {
|
||||
NewsReaderDetailFragment ndf = ((NewsReaderDetailFragment) activity.getSupportFragmentManager().findFragmentById(R.id.content_frame));
|
||||
if(ndf != null)
|
||||
ndf.UpdateCursor();
|
||||
|
||||
Log.d(TAG, "Finished Download extra items..");
|
||||
}
|
||||
};
|
||||
}
|
|
@ -24,6 +24,7 @@ package de.luhmer.owncloudnewsreader.helper;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.services.SyncItemStateService;
|
||||
|
||||
public class PostDelayHandler {
|
|
@ -27,6 +27,7 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue