Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
# Conflicts:
#	Awful.apk/src/main/AndroidManifest.xml
  • Loading branch information
baka-kaba committed Aug 9, 2019
2 parents be48cc7 + a728839 commit 46756a7
Show file tree
Hide file tree
Showing 34 changed files with 803 additions and 190 deletions.
4 changes: 2 additions & 2 deletions Awful.apk/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
buildscript {
ext.kotlin_version = '1.3.11'
ext.kotlin_version = '1.3.41'

repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'io.fabric.tools:gradle:1.+'
}
Expand Down
4 changes: 2 additions & 2 deletions Awful.apk/src/main/assets/css/amberpos.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ body {
background-color: #1A4000;
}

.postcontent {
border-color: #eacf4c;
.postseparator {
background-color: #eacf4c;
}

.postcontent .bbc-block {
Expand Down
4 changes: 4 additions & 0 deletions Awful.apk/src/main/assets/css/classic.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ body {
background-color: #5BA611;
}

.postseparator {
display: none;
}

.postcontent {
padding: 5px;
margin: 5px 5px 0;
Expand Down
8 changes: 8 additions & 0 deletions Awful.apk/src/main/assets/css/fyad.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ body {
background-color: #ECFFD9;
}

.postheader {
padding-bottom: 0px;
}

.postseparator {
display: none;
}

.postcontent {
background-color: #FFFFFF;
border: 3px solid #000000;
Expand Down
31 changes: 22 additions & 9 deletions Awful.apk/src/main/assets/css/general.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,46 @@
display: flex;
border: 0;
margin-left: 15px;
padding-top: 15px;
padding: 15px 0px 5px;
}

.postmenu {
font-weight: bolder;
font-size: 1.7em;
display: contents;
width: 24px;
height: 24px;
margin-right: 5px;
margin-top: -4px;
}

.postmenu:after {
font-family: 'icons' !important;
content: "\e902";
font-weight: normal;
-webkit-font-smoothing: antialiased;
display: inline-block;
-webkit-user-select: none;
user-select: none;
margin-top: -10px;
padding: 10px;
height: 100%;
padding: 4px;
display:block;
}

/*
this is the dividing line between the header and the post content
I've given it no vertical spacing, so the header and content can define their own padding etc
(means that e.g. post content in previews looks right because it controls its spacing)
*/
.postseparator {
display: block;
height: 2px;
padding: 0px;
margin: 0px 15px;
background-color: #eae9ea;
}

.postcontent {
word-wrap: break-word;
padding: 10px 0;
border-top: 2px solid #eae9ea;
margin: 5px 15px;
padding: 10px 0px;
margin: 0px 15px;
}

.playGif {
Expand Down
8 changes: 6 additions & 2 deletions Awful.apk/src/main/assets/css/oled.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ body {
}

.postcontent {
border-top: none;
margin: 5px 10px;
}

Expand Down Expand Up @@ -84,9 +83,14 @@ body {
vertical-align: top;
clear: left;
border: 0;
border-bottom: 1px solid #e7e7e7;
border-top: 1px solid #e7e7e7;
margin: 0;
padding: 10px;
padding-right: 0;
}

.postseparator {
height: 1px;
background-color: #e7e7e7;
margin: 0px;
}
4 changes: 2 additions & 2 deletions Awful.apk/src/main/assets/css/yospos.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ body {
padding: 5px;
}

.postcontent {
border-color: #0F0;
.postseparator {
background-color: #0F0;
}

.postcontent .bbc-block {
Expand Down
1 change: 1 addition & 0 deletions Awful.apk/src/main/assets/mustache/post.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</div>
<nav class="postmenu" username="{{username}}" userid="{{userID}}" lastreadurl="{{lastReadUrl}}" {{#editable}}editable{{/editable}} {{#mod}}isMod{{/mod}} {{#admin}}isAdmin{{/admin}} {{#plat}}isPlat{{/plat}} ></nav>
</header>
<div class="postseparator"></div>
<section class="postcontent">
{{{postcontent}}}
</section >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.private_message_activity);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar = findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
setUpActionBar();
setActionbarTitle("Message");
Expand Down
44 changes: 28 additions & 16 deletions Awful.apk/src/main/java/com/ferg/awfulapp/MessageFragment.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ferg.awfulapp;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.ContentUris;
Expand Down Expand Up @@ -34,9 +35,13 @@
import com.ferg.awfulapp.task.PMReplyRequest;
import com.ferg.awfulapp.task.PMRequest;
import com.ferg.awfulapp.task.SendPrivateMessageRequest;
import com.ferg.awfulapp.thread.AwfulHtmlPage;
import com.ferg.awfulapp.thread.AwfulMessage;
import com.ferg.awfulapp.webview.AwfulWebView;
import com.ferg.awfulapp.webview.WebViewJsInterface;
import com.ferg.awfulapp.widget.ThreadIconPicker;

import timber.log.Timber;

import static android.view.View.GONE;
import static android.view.View.VISIBLE;
Expand All @@ -57,6 +62,7 @@ public class MessageFragment extends AwfulFragment implements OnClickListener {
private EditText mRecipient;
private EditText mSubject;
private View mBackground;
private ThreadIconPicker threadIconPicker;

private AwfulPreferences mPrefs;

Expand Down Expand Up @@ -106,20 +112,23 @@ public View onCreateView(LayoutInflater aInflater, ViewGroup aContainer, Bundle

View result = aInflater.inflate(R.layout.private_message_fragment, aContainer, false);

messageWebView = (AwfulWebView) result.findViewById(R.id.messagebody);
mHideButton = (ImageButton) result.findViewById(R.id.hide_message);
messageWebView = result.findViewById(R.id.messagebody);
mHideButton = result.findViewById(R.id.hide_message);
mHideButton.setOnClickListener(this);
mRecipient = (EditText) result.findViewById(R.id.message_user);
mSubject = (EditText) result.findViewById(R.id.message_subject);
mUsername = (TextView) result.findViewById(R.id.username);
mPostdate = (TextView) result.findViewById(R.id.post_date);
mTitle = (TextView) result.findViewById(R.id.message_title);
mRecipient = result.findViewById(R.id.message_user);
mSubject = result.findViewById(R.id.message_subject);
mUsername = result.findViewById(R.id.username);
mPostdate = result.findViewById(R.id.post_date);
mTitle = result.findViewById(R.id.message_title);

messageComposer = (MessageComposer) getChildFragmentManager().findFragmentById(R.id.message_composer_fragment);
threadIconPicker = (ThreadIconPicker) getChildFragmentManager().findFragmentById(R.id.thread_icon_picker);
threadIconPicker.usePrivateMessageIcons();

mBackground = result;
updateColors(result, mPrefs);
messageWebView.setJavascriptHandler(new WebViewJsInterface());
messageWebView.setContent(AwfulHtmlPage.getContainerHtml(mPrefs, null, false));

if(pmId <=0){
messageWebView.setVisibility(GONE);
Expand Down Expand Up @@ -174,11 +183,17 @@ public void onActivityCreated(Bundle savedState){


private void syncPM() {
queueRequest(new PMRequest(getActivity(), pmId).build(this, new AwfulRequest.AwfulResultCallback<Void>() {
// TODO: rework this so we don't hold onto the activity - AwfulRequest wants to make a Toast so we can't just pass in the app context
final Activity activity = getActivity();
if (activity == null) {
Timber.i("Activity unavailable - abandoning PM load");
return;
}
queueRequest(new PMRequest(activity, pmId).build(this, new AwfulRequest.AwfulResultCallback<Void>() {
@Override
public void success(Void result) {
restartLoader(pmId, null, mPMDataCallback);
queueRequest(new PMReplyRequest(getActivity(), pmId).build(MessageFragment.this, new AwfulRequest.AwfulResultCallback<Void>() {
queueRequest(new PMReplyRequest(activity, pmId).build(MessageFragment.this, new AwfulRequest.AwfulResultCallback<Void>() {
@Override
public void success(Void result) {
restartLoader(pmId, null, mPMDataCallback);
Expand Down Expand Up @@ -262,6 +277,7 @@ public void saveReply(){
values.put(AwfulMessage.TYPE, AwfulMessage.TYPE_PM);
values.put(AwfulMessage.RECIPIENT, mRecipient.getText().toString());
values.put(AwfulMessage.REPLY_CONTENT, messageComposer.getText());
values.put(AwfulMessage.REPLY_ICON, threadIconPicker.getIcon().iconId);
if(content.update(ContentUris.withAppendedId(AwfulMessage.CONTENT_URI_REPLY,pmId), values, null, null)<1){
content.insert(AwfulMessage.CONTENT_URI_REPLY, values);
}
Expand Down Expand Up @@ -311,7 +327,7 @@ private void newMessage(){
mUsername.setText("");
mRecipient.setText("");
mPostdate.setText("");
messageWebView.setContent(null);
messageWebView.setBodyHtml(null);
mTitle.setText("New Message");
mSubject.setText("");
}
Expand Down Expand Up @@ -361,11 +377,11 @@ public void onLoadFinished(Loader<Cursor> aLoader, Cursor aData) {
if(aData != null && aData.moveToFirst()){
Log.v(TAG,"PM load finished, populating: "+aData.getCount());
if(messageWebView != null){
messageWebView.setContent(null);
messageWebView.setBodyHtml(null);
}
String title = aData.getString(aData.getColumnIndex(AwfulMessage.TITLE));
mTitle.setText(title);
messageWebView.setContent(AwfulMessage.getMessageHtml(aData.getString(aData.getColumnIndex(AwfulMessage.CONTENT)),mPrefs));
messageWebView.setBodyHtml(AwfulMessage.getMessageHtml(aData.getString(aData.getColumnIndex(AwfulMessage.CONTENT))));
mPostdate.setText(aData.getString(aData.getColumnIndex(AwfulMessage.DATE)));
String replyTitle = aData.getString(aData.getColumnIndex(AwfulMessage.REPLY_TITLE));
String replyContent = aData.getString(aData.getColumnIndex(AwfulMessage.REPLY_CONTENT));
Expand Down Expand Up @@ -424,8 +440,4 @@ protected boolean doScroll(boolean down) {
}


private String getBlankPage(){
return "<html><head></head><body style='{background-color:#"+ ColorProvider.convertToRGB(ColorProvider.BACKGROUND.getColor()) +";'></body></html>";
}

}
21 changes: 15 additions & 6 deletions Awful.apk/src/main/java/com/ferg/awfulapp/PostReplyFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.CursorLoader;
Expand Down Expand Up @@ -448,7 +449,8 @@ private void showSubmitDialog() {
submitPost();
})
.setNeutralButton(R.string.preview, (dialog, button) -> previewPost())
.setNegativeButton(R.string.cancel, (dialog, button) -> {})
.setNegativeButton(R.string.cancel, (dialog, button) -> {
})
.show();
}

Expand Down Expand Up @@ -499,28 +501,35 @@ public void failure(VolleyError error) {
*/
private void previewPost() {
ContentValues cv = prepareCV();
if (cv == null) {
Activity activity = getActivity();
FragmentManager fragmentManager = getFragmentManager();
if (cv == null || activity == null || fragmentManager == null) {
return;
}

final PreviewFragment previewFrag = new PreviewFragment();
previewFrag.setStyle(DialogFragment.STYLE_NO_TITLE, 0);
previewFrag.show(getFragmentManager(), "Post Preview");
// TODO: 12/02/2017 this result should already be on the UI thread?
previewFrag.show(fragmentManager, "Post Preview");

AwfulRequest.AwfulResultCallback<String> previewCallback = new AwfulRequest.AwfulResultCallback<String>() {
@Override
public void success(final String result) {
getAwfulActivity().runOnUiThread(() -> previewFrag.setContent(result));
previewFrag.setContent(result);
}

@Override
public void failure(VolleyError error) {
previewFrag.dismiss();
// love dialogs and callbacks very elegant
if (!previewFrag.isStateSaved() && previewFrag.getActivity() != null && !previewFrag.getActivity().isFinishing()) {
previewFrag.dismiss();
}
if (getView() != null) {
Snackbar.make(getView(), "Preview failed.", Snackbar.LENGTH_LONG)
.setAction("Retry", v -> previewPost()).show();
}
}
};

if (mReplyType == TYPE_EDIT) {
queueRequest(new PreviewEditRequest(getActivity(), cv).build(this, previewCallback));
} else {
Expand Down
Loading

0 comments on commit 46756a7

Please sign in to comment.