Skip to content

Commit

Permalink
Housekeeping (#719)
Browse files Browse the repository at this point in the history
* Fixes probation parsing

* Parse userid / username from profile, add find own post function to threads, add thread tags, more gradle
  • Loading branch information
Sereri authored Oct 13, 2020
1 parent 4398a07 commit bc517d0
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Awful.apk/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
buildscript {
ext.kotlin_version = '1.3.72'
ext.kotlin_version = '1.4.10'

repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.yospos:
toggleYospos();
break;
case R.id.show_self:
showUsersPosts(getPrefs().userId, getPrefs().username);
break;
default:
return super.onOptionsItemSelected(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.ferg.awfulapp.constants.Constants.*
import com.ferg.awfulapp.preferences.AwfulPreferences
import com.ferg.awfulapp.preferences.Keys.IGNORE_FORMKEY
import com.ferg.awfulapp.preferences.Keys.USER_AVATAR_URL
import com.ferg.awfulapp.preferences.Keys.USER_ID
import com.ferg.awfulapp.preferences.Keys.USERNAME
import com.ferg.awfulapp.util.AwfulError
import org.jsoup.nodes.Document

Expand Down Expand Up @@ -35,7 +37,13 @@ class RefreshUserProfileRequest(context: Context) : AwfulRequest<Void?>(context,
?: throw AwfulError("Couldn't read profile page")
preferences.setPreference(IGNORE_FORMKEY, formKey.`val`())

// TODO: set the username here, and have any "update username" actions use this request to do it
val userId = doc.selectFirst("[name=userId]")
?: throw AwfulError("Couldn't read profile page")
preferences.setPreference(USER_ID, userId.`val`().toInt())
val username = doc.getElementById("loggedinusername")
?: throw AwfulError("Couldn't read profile page")
preferences.setPreference(USERNAME, username.text().trim())

// the user's avatar (if any) is the image before the first <br> tag -
// any images after that are gang tags, extra images to make the avatar longer, etc
val avatarUrl = doc.selectFirst(".title")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class PostParseTask(
put(USERNAME, textForClass("author"))
put(REGDATE, textForClass("registered"))
put(IS_PLAT, postData.hasDescendantWithClass("platinum").sqlBool)
put(IS_MOD, postData.hasDescendantWithClass("role-mod").sqlBool)
put(IS_MOD, postData.hasDescendantWithClass("role-mod, .role-supermod, .role-ik").sqlBool)
put(IS_ADMIN, postData.hasDescendantWithClass("role-admin").sqlBool)

// grab the custom title, and also the avatar if there is one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ public static AwfulError checkPageErrors(Document page, AwfulPreferences prefs)
Matcher m = PROBATION_MESSAGE_REGEX.matcher(probation.text());
if (m.find()) {
String date = m.group(2);
//for example January 11, 2013 10:35 AM CST
SimpleDateFormat probationFormat = new SimpleDateFormat("MMM d, yyyy HH:mm", Locale.US);

// Jan 11, 2013 10:35 AM vs Jan 11, 2013 22:35
String pattern = date.endsWith("m") ? "MMM d, yyyy hh:mm aa" : "MMM d, yyyy HH:mm";
SimpleDateFormat probationFormat = new SimpleDateFormat(pattern, Locale.US);

try {
//TODO this might have timezone issues?
probTimestamp = probationFormat.parse(date).getTime();
} catch (ParseException e) {
Timber.w(e, "checkPageErrors: couldn't parse probation date text: %s", date);
Expand Down
Binary file added Awful.apk/src/main/res/drawable-ldpi/qcs_c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Awful.apk/src/main/res/drawable-ldpi/qcs_q.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Awful.apk/src/main/res/drawable-ldpi/qcs_s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="40dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="40dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M16.5,3c-1.74,0 -3.41,0.81 -4.5,2.09C10.91,3.81 9.24,3 7.5,3 4.42,3 2,5.42 2,8.5c0,3.78 3.4,6.86 8.55,11.54L12,21.35l1.45,-1.32C18.6,15.36 22,12.28 22,8.5 22,5.42 19.58,3 16.5,3zM12.1,18.55l-0.1,0.1 -0.1,-0.1C7.14,14.24 4,11.39 4,8.5 4,6.5 5.5,5 7.5,5c1.54,0 3.04,0.99 3.57,2.36h1.87C13.46,5.99 14.96,5 16.5,5c2,0 3.5,1.5 3.5,3.5 0,2.89 -3.14,5.74 -7.9,10.05z"/>
</vector>
8 changes: 7 additions & 1 deletion Awful.apk/src/main/res/menu/post_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<item
app:actionProviderClass="androidx.appcompat.widget.ShareActionProvider"
android:id="@+id/share_thread"
android:icon="@drawable/ic_share_dark"
android:icon="@drawable/ic_baseline_favorite_border"
android:title="@string/share_thread"
app:showAsAction="never"
/>
Expand All @@ -45,6 +45,12 @@
app:showAsAction="never|collapseActionView"
app:actionViewClass="com.ferg.awfulapp.widget.WebViewSearchBar"
/>
<item
android:id="@+id/show_self"
android:icon="@drawable/ic_find_in_page_dark"
android:title="@string/show_self"
app:showAsAction="never"
/>
<item
android:id="@+id/keep_screen_on"
android:icon="@drawable/ic_visibility_dark"
Expand Down
2 changes: 2 additions & 0 deletions Awful.apk/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<string name="yospos">YOSPOS</string>
<string name="thread_lock">Lock thread</string>
<string name="thread_unlock">Unlock thread</string>
<string name="show_self">Admire your posts</string>

<string name="next_page">Next page</string>
<string name="mark_last_read_progress">Marking Last-Read</string>
Expand Down Expand Up @@ -508,6 +509,7 @@
<string name="web_view_next_result_description">Next result</string>
<string name="web_view_search_box_hint">Search in page</string>
<string name="getting_forums">Getting forums</string>
<string name="imgur_api_client_id">test</string>


<!--
Expand Down

0 comments on commit bc517d0

Please sign in to comment.