Skip to content

Commit

Permalink
3.7.4 (#721)
Browse files Browse the repository at this point in the history
* 3.7.2
adds userid to copied thread urls. I think its all of them
Upped targetSdkVersion so the play store stops complaining

* Adds search option to in-thread menu

* Differentiates handling of user roles

* 3.7.3 and notes

* added additional bookmark colors

* 3.7.4 and log
  • Loading branch information
Sereri authored Oct 30, 2020
1 parent d5e476b commit 1a13406
Show file tree
Hide file tree
Showing 20 changed files with 119 additions and 62 deletions.
4 changes: 2 additions & 2 deletions Awful.apk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ android {
defaultConfig {
applicationId = "com.ferg.awfulapp"
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 29
resConfigs "en"

// Stops the Gradle plugin’s automatic rasterization of vectors
Expand Down Expand Up @@ -162,5 +162,5 @@ dependencies {

testImplementation 'junit:junit:4.12'
testImplementation 'org.hamcrest:hamcrest-library:1.3'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.3'
}
4 changes: 2 additions & 2 deletions Awful.apk/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ferg.awfulapp"
android:versionCode="30701"
android:versionName="3.7.1"
android:versionCode="30704"
android:versionName="3.7.4"
android:installLocation="auto">
<supports-screens
android:smallScreens="true"
Expand Down
15 changes: 12 additions & 3 deletions Awful.apk/src/main/assets/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@

<main>
<section>
<h2>3.7.1</h2>
<h2>3.7.4</h2>
<ul>
<li>The 3 new bookmark colors are now also available in this app. How much more colors can there be, like 2?</li>
<li>You can now zoom gifs via the "display image" function. Truly we are living in the future.</li>
<li>New button in threads to find you are posts.</li>
<li>IK and super-mods are now marked as mods.</li>
<li>Searching a thread is now also available inside that thread via the menu. Makes slightly more sense than in the thread longpress-menu, <i>I GUESS</i></li>
<li>Added stars for supermods and IKs. And for coders? Whatever that is.</li>
<li>Fixed probation time parsing. Probably. Look, just don't get probated ok?</li>
<li>Fixed gfycat display. Turns out trying to fix a correct url is bad?</li>
<li>Fixed video auto-play function. Though I guess nobody used that anyway</li>
<li>Recipient is now above subject in the PM view. Hope this doesn't break your very important workflow.</li>
<li>Copying thread urls will now respect filtering for a user's post. Opening such a thread url still does not. *sets status to "it's complicated"*</li>
<li>Some "new" thread tags for QCS.</li>
<li>Fixed imgur upload again.</li>
<li>Updated some libraries which probably does <i>something</i>. Is the app faster now? Is me telling you a placebo effect? You decide!</li>
<li>Oh wow you are still reading this. Hi!</li>
</ul>
</section>

Expand Down
Binary file added Awful.apk/src/main/assets/images/ic_star_coder.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/assets/images/ic_star_ik.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Awful.apk/src/main/assets/javascript/thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ function showPostMenu(postMenu) {
postMenu.getAttribute('userid'),
postMenu.getAttribute('lastreadurl'),
postMenu.hasAttribute('editable'),
postMenu.hasAttribute('isMod') || postMenu.hasAttribute('isAdmin'),
postMenu.hasAttribute('has-role'),
postMenu.hasAttribute('isPlat')
);
}
Expand Down
12 changes: 6 additions & 6 deletions Awful.apk/src/main/assets/mustache/post.mustache
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<article class="post {{seen}} {{#isMarked}}marked{{/isMarked}} {{#isOP}}op{{/isOP}} {{#isSelf}}self{{/isSelf}}" id="post{{ postID }}">
<article class="post {{seen}} {{#isMarked}}marked{{/isMarked}} {{#isOP}}op{{/isOP}} {{#isSelf}}self{{/isSelf}}" id="post{{postID}}">
<header class="postheader">
<div class="posterinfo">
{{# avatarURL }}
{{#avatarURL}}
<img class="avatar" src="{{.}}" title="{{username}}'s avatar" />
{{/avatarURL }}
<section class="postinfo">
<aside class="postinfo-poster"><span class="postinfo-poster-name">{{username}} {{#mod}}<img src="file:///android_asset/images/ic_star_blue.png" />{{/mod}} {{#admin}}<img src="file:///android_asset/images/ic_star_red.png" />{{/admin}} </span> {{^admin }}{{^mod}}{{#plat}}<span class="icon-gren"></span>{{/plat}}{{/mod}}{{/admin}}</aside>
<aside class="postinfo-poster"><span class="postinfo-poster-name">{{username}} {{#role}}<img src="file:///android_asset/images/ic_star_{{role}}.png" />{{/role}}</span> {{^role}}{{#plat}}<span class="icon-gren"></span>{{/plat}}{{/role}}</aside>
<time class="postinfo-postdate">{{ postDate }}</time>
{{#regDate}}<time class="postinfo-regdate">Reg Date: {{regDate}}</time>{{/regDate}}
<aside class="postinfo-title">{{{ avatarText }}}</aside>
<aside class="postinfo-title">{{{avatarText}}}</aside>
</section >
</div>
<nav class="postmenu" username="{{username}}" userid="{{userID}}" lastreadurl="{{lastReadUrl}}" {{#editable}}editable{{/editable}} {{#mod}}isMod{{/mod}} {{#admin}}isAdmin{{/admin}} {{#plat}}isPlat{{/plat}} ></nav>
<nav class="postmenu" username="{{username}}" userid="{{userID}}" lastreadurl="{{lastReadUrl}}" {{#editable}}editable{{/editable}} {{#role}}has-role {{role}}{{/role}} {{#plat}}isPlat{{/plat}} ></nav>
</header>
<div class="postseparator"></div>
<section class="postcontent">
<section class="postcontent">
{{{postcontent}}}
</section >
</article>
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public void failure(VolleyError error) {
*/
private void toggleBookmarkColor(final int id, final int bookmarkStatus) {
final ContentResolver cr = this.getAwfulApplication().getContentResolver();
if(bookmarkStatus==3){
if(bookmarkStatus==6){
queueRequest(new BookmarkColorRequest(getActivity(), id).build(this, new AwfulRequest.AwfulResultCallback<Void>() {

@Override
Expand All @@ -537,7 +537,7 @@ public void failure(VolleyError error) {}
@Override
public void success(Void result) {
ContentValues cv = new ContentValues();
cv.put(AwfulThread.BOOKMARKED, ((bookmarkStatus==3)?bookmarkStatus+2:bookmarkStatus+1)%4);
cv.put(AwfulThread.BOOKMARKED, ((bookmarkStatus==6)?bookmarkStatus+2:bookmarkStatus+1)%7);
cr.update(AwfulThread.CONTENT_URI, cv, AwfulThread.ID+"=?", AwfulProvider.int2StrArray(id));
refreshInfo();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
import android.os.Handler;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.ferg.awfulapp.search.SearchFilter;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.fragment.app.FragmentManager;
import androidx.loader.app.LoaderManager;
Expand Down Expand Up @@ -547,7 +549,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
rateThread();
break;
case R.id.copy_url:
copyThreadURL(null);
copyThreadURL(null, postFilterUserId);
break;
case R.id.find:
((WebViewSearchBar) item.getActionView()).setWebView(mThreadView);
Expand All @@ -565,6 +567,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.show_self:
showUsersPosts(getPrefs().userId, getPrefs().username);
break;
case R.id.search_this_thread:
SearchFilter threadFilter = new SearchFilter(SearchFilter.FilterType.ThreadId, Integer.toString(currentThreadId));
navigate(new NavigationEvent.SearchForums(threadFilter));
return true;
default:
return super.onOptionsItemSelected(item);
}
Expand All @@ -577,14 +583,18 @@ public boolean onOptionsItemSelected(MenuItem item) {
* Get a URL that links to a particular thread.
*
* @param postId An optional post ID, appended as the URL's fragment
* @param userId An optional user ID, appended as a query parameter
* @return the full URL
*/
@NonNull
private String generateThreadUrl(@Nullable Integer postId) {
private String generateThreadUrl(@Nullable Integer postId, @Nullable Integer userId) {
Uri.Builder builder = Uri.parse(Constants.FUNCTION_THREAD).buildUpon()
.appendQueryParameter(Constants.PARAM_THREAD_ID, String.valueOf(getThreadId()))
.appendQueryParameter(Constants.PARAM_PAGE, String.valueOf(getPageNumber()))
.appendQueryParameter(Constants.PARAM_PER_PAGE, String.valueOf(getPrefs().postPerPage));
if (userId != null) {
builder.appendQueryParameter(Constants.PARAM_USER_ID, String.valueOf(userId));
}
if (postId != null) {
builder.fragment("post" + postId);
}
Expand Down Expand Up @@ -620,7 +630,7 @@ public Intent createShareIntent(@Nullable String url) {
if (url == null) {
// we're sharing the current thread - we can add the title in here
intent.putExtra(Intent.EXTRA_SUBJECT, mTitle);
url = generateThreadUrl(null);
url = generateThreadUrl(null, postFilterUserId);
}
return intent.putExtra(Intent.EXTRA_TEXT, url);
}
Expand All @@ -630,10 +640,11 @@ public Intent createShareIntent(@Nullable String url) {
/**
* Copy a thread's URL to the clipboard
* @param postId An optional post ID, used as the url's fragment
* @param userId An optional user ID, appended to the url as a parameter
*/
public void copyThreadURL(@Nullable Integer postId) {
public void copyThreadURL(@Nullable Integer postId, @Nullable Integer userId) {
String clipLabel = getString(R.string.copy_url) + getPageNumber();
String clipText = generateThreadUrl(postId);
String clipText = generateThreadUrl(postId, userId);
safeCopyToClipboard(clipLabel, clipText, R.string.copy_url_success);
}

Expand Down Expand Up @@ -1091,7 +1102,7 @@ private class ClickInterface extends WebViewJsInterface {
@JavascriptInterface
public void onMoreClick(final String aPostId, final String aUsername, final String aUserId, final String lastReadUrl, final boolean editable, final boolean isAdminOrMod, final boolean isPlat) {
PostContextMenu postActions = PostContextMenu.newInstance(getThreadId(), Integer.parseInt(aPostId),
Integer.parseInt(lastReadUrl), editable, aUsername, Integer.parseInt(aUserId), isPlat, isAdminOrMod);
Integer.parseInt(lastReadUrl), editable, aUsername, Integer.parseInt(aUserId), isPlat, isAdminOrMod, postFilterUserId);
postActions.setTargetFragment(ThreadDisplayFragment.this, -1);
postActions.show(mSelf.getFragmentManager(), "Post Actions");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class PostContextMenu extends BasePopupMenu<PostContextMenu.PostMenuActio
private static final String ARG_POST_ID = "postId";
private static final String ARG_LAST_READ_CODE = "lastReadCode";
private static final String ARG_POSTER_USERNAME = "posterUsername";
private static final String ARG_POST_FILTER_USER_ID = "postFilterUserId";

private int posterUserId;
private boolean editable;
Expand All @@ -52,6 +53,7 @@ public class PostContextMenu extends BasePopupMenu<PostContextMenu.PostMenuActio
private int threadId;
private int postId;
private int lastReadCode;
private int postFilterUserId;
private String posterUsername = null;


Expand All @@ -75,7 +77,8 @@ public static PostContextMenu newInstance(int threadId,
@NonNull String posterUsername,
int posterUserId,
boolean posterHasPlat,
boolean posterIsAdminOrMod) {
boolean posterIsAdminOrMod,
Integer postFilterUserId) {
Bundle args = new Bundle();
PostContextMenu fragment = new PostContextMenu();

Expand All @@ -87,6 +90,9 @@ public static PostContextMenu newInstance(int threadId,
args.putInt(ARG_POST_ID, postId);
args.putInt(ARG_LAST_READ_CODE, lastReadCode);
args.putString(ARG_POSTER_USERNAME, posterUsername);
if (postFilterUserId != null) {
args.putInt(ARG_POST_FILTER_USER_ID, postFilterUserId);
}
fragment.setArguments(args);
return fragment;
}
Expand All @@ -102,6 +108,7 @@ void init(@NonNull Bundle args) {
postId = args.getInt(ARG_POST_ID);
lastReadCode = args.getInt(ARG_LAST_READ_CODE);
posterUsername = args.getString(ARG_POSTER_USERNAME);
postFilterUserId = args.getInt(ARG_POST_FILTER_USER_ID);
}


Expand Down Expand Up @@ -131,7 +138,7 @@ List<PostMenuAction> generateMenuItems() {
}
awfulActions.add(COPY_URL);
awfulActions.add(RAP_SHEET);
if (!ownPost) {
if (!ownPost && !posterIsAdminOrMod) {
awfulActions.add(IGNORE_USER);
}
return awfulActions;
Expand Down Expand Up @@ -162,7 +169,7 @@ void onActionClicked(@NonNull PostMenuAction action) {
parent.markLastRead(lastReadCode);
break;
case COPY_URL:
parent.copyThreadURL(postId);
parent.copyThreadURL(postId, postFilterUserId);
break;
case YOUR_POSTS:
case USER_POSTS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,8 @@ private static String[] arrayOfKeys(@NonNull Map<String, ?> map) {
sPostProjectionMap.put(AwfulPost.PREVIOUSLY_READ, AwfulPost.PREVIOUSLY_READ);
sPostProjectionMap.put(AwfulPost.EDITABLE, AwfulPost.EDITABLE);
sPostProjectionMap.put(AwfulPost.IS_OP, AwfulPost.IS_OP);
sPostProjectionMap.put(AwfulPost.IS_ADMIN, AwfulPost.IS_ADMIN);
sPostProjectionMap.put(AwfulPost.IS_MOD, AwfulPost.IS_MOD);
sPostProjectionMap.put(AwfulPost.IS_PLAT, AwfulPost.IS_PLAT);
sPostProjectionMap.put(AwfulPost.ROLE, AwfulPost.ROLE);
sPostProjectionMap.put(AwfulPost.AVATAR, AwfulPost.AVATAR);
sPostProjectionMap.put(AwfulPost.AVATAR_TEXT, AwfulPost.AVATAR_TEXT);
sPostProjectionMap.put(AwfulPost.CONTENT, AwfulPost.CONTENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class DatabaseHelper extends SQLiteOpenHelper {

private static final String DATABASE_NAME = "awful.db";
private static final int DATABASE_VERSION = 33;
private static final int DATABASE_VERSION = 34;

static final String TABLE_FORUM = "forum";
static final String TABLE_THREADS = "threads";
Expand Down Expand Up @@ -106,9 +106,8 @@ private void createPostTable(SQLiteDatabase aDb) {
AwfulPost.PREVIOUSLY_READ + " INTEGER," +
AwfulPost.EDITABLE + " INTEGER," +
AwfulPost.IS_OP + " INTEGER," +
AwfulPost.IS_ADMIN + " INTEGER," +
AwfulPost.IS_MOD + " INTEGER," +
AwfulPost.IS_PLAT + " INTEGER," +
AwfulPost.ROLE + " VARCHAR," +
AwfulPost.AVATAR + " VARCHAR," +
AwfulPost.AVATAR_TEXT + " VARCHAR," +
AwfulPost.CONTENT + " VARCHAR," +
Expand Down Expand Up @@ -179,10 +178,12 @@ public void onUpgrade(SQLiteDatabase aDb, int aOldVersion, int aNewVersion) {
case 31:
dropTables(aDb, TABLE_THREADS);
createThreadTable(aDb);
break;//make sure to keep this break statement on the last case of this switch
case 32:
dropTables(aDb, TABLE_DRAFTS);
createDraftTable(aDb);
case 33:
dropTables(aDb, TABLE_POSTS);
createPostTable(aDb);
break;//make sure to keep this break statement on the last case of this switch
default:
wipeRecreateTables(aDb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -62,6 +63,30 @@ public abstract class AwfulHtmlPage {
"thread.js"
};

/**
* All user roles we have icons for
*/
static final String[] ROLES = {
"admin",
"supermod",
"mod",
"coder",
"ik"
};

/**
* parses the user role and returns it if it is a known role. Null otherwise
* @param role the user role
* @return the role as a string or null
*/
private static String parseRole(String role) {
if (role.length() > 0 && Arrays.asList(ROLES).contains(role)) {
return role;
}

return null;
}

/**
* Get the main HTML for the containing page.
* <p>
Expand Down Expand Up @@ -191,8 +216,7 @@ private static String getPostsHtml(List<AwfulPost> aPosts, AwfulPreferences aPre
postData.put("userID", post.getUserId());
postData.put("postDate", post.getDate());
postData.put("regDate", post.getRegDate());
postData.put("mod", post.isMod() ? "mod" : null);
postData.put("admin", post.isAdmin() ? "admin" : null);
postData.put("role", parseRole(post.getRole()));
postData.put("plat", post.isPlat() ? "plat" : null);
postData.put("avatarText", "" + post.getAvatarText());
postData.put("lastReadUrl", post.getLastReadUrl());
Expand Down
Loading

0 comments on commit 1a13406

Please sign in to comment.