This commit is contained in:
Andrew Dolgov 2014-10-17 00:06:56 +04:00
parent 5775c0d56b
commit 97cc96839d
283 changed files with 5142 additions and 3559 deletions

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="libs/gson-1.7.1.jar"/>
<classpathentry kind="lib" path="libs/jsoup-1.6.1.jar"/>
<classpathentry kind="lib" path="libs/android-support-v4.jar"/>
<classpathentry kind="lib" path="libs/dashclock-api-r1.1.jar"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

13
.gitignore vendored
View File

@ -1,3 +1,12 @@
/gen
/bin
bin/
gen/
.gradle/
build/
local.properties
import-summary.txt
Thumbs.db
.idea/workspace.xml
.idea/tasks.xml
.idea/datasources.xml
.idea/dataSources.ids
.idea/libraries

1
.idea/.name Normal file
View File

@ -0,0 +1 @@
Tiny-Tiny-RSS-for-Honeycomb

23
.idea/compiler.xml Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

View File

@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="" />
</component>

5
.idea/encodings.xml Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>

19
.idea/gradle.xml Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/orgfoxttrss" />
<option value="$PROJECT_DIR$/taskerlocaleapi" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

26
.idea/misc.xml Normal file
View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>Android API 19 Platform</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>

11
.idea/modules.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Tiny-Tiny-RSS-for-Honeycomb.iml" filepath="$PROJECT_DIR$/Tiny-Tiny-RSS-for-Honeycomb.iml" />
<module fileurl="file://$PROJECT_DIR$/orgfoxttrss/orgfoxttrss.iml" filepath="$PROJECT_DIR$/orgfoxttrss/orgfoxttrss.iml" />
<module fileurl="file://$PROJECT_DIR$/taskerlocaleapi/taskerlocaleapi.iml" filepath="$PROJECT_DIR$/taskerlocaleapi/taskerlocaleapi.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,5 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>

7
.idea/vcs.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.fox.ttrss</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -1,2 +0,0 @@
eclipse.preferences.version=1
encoding//src/org/fox/ttrss/util/EnlargingImageView.java=UTF-8

View File

@ -1,11 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View File

@ -1,24 +0,0 @@
Tiny Tiny RSS client for Android
================================
http://tt-rss.org/tt-rss-android
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright (c) 2011 Andrew Dolgov (unless explicitly stated otherwise).
## See also
* FAQ: http://tt-rss.org/redmine/projects/tt-rss-android/wiki/#FAQ
* Forum: http://tt-rss.org/forum

View File

@ -0,0 +1,19 @@
<?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="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

17
build.gradle Normal file
View File

@ -0,0 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
}
}
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
maven { url "http://jzaccone.github.io/SlidingMenu-aar" }
jcenter()
}
}

View File

@ -1,2 +0,0 @@
# Project target.
target=android-14

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip

164
gradlew vendored Normal file
View File

@ -0,0 +1,164 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
gradlew.bat vendored Normal file
View File

@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
</lint>

32
orgfoxttrss/build.gradle Normal file
View File

@ -0,0 +1,32 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "org.fox.ttrss"
minSdkVersion 8
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
//compile project(':slidingMenulibrary')
compile 'com.jeremyfeinstein.slidingmenu:library:1.3@aar'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compile 'com.viewpagerindicator:library:2.4.1'
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.code.gson:gson:1.7.1'
compile 'com.android.support:appcompat-v7:18.0.0'
compile files('libs/dashclock-api-r1.1.jar')
compile files('libs/jsoup-1.6.1.jar')
compile files('libs/universal-image-loader-1.9.3.jar')
}

3
orgfoxttrss/lint.xml Normal file
View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<lint>
</lint>

View File

@ -0,0 +1,94 @@
<?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="Tiny-Tiny-RSS-for-Honeycomb" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":orgfoxttrss" />
</configuration>
</facet>
<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="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
<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>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
<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/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" 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/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" 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/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
</content>
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="dashclock-api-r1.1" level="project" />
<orderEntry type="library" exported="" name="systembartint-1.0.3" level="project" />
<orderEntry type="library" exported="" name="jsoup-1.6.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" />
<orderEntry type="library" exported="" name="library-1.3" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-18.0.0" level="project" />
<orderEntry type="library" exported="" name="gson-1.7.1" level="project" />
<orderEntry type="library" exported="" name="library-2.4.1" level="project" />
<orderEntry type="library" exported="" name="universal-image-loader-1.9.3" level="project" />
</component>
</module>

View File

@ -1,39 +1,39 @@
package android.support.v4.app;
// http://code.google.com/p/android/issues/detail?id=37484
// Thanks for your amazing code quality, Google.
import android.os.Bundle;
import android.view.ViewGroup;
public class ClassloaderWorkaroundFragmentStatePagerAdapter extends
FragmentStatePagerAdapter {
public ClassloaderWorkaroundFragmentStatePagerAdapter(FragmentManager fm) {
super(fm);
// TODO Auto-generated constructor stub
}
@Override
public Fragment getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
Fragment f = (Fragment) super.instantiateItem(container, position);
Bundle savedFragmentState = f.mSavedFragmentState;
if (savedFragmentState != null) {
savedFragmentState.setClassLoader(f.getClass().getClassLoader());
}
return f;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return 0;
}
}
package android.support.v4.app;
// http://code.google.com/p/android/issues/detail?id=37484
// Thanks for your amazing code quality, Google.
import android.os.Bundle;
import android.view.ViewGroup;
public class ClassloaderWorkaroundFragmentStatePagerAdapter extends
FragmentStatePagerAdapter {
public ClassloaderWorkaroundFragmentStatePagerAdapter(FragmentManager fm) {
super(fm);
// TODO Auto-generated constructor stub
}
@Override
public Fragment getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
Fragment f = (Fragment) super.instantiateItem(container, position);
Bundle savedFragmentState = f.mSavedFragmentState;
if (savedFragmentState != null) {
savedFragmentState.setClassLoader(f.getClass().getClassLoader());
}
return f;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return 0;
}
}

View File

