├── .gitignore ├── Android Projects-reddinator.iml ├── LICENSE ├── README.md ├── Repo └── reddinator-release.apk ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── reddinator ├── .classpath ├── .gitignore ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── COPYING ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── proguard-project.txt ├── project.properties ├── reddinator-reddinator.iml └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ ├── account.html │ ├── comments.html │ ├── comments_context.html │ ├── credits.html │ ├── css │ │ ├── core.css │ │ ├── font-awesome.min.css │ │ ├── fonts │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ ├── fontawesome-webfont.woff │ │ │ └── fontawesome-webfont.woff2 │ │ ├── reddit-markdown.css │ │ └── styles │ │ │ ├── border-rainbow.css │ │ │ └── layout-alternate.css │ ├── images │ │ ├── nsfw.png │ │ └── self_default.png │ ├── js │ │ ├── account.js │ │ ├── comments.js │ │ ├── common.js │ │ ├── jquery-2.1.3.min.js │ │ ├── jquery-2.2.4.min.js │ │ ├── prosemirror-test.html │ │ └── prosemirror.js │ ├── messages.html │ └── themes.json │ ├── java │ └── au │ │ └── com │ │ └── wallaceit │ │ └── reddinator │ │ ├── Reddinator.java │ │ ├── activity │ │ ├── AboutDialog.java │ │ ├── AccountActivity.java │ │ ├── CommentsContextDialogActivity.java │ │ ├── ComposeMessageActivity.java │ │ ├── FeedItemDialogActivity.java │ │ ├── MainActivity.java │ │ ├── MessagesActivity.java │ │ ├── OAuthView.java │ │ ├── PrefsActivity.java │ │ ├── PrefsFragment.java │ │ ├── SearchActivity.java │ │ ├── SubmitActivity.java │ │ ├── SubredditSelectActivity.java │ │ ├── ThemeEditorActivity.java │ │ ├── ThemesActivity.java │ │ ├── ViewAllSubredditsActivity.java │ │ ├── ViewImageDialogActivity.java │ │ ├── ViewRedditActivity.java │ │ ├── WebViewActivity.java │ │ └── WidgetMenuDialogActivity.java │ │ ├── core │ │ ├── RedditData.java │ │ ├── SubredditManager.java │ │ ├── ThemeHelper.java │ │ ├── ThemeManager.java │ │ └── Utilities.java │ │ ├── service │ │ ├── BootReceiver.java │ │ ├── MailCheckReceiver.java │ │ ├── MailCheckService.java │ │ ├── StackWidgetProvider.java │ │ ├── UpgradeReceiver.java │ │ ├── WidgetCommon.java │ │ ├── WidgetProvider.java │ │ ├── WidgetProviderBase.java │ │ └── WidgetService.java │ │ ├── tasks │ │ ├── CommentTask.java │ │ ├── ComposeMessageTask.java │ │ ├── HidePostTask.java │ │ ├── LoadImageBitmapTask.java │ │ ├── LoadPostTask.java │ │ ├── LoadRandomTask.java │ │ ├── LoadSubredditInfoTask.java │ │ ├── MarkMessageTask.java │ │ ├── SavePostTask.java │ │ ├── SubmitTask.java │ │ ├── SubscriptionEditTask.java │ │ ├── SyncUserDataTask.java │ │ ├── VoteTask.java │ │ └── WidgetVoteTask.java │ │ └── ui │ │ ├── AccountFeedFragment.java │ │ ├── ActionbarActivity.java │ │ ├── ActionbarFragmentActivity.java │ │ ├── HtmlDialog.java │ │ ├── RWebView.java │ │ ├── RedditViewPager.java │ │ ├── SimpleTabsAdapter.java │ │ ├── SimpleTabsWidget.java │ │ ├── SubAutoCompleteAdapter.java │ │ ├── SubredditFeedAdapter.java │ │ ├── TabCommentsFragment.java │ │ └── TabWebFragment.java │ └── res │ ├── drawable-hdpi │ ├── border.xml │ ├── github_logo.png │ ├── ic_notify.png │ ├── menu_overflow.png │ ├── noimage.png │ ├── nsfw.png │ ├── reddinator_logo.png │ └── self_default.png │ ├── drawable-mdpi │ ├── ic_notify.png │ └── menu_overflow.png │ ├── drawable-xhdpi │ ├── ic_notify.png │ └── menu_overflow.png │ ├── drawable-xxhdpi │ └── ic_notify.png │ ├── drawable-xxxhdpi │ └── ic_notify.png │ ├── drawable │ └── round_corners.xml │ ├── layout │ ├── activity_account.xml │ ├── activity_comments_context_dialog.xml │ ├── activity_compose.xml │ ├── activity_item_dialog.xml │ ├── activity_main.xml │ ├── activity_messages.xml │ ├── activity_search.xml │ ├── activity_submit.xml │ ├── activity_subreddit_select.xml │ ├── activity_subreddits.xml │ ├── activity_theme_editor.xml │ ├── activity_themes.xml │ ├── activity_transparent.xml │ ├── activity_view_image_dialog.xml │ ├── activity_viewreddit.xml │ ├── activity_webview.xml │ ├── appheader.xml │ ├── applistrow.xml │ ├── autocomplete_list_item.xml │ ├── color_picker_dialog.xml │ ├── dialog_filter.xml │ ├── dialog_html.xml │ ├── dialog_info.xml │ ├── dialog_multi_add.xml │ ├── dialog_multi_edit.xml │ ├── item_dialog_row.xml │ ├── listrowload.xml │ ├── listrowloadmore.xml │ ├── multi_sublist_add_item.xml │ ├── multi_sublist_item.xml │ ├── mymultilistitem.xml │ ├── mymultilistitem_add.xml │ ├── myredditlistitem.xml │ ├── myredditlistitem_add.xml │ ├── subreddititem.xml │ ├── tab.xml │ ├── tabs.xml │ ├── tabs_scrolling.xml │ ├── theme_editor_row.xml │ ├── themes_list_item.xml │ ├── webtab.xml │ ├── widget.xml │ ├── widget_list_row.xml │ ├── widget_stack.xml │ ├── widget_stack_load_row.xml │ ├── widget_stack_more_row.xml │ └── widget_stack_row.xml │ ├── menu │ ├── account_menu.xml │ ├── feed_menu.xml │ ├── messages_menu.xml │ ├── subreddit_select_menu.xml │ ├── themes_menu.xml │ ├── view_menu.xml │ └── web_view_menu.xml │ ├── values-en-rUS │ └── strings.xml │ ├── values-es │ ├── arrays.xml │ └── strings.xml │ ├── values-v11 │ └── styles.xml │ ├── values-v14 │ └── styles.xml │ ├── values-v17 │ └── styles.xml │ ├── values-w820dp │ └── dimens.xml │ ├── values │ ├── arrays.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml │ └── xml │ ├── account_preferences.xml │ ├── app_widget_provider_info.xml │ ├── app_widget_stack_provider_info.xml │ ├── changelog_master.xml │ ├── filepaths.xml │ ├── preferences.xml │ └── utility_preferences.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle/ 2 | local.properties 3 | *.swp 4 | .idea/ 5 | build/ -------------------------------------------------------------------------------- /Android Projects-reddinator.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Reddinator 2 | ==================== 3 | 4 | Reddit Widget 5 | --------------------- 6 | 7 | [![Get it on Google Play!](https://developer.android.com/images/brand/en_generic_rgb_wo_60.png)](https://play.google.com/store/apps/details?id=au.com.wallaceit.reddinator) 8 | 9 | Reddinator is a Reddit Widget & App. 10 | It's built to be easy to use, highly customisable and completely optimised to make you spend every waking moment on Reddit. 11 | 12 | If you love having Reddit at your fingertips then this is the App for you. 13 | 14 | >"This app fully embraces how I like to browse reddit; quickly and conveniently." 15 | 16 | >"Well played. Reddit. Open-source. Permission-free. Bonus: widget. Couldn't ask for more!" 17 | 18 | >"the only reddit reader worth installing" 19 | 20 | >"Great app. No special permissions or anything!" 21 | 22 | --Reddinator reviewers 23 | 24 | Scroll down below for an overview of the awesome. 25 | 26 | Features: 27 | - All Widgets are independently customisable, allowing you to pick a built-in or custom theme for each widget. 28 | - "Load more" button at the bottom of all feeds, allowing you to Reddit till your hearts content 29 | - Seamless account integration keeps your Subreddits & Multis at your fingertips 30 | - Search & subscribe to new Subreddits & unsubscribe from the stale ones 31 | - Search for posts 32 | - Domain subreddits (view posts from a domain) 33 | - Create & Edit Multireddits 34 | - Get notified of new messages via indicators & notifications. 35 | - Access messages, account history, saved & hidden posts straight from the app. 36 | - Reddinator View combines the items content, Reddit comments page and voting buttons into a tabbed layout. Read the article and participate in Reddits great community discussion at the same time! 37 | - Choose default click action for feed items. You can open in the tabbed "Reddinator View", the item's content page or open the item's Reddit page in the web browser. 38 | - Vote for posts quickly and easily, including from the widget. 39 | - Use the post option dialogue to quickly hide, save and perform other useful functions for each post 40 | (Click on the cogs icon in a post widget or long press on a post within the app) 41 | - Vote & reply to posts, comments and messages 42 | 43 | Global options: 44 | - Feed Item click action (as listed above) 45 | - Initial feed items to load 46 | - Widget Auto-refresh interval (can be disabled) 47 | - Application themes: Apply custom themes to the app or a single widget. Select from 5 predefined themed or build your own. 48 | - Choose which content to pre-load when using the Reddinator view, by default the comments are preloaded & ready for viewing, just swipe to the left. 49 | - Feed item text size 50 | - Comments text size 51 | - Default text size for content web view 52 | - Default text size for other web views 53 | 54 | If you have a feature that you would like to see added, or any bugs to report please send us an email and we will look into it. 55 | 56 | How to build and deploy 57 | ---- 58 | 59 | ####Command Line: 60 | 61 | ```` 62 | ./gradlew installDebug 63 | ```` 64 | 65 | ####Intellij IDEA 13: 66 | 67 | Open the project in Intellij, it should recognize it as a gradle project and build accordingly. 68 | -------------------------------------------------------------------------------- /Repo/reddinator-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/Repo/reddinator-release.apk -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules 2 | 3 | /*task wrapper(type: Wrapper) { 4 | gradleVersion= '1.8' 5 | }*/ 6 | 7 | buildscript { 8 | repositories { 9 | maven { 10 | url 'https://maven.google.com/' 11 | name 'Google' 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Oct 12 18:22:12 AEDT 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /reddinator/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /reddinator/.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | build/ 3 | -------------------------------------------------------------------------------- /reddinator/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Reddinator 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /reddinator/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /reddinator/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | jcenter() 5 | maven { 6 | url 'https://maven.google.com/' 7 | name 'Google' 8 | } 9 | google() 10 | } 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:3.5.1' 13 | } 14 | } 15 | 16 | apply plugin: 'com.android.application' 17 | 18 | repositories { 19 | maven { url "https://dl.bintray.com/populov/maven" } 20 | maven { url 'https://guardian.github.com/maven/repo-releases' } 21 | mavenCentral() 22 | jcenter({ url "https://jcenter.bintray.com/" }) 23 | maven { 24 | url 'https://maven.google.com/' 25 | name 'Google' 26 | } 27 | } 28 | 29 | android { 30 | compileSdkVersion 28 31 | buildToolsVersion '28.0.3' 32 | defaultConfig { 33 | minSdkVersion 14 34 | targetSdkVersion 28 35 | javaCompileOptions { 36 | annotationProcessorOptions { 37 | includeCompileClasspath false 38 | } 39 | } 40 | vectorDrawables.useSupportLibrary = true 41 | } 42 | signingConfigs { 43 | debug { 44 | storeFile file('/home/michael/.android/debug.keystore') 45 | keyAlias 'androiddebugkey' 46 | keyPassword 'android' 47 | storePassword 'android' 48 | } 49 | } 50 | buildTypes { 51 | debug { 52 | debuggable true 53 | signingConfig signingConfigs.debug 54 | } 55 | release { 56 | debuggable false 57 | } 58 | } 59 | productFlavors { 60 | } 61 | compileOptions { 62 | sourceCompatibility JavaVersion.VERSION_1_8 63 | targetCompatibility JavaVersion.VERSION_1_8 64 | } 65 | } 66 | 67 | 68 | dependencies { 69 | implementation 'com.android.support:support-v4:28.0.0' 70 | implementation 'com.android.support:appcompat-v7:28.0.0' 71 | implementation 'com.squareup.okhttp3:okhttp:3.10.0' 72 | implementation 'org.apache.commons:commons-lang3:3.9' 73 | implementation 'com.joanzapata.android:android-iconify:1.0.11' 74 | implementation 'com.larswerkman:HoloColorPicker:1.5' 75 | implementation 'io.github.kobakei:ratethisapp:1.2.0' 76 | implementation 'de.cketti.library.changelog:ckchangelog:1.2.2' 77 | implementation 'com.sothree.slidinguppanel:library:3.4.0' 78 | implementation 'com.gu:option:1.3' 79 | implementation 'net.rdrei.android.dirchooser:library:3.2@aar' 80 | implementation 'com.android.support:support-vector-drawable:28.0.0' 81 | implementation 'com.android.support:recyclerview-v7:28.0.0' 82 | } 83 | -------------------------------------------------------------------------------- /reddinator/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /reddinator/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Dec 20 14:00:53 EST 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /reddinator/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.activity_webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /reddinator/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-16 15 | -------------------------------------------------------------------------------- /reddinator/src/main/assets/account.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Reddinator Account 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 50 | 73 | 76 | 81 | 93 |
94 |
95 | 96 |
97 |
98 |
99 |

Loading...

100 |
101 | 102 | -------------------------------------------------------------------------------- /reddinator/src/main/assets/comments.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Reddinator Comments 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 22 | 23 | 24 | 62 | 65 | 70 | 84 |
85 |
86 | 90 | 91 |
92 |
93 | 94 |
95 |
96 |
97 |

Loading...

98 |
99 | 100 | -------------------------------------------------------------------------------- /reddinator/src/main/assets/comments_context.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Reddinator Comments 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 55 | 58 | 63 | 84 |
85 |
86 | 87 |
88 |
89 |
90 |

Loading...

91 |
92 | 93 | -------------------------------------------------------------------------------- /reddinator/src/main/assets/credits.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | 21 |

Developed and maintained by

22 |

Michael B Wallace
micwallace11@gmail.com

23 |

Contributions by

24 |

Vishnu Rajeevan
(github.com/burntcookie90)

25 |

Contact Michael to help make Reddinator better

26 |

Libraries

27 |

A huge thanks to the following open-source libraries that have saved lots of time and prevented re-invention of the wheel.

28 | 66 |

Licensing

67 |

Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au)

68 |

Reddinator 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.

69 |

Reddinator 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. 70 |
http://www.gnu.org/licenses/gpl-3.0.en.html 71 |

72 | 73 | -------------------------------------------------------------------------------- /reddinator/src/main/assets/css/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/assets/css/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /reddinator/src/main/assets/css/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/assets/css/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /reddinator/src/main/assets/css/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/assets/css/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /reddinator/src/main/assets/css/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/assets/css/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /reddinator/src/main/assets/css/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/assets/css/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /reddinator/src/main/assets/css/reddit-markdown.css: -------------------------------------------------------------------------------- 1 | .md-container { 2 | font-size: small 3 | } 4 | 5 | .md { 6 | /*max-width: 60em;*/ 7 | /*color: #222222*/ 8 | } 9 | 10 | .md .-headers, .md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { 11 | border: 0; 12 | color: inherit; 13 | -webkit-font-smoothing: antialiased 14 | } 15 | 16 | .md .-headers code, .md h1 code, .md h2 code, .md h3 code, .md h4 code, .md h5 code, .md h6 code { 17 | font-size: inherit 18 | } 19 | 20 | .md blockquote, .md del { 21 | /*color: #4f4f4f*/ 22 | } 23 | 24 | .md a { 25 | /*color: #0079d3;*/ 26 | text-decoration: none 27 | } 28 | 29 | .md h6 { 30 | text-decoration: underline 31 | } 32 | 33 | .md em { 34 | font-style: italic; 35 | font-weight: inherit 36 | } 37 | 38 | .md th, .md strong, .md .-headers, .md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { 39 | font-weight: 600; 40 | font-style: inherit 41 | } 42 | 43 | .md h2, .md h4 { 44 | font-weight: 500 45 | } 46 | 47 | .md, .md h6 { 48 | font-weight: 400 49 | } 50 | 51 | .md * { 52 | margin-left: 0; 53 | margin-right: 0 54 | margin-bottom: 0; 55 | } 56 | 57 | .md tr, .md code, .md .-cells, .md .-lists, .md .-blocks, .md .-headers, .md h1, .md h2, .md h3, .md h4, .md h5, .md h6, .md th, .md td, .md ul, .md ol, .md .-lists, .md pre, .md blockquote, .md table, .md p, .md ul, .md ol { 58 | margin: 0; 59 | padding: 0 60 | } 61 | 62 | .md hr { 63 | border: 0; 64 | color: transparent; 65 | background: #c5c1ad; 66 | height: 2px; 67 | padding: 0 68 | } 69 | 70 | .md blockquote { 71 | border-left: 2px solid #c5c1ad 72 | } 73 | 74 | .md code, .md pre { 75 | border: 1px solid #eeeed2; 76 | background-color: #fcfcf7; 77 | color: #000000; 78 | border-radius: 2px 79 | } 80 | 81 | .md code { 82 | margin: 0 2px; 83 | white-space: nowrap; 84 | width: 100%; 85 | overflow-x:auto; 86 | } 87 | 88 | .md p code { 89 | line-height: 1em 90 | } 91 | 92 | .md pre { 93 | overflow: auto 94 | } 95 | 96 | .md pre code { 97 | white-space: pre; 98 | background-color: transparent; 99 | border: 0; 100 | display: block; 101 | padding: 0 !important 102 | } 103 | 104 | .md td, .md th { 105 | border: 1px solid #e5e3da; 106 | text-align: left 107 | } 108 | 109 | .md td[align=center], .md th[align=center] { 110 | text-align: center 111 | } 112 | 113 | .md td[align=right], .md th[align=right] { 114 | text-align: right 115 | } 116 | 117 | .md img { 118 | max-width: 100% 119 | } 120 | 121 | .md ul { 122 | list-style-type: disc 123 | } 124 | 125 | .md ol { 126 | list-style-type: decimal 127 | } 128 | 129 | .md blockquote { 130 | padding: 0 8px; 131 | margin-left: 5px 132 | } 133 | 134 | .md code { 135 | padding: 0 4px 136 | } 137 | 138 | .md pre, .md .-cells, .md th, .md td { 139 | padding: 4px 9px 140 | } 141 | 142 | .md .-lists, .md ul, .md ol { 143 | padding-left: 40px 144 | } 145 | 146 | .md sup { 147 | font-size: 0.86em; 148 | line-height: 0 149 | } 150 | 151 | .md li li, .md li p { 152 | font-size: 1em !important 153 | } 154 | 155 | .link .usertext .md { 156 | padding: 5px 5px 157 | } 158 | 159 | code { 160 | font-family: monospace, monospace 161 | } 162 | 163 | .md { 164 | /*font-size: 1.0769230769230769em*/ 165 | font-size: 1em; 166 | margin-bottom:0; 167 | margin-top:6px; 168 | } 169 | 170 | .md h1, .md h2 { 171 | font-size: 1.2857142857142858em; 172 | line-height: 1.3888888888888888em; 173 | margin-top: 0.8333333333333334em; 174 | margin-bottom: 0.8333333333333334em 175 | } 176 | 177 | .md h3, .md h4 { 178 | font-size: 1.1428571428571428em; 179 | line-height: 1.25em; 180 | margin-top: 0.625em; 181 | margin-bottom: 0.625em 182 | } 183 | 184 | .md h5, .md h6 { 185 | font-size: 1em; 186 | line-height: 1.4285714285714286em; 187 | margin-top: 0.7142857142857143em; 188 | margin-bottom: 0.35714285714285715em 189 | } 190 | 191 | .md .-blocks, .md .-lists, .md pre, .md blockquote, .md table, .md p, .md ul, .md ol { 192 | /*margin-top: 0.35714285714285715em; 193 | margin-bottom: 0.35714285714285715em*/ 194 | margin-top: 0 !important; 195 | margin-bottom: 0 !important; 196 | } 197 | 198 | .md textarea, .md .-text, .md p, .md pre > code, .md th, .md td, .md li { 199 | font-size: 1em; 200 | /*line-height: 1.4285714285714286em*/ 201 | } 202 | 203 | .md > :first-child, .md .-cells > :first-child, .md .-lists > :first-child, .md .-blocks > :first-child, .md .-headers > :first-child, .md h1 > :first-child, .md h2 > :first-child, .md h3 > :first-child, .md h4 > :first-child, .md h5 > :first-child, .md h6 > :first-child, .md th > :first-child, .md td > :first-child, .md ul > :first-child, .md ol > :first-child, .md .-lists > :first-child, .md pre > :first-child, .md blockquote > :first-child, .md table > :first-child, .md p > :first-child, .md ul > :first-child, .md ol > :first-child { 204 | margin-top: 0 205 | } 206 | 207 | .md > :last-child, .md .-cells > :last-child, .md .-lists > :last-child, .md .-blocks > :last-child, .md .-headers > :last-child, .md h1 > :last-child, .md h2 > :last-child, .md h3 > :last-child, .md h4 > :last-child, .md h5 > :last-child, .md h6 > :last-child, .md th > :last-child, .md td > :last-child, .md ul > :last-child, .md ol > :last-child, .md .-lists > :last-child, .md pre > :last-child, .md blockquote > :last-child, .md table > :last-child, .md p > :last-child, .md ul > :last-child, .md ol > :last-child { 208 | margin-bottom: 0 209 | } -------------------------------------------------------------------------------- /reddinator/src/main/assets/css/styles/border-rainbow.css: -------------------------------------------------------------------------------- 1 | /* Color comments tree; sorry, i too wish css had :nthdecendant() */ 2 | 3 | #base .border, 4 | #base .border .sub-border { 5 | border-color: #2F6698 !important; 6 | } 7 | 8 | #base .border .border, 9 | #base .border .border .sub-border { 10 | border-color: #2CB0CF !important; 11 | } 12 | 13 | #base .border .border .border, 14 | #base .border .border .border .sub-border { 15 | border-color: #1E9F72 !important; 16 | } 17 | 18 | #base .border .border .border .border, 19 | #base .border .border .border .border .sub-border{ 20 | border-color: #2F9E2D !important; 21 | } 22 | 23 | #base .border .border .border .border .border, 24 | #base .border .border .border .border .border .sub-border{ 25 | border-color: #98CF19 !important; 26 | } 27 | 28 | #base .border .border .border .border .border .border 29 | #base .border .border .border .border .border .border .sub-border{ 30 | border-color: #CCE717 !important; 31 | } 32 | 33 | #base .border .border .border .border .border .border .border, 34 | #base .border .border .border .border .border .border .border .sub-border{ 35 | border-color: #F7F618 !important; 36 | } 37 | 38 | #base .border .border .border .border .border .border .border .border, 39 | #base .border .border .border .border .border .border .border .border .sub-border{ 40 | border-color: #FDCC0F !important; 41 | } 42 | 43 | #base .border .border .border .border .border .border .border .border .border, 44 | #base .border .border .border .border .border .border .border .border .border .sub-border{ 45 | border-color: #F7980E !important; 46 | } 47 | 48 | #base .border .border .border .border .border .border .border .border .border .border, 49 | #base .border .border .border .border .border .border .border .border .border .border .sub-border { 50 | border-color: #F96610 !important; 51 | } 52 | 53 | #base .border .border .border .border .border .border .border .border .border .border .border, 54 | #base .border .border .border .border .border .border .border .border .border .border .border .sub-border{ 55 | border-color: #FB0B0B !important; 56 | } -------------------------------------------------------------------------------- /reddinator/src/main/assets/css/styles/layout-alternate.css: -------------------------------------------------------------------------------- 1 | /* Alternate layout with top and left border only */ 2 | .comment_box { 3 | border-right:none; 4 | border-bottom:none; 5 | border-radius:0; 6 | border-top-left-radius: 4px; 7 | padding-bottom: 0; 8 | } 9 | 10 | .more_box { 11 | margin-right: 0 !important; 12 | } 13 | 14 | .comment_replies { 15 | padding-right: 2px; 16 | } 17 | 18 | .reply_expand { 19 | margin-right: 0px; 20 | } -------------------------------------------------------------------------------- /reddinator/src/main/assets/images/nsfw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/assets/images/nsfw.png -------------------------------------------------------------------------------- /reddinator/src/main/assets/images/self_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/assets/images/self_default.png -------------------------------------------------------------------------------- /reddinator/src/main/assets/js/prosemirror-test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 20 | 21 | 22 | 25 | 26 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /reddinator/src/main/assets/messages.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Reddinator Messages 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 53 | 72 | 75 | 80 |
81 |
82 | 83 |
84 |
85 |
86 |

Loading...

87 |
88 | 89 | -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/activity/PrefsActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 3 | * This file is part of Reddinator. 4 | * 5 | * Reddinator is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * Reddinator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Reddinator (COPYING). If not, see . 17 | */ 18 | package au.com.wallaceit.reddinator.activity; 19 | 20 | import android.app.ActionBar; 21 | 22 | import android.content.Intent; 23 | import android.net.Uri; 24 | import android.os.Bundle; 25 | import android.preference.PreferenceActivity; 26 | import android.preference.PreferenceManager; 27 | import android.view.KeyEvent; 28 | import android.view.MenuItem; 29 | import android.widget.Toast; 30 | 31 | import java.util.Date; 32 | 33 | import au.com.wallaceit.reddinator.service.WidgetCommon; 34 | import au.com.wallaceit.reddinator.service.WidgetProvider; 35 | 36 | public class PrefsActivity extends PreferenceActivity { 37 | private PrefsFragment fragment; 38 | 39 | @Override 40 | protected void onCreate(Bundle savedInstanceState) { 41 | super.onCreate(savedInstanceState); 42 | ActionBar actionBar = getActionBar(); 43 | if (actionBar != null) { 44 | actionBar.setDisplayHomeAsUpEnabled(true); 45 | } 46 | fragment = new PrefsFragment(); 47 | getFragmentManager().beginTransaction().replace(android.R.id.content, fragment).commit(); 48 | } 49 | 50 | public void onBackPressed() { 51 | fragment.onBackPressed(); 52 | } 53 | 54 | @Override 55 | public boolean onOptionsItemSelected(MenuItem item) { 56 | switch (item.getItemId()) { 57 | case android.R.id.home: 58 | this.onBackPressed(); 59 | break; 60 | default: 61 | return super.onOptionsItemSelected(item); 62 | } 63 | return true; 64 | } 65 | 66 | @Override 67 | public boolean onKeyDown(int keyCode, KeyEvent event) { 68 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN){ 69 | Toast.makeText(this, "Last widget refresh: " + new Date(PreferenceManager.getDefaultSharedPreferences(this).getLong("last_auto_refresh", 0)).toString(), Toast.LENGTH_LONG).show(); 70 | return true; 71 | } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP){ 72 | Intent intent = new Intent(this, WidgetProvider.class); 73 | intent.setAction(WidgetCommon.ACTION_AUTO_UPDATE); 74 | intent.setPackage(this.getPackageName()); 75 | intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); 76 | sendBroadcast(intent); 77 | Toast.makeText(this, "Testing widget auto update", Toast.LENGTH_LONG).show(); 78 | finish(); 79 | return true; 80 | } 81 | return super.onKeyDown(keyCode, event); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/service/BootReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 3 | * This file is part of Reddinator. 4 | * 5 | * Reddinator is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * Reddinator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Reddinator (COPYING). If not, see . 17 | */ 18 | 19 | package au.com.wallaceit.reddinator.service; 20 | 21 | import android.content.BroadcastReceiver; 22 | import android.content.Context; 23 | import android.content.Intent; 24 | 25 | public class BootReceiver extends BroadcastReceiver { 26 | 27 | @Override 28 | public void onReceive(Context context, Intent intent) { 29 | if (!Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()) && 30 | !Intent.ACTION_PACKAGE_FIRST_LAUNCH.equals(intent.getAction()) && 31 | !Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) 32 | return; 33 | // set mail check alarm 34 | MailCheckReceiver.setAlarm(context); 35 | // set widget update alarm if widgets enabled 36 | WidgetCommon.setUpdateSchedule(context); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/service/MailCheckReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 3 | * This file is part of Reddinator. 4 | * 5 | * Reddinator is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * Reddinator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Reddinator (COPYING). If not, see . 17 | */ 18 | 19 | package au.com.wallaceit.reddinator.service; 20 | 21 | import android.app.AlarmManager; 22 | import android.app.PendingIntent; 23 | import android.content.BroadcastReceiver; 24 | import android.content.Context; 25 | import android.content.Intent; 26 | import android.content.SharedPreferences; 27 | import android.net.Uri; 28 | import android.preference.PreferenceManager; 29 | 30 | import au.com.wallaceit.reddinator.R; 31 | 32 | public class MailCheckReceiver extends BroadcastReceiver { 33 | 34 | private static String CHECK_ACTION = "reddinator.background.mailcheck"; 35 | 36 | public static void setAlarm(Context context){ 37 | 38 | Intent intent = new Intent(context.getApplicationContext(), MailCheckReceiver.class); 39 | intent.setPackage(context.getPackageName()); 40 | intent.setAction(CHECK_ACTION); 41 | intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); 42 | PendingIntent updateIntent = PendingIntent.getBroadcast(context.getApplicationContext(), 0, intent, 0); 43 | 44 | final AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); 45 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); 46 | int refreshRate = Integer.valueOf(prefs.getString(context.getString(R.string.background_mail_pref), "43200000")); 47 | String token = prefs.getString("oauthtoken", ""); 48 | boolean loggedIn = (!token.equals("")); 49 | if (refreshRate == 0 || !loggedIn) { 50 | alarmManager.cancel(updateIntent); // cancel if disabled or not logged in 51 | } else { 52 | alarmManager.setRepeating(AlarmManager.RTC, System.currentTimeMillis() + refreshRate, refreshRate, updateIntent); 53 | } 54 | } 55 | 56 | @Override 57 | public void onReceive(Context context, Intent intent) { 58 | MailCheckService.checkMail(context, MailCheckService.NOTIFY_CHECK_ACTION); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/service/UpgradeReceiver.java: -------------------------------------------------------------------------------- 1 | package au.com.wallaceit.reddinator.service; 2 | 3 | /* 4 | * Copyright 2016 Michael Boyde Wallace (http://wallaceit.com.au) 5 | * This file is part of reddinator. 6 | * 7 | * reddinator is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * reddinator is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with reddinator (COPYING). If not, see . 19 | * 20 | * Created by michael on 3/10/16. 21 | */ 22 | 23 | import android.appwidget.AppWidgetManager; 24 | import android.content.BroadcastReceiver; 25 | import android.content.ComponentName; 26 | import android.content.Context; 27 | import android.content.Intent; 28 | 29 | import org.json.JSONArray; 30 | import org.json.JSONException; 31 | 32 | import java.io.File; 33 | 34 | import au.com.wallaceit.reddinator.Reddinator; 35 | 36 | public class UpgradeReceiver extends BroadcastReceiver { 37 | Reddinator global; 38 | 39 | public UpgradeReceiver() { 40 | } 41 | 42 | @Override 43 | public void onReceive(Context context, Intent intent) { 44 | // Run upgrades for new version support 45 | global = (Reddinator) context.getApplicationContext(); 46 | // Clear old thumbnails directory 47 | File oldCacheDir = new File(context.getCacheDir().getPath() + "/thumbnail_cache/"); 48 | if (oldCacheDir.exists()) 49 | deleteRecursive(oldCacheDir); 50 | // Migrate feeds to new file storage and remove from preferences 51 | migrateFeedData(0); // app feed data 52 | AppWidgetManager mgr2 = AppWidgetManager.getInstance(context); 53 | int[] appWidgetIds = mgr2.getAppWidgetIds(new ComponentName(context, WidgetProvider.class)); 54 | for (int appWidgetId : appWidgetIds) { 55 | migrateFeedData(appWidgetId); 56 | } 57 | } 58 | 59 | private void deleteRecursive(File fileOrDirectory) { 60 | if (fileOrDirectory.isDirectory()) 61 | for (File child : fileOrDirectory.listFiles()) 62 | deleteRecursive(child); 63 | 64 | //noinspection ResultOfMethodCallIgnored 65 | fileOrDirectory.delete(); 66 | } 67 | 68 | private void migrateFeedData(int feedId){ 69 | String prefKey = "feeddata-" + (feedId == 0 ? "app" : feedId); 70 | String feedData = global.mSharedPreferences.getString(prefKey, null); 71 | if (feedData==null) 72 | return; 73 | JSONArray data; 74 | try { 75 | data = new JSONArray(feedData); 76 | global.setFeed(feedId, data); 77 | global.mSharedPreferences.edit().remove(prefKey).apply(); 78 | } catch (JSONException e) { 79 | e.printStackTrace(); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/tasks/CommentTask.java: -------------------------------------------------------------------------------- 1 | package au.com.wallaceit.reddinator.tasks; 2 | /* 3 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 4 | * This file is part of Reddinator. 5 | * 6 | * Reddinator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Reddinator is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Reddinator (COPYING). If not, see . 18 | * 19 | * Created by michael on 6/02/16. 20 | */ 21 | 22 | import android.os.AsyncTask; 23 | import org.json.JSONObject; 24 | import au.com.wallaceit.reddinator.Reddinator; 25 | import au.com.wallaceit.reddinator.core.RedditData; 26 | 27 | public class CommentTask extends AsyncTask { 28 | private Reddinator global; 29 | private String redditId; 30 | private String messageText; 31 | private RedditData.RedditApiException exception = null; 32 | private Callback callback = null; 33 | private int action = 0; // 0=add, 1=edit, -1=delete 34 | public static final int ACTION_ADD = 0; 35 | public static final int ACTION_EDIT = 1; 36 | public static final int ACTION_DELETE = -1; 37 | 38 | public interface Callback { 39 | void onCommentComplete(JSONObject result, RedditData.RedditApiException exception, int action, String redditId); 40 | } 41 | 42 | public CommentTask(Reddinator global, String thingId, String text, int action, Callback callback) { 43 | this.global = global; 44 | this.callback = callback; 45 | messageText = text; 46 | redditId = thingId; 47 | this.action = action; 48 | } 49 | 50 | @Override 51 | protected JSONObject doInBackground(String... strings) { 52 | // Do the vote 53 | JSONObject result = null; 54 | try { 55 | switch (action){ 56 | case ACTION_DELETE: 57 | global.mRedditData.deleteComment(redditId); 58 | result = new JSONObject(); 59 | break; 60 | case ACTION_ADD: 61 | result = global.mRedditData.postComment(redditId, messageText); 62 | break; 63 | case ACTION_EDIT: 64 | result = global.mRedditData.editComment(redditId, messageText); 65 | break; 66 | } 67 | 68 | } catch (RedditData.RedditApiException e) { 69 | e.printStackTrace(); 70 | exception = e; 71 | return null; 72 | } 73 | 74 | return result; 75 | } 76 | 77 | @Override 78 | protected void onPostExecute(JSONObject result) { 79 | if (callback!=null) 80 | callback.onCommentComplete(result, exception, action, redditId); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/tasks/ComposeMessageTask.java: -------------------------------------------------------------------------------- 1 | package au.com.wallaceit.reddinator.tasks; 2 | /* 3 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 4 | * This file is part of Reddinator. 5 | * 6 | * Reddinator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Reddinator is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Reddinator (COPYING). If not, see . 18 | * 19 | * Created by michael on 9/02/16. 20 | */ 21 | 22 | import android.os.AsyncTask; 23 | 24 | import au.com.wallaceit.reddinator.Reddinator; 25 | import au.com.wallaceit.reddinator.core.RedditData; 26 | 27 | public class ComposeMessageTask extends AsyncTask { 28 | private Reddinator global; 29 | private RedditData.RedditApiException exception = null; 30 | private Callback messageCallback = null; 31 | private String[] args; // [to, subject, text, subreddit, optional args...] 32 | 33 | public interface Callback { 34 | void onMessageSent(boolean result, RedditData.RedditApiException exception, String[] args); 35 | } 36 | 37 | public ComposeMessageTask(Reddinator global, Callback messageCallback, String[] args) { 38 | this.global = global; 39 | this.messageCallback = messageCallback; 40 | this.args = args; 41 | } 42 | 43 | @Override 44 | protected Boolean doInBackground(String... strings) { 45 | // Do the vote 46 | try { 47 | global.mRedditData.composeMessage(args[0], args[1], args[2], args.length>3?args[3]:null); 48 | } catch (RedditData.RedditApiException e) { 49 | e.printStackTrace(); 50 | exception = e; 51 | return false; 52 | } 53 | return true; 54 | } 55 | 56 | @Override 57 | protected void onPostExecute(Boolean result) { 58 | if (messageCallback !=null) 59 | messageCallback.onMessageSent(result, exception, args); 60 | } 61 | } -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/tasks/HidePostTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 3 | * This file is part of Reddinator. 4 | * 5 | * Reddinator is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * Reddinator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Reddinator (COPYING). If not, see . 17 | * 18 | * Created by michael on 1/02/16. 19 | */ 20 | package au.com.wallaceit.reddinator.tasks; 21 | 22 | import android.content.Context; 23 | import android.os.AsyncTask; 24 | import android.widget.Toast; 25 | 26 | import au.com.wallaceit.reddinator.Reddinator; 27 | import au.com.wallaceit.reddinator.core.RedditData; 28 | import au.com.wallaceit.reddinator.core.Utilities; 29 | 30 | public class HidePostTask extends AsyncTask { 31 | private Reddinator global; 32 | private RedditData.RedditApiException exception; 33 | private Context context; 34 | private Runnable callback; 35 | private boolean fromWidget = false; 36 | 37 | public HidePostTask(Context context, boolean fromWidget, Runnable callback){ 38 | this.context = context; 39 | this.fromWidget = fromWidget; 40 | this.callback = callback; 41 | global = (Reddinator) context.getApplicationContext(); 42 | } 43 | 44 | @Override 45 | protected Boolean doInBackground(String... params) { 46 | try { 47 | if (params[0].equals("unhide")){ 48 | global.mRedditData.unHide(params[1]); 49 | } else { 50 | global.mRedditData.hide(params[0]); 51 | } 52 | } catch (RedditData.RedditApiException e) { 53 | e.printStackTrace(); 54 | exception = e; 55 | return false; 56 | } 57 | return true; 58 | } 59 | 60 | @Override 61 | protected void onPostExecute(Boolean result) { 62 | if (!result){ 63 | // check login required 64 | if (exception.isAuthError()) global.mRedditData.initiateLogin(context, fromWidget); 65 | // show error 66 | Utilities.showApiErrorToastOrDialog(context, exception); 67 | } 68 | if (callback!=null) 69 | callback.run(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/tasks/LoadImageBitmapTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 3 | * This file is part of Reddinator. 4 | * 5 | * Reddinator is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * Reddinator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Reddinator (COPYING). If not, see . 17 | * 18 | * Created by michael on 9/08/16. 19 | */ 20 | package au.com.wallaceit.reddinator.tasks; 21 | 22 | import android.graphics.Bitmap; 23 | import android.graphics.BitmapFactory; 24 | import android.os.AsyncTask; 25 | import android.util.Log; 26 | 27 | import java.io.IOException; 28 | import java.net.MalformedURLException; 29 | import java.net.URL; 30 | import java.net.URLConnection; 31 | 32 | public class LoadImageBitmapTask extends AsyncTask { 33 | private String url; 34 | private ImageCallback callback; 35 | 36 | public LoadImageBitmapTask(String url, ImageCallback callback) { 37 | this.url = url; 38 | this.callback = callback; 39 | } 40 | 41 | public static abstract class ImageCallback implements Runnable { 42 | public Bitmap image = null; 43 | @Override 44 | public void run(){ 45 | } 46 | } 47 | 48 | @Override 49 | protected Bitmap doInBackground(Void... voids) { 50 | URL url; 51 | try { 52 | url = new URL(this.url); 53 | URLConnection con = url.openConnection(); 54 | con.setConnectTimeout(8000); 55 | con.setReadTimeout(8000); 56 | return BitmapFactory.decodeStream(con.getInputStream()); 57 | } catch (Exception e) { 58 | Log.d("Reddinator", "Count not load image with URL: "+this.url, e); 59 | return null; 60 | } 61 | } 62 | 63 | @Override 64 | protected void onPostExecute(Bitmap result) { 65 | if (callback!=null){ 66 | callback.image = result; 67 | callback.run(); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/tasks/LoadPostTask.java: -------------------------------------------------------------------------------- 1 | package au.com.wallaceit.reddinator.tasks; 2 | /* 3 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 4 | * This file is part of Reddinator. 5 | * 6 | * Reddinator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Reddinator is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Reddinator (COPYING). If not, see . 18 | * 19 | * Created by michael on 27/03/16. 20 | */ 21 | 22 | import android.os.AsyncTask; 23 | 24 | import org.json.JSONArray; 25 | 26 | import au.com.wallaceit.reddinator.Reddinator; 27 | import au.com.wallaceit.reddinator.core.RedditData; 28 | 29 | public class LoadPostTask extends AsyncTask { 30 | private Reddinator global; 31 | private RedditData.RedditApiException exception = null; 32 | private Callback voteCallback = null; 33 | 34 | public interface Callback { 35 | void onPostLoaded(JSONArray result, RedditData.RedditApiException exception); 36 | } 37 | 38 | public LoadPostTask(Reddinator global, Callback voteCallback) { 39 | this.global = global; 40 | this.voteCallback = voteCallback; 41 | } 42 | 43 | @Override 44 | protected JSONArray doInBackground(String... strings) { 45 | // Do the vote 46 | try { 47 | return global.mRedditData.getCommentsFeed(strings[0], strings[1], 25); 48 | } catch (RedditData.RedditApiException e) { 49 | e.printStackTrace(); 50 | exception = e; 51 | return null; 52 | } 53 | } 54 | 55 | @Override 56 | protected void onPostExecute(JSONArray data) { 57 | if (voteCallback!=null) 58 | voteCallback.onPostLoaded(data, exception); 59 | } 60 | } -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/tasks/LoadRandomTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 3 | * This file is part of Reddinator. 4 | * 5 | * Reddinator is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * Reddinator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Reddinator (COPYING). If not, see . 17 | * 18 | * Created by michael on 29/07/16. 19 | */ 20 | package au.com.wallaceit.reddinator.tasks; 21 | 22 | import android.os.AsyncTask; 23 | 24 | import org.json.JSONObject; 25 | 26 | import au.com.wallaceit.reddinator.Reddinator; 27 | import au.com.wallaceit.reddinator.core.RedditData; 28 | 29 | public class LoadRandomTask extends AsyncTask { 30 | private Reddinator global; 31 | private RedditData.RedditApiException exception = null; 32 | private Callback randomCallback = null; 33 | 34 | public interface Callback { 35 | void onRandomSubredditLoaded(JSONObject result, RedditData.RedditApiException exception); 36 | } 37 | 38 | public LoadRandomTask(Reddinator global, Callback randomCallback) { 39 | this.global = global; 40 | this.randomCallback = randomCallback; 41 | } 42 | 43 | @Override 44 | protected JSONObject doInBackground(String... strings) { 45 | // Retrieve 46 | try { 47 | return global.mRedditData.getRandomSubreddit(); 48 | } catch (RedditData.RedditApiException e) { 49 | e.printStackTrace(); 50 | exception = e; 51 | return null; 52 | } 53 | } 54 | 55 | @Override 56 | protected void onPostExecute(JSONObject data) { 57 | if (randomCallback!=null) 58 | randomCallback.onRandomSubredditLoaded(data, exception); 59 | } 60 | } -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/tasks/LoadSubredditInfoTask.java: -------------------------------------------------------------------------------- 1 | package au.com.wallaceit.reddinator.tasks; 2 | /* 3 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 4 | * This file is part of Reddinator. 5 | * 6 | * Reddinator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Reddinator is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Reddinator (COPYING). If not, see . 18 | * 19 | * Created by michael on 30/03/16. 20 | */ 21 | 22 | import android.os.AsyncTask; 23 | 24 | import org.json.JSONObject; 25 | 26 | import au.com.wallaceit.reddinator.Reddinator; 27 | import au.com.wallaceit.reddinator.core.RedditData; 28 | 29 | public class LoadSubredditInfoTask extends AsyncTask { 30 | private Reddinator global; 31 | private RedditData.RedditApiException exception = null; 32 | private Callback callback = null; 33 | 34 | public interface Callback { 35 | void onSubredditInfoLoaded(JSONObject result, RedditData.RedditApiException exception); 36 | } 37 | 38 | public LoadSubredditInfoTask(Reddinator global, Callback voteCallback) { 39 | this.global = global; 40 | this.callback = voteCallback; 41 | } 42 | 43 | @Override 44 | protected JSONObject doInBackground(String... strings) { 45 | // Do the vote 46 | try { 47 | return global.mRedditData.getSubredditInfo(strings[0]); 48 | } catch (RedditData.RedditApiException e) { 49 | e.printStackTrace(); 50 | exception = e; 51 | return null; 52 | } 53 | } 54 | 55 | @Override 56 | protected void onPostExecute(JSONObject data) { 57 | if (callback!=null) 58 | callback.onSubredditInfoLoaded(data, exception); 59 | } 60 | } -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/tasks/MarkMessageTask.java: -------------------------------------------------------------------------------- 1 | package au.com.wallaceit.reddinator.tasks; 2 | /* 3 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 4 | * This file is part of Reddinator. 5 | * 6 | * Reddinator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Reddinator is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Reddinator (COPYING). If not, see . 18 | * 19 | * Created by michael on 7/02/16. 20 | */ 21 | 22 | import android.os.AsyncTask; 23 | import android.widget.Toast; 24 | 25 | import java.util.ArrayList; 26 | 27 | import au.com.wallaceit.reddinator.Reddinator; 28 | import au.com.wallaceit.reddinator.core.RedditData; 29 | 30 | public class MarkMessageTask extends AsyncTask { 31 | private Reddinator global; 32 | private ArrayList redditIds; 33 | private RedditData.RedditApiException exception = null; 34 | 35 | public MarkMessageTask(Reddinator global, ArrayList redditIds) { 36 | this.global = global; 37 | this.redditIds = redditIds; 38 | } 39 | 40 | @Override 41 | protected Boolean doInBackground(String... strings) { 42 | // Do the vote 43 | try { 44 | global.mRedditData.markMessagesRead(redditIds); 45 | } catch (RedditData.RedditApiException e) { 46 | e.printStackTrace(); 47 | exception = e; 48 | return false; 49 | } 50 | return true; 51 | } 52 | 53 | @Override 54 | protected void onPostExecute(Boolean result) { 55 | if (result) { 56 | global.clearUnreadMessages(); 57 | } else { 58 | // show error 59 | Toast.makeText(global.getApplicationContext(), "Failed to mark message read: "+exception.getMessage(), Toast.LENGTH_LONG).show(); 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/tasks/SavePostTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 3 | * This file is part of Reddinator. 4 | * 5 | * Reddinator is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * Reddinator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Reddinator (COPYING). If not, see . 17 | * 18 | * Created by michael on 1/02/16. 19 | */ 20 | package au.com.wallaceit.reddinator.tasks; 21 | 22 | import android.content.Context; 23 | import android.os.AsyncTask; 24 | import android.widget.Toast; 25 | 26 | import au.com.wallaceit.reddinator.R; 27 | import au.com.wallaceit.reddinator.Reddinator; 28 | import au.com.wallaceit.reddinator.core.RedditData; 29 | import au.com.wallaceit.reddinator.core.Utilities; 30 | 31 | public class SavePostTask extends AsyncTask { 32 | private Reddinator global; 33 | private RedditData.RedditApiException exception; 34 | private Context context; 35 | private Runnable callback; 36 | private boolean fromWidget = false; 37 | private boolean unsave = false; 38 | 39 | public SavePostTask(Context context, boolean fromWidget, Runnable callback){ 40 | this.context = context; 41 | this.fromWidget = fromWidget; 42 | this.callback = callback; 43 | global = (Reddinator) context.getApplicationContext(); 44 | } 45 | 46 | @Override 47 | protected Boolean doInBackground(String... params) { 48 | try { 49 | if (params[0].equals("unsave")){ 50 | global.mRedditData.unSave(params[1]); 51 | unsave = true; 52 | } else { 53 | global.mRedditData.save(params[0], params[1]); 54 | } 55 | } catch (RedditData.RedditApiException e) { 56 | e.printStackTrace(); 57 | exception = e; 58 | return false; 59 | } 60 | return true; 61 | } 62 | 63 | @Override 64 | protected void onPostExecute(Boolean result) { 65 | if (!result){ 66 | // check login required 67 | if (exception.isAuthError()) global.mRedditData.initiateLogin(context, fromWidget); 68 | // show error 69 | Utilities.showApiErrorToastOrDialog(context, exception); 70 | } else { 71 | if (!unsave) 72 | Toast.makeText(context, context.getString(R.string.post_saved), Toast.LENGTH_SHORT).show(); 73 | } 74 | if (callback!=null) 75 | callback.run(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/tasks/SubmitTask.java: -------------------------------------------------------------------------------- 1 | package au.com.wallaceit.reddinator.tasks; 2 | /* 3 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 4 | * This file is part of Reddinator. 5 | * 6 | * Reddinator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Reddinator is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Reddinator (COPYING). If not, see . 18 | * 19 | * Created by michael on 17/06/16. 20 | */ 21 | import android.os.AsyncTask; 22 | import org.json.JSONObject; 23 | import au.com.wallaceit.reddinator.Reddinator; 24 | import au.com.wallaceit.reddinator.core.RedditData; 25 | 26 | public class SubmitTask extends AsyncTask { 27 | private Reddinator global; 28 | private Callback submitCallback; 29 | private JSONObject jsonResult; 30 | private RedditData.RedditApiException exception; 31 | private boolean isLink; 32 | private String subreddit; 33 | private String title; 34 | private String data; 35 | 36 | public interface Callback { 37 | void onSubmitted(JSONObject result, RedditData.RedditApiException exception, boolean isLink); 38 | } 39 | 40 | public SubmitTask(Reddinator global, String subreddit, String title, String data, boolean isLink, Callback callback){ 41 | this.global = global; 42 | this.submitCallback = callback; 43 | this.isLink = isLink; 44 | this.title = title; 45 | this.data = data; 46 | this.subreddit = subreddit; 47 | } 48 | 49 | @Override 50 | protected Boolean doInBackground(String... strings) { 51 | try { 52 | jsonResult = global.mRedditData.submit(subreddit, isLink, title, data); 53 | return true; 54 | } catch (RedditData.RedditApiException e) { 55 | e.printStackTrace(); 56 | exception = e; 57 | } 58 | return false; 59 | } 60 | 61 | @Override 62 | protected void onPostExecute(Boolean result) { 63 | if (submitCallback!=null) 64 | submitCallback.onSubmitted(jsonResult, exception, isLink); 65 | } 66 | } -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/tasks/SyncUserDataTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 3 | * This file is part of Reddinator. 4 | * 5 | * Reddinator is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * Reddinator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Reddinator (COPYING). If not, see . 17 | * 18 | * Created by michael on 1/02/16. 19 | */ 20 | package au.com.wallaceit.reddinator.tasks; 21 | 22 | import android.app.ProgressDialog; 23 | import android.content.Context; 24 | import android.os.AsyncTask; 25 | 26 | import au.com.wallaceit.reddinator.R; 27 | import au.com.wallaceit.reddinator.Reddinator; 28 | import au.com.wallaceit.reddinator.core.RedditData; 29 | import au.com.wallaceit.reddinator.core.Utilities; 30 | 31 | public class SyncUserDataTask extends AsyncTask { 32 | public static int MODE_SUBREDDITS = 1; 33 | public static int MODE_MULTIS = 2; 34 | 35 | private Reddinator global; 36 | private RedditData.RedditApiException exception; 37 | private Context context; 38 | private Runnable callback; 39 | private boolean showUI; 40 | private ProgressDialog progressDialog = null; 41 | private int mode; 42 | 43 | public SyncUserDataTask(Context context, Runnable callback, boolean showUI, int mode){ 44 | this.context = context; 45 | this.callback = callback; 46 | this.showUI = showUI; 47 | this.mode = mode; 48 | global = (Reddinator) context.getApplicationContext(); 49 | } 50 | 51 | @Override 52 | protected void onPreExecute() { 53 | if (showUI) 54 | progressDialog = ProgressDialog.show(context, context.getString(R.string.loading), "", true); 55 | } 56 | 57 | @Override 58 | protected Boolean doInBackground(String... params) { 59 | // load subreddits & multis 60 | try { 61 | if (mode != MODE_MULTIS) { 62 | publishProgress(context.getString(R.string.loading_subreddits)); 63 | global.loadAccountSubreddits(); 64 | if (mode == MODE_SUBREDDITS) return true; 65 | } 66 | 67 | publishProgress(context.getString(R.string.loading_multis)); 68 | global.loadAccountMultis(); 69 | if (mode == MODE_MULTIS) return true; 70 | 71 | publishProgress(context.getString(R.string.loading_filters)); 72 | global.syncAllFilters(); 73 | } catch (RedditData.RedditApiException e) { 74 | e.printStackTrace(); 75 | exception = e; 76 | return false; 77 | } 78 | return true; 79 | } 80 | 81 | @Override 82 | protected void onProgressUpdate(String... statusText){ 83 | if (!showUI) return; 84 | progressDialog.setMessage(statusText[0]); 85 | } 86 | 87 | @Override 88 | protected void onPostExecute(Boolean result) { 89 | if (showUI) { 90 | if (progressDialog != null) 91 | progressDialog.dismiss(); 92 | if (!result){ 93 | // check login required 94 | if (exception.isAuthError()) global.mRedditData.initiateLogin(context, false); 95 | // show error 96 | Utilities.showApiErrorToastOrDialog(context, exception); 97 | } 98 | } 99 | if (result) 100 | global.mSharedPreferences.edit().putLong("last_sync_time", System.currentTimeMillis()).apply(); 101 | 102 | if (callback!=null) 103 | callback.run(); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/tasks/VoteTask.java: -------------------------------------------------------------------------------- 1 | package au.com.wallaceit.reddinator.tasks; 2 | /* 3 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 4 | * This file is part of Reddinator. 5 | * 6 | * Reddinator is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Reddinator is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Reddinator (COPYING). If not, see . 18 | * 19 | * Created by michael on 6/02/16. 20 | */ 21 | 22 | import android.os.AsyncTask; 23 | import au.com.wallaceit.reddinator.Reddinator; 24 | import au.com.wallaceit.reddinator.core.RedditData; 25 | 26 | public class VoteTask extends AsyncTask { 27 | private Reddinator global; 28 | private String redditId; 29 | private int listPosition = -1; 30 | private int direction; 31 | private int netVote; // how the score will change after the vote is successful (ie. if already upvoted, downvoting causes -2 score change) 32 | private int currentVote; 33 | private RedditData.RedditApiException exception = null; 34 | private Callback voteCallback = null; 35 | 36 | public interface Callback { 37 | void onVoteComplete(boolean result, RedditData.RedditApiException exception, String redditId, int direction, int netVote, int listPosition); 38 | } 39 | 40 | public VoteTask(Reddinator global, Callback voteCallback, String redditId, int listPosition, int direction, int currentVote) { 41 | this(global, voteCallback, redditId, direction, currentVote); 42 | this.listPosition = listPosition; 43 | } 44 | 45 | public VoteTask(Reddinator global, Callback voteCallback, String redditId, int direction, int currentVote) { 46 | this.global = global; 47 | this.voteCallback = voteCallback; 48 | this.direction = direction; 49 | this.netVote = direction; 50 | this.currentVote = currentVote; 51 | this.redditId = redditId; 52 | } 53 | 54 | @Override 55 | protected Boolean doInBackground(String... strings) { 56 | if (direction == 1) { 57 | if (currentVote==1) { // if already upvoted, neutralize. 58 | direction = 0; 59 | netVote = -1; 60 | } else if (currentVote==-1){ 61 | netVote = 2; 62 | } 63 | } else { // downvote 64 | if (currentVote==-1) { 65 | direction = 0; 66 | netVote = 1; 67 | } else if (currentVote==1){ 68 | netVote = -2; 69 | } 70 | } 71 | // Do the vote 72 | try { 73 | return global.mRedditData.vote(redditId, direction); 74 | } catch (RedditData.RedditApiException e) { 75 | e.printStackTrace(); 76 | exception = e; 77 | return false; 78 | } 79 | } 80 | 81 | @Override 82 | protected void onPostExecute(Boolean result) { 83 | if (voteCallback!=null) 84 | voteCallback.onVoteComplete(result, exception, redditId, direction, netVote, listPosition); 85 | } 86 | } -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/tasks/WidgetVoteTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 3 | * This file is part of Reddinator. 4 | * 5 | * Reddinator is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * Reddinator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Reddinator (COPYING). If not, see . 17 | * 18 | * Created by michael on 23/01/16. 19 | */ 20 | package au.com.wallaceit.reddinator.tasks; 21 | 22 | import android.content.Context; 23 | import android.os.AsyncTask; 24 | import android.widget.Toast; 25 | 26 | import org.json.JSONException; 27 | import org.json.JSONObject; 28 | 29 | import au.com.wallaceit.reddinator.R; 30 | import au.com.wallaceit.reddinator.Reddinator; 31 | import au.com.wallaceit.reddinator.core.RedditData; 32 | import au.com.wallaceit.reddinator.core.Utilities; 33 | import au.com.wallaceit.reddinator.service.WidgetCommon; 34 | 35 | public class WidgetVoteTask extends AsyncTask { 36 | private Context context; 37 | private Reddinator global; 38 | private int widgetId; 39 | private String redditid; 40 | private int direction; 41 | private String curVote; 42 | private int netvote; 43 | private int listposition; 44 | private RedditData.RedditApiException exception; 45 | private boolean archived = false; 46 | 47 | public WidgetVoteTask(Context context, int widgetId, int dir, int position, String redditId) { 48 | this.context = context; 49 | global = (Reddinator) context.getApplicationContext(); 50 | direction = dir; 51 | netvote = dir; 52 | this.widgetId = widgetId; 53 | // Get data by position in list 54 | listposition = position; 55 | JSONObject item = global.getFeedObject(widgetId, position, redditId); 56 | try { 57 | redditid = item.getString("name"); 58 | curVote = item.getString("likes"); 59 | archived = item.getBoolean("archived"); 60 | if (archived) 61 | return; 62 | } catch (JSONException e) { 63 | redditid = "null"; 64 | curVote = "null"; 65 | } 66 | //AppWidgetManager mgr = AppWidgetManager.getInstance(context).get.getAppWidgetInfo(widgetId).provider; 67 | 68 | WidgetCommon.showLoaderAndRefreshViews(context, widgetId); 69 | } 70 | 71 | @Override 72 | protected Boolean doInBackground(String... strings) { 73 | if (archived) 74 | return false; 75 | // enumerate current vote, score change & clicked direction 76 | if (direction == 1) { 77 | if (curVote.equals("true")) { // if already upvoted, neutralize. 78 | direction = 0; 79 | netvote = -1; 80 | } else if (curVote.equals("false")){ 81 | netvote = 2; 82 | } 83 | } else { // downvote 84 | if (curVote.equals("false")) { 85 | direction = 0; 86 | netvote = 1; 87 | } else if (curVote.equals("true")){ 88 | netvote = -2; 89 | } 90 | } 91 | // Do the vote 92 | try { 93 | return global.mRedditData.vote(redditid, direction); 94 | } catch (RedditData.RedditApiException e) { 95 | e.printStackTrace(); 96 | exception = e; 97 | return false; 98 | } 99 | } 100 | 101 | @Override 102 | protected void onPostExecute(Boolean result) { 103 | if (result) { 104 | // set icon + current "likes" in the data array, this way ViewRedditActivity will get the new version without updating the hole feed. 105 | String value = "null"; 106 | switch (direction) { 107 | case -1: 108 | value = "false"; 109 | break; 110 | case 0: 111 | value = "null"; 112 | break; 113 | case 1: 114 | value = "true"; 115 | break; 116 | } 117 | 118 | global.setItemVote(widgetId, listposition, redditid, value, netvote); 119 | } else { 120 | if (archived) { 121 | Toast.makeText(context, R.string.archived_post_error, Toast.LENGTH_LONG).show(); 122 | return; 123 | } 124 | // check login required 125 | if (exception.isAuthError()) global.mRedditData.initiateLogin(context, true); 126 | // show error 127 | Utilities.showApiErrorToastOrDialog(context, exception); 128 | } 129 | WidgetCommon.hideLoaderAndRefreshViews(context, widgetId, (!result && !exception.isAuthError())); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/ui/ActionbarActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 3 | * This file is part of Reddinator. 4 | * 5 | * Reddinator is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * Reddinator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Reddinator (COPYING). If not, see . 17 | */ 18 | package au.com.wallaceit.reddinator.ui; 19 | 20 | import android.app.Activity; 21 | import android.os.Bundle; 22 | 23 | import au.com.wallaceit.reddinator.core.Utilities; 24 | 25 | public class ActionbarActivity extends Activity { 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | // Set actionbar overflow icon drawable 31 | Utilities.updateActionbarOverflowIcon(this, Utilities.getActionbarIconColor()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/ui/ActionbarFragmentActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 3 | * This file is part of Reddinator. 4 | * 5 | * Reddinator is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * Reddinator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Reddinator (COPYING). If not, see . 17 | */ 18 | package au.com.wallaceit.reddinator.ui; 19 | 20 | import android.os.Bundle; 21 | import android.support.v4.app.FragmentActivity; 22 | 23 | import au.com.wallaceit.reddinator.core.Utilities; 24 | 25 | public class ActionbarFragmentActivity extends FragmentActivity { 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | // Set actionbar overflow icon drawable 31 | Utilities.updateActionbarOverflowIcon(this, Utilities.getActionbarIconColor()); 32 | } 33 | } -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/ui/HtmlDialog.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 2 | * This file is part of Reddinator. 3 | * 4 | * Reddinator is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Reddinator is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Reddinator (COPYING). If not, see . 16 | * 17 | * Created by michael on 27/03/16. 18 | */ 19 | 20 | package au.com.wallaceit.reddinator.ui; 21 | 22 | import android.annotation.SuppressLint; 23 | import android.app.Activity; 24 | import android.app.AlertDialog; 25 | import android.view.LayoutInflater; 26 | import android.view.View; 27 | import android.webkit.WebView; 28 | import android.webkit.WebViewClient; 29 | 30 | import au.com.wallaceit.reddinator.R; 31 | import au.com.wallaceit.reddinator.Reddinator; 32 | 33 | public class HtmlDialog extends AlertDialog { 34 | public static HtmlDialog init(Activity context, String title, String html){ 35 | HtmlDialog dialog = new HtmlDialog(context, title, html); 36 | dialog.show(); 37 | return dialog; 38 | } 39 | 40 | private HtmlDialog(Activity context, String title, String html) { 41 | super(context, R.style.HtmlDialog); 42 | @SuppressLint("InflateParams") 43 | View view = LayoutInflater.from(context).inflate(R.layout.dialog_html, null); 44 | WebView wv = (WebView) view.findViewById(R.id.webView); 45 | setTitle(title); 46 | setView(view); 47 | setCancelable(true); 48 | 49 | context.registerForContextMenu(wv); 50 | wv.setWebViewClient(new NoNavClient()); 51 | wv.loadDataWithBaseURL("https://www.reddit.com", html, "text/html", "UTF-8", ""); 52 | setCanceledOnTouchOutside(true); 53 | } 54 | 55 | private class NoNavClient extends WebViewClient { 56 | @Override 57 | public boolean shouldOverrideUrlLoading(WebView view, String url) { 58 | 59 | ((Reddinator) getContext().getApplicationContext()).handleLink(getContext(), url); 60 | return true; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/ui/RedditViewPager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 3 | * This file is part of Reddinator. 4 | * 5 | * Reddinator is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * Reddinator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Reddinator (COPYING). If not, see . 17 | * 18 | * Created by michael on 3/04/16. 19 | * This class overrides view pager to prevent gesture pager swiping 20 | * Sourced from this SO post: http://stackoverflow.com/questions/9650265 21 | * Thanks to Rajul for this solution 22 | */ 23 | package au.com.wallaceit.reddinator.ui; 24 | 25 | import android.content.Context; 26 | import android.support.v4.view.ViewPager; 27 | import android.util.AttributeSet; 28 | import android.view.MotionEvent; 29 | 30 | public class RedditViewPager extends ViewPager { 31 | 32 | private boolean enabled = true; 33 | 34 | public RedditViewPager(Context context) { 35 | super(context); 36 | } 37 | 38 | public RedditViewPager(Context context, AttributeSet attrs) { 39 | super(context, attrs); 40 | } 41 | 42 | @Override 43 | public boolean onTouchEvent(MotionEvent event) { 44 | return this.enabled && super.onTouchEvent(event); 45 | } 46 | 47 | @Override 48 | public boolean onInterceptTouchEvent(MotionEvent event) { 49 | return this.enabled && super.onInterceptTouchEvent(event); 50 | } 51 | 52 | public void setPagingEnabled(boolean enabled) { 53 | this.enabled = enabled; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/ui/SimpleTabsAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 3 | * This file is part of Reddinator. 4 | * 5 | * Reddinator is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * Reddinator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Reddinator (COPYING). If not, see . 17 | * 18 | * Created by michael on 14/05/15. 19 | */ 20 | package au.com.wallaceit.reddinator.ui; 21 | 22 | import android.app.Activity; 23 | import android.content.Context; 24 | import android.support.v4.view.PagerAdapter; 25 | import android.view.View; 26 | import android.view.ViewGroup; 27 | 28 | public class SimpleTabsAdapter extends PagerAdapter { 29 | 30 | private View layout = null; 31 | private String[] labels; 32 | private int[] layoutIds; 33 | private Activity context; 34 | 35 | public SimpleTabsAdapter(String[] labels, int[] layoutIds, Context context, View layout){ 36 | this.context = (Activity) context; 37 | this.layout = layout; 38 | this.labels = labels; 39 | this.layoutIds = layoutIds; 40 | } 41 | 42 | public Object instantiateItem(ViewGroup collection, int position) { 43 | if (position>labels.length) 44 | return null; 45 | if (layout==null) 46 | return context.findViewById(layoutIds[position]); 47 | return layout.findViewById(layoutIds[position]); 48 | } 49 | 50 | public void destroyItem(ViewGroup container, int position, Object object) { 51 | 52 | } 53 | 54 | @Override 55 | public int getCount() { 56 | return labels.length; 57 | } 58 | 59 | @Override 60 | public CharSequence getPageTitle(int position) { 61 | if (position>labels.length) 62 | return null; 63 | return labels[position]; 64 | } 65 | 66 | @Override 67 | public boolean isViewFromObject(View arg0, Object arg1) { 68 | return arg0 == arg1; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /reddinator/src/main/java/au/com/wallaceit/reddinator/ui/SubAutoCompleteAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Michael Boyde Wallace (http://wallaceit.com.au) 3 | * This file is part of Reddinator. 4 | * 5 | * Reddinator is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * Reddinator is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with Reddinator (COPYING). If not, see . 17 | * 18 | * Created by michael on 14/05/15. 19 | */ 20 | package au.com.wallaceit.reddinator.ui; 21 | 22 | import android.content.Context; 23 | import android.widget.ArrayAdapter; 24 | import android.widget.Filter; 25 | import android.widget.Filterable; 26 | import android.widget.Toast; 27 | 28 | import org.json.JSONArray; 29 | import org.json.JSONException; 30 | 31 | import au.com.wallaceit.reddinator.Reddinator; 32 | import au.com.wallaceit.reddinator.core.RedditData; 33 | 34 | public class SubAutoCompleteAdapter extends ArrayAdapter implements Filterable { 35 | private Reddinator global; 36 | private JSONArray suggestions = new JSONArray(); 37 | 38 | public SubAutoCompleteAdapter(Context context, int resource) { 39 | super(context, resource); 40 | global = (Reddinator) context.getApplicationContext(); 41 | } 42 | 43 | @Override 44 | public int getCount() { 45 | if (suggestions==null) 46 | return 0; 47 | 48 | return suggestions.length(); 49 | } 50 | 51 | @Override 52 | public String getItem(int index) { 53 | try { 54 | return suggestions.getString(index); 55 | } catch (JSONException e) { 56 | e.printStackTrace(); 57 | } 58 | return null; 59 | } 60 | 61 | @Override 62 | public Filter getFilter() { 63 | return new Filter() { 64 | private Exception exception; 65 | @Override 66 | protected FilterResults performFiltering(CharSequence constraint) { 67 | FilterResults filterResults = new FilterResults(); 68 | if (constraint != null) { 69 | // Retrieve the autocomplete results. 70 | try { 71 | JSONArray suggestions = global.mRedditData.searchRedditNames(constraint.toString()); 72 | // Assign the data to the FilterResults 73 | filterResults.values = suggestions; 74 | filterResults.count = suggestions.length(); 75 | } catch (RedditData.RedditApiException e) { 76 | e.printStackTrace(); 77 | exception = e; 78 | return null; 79 | } 80 | } 81 | return filterResults; 82 | } 83 | 84 | @Override 85 | protected void publishResults(CharSequence constraint, FilterResults results) { 86 | if (results != null) { 87 | suggestions = (JSONArray) results.values; 88 | if (results.count > 0) { 89 | notifyDataSetChanged(); 90 | return; 91 | } 92 | } else { 93 | Toast.makeText(getContext(), exception.getMessage(), Toast.LENGTH_LONG).show(); 94 | } 95 | notifyDataSetInvalidated(); 96 | }}; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /reddinator/src/main/res/drawable-hdpi/border.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /reddinator/src/main/res/drawable-hdpi/github_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/res/drawable-hdpi/github_logo.png -------------------------------------------------------------------------------- /reddinator/src/main/res/drawable-hdpi/ic_notify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/res/drawable-hdpi/ic_notify.png -------------------------------------------------------------------------------- /reddinator/src/main/res/drawable-hdpi/menu_overflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/res/drawable-hdpi/menu_overflow.png -------------------------------------------------------------------------------- /reddinator/src/main/res/drawable-hdpi/noimage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/res/drawable-hdpi/noimage.png -------------------------------------------------------------------------------- /reddinator/src/main/res/drawable-hdpi/nsfw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/res/drawable-hdpi/nsfw.png -------------------------------------------------------------------------------- /reddinator/src/main/res/drawable-hdpi/reddinator_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/res/drawable-hdpi/reddinator_logo.png -------------------------------------------------------------------------------- /reddinator/src/main/res/drawable-hdpi/self_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/res/drawable-hdpi/self_default.png -------------------------------------------------------------------------------- /reddinator/src/main/res/drawable-mdpi/ic_notify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/res/drawable-mdpi/ic_notify.png -------------------------------------------------------------------------------- /reddinator/src/main/res/drawable-mdpi/menu_overflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/res/drawable-mdpi/menu_overflow.png -------------------------------------------------------------------------------- /reddinator/src/main/res/drawable-xhdpi/ic_notify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/res/drawable-xhdpi/ic_notify.png -------------------------------------------------------------------------------- /reddinator/src/main/res/drawable-xhdpi/menu_overflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/res/drawable-xhdpi/menu_overflow.png -------------------------------------------------------------------------------- /reddinator/src/main/res/drawable-xxhdpi/ic_notify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/res/drawable-xxhdpi/ic_notify.png -------------------------------------------------------------------------------- /reddinator/src/main/res/drawable-xxxhdpi/ic_notify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micwallace/reddinator/09c15dd3bfba14646794005e1f65a47ada39c8de/reddinator/src/main/res/drawable-xxxhdpi/ic_notify.png -------------------------------------------------------------------------------- /reddinator/src/main/res/drawable/round_corners.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /reddinator/src/main/res/layout/activity_account.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 16 | -------------------------------------------------------------------------------- /reddinator/src/main/res/layout/activity_compose.xml: -------------------------------------------------------------------------------- 1 | 7 |