@ -1,93 +1,93 @@
package org.fox.ttrss.tasker;
import org.fox.ttrss.ApiRequest;
import org.fox.ttrss.CommonActivity;
import org.fox.ttrss.OnlineActivity;
import org.fox.ttrss.offline.OfflineDownloadService;
import org.fox.ttrss.offline.OfflineUploadService;
import org.fox.ttrss.util.SimpleLoginManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
public class TaskerReceiver extends BroadcastReceiver {
private final String TAG = this.getClass().getSimpleName();
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Got action: " + intent.getAction());
final Context fContext = context;
if (com.twofortyfouram.locale.Intent.ACTION_FIRE_SETTING.equals(intent.getAction())) {
final Bundle settings = intent.getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE);
final int actionId = settings != null ? settings.getInt("actionId", -1) : -1;
Log.d(TAG, "received action id=" + actionId);
SimpleLoginManager loginMgr = new SimpleLoginManager() {
@Override
protected void onLoginSuccess(int requestId, String sessionId, int apiLevel) {
switch (actionId) {
case TaskerSettingsActivity.ACTION_DOWNLOAD:
if (true) {
Intent intent = new Intent(fContext,
OfflineDownloadService.class);
intent.putExtra("sessionId", sessionId);
intent.putExtra("batchMode", true);
fContext.startService(intent);
}
break;
case TaskerSettingsActivity.ACTION_UPLOAD:
if (true) {
Intent intent = new Intent(fContext,
OfflineUploadService.class);
intent.putExtra("sessionId", sessionId);
intent.putExtra("batchMode", true);
fContext.startService(intent);
}
break;
default:
Log.d(TAG, "unknown action id=" + actionId);
}
}
@Override
protected void onLoginFailed(int requestId, ApiRequest ar) {
Toast toast = Toast.makeText(fContext, fContext.getString(ar.getErrorMessage()), Toast.LENGTH_SHORT);
toast.show();
}
@Override
protected void onLoggingIn(int requestId) {
//
}
};
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String login = prefs.getString("login", "").trim();
String password = prefs.getString("password", "").trim();
String ttrssUrl = prefs.getString("ttrss_url", "").trim();
if (ttrssUrl.equals("")) {
Toast toast = Toast.makeText(fContext, "Could not download articles: not configured?", Toast.LENGTH_SHORT);
toast.show();
} else {
loginMgr.logIn(context, 1, login, password);
}
}
}
}
package org.fox.ttrss.tasker;
import org.fox.ttrss.ApiRequest;
import org.fox.ttrss.CommonActivity;
import org.fox.ttrss.OnlineActivity;
import org.fox.ttrss.offline.OfflineDownloadService;
import org.fox.ttrss.offline.OfflineUploadService;
import org.fox.ttrss.util.SimpleLoginManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
public class TaskerReceiver extends BroadcastReceiver {
private final String TAG = this.getClass().getSimpleName();
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Got action: " + intent.getAction());
final Context fContext = context;
if (com.twofortyfouram.locale.Intent.ACTION_FIRE_SETTING.equals(intent.getAction())) {
final Bundle settings = intent.getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE);
final int actionId = settings != null ? settings.getInt("actionId", -1) : -1;
Log.d(TAG, "received action id=" + actionId);
SimpleLoginManager loginMgr = new SimpleLoginManager() {
@Override
protected void onLoginSuccess(int requestId, String sessionId, int apiLevel) {
switch (actionId) {
case TaskerSettingsActivity.ACTION_DOWNLOAD:
if (true) {
Intent intent = new Intent(fContext,
OfflineDownloadService.class);
intent.putExtra("sessionId", sessionId);
intent.putExtra("batchMode", true);
fContext.startService(intent);
}
break;
case TaskerSettingsActivity.ACTION_UPLOAD:
if (true) {
Intent intent = new Intent(fContext,
OfflineUploadService.class);
intent.putExtra("sessionId", sessionId);
intent.putExtra("batchMode", true);
fContext.startService(intent);
}
break;
default:
Log.d(TAG, "unknown action id=" + actionId);
}
}
@Override
protected void onLoginFailed(int requestId, ApiRequest ar) {
Toast toast = Toast.makeText(fContext, fContext.getString(ar.getErrorMessage()), Toast.LENGTH_SHORT);
toast.show();
}
@Override
protected void onLoggingIn(int requestId) {
//
}
};
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String login = prefs.getString("login", "").trim();
String password = prefs.getString("password", "").trim();
String ttrssUrl = prefs.getString("ttrss_url", "").trim();
if (ttrssUrl.equals("")) {
Toast toast = Toast.makeText(fContext, "Could not download articles: not configured?", Toast.LENGTH_SHORT);
toast.show();
} else {
loginMgr.logIn(context, 1, login, password);
}
}
}
}

View File

@ -1,96 +1,96 @@
package org.fox.ttrss.tasker;
import org.fox.ttrss.R;
import org.fox.ttrss.offline.OfflineDownloadService;
import org.fox.ttrss.offline.OfflineUploadService;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
public class TaskerSettingsActivity extends Activity {
protected static final int ACTION_DOWNLOAD = 0;
protected static final int ACTION_UPLOAD = 1;
private final String TAG = this.getClass().getSimpleName();
protected Bundle m_settings = new Bundle();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle settings = getIntent().getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE);
int actionId = settings != null ? settings.getInt("actionId", -1) : -1;
setContentView(R.layout.tasker_settings);
RadioGroup radioGroup = (RadioGroup) findViewById(R.id.taskerActions);
switch (actionId) {
case TaskerSettingsActivity.ACTION_DOWNLOAD:
radioGroup.check(R.id.actionDownload);
break;
case TaskerSettingsActivity.ACTION_UPLOAD:
radioGroup.check(R.id.actionUpload);
break;
default:
Log.d(TAG, "unknown action id=" + actionId);
}
radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.actionDownload:
m_settings.putInt("actionId", ACTION_DOWNLOAD);
break;
case R.id.actionUpload:
m_settings.putInt("actionId", ACTION_UPLOAD);
break;
}
}
});
Button button = (Button)findViewById(R.id.close_button);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
@Override
public void finish() {
final Intent intent = new Intent();
intent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE, m_settings);
String blurb = "?";
switch (m_settings.getInt("actionId")) {
case TaskerSettingsActivity.ACTION_DOWNLOAD:
blurb = getString(R.string.download_articles_and_go_offline);
break;
case TaskerSettingsActivity.ACTION_UPLOAD:
blurb = getString(R.string.synchronize_read_articles_and_go_online);
break;
}
intent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB, blurb);
setResult(RESULT_OK, intent);
super.finish();
}
}
package org.fox.ttrss.tasker;
import org.fox.ttrss.R;
import org.fox.ttrss.offline.OfflineDownloadService;
import org.fox.ttrss.offline.OfflineUploadService;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
public class TaskerSettingsActivity extends Activity {
protected static final int ACTION_DOWNLOAD = 0;
protected static final int ACTION_UPLOAD = 1;
private final String TAG = this.getClass().getSimpleName();
protected Bundle m_settings = new Bundle();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle settings = getIntent().getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE);
int actionId = settings != null ? settings.getInt("actionId", -1) : -1;
setContentView(R.layout.tasker_settings);
RadioGroup radioGroup = (RadioGroup) findViewById(R.id.taskerActions);
switch (actionId) {
case TaskerSettingsActivity.ACTION_DOWNLOAD:
radioGroup.check(R.id.actionDownload);
break;
case TaskerSettingsActivity.ACTION_UPLOAD:
radioGroup.check(R.id.actionUpload);
break;
default:
Log.d(TAG, "unknown action id=" + actionId);
}
radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.actionDownload:
m_settings.putInt("actionId", ACTION_DOWNLOAD);
break;
case R.id.actionUpload:
m_settings.putInt("actionId", ACTION_UPLOAD);
break;
}
}
});
Button button = (Button)findViewById(R.id.close_button);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
@Override
public void finish() {
final Intent intent = new Intent();
intent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE, m_settings);
String blurb = "?";
switch (m_settings.getInt("actionId")) {
case TaskerSettingsActivity.ACTION_DOWNLOAD:
blurb = getString(R.string.download_articles_and_go_offline);
break;
case TaskerSettingsActivity.ACTION_UPLOAD:
blurb = getString(R.string.synchronize_read_articles_and_go_online);
break;
}
intent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB, blurb);
setResult(RESULT_OK, intent);
super.finish();
}
}

View File

@ -1,252 +1,252 @@
package org.fox.ttrss.util;
/*
* Copyright (C) 2013 Tomáš Procházka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.lang.reflect.Field;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
/**
* Special version of ImageView which allow enlarge width of image if android:adjustViewBounds is true.
*
* <p>It simulate HTML behaviour &lt;img src="" widh="100" /&gt;</p>
* <p><a href="http://stackoverflow.com/questions/6202000/imageview-one-dimension-to-fit-free-space-and-second-evaluate-to-keep-aspect-rati">Stackoverflow question link</a></p>
*
* <p>It also allow set related view which will be used as reference for size measure.</p>
*
* @author Tomáš Procházka &lt;<a href="mailto:tomas.prochazka@inmite.eu">tomas.prochazka@gmail.com</a>&gt;
* @version $Revision: 0$ ($Date: 6.6.2011 18:16:52$)
*/
public class EnlargingImageView extends android.widget.ImageView {
private int mDrawableWidth;
private int mDrawableHeight;
private boolean mAdjustViewBoundsL;
private int mMaxWidthL = Integer.MAX_VALUE;
private int mMaxHeightL = Integer.MAX_VALUE;
private View relatedView;
public EnlargingImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// hack for acces some private field of parent :-(
Field f;
try {
f = android.widget.ImageView.class.getDeclaredField("mAdjustViewBounds");
f.setAccessible(true);
setAdjustViewBounds((Boolean) f.get(this));
f = android.widget.ImageView.class.getDeclaredField("mMaxWidth");
f.setAccessible(true);
setMaxWidth((Integer) f.get(this));
f = android.widget.ImageView.class.getDeclaredField("mMaxHeight");
f.setAccessible(true);
setMaxHeight((Integer) f.get(this));
} catch (Exception e) {
e.printStackTrace();
}
}
public EnlargingImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public EnlargingImageView(Context context) {
super(context);
}
public void setAdjustViewBounds(boolean adjustViewBounds) {
super.setAdjustViewBounds(adjustViewBounds);
mAdjustViewBoundsL = adjustViewBounds;
}
public void setMaxWidth(int maxWidth) {
super.setMaxWidth(maxWidth);
mMaxWidthL = maxWidth;
}
public void setMaxHeight(int maxHeight) {
super.setMaxHeight(maxHeight);
mMaxHeightL = maxHeight;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (getDrawable() == null) {
setMeasuredDimension(0, 0);
return;
}
mDrawableWidth = getDrawable().getIntrinsicWidth();
mDrawableHeight = getDrawable().getIntrinsicHeight();
int w = 0;
int h = 0;
// Desired aspect ratio of the view's contents (not including padding)
float desiredAspect = 0.0f;
// We are allowed to change the view's width
boolean resizeWidth = false;
// We are allowed to change the view's height
boolean resizeHeight = false;
if (mDrawableWidth > 0) {
w = mDrawableWidth;
h = mDrawableHeight;
if (w <= 0) w = 1;
if (h <= 0) h = 1;
// We are supposed to adjust view bounds to match the aspect
// ratio of our drawable. See if that is possible.
if (mAdjustViewBoundsL) {
int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
resizeWidth = widthSpecMode != MeasureSpec.EXACTLY;
resizeHeight = heightSpecMode != MeasureSpec.EXACTLY;
desiredAspect = (float) w / (float) h;
}
}
int pleft = getPaddingLeft();
int pright = getPaddingRight();
int ptop = getPaddingTop();
int pbottom = getPaddingBottom();
int widthSize;
int heightSize;
if (resizeWidth || resizeHeight) {
/* If we get here, it means we want to resize to match the
drawables aspect ratio, and we have the freedom to change at
least one dimension.
*/
// Get the max possible width given our constraints
widthSize = resolveAdjustedSize(w + pleft + pright,
mMaxWidthL, widthMeasureSpec);
// Get the max possible height given our constraints
heightSize = resolveAdjustedSize(h + ptop + pbottom,
mMaxHeightL, heightMeasureSpec);
if (desiredAspect != 0.0f) {
// See what our actual aspect ratio is
float actualAspect = (float) (widthSize - pleft - pright) /
(heightSize - ptop - pbottom);
if (Math.abs(actualAspect - desiredAspect) > 0.0000001) {
// Try adjusting width to be proportional to height
if (resizeWidth) {
int newWidth = (int) (desiredAspect * (heightSize - ptop - pbottom)) + pleft + pright;
if (/*newWidth <= widthSize &&*/newWidth > 0) {
widthSize = Math.min(newWidth, mMaxWidthL);
heightSize = (int) ((widthSize - pleft - pright) / desiredAspect) + ptop + pbottom;
}
}
// Try adjusting height to be proportional to width
if (resizeHeight) {
int newHeight = (int) ((widthSize - pleft - pright) / desiredAspect) + ptop + pbottom;
if (/*newHeight <= heightSize && */newHeight > 0) {
heightSize = Math.min(newHeight, mMaxHeightL);
widthSize = (int) (desiredAspect * (heightSize - ptop - pbottom)) + pleft + pright;
}
}
}
}
} else {
/* We are either don't want to preserve the drawables aspect ratio,
or we are not allowed to change view dimensions. Just measure in
the normal way.
*/
w += pleft + pright;
h += ptop + pbottom;
w = Math.max(w, getSuggestedMinimumWidth());
h = Math.max(h, getSuggestedMinimumHeight());
widthSize = resolveSize(w, widthMeasureSpec);
heightSize = resolveSize(h, heightMeasureSpec);
}
//Log.d(Constants.LOGTAG, mDrawableWidth + ":" + mDrawableHeight + " to " + widthSize + ":" + heightSize);
setMeasuredDimension(widthSize, heightSize);
if (relatedView != null) {
//Log.i(Constants.LOGTAG, getTag() + " onMeasure:" + widthSize + ", " + heightSize + " update size of related view!");
relatedView.getLayoutParams().width = widthSize;
relatedView.getLayoutParams().height = heightSize;
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
//Log.d(Constants.LOGTAG, getTag() + " onLayout:" + left + ", " + top + ", " + right + ", " + bottom);
}
/**
* Experimental. This view will be set to the same size as this image.
*/
public void setRelatedView(View view) {
relatedView = view;
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
//Log.d(Constants.LOGTAG, getTag() + " onSizeChanged:" + w + ", " + h + ", " + oldw + ", " + oldh);
}
private int resolveAdjustedSize(int desiredSize, int maxSize, int measureSpec) {
int result = desiredSize;
int specMode = MeasureSpec.getMode(measureSpec);
int specSize = MeasureSpec.getSize(measureSpec);
switch (specMode) {
case MeasureSpec.UNSPECIFIED:
/* Parent says we can be as big as we want. Just don't be larger
than max size imposed on ourselves.
*/
result = Math.min(desiredSize, maxSize);
break;
case MeasureSpec.AT_MOST:
// Parent says we can be as big as we want, up to specSize.
// Don't be larger than specSize, and don't be larger than
// the max size imposed on ourselves.
result = Math.min(Math.min(desiredSize, specSize), maxSize);
break;
case MeasureSpec.EXACTLY:
// No choice. Do what we are told.
result = specSize;
break;
}
return result;
}
package org.fox.ttrss.util;
/*
* Copyright (C) 2013 Tomáš Procházka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.lang.reflect.Field;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
/**
* Special version of ImageView which allow enlarge width of image if android:adjustViewBounds is true.
*
* <p>It simulate HTML behaviour &lt;img src="" widh="100" /&gt;</p>
* <p><a href="http://stackoverflow.com/questions/6202000/imageview-one-dimension-to-fit-free-space-and-second-evaluate-to-keep-aspect-rati">Stackoverflow question link</a></p>
*
* <p>It also allow set related view which will be used as reference for size measure.</p>
*
* @author Tomáš Procházka &lt;<a href="mailto:tomas.prochazka@inmite.eu">tomas.prochazka@gmail.com</a>&gt;
* @version $Revision: 0$ ($Date: 6.6.2011 18:16:52$)
*/
public class EnlargingImageView extends android.widget.ImageView {
private int mDrawableWidth;
private int mDrawableHeight;
private boolean mAdjustViewBoundsL;
private int mMaxWidthL = Integer.MAX_VALUE;
private int mMaxHeightL = Integer.MAX_VALUE;
private View relatedView;
public EnlargingImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// hack for acces some private field of parent :-(
Field f;
try {
f = android.widget.ImageView.class.getDeclaredField("mAdjustViewBounds");
f.setAccessible(true);
setAdjustViewBounds((Boolean) f.get(this));
f = android.widget.ImageView.class.getDeclaredField("mMaxWidth");
f.setAccessible(true);
setMaxWidth((Integer) f.get(this));
f = android.widget.ImageView.class.getDeclaredField("mMaxHeight");
f.setAccessible(true);
setMaxHeight((Integer) f.get(this));
} catch (Exception e) {
e.printStackTrace();
}
}
public EnlargingImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public EnlargingImageView(Context context) {
super(context);
}
public void setAdjustViewBounds(boolean adjustViewBounds) {
super.setAdjustViewBounds(adjustViewBounds);
mAdjustViewBoundsL = adjustViewBounds;
}
public void setMaxWidth(int maxWidth) {
super.setMaxWidth(maxWidth);
mMaxWidthL = maxWidth;
}
public void setMaxHeight(int maxHeight) {
super.setMaxHeight(maxHeight);
mMaxHeightL = maxHeight;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (getDrawable() == null) {
setMeasuredDimension(0, 0);
return;
}
mDrawableWidth = getDrawable().getIntrinsicWidth();
mDrawableHeight = getDrawable().getIntrinsicHeight();
int w = 0;
int h = 0;
// Desired aspect ratio of the view's contents (not including padding)
float desiredAspect = 0.0f;
// We are allowed to change the view's width
boolean resizeWidth = false;
// We are allowed to change the view's height
boolean resizeHeight = false;
if (mDrawableWidth > 0) {
w = mDrawableWidth;
h = mDrawableHeight;
if (w <= 0) w = 1;
if (h <= 0) h = 1;
// We are supposed to adjust view bounds to match the aspect
// ratio of our drawable. See if that is possible.
if (mAdjustViewBoundsL) {
int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
resizeWidth = widthSpecMode != MeasureSpec.EXACTLY;
resizeHeight = heightSpecMode != MeasureSpec.EXACTLY;
desiredAspect = (float) w / (float) h;
}
}
int pleft = getPaddingLeft();
int pright = getPaddingRight();
int ptop = getPaddingTop();
int pbottom = getPaddingBottom();
int widthSize;
int heightSize;
if (resizeWidth || resizeHeight) {
/* If we get here, it means we want to resize to match the
drawables aspect ratio, and we have the freedom to change at
least one dimension.
*/
// Get the max possible width given our constraints
widthSize = resolveAdjustedSize(w + pleft + pright,
mMaxWidthL, widthMeasureSpec);
// Get the max possible height given our constraints
heightSize = resolveAdjustedSize(h + ptop + pbottom,
mMaxHeightL, heightMeasureSpec);
if (desiredAspect != 0.0f) {
// See what our actual aspect ratio is
float actualAspect = (float) (widthSize - pleft - pright) /
(heightSize - ptop - pbottom);
if (Math.abs(actualAspect - desiredAspect) > 0.0000001) {
// Try adjusting width to be proportional to height
if (resizeWidth) {
int newWidth = (int) (desiredAspect * (heightSize - ptop - pbottom)) + pleft + pright;
if (/*newWidth <= widthSize &&*/newWidth > 0) {
widthSize = Math.min(newWidth, mMaxWidthL);
heightSize = (int) ((widthSize - pleft - pright) / desiredAspect) + ptop + pbottom;
}
}
// Try adjusting height to be proportional to width
if (resizeHeight) {
int newHeight = (int) ((widthSize - pleft - pright) / desiredAspect) + ptop + pbottom;
if (/*newHeight <= heightSize && */newHeight > 0) {
heightSize = Math.min(newHeight, mMaxHeightL);
widthSize = (int) (desiredAspect * (heightSize - ptop - pbottom)) + pleft + pright;
}
}
}
}
} else {
/* We are either don't want to preserve the drawables aspect ratio,
or we are not allowed to change view dimensions. Just measure in
the normal way.
*/
w += pleft + pright;
h += ptop + pbottom;
w = Math.max(w, getSuggestedMinimumWidth());
h = Math.max(h, getSuggestedMinimumHeight());
widthSize = resolveSize(w, widthMeasureSpec);
heightSize = resolveSize(h, heightMeasureSpec);
}
//Log.d(Constants.LOGTAG, mDrawableWidth + ":" + mDrawableHeight + " to " + widthSize + ":" + heightSize);
setMeasuredDimension(widthSize, heightSize);
if (relatedView != null) {
//Log.i(Constants.LOGTAG, getTag() + " onMeasure:" + widthSize + ", " + heightSize + " update size of related view!");
relatedView.getLayoutParams().width = widthSize;
relatedView.getLayoutParams().height = heightSize;
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
//Log.d(Constants.LOGTAG, getTag() + " onLayout:" + left + ", " + top + ", " + right + ", " + bottom);
}
/**
* Experimental. This view will be set to the same size as this image.
*/
public void setRelatedView(View view) {
relatedView = view;
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
//Log.d(Constants.LOGTAG, getTag() + " onSizeChanged:" + w + ", " + h + ", " + oldw + ", " + oldh);
}
private int resolveAdjustedSize(int desiredSize, int maxSize, int measureSpec) {
int result = desiredSize;
int specMode = MeasureSpec.getMode(measureSpec);
int specSize = MeasureSpec.getSize(measureSpec);
switch (specMode) {
case MeasureSpec.UNSPECIFIED:
/* Parent says we can be as big as we want. Just don't be larger
than max size imposed on ourselves.
*/
result = Math.min(desiredSize, maxSize);
break;
case MeasureSpec.AT_MOST:
// Parent says we can be as big as we want, up to specSize.
// Don't be larger than specSize, and don't be larger than
// the max size imposed on ourselves.
result = Math.min(Math.min(desiredSize, specSize), maxSize);
break;
case MeasureSpec.EXACTLY:
// No choice. Do what we are told.
result = specSize;
break;
}
return result;
}
}

View File

@ -1,224 +1,224 @@
package org.fox.ttrss.util;
// http://www.lukehorvat.com/blog/android-seekbardialogpreference/
import org.fox.ttrss.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
/**
* A {@link DialogPreference} that provides a user with the means to select an
* integer from a {@link SeekBar}, and persist it.
*
* @author lukehorvat
*
*/
public class FontSizeDialogPreference extends DialogPreference {
private static final int DEFAULT_MIN_PROGRESS = 9;
private static final int DEFAULT_MAX_PROGRESS = 24;
private static final String DEFAULT_PROGRESS = "0";
private int mMinProgress = DEFAULT_MIN_PROGRESS;
private int mMaxProgress = DEFAULT_MAX_PROGRESS;
private int mProgress;
private CharSequence mProgressTextSuffix;
private TextView mProgressText;
private SeekBar mSeekBar;
public FontSizeDialogPreference(Context context) {
this(context, null);
}
public FontSizeDialogPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setProgressTextSuffix(" " + context.getString(R.string.font_size_dialog_suffix));
// set layout
setDialogLayoutResource(R.layout.select_font_size_dialog);
setPositiveButtonText(android.R.string.ok);
setNegativeButtonText(android.R.string.cancel);
setDialogIcon(null);
}
@Override
protected void onSetInitialValue(boolean restore, Object defaultValue) {
setProgress(restore ? Integer.valueOf(getPersistedString(DEFAULT_PROGRESS))
: Integer.valueOf((String)defaultValue));
}
@Override
protected Object onGetDefaultValue(TypedArray a, int index) {
return a.getString(index);
}
@Override
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
mProgressText = (TextView) view.findViewById(R.id.text_progress);
mSeekBar = (SeekBar) view.findViewById(R.id.seek_bar);
mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// update text that displays the current SeekBar progress value
// note: this does not persist the progress value. that is only
// ever done in setProgress()
String progressStr = String.valueOf(progress + mMinProgress);
mProgressText.setText(mProgressTextSuffix == null ? progressStr
: progressStr.concat(mProgressTextSuffix.toString()));
mProgressText.setTextSize(TypedValue.COMPLEX_UNIT_SP, progress + mMinProgress);
}
});
mSeekBar.setMax(mMaxProgress - mMinProgress);
mSeekBar.setProgress(mProgress - mMinProgress);
}
public int getMinProgress() {
return mMinProgress;
}
public void setMinProgress(int minProgress) {
mMinProgress = minProgress;
setProgress(Math.max(mProgress, mMinProgress));
}
public int getMaxProgress() {
return mMaxProgress;
}
public void setMaxProgress(int maxProgress) {
mMaxProgress = maxProgress;
setProgress(Math.min(mProgress, mMaxProgress));
}
public int getProgress() {
return mProgress;
}
public void setProgress(int progress) {
progress = Math.max(Math.min(progress, mMaxProgress), mMinProgress);
if (progress != mProgress) {
mProgress = progress;
persistString(String.valueOf(progress));
notifyChanged();
}
}
public CharSequence getProgressTextSuffix() {
return mProgressTextSuffix;
}
public void setProgressTextSuffix(CharSequence progressTextSuffix) {
mProgressTextSuffix = progressTextSuffix;
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
// when the user selects "OK", persist the new value
if (positiveResult) {
int seekBarProgress = mSeekBar.getProgress() + mMinProgress;
if (callChangeListener(seekBarProgress)) {
setProgress(seekBarProgress);
}
}
}
@Override
protected Parcelable onSaveInstanceState() {
// save the instance state so that it will survive screen orientation
// changes and other events that may temporarily destroy it
final Parcelable superState = super.onSaveInstanceState();
// set the state's value with the class member that holds current
// setting value
final SavedState myState = new SavedState(superState);
myState.minProgress = getMinProgress();
myState.maxProgress = getMaxProgress();
myState.progress = getProgress();
return myState;
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
// check whether we saved the state in onSaveInstanceState()
if (state == null || !state.getClass().equals(SavedState.class)) {
// didn't save the state, so call superclass
super.onRestoreInstanceState(state);
return;
}
// restore the state
SavedState myState = (SavedState) state;
setMinProgress(myState.minProgress);
setMaxProgress(myState.maxProgress);
setProgress(myState.progress);
super.onRestoreInstanceState(myState.getSuperState());
}
private static class SavedState extends BaseSavedState {
int minProgress;
int maxProgress;
int progress;
public SavedState(Parcelable superState) {
super(superState);
}
public SavedState(Parcel source) {
super(source);
minProgress = source.readInt();
maxProgress = source.readInt();
progress = source.readInt();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeInt(minProgress);
dest.writeInt(maxProgress);
dest.writeInt(progress);
}
@SuppressWarnings("unused")
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() {
@Override
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}
@Override
public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
}
package org.fox.ttrss.util;
// http://www.lukehorvat.com/blog/android-seekbardialogpreference/
import org.fox.ttrss.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
/**
* A {@link DialogPreference} that provides a user with the means to select an
* integer from a {@link SeekBar}, and persist it.
*
* @author lukehorvat
*
*/
public class FontSizeDialogPreference extends DialogPreference {
private static final int DEFAULT_MIN_PROGRESS = 9;
private static final int DEFAULT_MAX_PROGRESS = 24;
private static final String DEFAULT_PROGRESS = "0";
private int mMinProgress = DEFAULT_MIN_PROGRESS;
private int mMaxProgress = DEFAULT_MAX_PROGRESS;
private int mProgress;
private CharSequence mProgressTextSuffix;
private TextView mProgressText;
private SeekBar mSeekBar;
public FontSizeDialogPreference(Context context) {
this(context, null);
}
public FontSizeDialogPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setProgressTextSuffix(" " + context.getString(R.string.font_size_dialog_suffix));
// set layout
setDialogLayoutResource(R.layout.select_font_size_dialog);
setPositiveButtonText(android.R.string.ok);
setNegativeButtonText(android.R.string.cancel);
setDialogIcon(null);
}
@Override
protected void onSetInitialValue(boolean restore, Object defaultValue) {
setProgress(restore ? Integer.valueOf(getPersistedString(DEFAULT_PROGRESS))
: Integer.valueOf((String)defaultValue));
}
@Override
protected Object onGetDefaultValue(TypedArray a, int index) {
return a.getString(index);
}
@Override
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
mProgressText = (TextView) view.findViewById(R.id.text_progress);
mSeekBar = (SeekBar) view.findViewById(R.id.seek_bar);
mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// update text that displays the current SeekBar progress value
// note: this does not persist the progress value. that is only
// ever done in setProgress()
String progressStr = String.valueOf(progress + mMinProgress);
mProgressText.setText(mProgressTextSuffix == null ? progressStr
: progressStr.concat(mProgressTextSuffix.toString()));
mProgressText.setTextSize(TypedValue.COMPLEX_UNIT_SP, progress + mMinProgress);
}
});
mSeekBar.setMax(mMaxProgress - mMinProgress);
mSeekBar.setProgress(mProgress - mMinProgress);
}
public int getMinProgress() {
return mMinProgress;
}
public void setMinProgress(int minProgress) {
mMinProgress = minProgress;
setProgress(Math.max(mProgress, mMinProgress));
}
public int getMaxProgress() {
return mMaxProgress;
}
public void setMaxProgress(int maxProgress) {
mMaxProgress = maxProgress;
setProgress(Math.min(mProgress, mMaxProgress));
}
public int getProgress() {
return mProgress;
}
public void setProgress(int progress) {
progress = Math.max(Math.min(progress, mMaxProgress), mMinProgress);
if (progress != mProgress) {
mProgress = progress;
persistString(String.valueOf(progress));
notifyChanged();
}
}
public CharSequence getProgressTextSuffix() {
return mProgressTextSuffix;
}
public void setProgressTextSuffix(CharSequence progressTextSuffix) {
mProgressTextSuffix = progressTextSuffix;
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
// when the user selects "OK", persist the new value
if (positiveResult) {
int seekBarProgress = mSeekBar.getProgress() + mMinProgress;
if (callChangeListener(seekBarProgress)) {
setProgress(seekBarProgress);
}
}
}
@Override
protected Parcelable onSaveInstanceState() {
// save the instance state so that it will survive screen orientation
// changes and other events that may temporarily destroy it
final Parcelable superState = super.onSaveInstanceState();
// set the state's value with the class member that holds current
// setting value
final SavedState myState = new SavedState(superState);
myState.minProgress = getMinProgress();
myState.maxProgress = getMaxProgress();
myState.progress = getProgress();
return myState;
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
// check whether we saved the state in onSaveInstanceState()
if (state == null || !state.getClass().equals(SavedState.class)) {
// didn't save the state, so call superclass
super.onRestoreInstanceState(state);
return;
}
// restore the state
SavedState myState = (SavedState) state;
setMinProgress(myState.minProgress);
setMaxProgress(myState.maxProgress);
setProgress(myState.progress);
super.onRestoreInstanceState(myState.getSuperState());
}
private static class SavedState extends BaseSavedState {
int minProgress;
int maxProgress;
int progress;
public SavedState(Parcelable superState) {
super(superState);
}
public SavedState(Parcel source) {
super(source);
minProgress = source.readInt();
maxProgress = source.readInt();
progress = source.readInt();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeInt(minProgress);
dest.writeInt(maxProgress);
dest.writeInt(progress);
}
@SuppressWarnings("unused")
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() {
@Override
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}
@Override
public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
}
}

View File

@ -1,37 +1,37 @@
package org.fox.ttrss.util;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.webkit.WebView;
public class LessBrokenWebView extends WebView {
public LessBrokenWebView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public LessBrokenWebView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public LessBrokenWebView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
int temp_ScrollY = getScrollY();
scrollTo(getScrollX(), getScrollY() + 1);
scrollTo(getScrollX(), temp_ScrollY);
}
return super.onTouchEvent(event);
}
}
package org.fox.ttrss.util;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.webkit.WebView;
public class LessBrokenWebView extends WebView {
public LessBrokenWebView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public LessBrokenWebView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public LessBrokenWebView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
int temp_ScrollY = getScrollY();
scrollTo(getScrollX(), getScrollY() + 1);
scrollTo(getScrollX(), temp_ScrollY);
}
return super.onTouchEvent(event);
}
}

View File

@ -1,34 +1,34 @@
package org.fox.ttrss.util;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.webkit.WebView;
import android.widget.ScrollView;
public class NoChildFocusScrollView extends ScrollView {
public NoChildFocusScrollView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public NoChildFocusScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public NoChildFocusScrollView(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
@Override
public void requestChildFocus(View child, View focused) {
if (focused instanceof WebView )
return;
super.requestChildFocus(child, focused);
}
}
package org.fox.ttrss.util;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.webkit.WebView;
import android.widget.ScrollView;
public class NoChildFocusScrollView extends ScrollView {
public NoChildFocusScrollView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public NoChildFocusScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public NoChildFocusScrollView(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
@Override
public void requestChildFocus(View child, View focused) {
if (focused instanceof WebView )
return;
super.requestChildFocus(child, focused);
}
}

View File

@ -1,105 +1,105 @@
package org.fox.ttrss.util;
import java.util.HashMap;
import org.fox.ttrss.ApiRequest;
import android.content.Context;
import android.util.Log;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
public abstract class SimpleLoginManager {
private final String TAG = this.getClass().getSimpleName();
protected class LoginRequest extends ApiRequest {
private int m_requestId;
protected String m_sessionId;
protected int m_apiLevel;
protected Context m_context;
public LoginRequest(Context context, int requestId) {
super(context);
m_context = context;
m_requestId = requestId;
}
protected void onPostExecute(JsonElement result) {
Log.d(TAG, "onPostExecute");
if (result != null) {
try {
JsonObject content = result.getAsJsonObject();
if (content != null) {
m_sessionId = content.get("session_id").getAsString();
Log.d(TAG, "[SLM] Authenticated!");
ApiRequest req = new ApiRequest(m_context) {
protected void onPostExecute(JsonElement result) {
m_apiLevel = 0;
if (result != null) {
try {
m_apiLevel = result.getAsJsonObject()
.get("level").getAsInt();
} catch (Exception e) {
e.printStackTrace();
}
}
Log.d(TAG, "[SLM] Received API level: " + m_apiLevel);
onLoginSuccess(m_requestId, m_sessionId, m_apiLevel);
}
};
@SuppressWarnings("serial")
HashMap<String, String> map = new HashMap<String, String>() {
{
put("sid", m_sessionId);
put("op", "getApiLevel");
}
};
req.execute(map);
return;
}
} catch (Exception e) {
e.printStackTrace();
}
}
m_sessionId = null;
onLoginFailed(m_requestId, this);
}
}
public void logIn(Context context, int requestId, final String login, final String password) {
LoginRequest ar = new LoginRequest(context, requestId);
HashMap<String, String> map = new HashMap<String, String>() {
{
put("op", "login");
put("user", login.trim());
put("password", password.trim());
}
};
onLoggingIn(requestId);
ar.execute(map);
}
protected abstract void onLoggingIn(int requestId);
protected abstract void onLoginSuccess(int requestId, String sessionId, int apiLevel);
protected abstract void onLoginFailed(int requestId, ApiRequest ar);
}
package org.fox.ttrss.util;
import java.util.HashMap;
import org.fox.ttrss.ApiRequest;
import android.content.Context;
import android.util.Log;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
public abstract class SimpleLoginManager {
private final String TAG = this.getClass().getSimpleName();
protected class LoginRequest extends ApiRequest {
private int m_requestId;
protected String m_sessionId;
protected int m_apiLevel;
protected Context m_context;
public LoginRequest(Context context, int requestId) {
super(context);
m_context = context;
m_requestId = requestId;
}
protected void onPostExecute(JsonElement result) {
Log.d(TAG, "onPostExecute");
if (result != null) {
try {
JsonObject content = result.getAsJsonObject();
if (content != null) {
m_sessionId = content.get("session_id").getAsString();
Log.d(TAG, "[SLM] Authenticated!");
ApiRequest req = new ApiRequest(m_context) {
protected void onPostExecute(JsonElement result) {
m_apiLevel = 0;
if (result != null) {
try {
m_apiLevel = result.getAsJsonObject()
.get("level").getAsInt();
} catch (Exception e) {
e.printStackTrace();
}
}
Log.d(TAG, "[SLM] Received API level: " + m_apiLevel);
onLoginSuccess(m_requestId, m_sessionId, m_apiLevel);
}
};
@SuppressWarnings("serial")
HashMap<String, String> map = new HashMap<String, String>() {
{
put("sid", m_sessionId);
put("op", "getApiLevel");
}
};
req.execute(map);
return;
}
} catch (Exception e) {
e.printStackTrace();
}
}
m_sessionId = null;
onLoginFailed(m_requestId, this);
}
}
public void logIn(Context context, int requestId, final String login, final String password) {
LoginRequest ar = new LoginRequest(context, requestId);
HashMap<String, String> map = new HashMap<String, String>() {
{
put("op", "login");
put("user", login.trim());
put("password", password.trim());
}
};
onLoggingIn(requestId);
ar.execute(map);
}
protected abstract void onLoggingIn(int requestId);
protected abstract void onLoginSuccess(int requestId, String sessionId, int apiLevel);
protected abstract void onLoginFailed(int requestId, ApiRequest ar);
}

View File

@ -1,29 +1,29 @@
package org.fox.ttrss.util;
import java.util.Hashtable;
import android.content.Context;
import android.graphics.Typeface;
import android.util.Log;
public class TypefaceCache {
private static final String TAG = "TypefaceCache";
private static final Hashtable<String, Typeface> cache = new Hashtable<String, Typeface>();
public static Typeface get(Context c, String typefaceName, int style) {
synchronized (cache) {
String key = typefaceName + ":" + style;
if (!cache.containsKey(key)) {
try {
Typeface t = Typeface.create(typefaceName, style);
cache.put(key, t);
} catch (Exception e) {
Log.e(TAG, "Could not get typeface '" + typefaceName + "' because " + e.getMessage());
return null;
}
}
return cache.get(key);
}
}
package org.fox.ttrss.util;
import java.util.Hashtable;
import android.content.Context;
import android.graphics.Typeface;
import android.util.Log;
public class TypefaceCache {
private static final String TAG = "TypefaceCache";
private static final Hashtable<String, Typeface> cache = new Hashtable<String, Typeface>();
public static Typeface get(Context c, String typefaceName, int style) {
synchronized (cache) {
String key = typefaceName + ":" + style;
if (!cache.containsKey(key)) {
try {
Typeface t = Typeface.create(typefaceName, style);
cache.put(key, t);
} catch (Exception e) {
Log.e(TAG, "Could not get typeface '" + typefaceName + "' because " + e.getMessage());
return null;
}
}
return cache.get(key);
}
}
}

View File

@ -1,65 +1,65 @@
package org.fox.ttrss.widget;
import org.fox.ttrss.R;
import android.app.PendingIntent;
import android.app.PendingIntent.CanceledException;
import android.app.Service;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.RemoteViews;
public class SmallWidgetProvider extends AppWidgetProvider {
private final String TAG = this.getClass().getSimpleName();
public static final String FORCE_UPDATE_ACTION = "org.fox.ttrss.WIDGET_FORCE_UPDATE";
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
//RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_small);
final int N = appWidgetIds.length;
for (int i=0; i < N; i++) {
int appWidgetId = appWidgetIds[i];
Intent updateIntent = new Intent(context, org.fox.ttrss.widget.WidgetUpdateService.class);
PendingIntent updatePendingIntent = PendingIntent.getService(context, 0, updateIntent, 0);
Intent intent = new Intent(context, org.fox.ttrss.OnlineActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_small);
views.setOnClickPendingIntent(R.id.widget_main, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, views);
try {
updatePendingIntent.send();
} catch (CanceledException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
@Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
if (FORCE_UPDATE_ACTION.equals(intent.getAction())) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
ComponentName thisAppWidget = new ComponentName(context.getPackageName(), SmallWidgetProvider.class.getName());
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget);
onUpdate(context, appWidgetManager, appWidgetIds);
}
}
}
package org.fox.ttrss.widget;
import org.fox.ttrss.R;
import android.app.PendingIntent;
import android.app.PendingIntent.CanceledException;
import android.app.Service;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.RemoteViews;
public class SmallWidgetProvider extends AppWidgetProvider {
private final String TAG = this.getClass().getSimpleName();
public static final String FORCE_UPDATE_ACTION = "org.fox.ttrss.WIDGET_FORCE_UPDATE";
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
//RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_small);
final int N = appWidgetIds.length;
for (int i=0; i < N; i++) {
int appWidgetId = appWidgetIds[i];
Intent updateIntent = new Intent(context, org.fox.ttrss.widget.WidgetUpdateService.class);
PendingIntent updatePendingIntent = PendingIntent.getService(context, 0, updateIntent, 0);
Intent intent = new Intent(context, org.fox.ttrss.OnlineActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_small);
views.setOnClickPendingIntent(R.id.widget_main, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, views);
try {
updatePendingIntent.send();
} catch (CanceledException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
@Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
if (FORCE_UPDATE_ACTION.equals(intent.getAction())) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
ComponentName thisAppWidget = new ComponentName(context.getPackageName(), SmallWidgetProvider.class.getName());
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget);
onUpdate(context, appWidgetManager, appWidgetIds);
}
}
}

View File

@ -1,141 +1,141 @@
package org.fox.ttrss.widget;
import java.util.HashMap;
import org.fox.ttrss.ApiRequest;
import org.fox.ttrss.R;
import org.fox.ttrss.util.SimpleLoginManager;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import android.app.Service;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
import android.widget.RemoteViews;
public class WidgetUpdateService extends Service {
private final String TAG = this.getClass().getSimpleName();
@Override
public IBinder onBind(Intent intent) {
Log.d(TAG, "onBind");
// TODO Auto-generated method stub
return null;
}
/* @Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG, "onStartCommand");
return super.onStartCommand(intent, flags, startId);
} */
public void update() {
}
@Override
public void onStart(Intent intent, int startId) {
final RemoteViews view = new RemoteViews(getPackageName(), R.layout.widget_small);
final ComponentName thisWidget = new ComponentName(this, SmallWidgetProvider.class);
final AppWidgetManager manager = AppWidgetManager.getInstance(this);
try {
view.setTextViewText(R.id.counter, String.valueOf(""));
view.setViewVisibility(R.id.progress, View.VISIBLE);
manager.updateAppWidget(thisWidget, view);
final SharedPreferences m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
if (m_prefs.getString("ttrss_url", "").trim().length() == 0) {
// Toast: need configure
} else {
SimpleLoginManager loginManager = new SimpleLoginManager() {
@Override
protected void onLoginSuccess(int requestId, String sessionId, int apiLevel) {
ApiRequest aru = new ApiRequest(getApplicationContext()) {
@Override
protected void onPostExecute(JsonElement result) {
if (result != null) {
try {
JsonObject content = result.getAsJsonObject();
if (content != null) {
int unread = content.get("unread").getAsInt();
view.setViewVisibility(R.id.progress, View.GONE);
view.setTextViewText(R.id.counter, String.valueOf(unread));
manager.updateAppWidget(thisWidget, view);
return;
}
} catch (Exception e) {
e.printStackTrace();
}
}
view.setViewVisibility(R.id.progress, View.GONE);
view.setTextViewText(R.id.counter, "?");
manager.updateAppWidget(thisWidget, view);
}
};
final String fSessionId = sessionId;
HashMap<String, String> umap = new HashMap<String, String>() {
{
put("op", "getUnread");
put("sid", fSessionId);
}
};
aru.execute(umap);
}
@Override
protected void onLoginFailed(int requestId, ApiRequest ar) {
view.setViewVisibility(R.id.progress, View.GONE);
view.setTextViewText(R.id.counter, "?");
manager.updateAppWidget(thisWidget, view);
}
@Override
protected void onLoggingIn(int requestId) {
}
};
String login = m_prefs.getString("login", "").trim();
String password = m_prefs.getString("password", "").trim();
loginManager.logIn(getApplicationContext(), 1, login, password);
}
} catch (Exception e) {
e.printStackTrace();
view.setViewVisibility(R.id.progress, View.GONE);
view.setTextViewText(R.id.counter, getString(R.string.app_name));
manager.updateAppWidget(thisWidget, view);
}
}
}
package org.fox.ttrss.widget;
import java.util.HashMap;
import org.fox.ttrss.ApiRequest;
import org.fox.ttrss.R;
import org.fox.ttrss.util.SimpleLoginManager;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import android.app.Service;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
import android.widget.RemoteViews;
public class WidgetUpdateService extends Service {
private final String TAG = this.getClass().getSimpleName();
@Override
public IBinder onBind(Intent intent) {
Log.d(TAG, "onBind");
// TODO Auto-generated method stub
return null;
}
/* @Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG, "onStartCommand");
return super.onStartCommand(intent, flags, startId);
} */
public void update() {
}
@Override
public void onStart(Intent intent, int startId) {
final RemoteViews view = new RemoteViews(getPackageName(), R.layout.widget_small);
final ComponentName thisWidget = new ComponentName(this, SmallWidgetProvider.class);
final AppWidgetManager manager = AppWidgetManager.getInstance(this);
try {
view.setTextViewText(R.id.counter, String.valueOf(""));
view.setViewVisibility(R.id.progress, View.VISIBLE);
manager.updateAppWidget(thisWidget, view);
final SharedPreferences m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
if (m_prefs.getString("ttrss_url", "").trim().length() == 0) {
// Toast: need configure
} else {
SimpleLoginManager loginManager = new SimpleLoginManager() {
@Override
protected void onLoginSuccess(int requestId, String sessionId, int apiLevel) {
ApiRequest aru = new ApiRequest(getApplicationContext()) {
@Override
protected void onPostExecute(JsonElement result) {
if (result != null) {
try {
JsonObject content = result.getAsJsonObject();
if (content != null) {
int unread = content.get("unread").getAsInt();
view.setViewVisibility(R.id.progress, View.GONE);
view.setTextViewText(R.id.counter, String.valueOf(unread));
manager.updateAppWidget(thisWidget, view);
return;
}
} catch (Exception e) {
e.printStackTrace();
}
}
view.setViewVisibility(R.id.progress, View.GONE);
view.setTextViewText(R.id.counter, "?");
manager.updateAppWidget(thisWidget, view);
}
};
final String fSessionId = sessionId;
HashMap<String, String> umap = new HashMap<String, String>() {
{
put("op", "getUnread");
put("sid", fSessionId);
}
};
aru.execute(umap);
}
@Override
protected void onLoginFailed(int requestId, ApiRequest ar) {
view.setViewVisibility(R.id.progress, View.GONE);
view.setTextViewText(R.id.counter, "?");
manager.updateAppWidget(thisWidget, view);
}
@Override
protected void onLoggingIn(int requestId) {
}
};
String login = m_prefs.getString("login", "").trim();
String password = m_prefs.getString("password", "").trim();
loginManager.logIn(getApplicationContext(), 1, login, password);
}
} catch (Exception e) {
e.printStackTrace();
view.setViewVisibility(R.id.progress, View.GONE);
view.setTextViewText(R.id.counter, getString(R.string.app_name));
manager.updateAppWidget(thisWidget, view);
}
}
}

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<alpha
android:fromAlpha="0"
android:toAlpha="1"
android:duration="150"
/>
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<alpha
android:fromAlpha="0"
android:toAlpha="1"
android:duration="150"
/>
</set>

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<alpha
android:fromAlpha="0"
android:toAlpha="1"
android:duration="250"
/>
<translate
android:fromXDelta="100%p"
android:toXDelta="0"
android:duration="250"
/>
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<alpha
android:fromAlpha="0"
android:toAlpha="1"
android:duration="250"
/>
<translate
android:fromXDelta="100%p"
android:toXDelta="0"
android:duration="250"
/>
</set>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="20%"
android:animation="@anim/feed_item"
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="20%"
android:animation="@anim/feed_item"
/>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="20%"
android:animation="@anim/headline_item"
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="20%"
android:animation="@anim/headline_item"
/>

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Some files were not shown because too many files have changed in this diff Show More