From 7433d9b2de7595e0a680c89731dffc2f184cbb40 Mon Sep 17 00:00:00 2001
From: Apostolof
Date: Sat, 7 Jul 2018 12:04:23 +0300
Subject: [PATCH 001/180] Add settings, Minor drawer bug fix
---
app/build.gradle | 2 +
app/src/main/AndroidManifest.xml | 9 ++
.../mthmmy/activities/LoginActivity.java | 3 +
.../bookmarks/BookmarkActivity.java | 39 +++++----
.../mthmmy/activities/main/MainActivity.java | 3 +
.../activities/settings/SettingsActivity.java | 44 ++++++++++
.../activities/settings/SettingsFragment.java | 82 +++++++++++++++++++
.../activities/topic/TopicActivity.java | 39 ++++++---
.../gr/thmmy/mthmmy/base/BaseActivity.java | 71 +++++++++++-----
.../mthmmy/services/NotificationService.java | 62 +++++++++-----
app/src/main/res/layout/activity_bookmark.xml | 4 +-
app/src/main/res/layout/activity_settings.xml | 33 ++++++++
app/src/main/res/values-v21/styles.xml | 1 +
app/src/main/res/values/strings.xml | 21 ++++-
app/src/main/res/values/styles.xml | 1 +
app/src/main/res/xml/app_preferences.xml | 35 ++++++++
16 files changed, 372 insertions(+), 77 deletions(-)
create mode 100644 app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsActivity.java
create mode 100644 app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java
create mode 100644 app/src/main/res/layout/activity_settings.xml
create mode 100644 app/src/main/res/xml/app_preferences.xml
diff --git a/app/build.gradle b/app/build.gradle
index aafe1fe9..a4de63b5 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -31,6 +31,8 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
+ implementation 'com.android.support:preference-v7:27.1.1'
+ implementation 'com.android.support:preference-v14:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 7417185a..b9789d97 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -105,6 +105,15 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.main.MainActivity" />
+
+
+
0 && postsList.get(postsList.size()-1)==null)
- {
+ } else if (postsList != null && postsList.size() > 0 && postsList.get(postsList.size() - 1) == null) {
postsList.remove(postsList.size() - 1);
topicAdapter.notifyItemRemoved(postsList.size());
topicAdapter.setBackButtonHidden();
@@ -356,6 +365,11 @@ public class TopicActivity extends BaseActivity {
super.onResume();
refreshTopicBookmark();
drawer.setSelection(-1);
+
+ if (sessionManager.isLoggedIn()) {
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
+ includeAppSignaturePreference = sharedPrefs.getBoolean(SettingsActivity.APP_SIGNATURE_ENABLE_KEY, true);
+ }
}
@Override
@@ -548,7 +562,8 @@ public class TopicActivity extends BaseActivity {
}
}
-//------------------------------------BOTTOM NAV BAR METHODS END------------------------------------
+
+ //------------------------------------BOTTOM NAV BAR METHODS END------------------------------------
private enum ResultCode {
SUCCESS, NETWORK_ERROR, PARSING_ERROR, OTHER_ERROR, SAME_PAGE, UNAUTHORIZED
}
@@ -632,7 +647,7 @@ public class TopicActivity extends BaseActivity {
Timber.i(e, "IO Exception");
return ResultCode.NETWORK_ERROR;
} catch (ParseException e) {
- if(isUnauthorized(document))
+ if (isUnauthorized(document))
return ResultCode.UNAUTHORIZED;
Timber.e(e, "Parsing Error");
return ResultCode.PARSING_ERROR;
@@ -673,9 +688,9 @@ public class TopicActivity extends BaseActivity {
pageIndicator.setText(String.valueOf(thisPage) + "/" + String.valueOf(numberOfPages));
pageRequestValue = thisPage;
- if(thisPage==numberOfPages){
+ if (thisPage == numberOfPages) {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- if(notificationManager!=null)
+ if (notificationManager != null)
notificationManager.cancel(NEW_POST_TAG, loadedPageTopicId);
}
@@ -702,7 +717,7 @@ public class TopicActivity extends BaseActivity {
}
}
- private void stopLoading(){
+ private void stopLoading() {
progressBar.setVisibility(ProgressBar.INVISIBLE);
if (replyPageUrl == null) {
replyFAB.hide();
@@ -718,7 +733,7 @@ public class TopicActivity extends BaseActivity {
* @param topic {@link Document} object containing this topic's source code
* @see org.jsoup.Jsoup Jsoup
*/
- private ArrayList parse(Document topic) throws ParseException{
+ private ArrayList parse(Document topic) throws ParseException {
try {
ParseHelpers.Language language = ParseHelpers.Language.getLanguage(topic);
@@ -898,7 +913,9 @@ public class TopicActivity extends BaseActivity {
@Override
protected Boolean doInBackground(String... args) {
- final String sentFrommTHMMY = "\n[right][size=7pt][i]sent from [url=https://play.google.com/store/apps/details?id=gr.thmmy.mthmmy]mTHMMY[/url] [/i][/size][/right]";
+ final String sentFrommTHMMY = includeAppSignaturePreference
+ ? "\n[right][size=7pt][i]sent from [url=https://play.google.com/store/apps/details?id=gr.thmmy.mthmmy]mTHMMY [/url][/i][/size][/right]"
+ : "";
RequestBody postBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("message", args[1] + sentFrommTHMMY)
diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java
index 9150065d..64096b56 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java
@@ -47,6 +47,7 @@ import gr.thmmy.mthmmy.activities.LoginActivity;
import gr.thmmy.mthmmy.activities.downloads.DownloadsActivity;
import gr.thmmy.mthmmy.activities.main.MainActivity;
import gr.thmmy.mthmmy.activities.profile.ProfileActivity;
+import gr.thmmy.mthmmy.activities.settings.SettingsActivity;
import gr.thmmy.mthmmy.model.Bookmark;
import gr.thmmy.mthmmy.model.ThmmyFile;
import gr.thmmy.mthmmy.services.DownloadHelper;
@@ -147,10 +148,11 @@ public abstract class BaseActivity extends AppCompatActivity {
protected static final int BOOKMARKS_ID = 2;
protected static final int LOG_ID = 3;
protected static final int ABOUT_ID = 4;
+ protected static final int SETTINGS_ID = 5;
private AccountHeader accountHeader;
private ProfileDrawerItem profileDrawerItem;
- private PrimaryDrawerItem downloadsItem, loginLogoutItem;
+ private PrimaryDrawerItem downloadsItem, settingsItem, loginLogoutItem;
private IconicsDrawable loginIcon, logoutIcon;
/**
@@ -162,9 +164,8 @@ public abstract class BaseActivity extends AppCompatActivity {
final int selectedSecondaryColor = ContextCompat.getColor(this, R.color.accent);
PrimaryDrawerItem homeItem, bookmarksItem, aboutItem;
- IconicsDrawable homeIcon, homeIconSelected, downloadsIcon, downloadsIconSelected,
- bookmarksIcon, bookmarksIconSelected, aboutIcon,
- aboutIconSelected;
+ IconicsDrawable homeIcon, homeIconSelected, downloadsIcon, downloadsIconSelected, settingsIcon,
+ settingsIconSelected, bookmarksIcon, bookmarksIconSelected, aboutIcon, aboutIconSelected;
//Drawer Icons
homeIcon = new IconicsDrawable(this)
@@ -188,6 +189,14 @@ public abstract class BaseActivity extends AppCompatActivity {
.color(primaryColor);
downloadsIconSelected = new IconicsDrawable(this)
+ .icon(GoogleMaterial.Icon.gmd_settings)
+ .color(selectedSecondaryColor);
+
+ settingsIcon = new IconicsDrawable(this)
+ .icon(GoogleMaterial.Icon.gmd_settings)
+ .color(primaryColor);
+
+ settingsIconSelected = new IconicsDrawable(this)
.icon(GoogleMaterial.Icon.gmd_file_download)
.color(selectedSecondaryColor);
@@ -243,6 +252,15 @@ public abstract class BaseActivity extends AppCompatActivity {
.withIcon(loginIcon)
.withSelectable(false);
+ settingsItem = new PrimaryDrawerItem()
+ .withTextColor(primaryColor)
+ .withSelectedColor(selectedPrimaryColor)
+ .withSelectedTextColor(selectedSecondaryColor)
+ .withIdentifier(SETTINGS_ID)
+ .withName(R.string.settings)
+ .withIcon(settingsIcon)
+ .withSelectedIcon(settingsIconSelected);
+
bookmarksItem = new PrimaryDrawerItem()
.withTextColor(primaryColor)
.withSelectedColor(selectedPrimaryColor)
@@ -337,7 +355,11 @@ public abstract class BaseActivity extends AppCompatActivity {
Intent i = new Intent(BaseActivity.this, AboutActivity.class);
startActivity(i);
}
-
+ } else if (drawerItem.equals(SETTINGS_ID)) {
+ if (!(BaseActivity.this instanceof SettingsActivity)) {
+ Intent intent = new Intent(BaseActivity.this, SettingsActivity.class);
+ startActivity(intent);
+ }
}
drawer.closeDrawer();
@@ -346,7 +368,7 @@ public abstract class BaseActivity extends AppCompatActivity {
});
if (sessionManager.isLoggedIn())
- drawerBuilder.addDrawerItems(homeItem, bookmarksItem, downloadsItem, loginLogoutItem, aboutItem);
+ drawerBuilder.addDrawerItems(homeItem, bookmarksItem, downloadsItem, settingsItem, loginLogoutItem, aboutItem);
else
drawerBuilder.addDrawerItems(homeItem, bookmarksItem, loginLogoutItem, aboutItem);
@@ -369,13 +391,20 @@ public abstract class BaseActivity extends AppCompatActivity {
if (!sessionManager.isLoggedIn()) //When logged out or if user is guest
{
drawer.removeItem(DOWNLOADS_ID);
+ drawer.removeItem(SETTINGS_ID);
loginLogoutItem.withName(R.string.login).withIcon(loginIcon); //Swap logout with login
profileDrawerItem.withName(sessionManager.getUsername());
setDefaultAvatar();
} else {
+ if (!drawer.getDrawerItems().contains(downloadsItem)){
+ drawer.addItemAtPosition(settingsItem, 2);
+ }
+ if (!drawer.getDrawerItems().contains(settingsItem)){
+ drawer.addItemAtPosition(settingsItem, 3);
+ }
loginLogoutItem.withName(R.string.logout).withIcon(logoutIcon); //Swap login with logout
profileDrawerItem.withName(sessionManager.getUsername());
- if(sessionManager.hasAvatar())
+ if (sessionManager.hasAvatar())
profileDrawerItem.withIcon(sessionManager.getAvatarLink());
else
setDefaultAvatar();
@@ -422,9 +451,9 @@ public abstract class BaseActivity extends AppCompatActivity {
mainActivity.updateTabs();
progressDialog.dismiss();
//if (BaseActivity.this instanceof TopicActivity){
- Intent intent = new Intent(BaseActivity.this, MainActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
+ Intent intent = new Intent(BaseActivity.this, MainActivity.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ startActivity(intent);
//}
}
}
@@ -560,12 +589,12 @@ public abstract class BaseActivity extends AppCompatActivity {
else if (bookmark.matchExists(topicsBookmarked)) toggleTopicToBookmarks(bookmark);
}
- protected boolean toggleNotification(Bookmark bookmark){
- if (bookmark.matchExists(topicsBookmarked)){
+ protected boolean toggleNotification(Bookmark bookmark) {
+ if (bookmark.matchExists(topicsBookmarked)) {
topicsBookmarked.get(bookmark.findIndex(topicsBookmarked)).toggleNotificationsEnabled();
updateTopicBookmarks();
- if (topicsBookmarked.get(bookmark.findIndex(topicsBookmarked)).isNotificationsEnabled()){
+ if (topicsBookmarked.get(bookmark.findIndex(topicsBookmarked)).isNotificationsEnabled()) {
FirebaseMessaging.getInstance().subscribeToTopic(bookmark.getId());
} else {
FirebaseMessaging.getInstance().unsubscribeFromTopic(bookmark.getId());
@@ -634,9 +663,9 @@ public abstract class BaseActivity extends AppCompatActivity {
prepareDownload(tempThmmyFile);
}
- private void prepareDownload(ThmmyFile thmmyFile){
+ private void prepareDownload(ThmmyFile thmmyFile) {
String fileName = thmmyFile.getFilename();
- if(FileUtils.fileNameExists(fileName))
+ if (FileUtils.fileNameExists(fileName))
openDownloadPrompt(thmmyFile);
else
DownloadHelper.enqueueDownload(thmmyFile);
@@ -647,7 +676,7 @@ public abstract class BaseActivity extends AppCompatActivity {
final BottomSheetDialog dialog = new BottomSheetDialog(this);
dialog.setContentView(view);
TextView downloadPromptTextView = view.findViewById(R.id.downloadPromptTextView);
- downloadPromptTextView.setText(getString(R.string.downloadPromptText,thmmyFile.getFilename()));
+ downloadPromptTextView.setText(getString(R.string.downloadPromptText, thmmyFile.getFilename()));
Button cancelButton = view.findViewById(R.id.cancel);
Button openButton = view.findViewById(R.id.open);
Button downloadButton = view.findViewById(R.id.download);
@@ -661,15 +690,15 @@ public abstract class BaseActivity extends AppCompatActivity {
@Override
public void onClick(View v) {
dialog.dismiss();
- try{
+ try {
String fileName = thmmyFile.getFilename();
Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_GRANT_READ_URI_PERMISSION);
- Uri fileUri = FileProvider.getUriForFile(getApplicationContext(), getPackageName() + ".provider", new File(SAVE_DIR, fileName));
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION);
+ Uri fileUri = FileProvider.getUriForFile(getApplicationContext(), getPackageName() + ".provider", new File(SAVE_DIR, fileName));
intent.setDataAndType(fileUri, getMimeType(fileName));
BaseActivity.this.startActivity(intent);
- }catch (Exception e){
- Timber.e(e,"Couldn't open downloaded file...");
+ } catch (Exception e) {
+ Timber.e(e, "Couldn't open downloaded file...");
Toast.makeText(getBaseContext(), "Couldn't open file...", Toast.LENGTH_SHORT).show();
}
diff --git a/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java b/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java
index 2ebe4a37..f6db39ad 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java
@@ -6,11 +6,14 @@ import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
+import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.service.notification.StatusBarNotification;
import android.support.annotation.RequiresApi;
import android.support.v4.app.NotificationCompat;
+import android.support.v7.preference.PreferenceManager;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
@@ -25,6 +28,9 @@ import gr.thmmy.mthmmy.model.PostNotification;
import timber.log.Timber;
import static android.support.v4.app.NotificationCompat.PRIORITY_MAX;
+import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.NOTIFICATION_VIBRATION_KEY;
+import static gr.thmmy.mthmmy.activities.settings.SettingsFragment.SELECTED_RINGTONE;
+import static gr.thmmy.mthmmy.activities.settings.SettingsFragment.SETTINGS_SHARED_PREFS;
import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE;
import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL;
@@ -40,15 +46,13 @@ public class NotificationService extends FirebaseMessagingService {
try {
int userId = BaseApplication.getInstance().getSessionManager().getUserId();
//Don't notify me if the sender is me!
- if(Integer.parseInt(json.getString("posterId"))!= userId)
- {
+ if (Integer.parseInt(json.getString("posterId")) != userId) {
int topicId = Integer.parseInt(json.getString("topicId"));
int postId = Integer.parseInt(json.getString("postId"));
String topicTitle = json.getString("topicTitle");
String poster = json.getString("poster");
sendNotification(new PostNotification(postId, topicId, topicTitle, poster));
- }
- else
+ } else
Timber.v("Notification suppressed (own userID).");
} catch (JSONException e) {
Timber.e(e, "JSON Exception");
@@ -70,6 +74,20 @@ public class NotificationService extends FirebaseMessagingService {
*/
private void sendNotification(PostNotification postNotification) {
Timber.i("Creating a notification...");
+
+ SharedPreferences settingsFile = getSharedPreferences(SETTINGS_SHARED_PREFS, Context.MODE_PRIVATE);
+ Uri notificationSoundUri = Uri.parse(settingsFile.getString(SELECTED_RINGTONE, null));
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
+ boolean notificationsVibrateEnabled = sharedPrefs.getBoolean(NOTIFICATION_VIBRATION_KEY, true);
+
+ int notificationDefaultValues = Notification.DEFAULT_LIGHTS;
+ if (notificationsVibrateEnabled) {
+ notificationDefaultValues |= Notification.DEFAULT_VIBRATE;
+ }
+ if (notificationSoundUri == null) {
+ notificationDefaultValues |= Notification.DEFAULT_SOUND;
+ }
+
String topicUrl = "https://www.thmmy.gr/smf/index.php?topic=" + postNotification.getTopicId() + "." + postNotification.getPostId();
Intent intent = new Intent(this, TopicActivity.class);
Bundle extras = new Bundle();
@@ -84,10 +102,9 @@ public class NotificationService extends FirebaseMessagingService {
String contentText = "New post by " + postNotification.getPoster();
int newPostsCount = 1;
- if (buildVersion >= Build.VERSION_CODES.M){
+ if (buildVersion >= Build.VERSION_CODES.M) {
Notification existingNotification = getActiveNotification(topicId);
- if(existingNotification!=null)
- {
+ if (existingNotification != null) {
newPostsCount = existingNotification.extras.getInt(NEW_POSTS_COUNT) + 1;
contentText = newPostsCount + " new posts";
}
@@ -103,21 +120,27 @@ public class NotificationService extends FirebaseMessagingService {
.setContentText(contentText)
.setAutoCancel(true)
.setContentIntent(pendingIntent)
- .setDefaults(Notification.DEFAULT_ALL)
+ .setDefaults(notificationDefaultValues)
.setGroup(GROUP_KEY)
.addExtras(notificationExtras);
+ //Checks for values other than defaults and applies them
+ if (notificationSoundUri != null) {
+ notificationBuilder.setSound(notificationSoundUri);
+ }
+ if (!notificationsVibrateEnabled) {
+ notificationBuilder.setVibrate(new long[]{0L});
+ }
if (buildVersion < Build.VERSION_CODES.O)
notificationBuilder.setPriority(PRIORITY_MAX);
boolean createSummaryNotification = false;
- if(buildVersion >= Build.VERSION_CODES.M)
+ if (buildVersion >= Build.VERSION_CODES.M)
createSummaryNotification = otherNotificationsExist(topicId);
NotificationCompat.Builder summaryNotificationBuilder = null;
- if(createSummaryNotification)
- {
+ if (createSummaryNotification) {
summaryNotificationBuilder =
new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification)
@@ -130,8 +153,6 @@ public class NotificationService extends FirebaseMessagingService {
}
-
-
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// Since Android Oreo notification channel is needed.
@@ -140,17 +161,16 @@ public class NotificationService extends FirebaseMessagingService {
notificationManager.notify(NEW_POST_TAG, topicId, notificationBuilder.build());
- if(createSummaryNotification)
- notificationManager.notify(SUMMARY_TAG,0, summaryNotificationBuilder.build());
+ if (createSummaryNotification)
+ notificationManager.notify(SUMMARY_TAG, 0, summaryNotificationBuilder.build());
}
@RequiresApi(api = Build.VERSION_CODES.M)
private Notification getActiveNotification(int notificationId) {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- if(notificationManager!=null)
- {
+ if (notificationManager != null) {
StatusBarNotification[] barNotifications = notificationManager.getActiveNotifications();
- for(StatusBarNotification notification: barNotifications) {
+ for (StatusBarNotification notification : barNotifications) {
if (notification.getId() == notificationId)
return notification.getNotification();
}
@@ -160,13 +180,13 @@ public class NotificationService extends FirebaseMessagingService {
}
@RequiresApi(api = Build.VERSION_CODES.M)
- private boolean otherNotificationsExist(int notificationId){
+ private boolean otherNotificationsExist(int notificationId) {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- if(notificationManager!=null) {
+ if (notificationManager != null) {
StatusBarNotification[] barNotifications = notificationManager.getActiveNotifications();
for (StatusBarNotification notification : barNotifications) {
String tag = notification.getTag();
- if (tag!=null && tag.equals(NEW_POST_TAG) && notification.getId() != notificationId)
+ if (tag != null && tag.equals(NEW_POST_TAG) && notification.getId() != notificationId)
return true;
}
}
diff --git a/app/src/main/res/layout/activity_bookmark.xml b/app/src/main/res/layout/activity_bookmark.xml
index 939fb01a..d35191dd 100644
--- a/app/src/main/res/layout/activity_bookmark.xml
+++ b/app/src/main/res/layout/activity_bookmark.xml
@@ -54,6 +54,4 @@
app:layout_anchorGravity="bottom|center"
app:mpb_indeterminateTint="@color/accent"
app:mpb_progressStyle="horizontal"/>
-
-
-
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
new file mode 100644
index 00000000..a6a0513b
--- /dev/null
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml
index 72e2ac82..628b2a36 100644
--- a/app/src/main/res/values-v21/styles.xml
+++ b/app/src/main/res/values-v21/styles.xml
@@ -24,5 +24,6 @@
- true
- true
- @android:color/transparent
+ - @style/PreferenceThemeOverlay.v14.Material
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index df0d3cd4..2517070c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -6,6 +6,7 @@
Authenticating…
Logout
Downloads
+ Settings
About
Home
Bookmarks
@@ -74,6 +75,7 @@
Remove
You have no bookmarked boards
You have no bookmarked topics
+ Toggle Notification
@@ -91,13 +93,26 @@
-
- Toggle Notification
-
File \"%1$s\" already exists. Download again?"
Download Symbol
Cancel
Open
Download
+
+
+ Settings
+ Settings
+
+ Notifications
+
+ Vibration
+ Summary
+ Notifications sound
+ Select your preferred notification sound
+
+ Posting
+ App signature
+ If enabled, a \"Posted from mThmmy\" message will be inserted at the end of your posts
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 3f32d79c..543cc9b2 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -23,6 +23,7 @@
+
+
-
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 4ffe55a1..8e9f47f2 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -25,6 +25,7 @@
- false
- true
- @style/PreferenceThemeOverlay.v14.Material
+ - @color/accent
+
+
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 8e9f47f2..bab8b574 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -24,6 +24,9 @@
+
+
From f54974ed7ff99330669d865c7da42154ef76106b Mon Sep 17 00:00:00 2001
From: Thodoris1999
Date: Sun, 2 Sep 2018 12:18:08 +0300
Subject: [PATCH 096/180] remove floating label on EditorView
---
.../java/gr/thmmy/mthmmy/editorview/EditorView.java | 2 +-
app/src/main/res/layout/editor_view.xml | 11 +++++++----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java b/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java
index fdec350c..a4ccc119 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java
@@ -59,7 +59,7 @@ public class EditorView extends LinearLayout {
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.EditorView, 0, 0);
try {
- edittextWrapper.setHint(a.getString(R.styleable.EditorView_hint));
+ editText.setHint(a.getString(R.styleable.EditorView_hint));
} finally {
a.recycle();
}
diff --git a/app/src/main/res/layout/editor_view.xml b/app/src/main/res/layout/editor_view.xml
index d249f889..4f691fbf 100644
--- a/app/src/main/res/layout/editor_view.xml
+++ b/app/src/main/res/layout/editor_view.xml
@@ -134,14 +134,17 @@
+ android:orientation="horizontal"
+ android:layout_marginTop="4dp">
+ android:layout_gravity="center"
+ android:orientation="vertical"
+ app:hintEnabled="false">
@@ -163,7 +166,7 @@
android:id="@+id/submit_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="bottom"
+ android:layout_gravity="center"
android:contentDescription="@string/submit"
android:padding="4dp"
app:srcCompat="@drawable/ic_send_accent_24dp"
From c09931f4b34264c6fbac7a06a696a46546769024 Mon Sep 17 00:00:00 2001
From: Thodoris1999
Date: Sun, 2 Sep 2018 12:32:32 +0300
Subject: [PATCH 097/180] change text color icon underline color
---
app/src/main/res/drawable/ic_format_color_text.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/src/main/res/drawable/ic_format_color_text.xml b/app/src/main/res/drawable/ic_format_color_text.xml
index 350065ff..9e8b6a46 100644
--- a/app/src/main/res/drawable/ic_format_color_text.xml
+++ b/app/src/main/res/drawable/ic_format_color_text.xml
@@ -1,6 +1,6 @@
-
+
From 28a58530730fdb0bd17dff9beb356cbe45774df7 Mon Sep 17 00:00:00 2001
From: Thodoris1999
Date: Sun, 2 Sep 2018 13:20:41 +0300
Subject: [PATCH 098/180] fixes
---
app/src/main/AndroidManifest.xml | 3 +++
app/src/main/res/layout/editor_view.xml | 5 ++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 6432f0c6..cd4582c4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -17,6 +17,9 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
+
@@ -157,7 +156,7 @@
android:id="@+id/emoji_keyboard_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="center"
+ android:layout_gravity="bottom"
android:padding="4dp"
app:srcCompat="@drawable/ic_tag_faces_24dp"
android:background="?android:selectableItemBackground"/>
@@ -166,7 +165,7 @@
android:id="@+id/submit_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="center"
+ android:layout_gravity="bottom"
android:contentDescription="@string/submit"
android:padding="4dp"
app:srcCompat="@drawable/ic_send_accent_24dp"
From 5489102ef4751820a44960781847dab4056c772e Mon Sep 17 00:00:00 2001
From: Ezerous
Date: Sun, 2 Sep 2018 14:52:57 +0300
Subject: [PATCH 099/180] Added drawer intro, tiny changes
---
CONTRIBUTING.md | 12 ++++++------
.../thmmy/mthmmy/activities/main/MainActivity.java | 9 +++++++--
.../thmmy/mthmmy/activities/topic/TopicActivity.java | 2 +-
.../thmmy/mthmmy/activities/topic/TopicAdapter.java | 4 ++--
.../mthmmy/activities/topic/tasks/ReplyTask.java | 2 +-
.../java/gr/thmmy/mthmmy/base/BaseApplication.java | 2 +-
.../thmmy/mthmmy/editorview/AutoFitGridLayout.java | 1 +
7 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 556dfb11..0badb7f8 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -7,7 +7,7 @@ to contribute to mTHMMY in a way that is efficient for everyone.
**Important!** Instead of creating publicly viewable issues for suspected security
vulnerabilities, please report them in private to
-`thmmynolife@gmail.com`.
+[thmmynolife@gmail.com](mailto:thmmynolife@gmail.com).
## I want to contribute!
@@ -18,7 +18,7 @@ There are many ways of contributing to mTHMMY:
- Submitting bugs and ideas to our [issue tracker][github-issues]
- Forking mTHMMY and submitting [pull requests](#pull-requests)
- Joining our core team
-- Contacting us by email at `thmmynolife@gmail.com`
+- Contacting us by email at [thmmynolife@gmail.com](mailto:thmmynolife@gmail.com)
## Issue tracker
@@ -27,17 +27,17 @@ Before creating a new issue make sure to **search the tracker** for similar ones
## Compiling
-Due to the app's integration with Firebase, a `google-services.json` is required inside the `app` directory. To get one, either [set up your own Firebase project][firebase-console] (with or without a self hosted [backend][sisyphus]), or ask us to provide you the one we use for development.
+Due to the app's integration with Firebase, a *google-services.json* file is required inside the *app* directory. To get one, either [set up your own Firebase project][firebase-console] (with or without a self hosted [backend][sisyphus]), or ask us to provide you the one we use for development.
## Pull requests
Pull requests with fixes and improvements to mTHMMY are most welcome. Any developer that wants to work independently from the core team can simply
-follow the workflow below to make a pull request:
+follow the workflow below to make a pull request (PR):
1. Fork the project into your personal space on Github
-1. Create a feature branch, away from `develop`
+1. Create a feature branch, away from [develop](https://github.com/ThmmyNoLife/mTHMMY/tree/develop)
1. Push the commit(s) to your fork
-1. Create a pull request (PR) targeting `develop` [at mTHMMY](https://github.com/ThmmyNoLife/mTHMMY/tree/develop)
+1. Create a PR targeting [develop at mTHMMY](https://github.com/ThmmyNoLife/mTHMMY/tree/develop)
1. Fill the PR title describing the change you want to make
1. Fill the PR description with a brief motive for your change and the method you used to achieve it
1. Submit the PR.
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java
index 59d686a6..4ffc3dff 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java
@@ -45,6 +45,8 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
//-----------------------------------------CLASS VARIABLES------------------------------------------
private static final int TIME_INTERVAL = 2000;
+ private SharedPreferences sharedPrefs;
+ private static final String DRAWER_INTRO = "DRAWER_INTRO";
private long mBackPressed;
private SectionsPagerAdapter sectionsPagerAdapter;
private ViewPager viewPager;
@@ -83,13 +85,12 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
TabLayout tabLayout = findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
- SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
+ sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
int preferredTab = Integer.parseInt(sharedPrefs.getString(DEFAULT_HOME_TAB, "0"));
if (preferredTab != 3 || sessionManager.isLoggedIn()) {
tabLayout.getTabAt(preferredTab).select();
}
-
setMainActivity(this);
}
@@ -103,6 +104,10 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
@Override
protected void onResume() {
drawer.setSelection(HOME_ID);
+ if(!sharedPrefs.getBoolean(DRAWER_INTRO, false)){
+ drawer.openDrawer();
+ sharedPrefs.edit().putBoolean(DRAWER_INTRO, true).apply();
+ }
updateTabs();
super.onResume();
}
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
index 8ba2bae3..f9a9f8c5 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
@@ -41,11 +41,11 @@ import gr.thmmy.mthmmy.activities.topic.tasks.PrepareForReply;
import gr.thmmy.mthmmy.activities.topic.tasks.ReplyTask;
import gr.thmmy.mthmmy.activities.topic.tasks.TopicTask;
import gr.thmmy.mthmmy.base.BaseActivity;
+import gr.thmmy.mthmmy.editorview.EmojiKeyboard;
import gr.thmmy.mthmmy.model.Bookmark;
import gr.thmmy.mthmmy.model.Post;
import gr.thmmy.mthmmy.model.ThmmyPage;
import gr.thmmy.mthmmy.utils.CustomLinearLayoutManager;
-import gr.thmmy.mthmmy.editorview.EmojiKeyboard;
import gr.thmmy.mthmmy.utils.HTMLUtils;
import gr.thmmy.mthmmy.utils.parsing.ParseHelpers;
import gr.thmmy.mthmmy.viewmodel.TopicViewModel;
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
index 1359e9fa..4c853526 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
@@ -42,12 +42,12 @@ import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.activities.board.BoardActivity;
import gr.thmmy.mthmmy.activities.profile.ProfileActivity;
import gr.thmmy.mthmmy.base.BaseActivity;
+import gr.thmmy.mthmmy.editorview.EditorView;
+import gr.thmmy.mthmmy.editorview.EmojiKeyboard;
import gr.thmmy.mthmmy.model.Post;
import gr.thmmy.mthmmy.model.ThmmyFile;
import gr.thmmy.mthmmy.model.ThmmyPage;
import gr.thmmy.mthmmy.utils.CircleTransform;
-import gr.thmmy.mthmmy.editorview.EditorView;
-import gr.thmmy.mthmmy.editorview.EmojiKeyboard;
import gr.thmmy.mthmmy.utils.parsing.ParseHelpers;
import gr.thmmy.mthmmy.viewmodel.TopicViewModel;
import timber.log.Timber;
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java
index 0b527421..63c2955b 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java
@@ -31,7 +31,7 @@ public class ReplyTask extends AsyncTask {
@Override
protected Boolean doInBackground(String... args) {
final String sentFrommTHMMY = includeAppSignature
- ? "\n[right][size=7pt][i]sent from [url=https://play.google.com/store/apps/details?id=gr.thmmy.mthmmy]mTHMMY [/url][/i][/size][/right]"
+ ? "\n[right][size=7pt][i]sent from [url=https://play.google.com/store/apps/details?id=gr.thmmy.mthmmy]mTHMMY[/url][/i] [/size][/right]"
: "";
RequestBody postBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java
index 6caa91d4..dbd760a7 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java
@@ -42,7 +42,7 @@ import timber.log.Timber;
public class BaseApplication extends Application {
private static BaseApplication baseApplication; //BaseApplication singleton
- //FirebaseAnalytics
+ //Firebase Analytics
private FirebaseAnalytics firebaseAnalytics;
//Client & SessionManager
diff --git a/app/src/main/java/gr/thmmy/mthmmy/editorview/AutoFitGridLayout.java b/app/src/main/java/gr/thmmy/mthmmy/editorview/AutoFitGridLayout.java
index 8e3055e5..2b3eff99 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/editorview/AutoFitGridLayout.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/editorview/AutoFitGridLayout.java
@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.GridLayout;
+
import gr.thmmy.mthmmy.R;
public class AutoFitGridLayout extends GridLayout {
From 4452c8b35505414eb6ce480932b89f3029ddbca2 Mon Sep 17 00:00:00 2001
From: Thodoris1999
Date: Sun, 2 Sep 2018 16:33:33 +0300
Subject: [PATCH 100/180] hopefully katarameno fix
---
.../activities/board/BoardActivity.java | 44 ++++++++++++-------
1 file changed, 28 insertions(+), 16 deletions(-)
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
index 75d0bea8..0aaa1525 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
@@ -156,7 +156,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
@Override
public void onLoadMore() {
- if (pagesLoaded < numberOfPages) {
+ if (pagesLoaded < numberOfPages && parsedTopics.get(parsedTopics.size() - 1) != null) {
parsedTopics.add(null);
boardAdapter.notifyItemInserted(parsedSubBoards.size() + parsedTopics.size());
@@ -185,6 +185,9 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
* parameter!
*/
private class BoardTask extends ParseTask {
+ ArrayList tempSubboards = new ArrayList<>();
+ ArrayList tempTopics = new ArrayList<>();
+
@Override
protected void onPreExecute() {
if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE);
@@ -195,10 +198,6 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
public void parse(Document boardPage) throws ParseException {
parsedTitle = boardPage.select("div.nav a.nav").last().text();
- //Removes loading item
- if (isLoadingMore) {
- if (parsedTopics.size() > 0) parsedTopics.remove(parsedTopics.size() - 1);
- }
//Finds number of pages
if (numberOfPages == -1) {
numberOfPages = 1;
@@ -254,7 +253,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
}
}
}
- parsedSubBoards.add(new Board(pUrl, pTitle, pMods, pStats, pLastPost, pLastPostUrl));
+ tempSubboards.add(new Board(pUrl, pTitle, pMods, pStats, pLastPost, pLastPostUrl));
}
}
}
@@ -293,7 +292,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
Timber.wtf("Board parsing about to fail. pLastPost came with: %s", pLastPost);
}
pLastPostUrl = topicColumns.last().select("a:has(img)").first().attr("href");
- parsedTopics.add(new Topic(pTopicUrl, pSubject, pStartedBy, pLastPost, pLastPostUrl,
+ tempTopics.add(new Topic(pTopicUrl, pSubject, pStartedBy, pLastPost, pLastPostUrl,
pStats, pLocked, pSticky, pUnread));
}
}
@@ -304,18 +303,31 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
@Override
protected void postExecution(ResultCode result) {
//TODO if (result == ResultCode.SUCCESS)...
- if (boardTitle == null || Objects.equals(boardTitle, "")
- || !Objects.equals(boardTitle, parsedTitle)) {
- boardTitle = parsedTitle;
- toolbar.setTitle(boardTitle);
- thisPageBookmark = new Bookmark(boardTitle, ThmmyPage.getBoardId(boardUrl), false);
+ if (result == ResultCode.SUCCESS) {
+ if (boardTitle == null || Objects.equals(boardTitle, "")
+ || !Objects.equals(boardTitle, parsedTitle)) {
+ boardTitle = parsedTitle;
+ toolbar.setTitle(boardTitle);
+ thisPageBookmark = new Bookmark(boardTitle, ThmmyPage.getBoardId(boardUrl), false);
+ }
+
+ //Removes loading item
+ if (isLoadingMore) {
+ if (parsedTopics.size() > 0) parsedTopics.remove(parsedTopics.size() - 1);
+ }
+
+ parsedTopics.clear();
+ parsedSubBoards.clear();
+ parsedTopics.addAll(tempTopics);
+ parsedSubBoards.addAll(tempSubboards);
+ boardAdapter.notifyDataSetChanged();
+
+ //Parse was successful
+ ++pagesLoaded;
+ if (newTopicFAB.getVisibility() != View.GONE) newTopicFAB.setEnabled(true);
}
- //Parse was successful
- ++pagesLoaded;
- if (newTopicFAB.getVisibility() != View.GONE) newTopicFAB.setEnabled(true);
progressBar.setVisibility(ProgressBar.INVISIBLE);
- boardAdapter.notifyDataSetChanged();
isLoadingMore = false;
}
}
From 8484af46986cff09ed4394a6bc548850caf77f32 Mon Sep 17 00:00:00 2001
From: Thodoris1999
Date: Sun, 2 Sep 2018 18:21:59 +0300
Subject: [PATCH 101/180] disable scrolling on new topics
---
.../java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
index 8ba2bae3..0c87db43 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
@@ -172,6 +172,7 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo
//LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
CustomLinearLayoutManager layoutManager = new CustomLinearLayoutManager(
getApplicationContext(), topicPageUrl);
+
recyclerView.setLayoutManager(layoutManager);
topicAdapter = new TopicAdapter(this, postsList);
recyclerView.setAdapter(topicAdapter);
@@ -632,10 +633,10 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo
postsList.addAll(postList);
topicAdapter.notifyDataSetChanged();
});
- viewModel.getFocusedPostIndex().observe(this, focusedPostIndex -> {
+ /*viewModel.getFocusedPostIndex().observe(this, focusedPostIndex -> {
if (focusedPostIndex == null) return;
recyclerView.scrollToPosition(focusedPostIndex);
- });
+ });*/
viewModel.getTopicTaskResultCode().observe(this, resultCode -> {
if (resultCode == null) return;
progressBar.setVisibility(ProgressBar.GONE);
From 97ba6219c718feeae144183cf258b40bfb8e56c1 Mon Sep 17 00:00:00 2001
From: Thodoris1999
Date: Tue, 4 Sep 2018 11:25:55 +0300
Subject: [PATCH 102/180] create content activity layout init
---
app/src/main/AndroidManifest.xml | 3 +
.../activities/CreateContentActivity.java | 56 +++++++++++++++++++
.../activities/board/BoardActivity.java | 50 ++++++++---------
.../res/layout/activity_create_content.xml | 33 +++++++++++
4 files changed, 114 insertions(+), 28 deletions(-)
create mode 100644 app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java
create mode 100644 app/src/main/res/layout/activity_create_content.xml
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cd4582c4..decb9b42 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -20,6 +20,7 @@
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java
new file mode 100644
index 00000000..bcc0a334
--- /dev/null
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java
@@ -0,0 +1,56 @@
+package gr.thmmy.mthmmy.activities;
+
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+import android.view.inputmethod.InputConnection;
+
+import gr.thmmy.mthmmy.R;
+import gr.thmmy.mthmmy.editorview.EditorView;
+import gr.thmmy.mthmmy.editorview.EmojiKeyboard;
+
+public class CreateContentActivity extends AppCompatActivity implements EmojiKeyboard.EmojiKeyboardOwner {
+
+ EditorView contentEditor;
+ EmojiKeyboard emojiKeyboard;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_create_content);
+
+ emojiKeyboard = findViewById(R.id.emoji_keyboard);
+
+ contentEditor = findViewById(R.id.main_content_editorview);
+ setEmojiKeyboardInputConnection(contentEditor.getInputConnection());
+ contentEditor.setEmojiKeyboardOwner(this);
+ contentEditor.setOnSubmitListener(v -> {
+
+ });
+ }
+
+ @Override
+ public void setEmojiKeyboardVisible(boolean visible) {
+ emojiKeyboard.setVisibility(visible ? View.VISIBLE : View.GONE);
+ }
+
+ @Override
+ public boolean isEmojiKeyboardVisible() {
+ return emojiKeyboard.getVisibility() == View.VISIBLE;
+ }
+
+ @Override
+ public void setEmojiKeyboardInputConnection(InputConnection ic) {
+ emojiKeyboard.setInputConnection(ic);
+ }
+
+ @Override
+ public void onBackPressed() {
+ if (emojiKeyboard.getVisibility() == View.VISIBLE) {
+ emojiKeyboard.setVisibility(View.GONE);
+ contentEditor.updateEmojiKeyboardVisibility();
+ } else {
+ super.onBackPressed();
+ }
+ }
+}
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
index 75d0bea8..04a03503 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
@@ -1,9 +1,11 @@
package gr.thmmy.mthmmy.activities.board;
+import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
+import android.support.v7.app.AlertDialog;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
@@ -20,6 +22,8 @@ import java.util.ArrayList;
import java.util.Objects;
import gr.thmmy.mthmmy.R;
+import gr.thmmy.mthmmy.activities.CreateContentActivity;
+import gr.thmmy.mthmmy.activities.LoginActivity;
import gr.thmmy.mthmmy.base.BaseActivity;
import gr.thmmy.mthmmy.model.Board;
import gr.thmmy.mthmmy.model.Bookmark;
@@ -95,37 +99,27 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
progressBar = findViewById(R.id.progressBar);
newTopicFAB = findViewById(R.id.board_fab);
- newTopicFAB.setEnabled(false);
- newTopicFAB.hide();
- /*if (!sessionManager.isLoggedIn()) newTopicFAB.hide();
+ if (!sessionManager.isLoggedIn()) newTopicFAB.hide();
else {
- newTopicFAB.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (sessionManager.isLoggedIn()) {
- //TODO create topic
- } else {
- new AlertDialog.Builder(BoardActivity.this)
- .setMessage("You need to be logged in to create a new topic!")
- .setPositiveButton("Login", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- Intent intent = new Intent(BoardActivity.this, LoginActivity.class);
- startActivity(intent);
- finish();
- overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
- }
- })
- .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- }
- })
- .show();
- }
+ newTopicFAB.setOnClickListener(view -> {
+ if (sessionManager.isLoggedIn()) {
+ //TODO create topic
+ startActivity(new Intent(this, CreateContentActivity.class));
+ } else {
+ new AlertDialog.Builder(BoardActivity.this)
+ .setMessage("You need to be logged in to create a new topic!")
+ .setPositiveButton("Login", (dialogInterface, i) -> {
+ Intent intent = new Intent(BoardActivity.this, LoginActivity.class);
+ startActivity(intent);
+ finish();
+ overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
+ })
+ .setNegativeButton("Cancel", (dialogInterface, i) -> {
+ })
+ .show();
}
});
- }*/
+ }
boardAdapter = new BoardAdapter(getApplicationContext(), parsedSubBoards, parsedTopics);
RecyclerView mainContent = findViewById(R.id.board_recycler_view);
diff --git a/app/src/main/res/layout/activity_create_content.xml b/app/src/main/res/layout/activity_create_content.xml
new file mode 100644
index 00000000..35bb9143
--- /dev/null
+++ b/app/src/main/res/layout/activity_create_content.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From 3ae5ca276bf014e569fed3e84253c24897aeeaf9 Mon Sep 17 00:00:00 2001
From: Thodoris1999
Date: Tue, 4 Sep 2018 12:21:09 +0300
Subject: [PATCH 103/180] complete new topic task
---
.../activities/CreateContentActivity.java | 53 ++++++++++-
.../thmmy/mthmmy/activities/NewTopicTask.java | 95 +++++++++++++++++++
.../activities/board/BoardActivity.java | 14 ++-
.../res/layout/activity_create_content.xml | 87 ++++++++++++-----
app/src/main/res/values/strings.xml | 3 +
5 files changed, 224 insertions(+), 28 deletions(-)
create mode 100644 app/src/main/java/gr/thmmy/mthmmy/activities/NewTopicTask.java
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java
index bcc0a334..48610cb7 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java
@@ -1,31 +1,57 @@
package gr.thmmy.mthmmy.activities;
+import android.content.Intent;
import android.os.Bundle;
+import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.inputmethod.InputConnection;
+import android.widget.TextView;
+import android.widget.Toast;
+import android.widget.Toolbar;
import gr.thmmy.mthmmy.R;
+import gr.thmmy.mthmmy.base.BaseApplication;
import gr.thmmy.mthmmy.editorview.EditorView;
import gr.thmmy.mthmmy.editorview.EmojiKeyboard;
+import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
+import timber.log.Timber;
-public class CreateContentActivity extends AppCompatActivity implements EmojiKeyboard.EmojiKeyboardOwner {
+public class CreateContentActivity extends AppCompatActivity implements EmojiKeyboard.EmojiKeyboardOwner,
+ NewTopicTask.NewTopicTaskCallbacks {
- EditorView contentEditor;
- EmojiKeyboard emojiKeyboard;
+ public final static String EXTRA_NEW_TOPIC_URL = "new-topic-extra";
+
+ private EditorView contentEditor;
+ private EmojiKeyboard emojiKeyboard;
+ private TextInputLayout subjectInput;
+ private MaterialProgressBar progressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_content);
+ TextView toolbarTitle = findViewById(R.id.toolbar_title);
+ toolbarTitle.setText(R.string.new_topic_toolbar);
+
+ progressBar = findViewById(R.id.progressBar);
+
+ Intent callingIntent = getIntent();
+ String newTopicUrl = callingIntent.getStringExtra(EXTRA_NEW_TOPIC_URL);
+
emojiKeyboard = findViewById(R.id.emoji_keyboard);
+ subjectInput = findViewById(R.id.subject_input);
+
contentEditor = findViewById(R.id.main_content_editorview);
setEmojiKeyboardInputConnection(contentEditor.getInputConnection());
contentEditor.setEmojiKeyboardOwner(this);
contentEditor.setOnSubmitListener(v -> {
-
+ if (newTopicUrl != null) {
+ new NewTopicTask(this).execute(newTopicUrl, subjectInput.getEditText().getText().toString(),
+ contentEditor.getText().toString());
+ }
});
}
@@ -53,4 +79,23 @@ public class CreateContentActivity extends AppCompatActivity implements EmojiKey
super.onBackPressed();
}
}
+
+ @Override
+ public void onNewTopicTaskStarted() {
+ Timber.i("New topic creation started");
+ progressBar.setVisibility(View.VISIBLE);
+ }
+
+ @Override
+ public void onNewTopicTaskFinished(boolean success) {
+ progressBar.setVisibility(View.INVISIBLE);
+ if (success) {
+ Timber.i("New topic created successfully");
+ finish();
+ } else {
+ Timber.w("New topic creation failed");
+ Toast.makeText(getBaseContext(), "Failed to create new topic!", Toast.LENGTH_LONG).show();
+ finish();
+ }
+ }
}
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/NewTopicTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/NewTopicTask.java
new file mode 100644
index 00000000..322cac43
--- /dev/null
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/NewTopicTask.java
@@ -0,0 +1,95 @@
+package gr.thmmy.mthmmy.activities;
+
+import android.os.AsyncTask;
+
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+
+import java.io.IOException;
+
+import gr.thmmy.mthmmy.base.BaseApplication;
+import okhttp3.MultipartBody;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import timber.log.Timber;
+
+import static gr.thmmy.mthmmy.activities.topic.Posting.replyStatus;
+
+public class NewTopicTask extends AsyncTask {
+
+ private NewTopicTaskCallbacks listener;
+
+ public NewTopicTask(NewTopicTaskCallbacks listener){
+ this.listener = listener;
+ }
+
+ @Override
+ protected void onPreExecute() {
+ listener.onNewTopicTaskStarted();
+ }
+
+ @Override
+ protected Boolean doInBackground(String... strings) {
+ Request request = new Request.Builder()
+ .url(strings[0] + ";wap2")
+ .build();
+
+ OkHttpClient client = BaseApplication.getInstance().getClient();
+
+ Document document;
+ String seqnum, sc, topic, createTopicUrl;
+ try {
+ Response response = client.newCall(request).execute();
+ document = Jsoup.parse(response.body().string());
+
+ seqnum = document.select("input[name=seqnum]").first().attr("value");
+ sc = document.select("input[name=sc]").first().attr("value");
+ topic = document.select("input[name=topic]").first().attr("value");
+ createTopicUrl = document.select("form").first().attr("action");
+
+ RequestBody postBody = new MultipartBody.Builder()
+ .setType(MultipartBody.FORM)
+ .addFormDataPart("message", strings[2])
+ .addFormDataPart("seqnum", seqnum)
+ .addFormDataPart("sc", sc)
+ .addFormDataPart("subject", strings[1])
+ .addFormDataPart("topic", topic)
+ .build();
+
+ Request post = new Request.Builder()
+ .url(createTopicUrl)
+ .header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36")
+ .post(postBody)
+ .build();
+
+ try {
+ client.newCall(post).execute();
+ Response response2 = client.newCall(post).execute();
+ switch (replyStatus(response2)) {
+ case SUCCESSFUL:
+ BaseApplication.getInstance().logFirebaseAnalyticsEvent("new_topic_creation", null);
+ return true;
+ default:
+ Timber.e("Malformed post. Request string: %s", post.toString());
+ return false;
+ }
+ } catch (IOException e) {
+ return false;
+ }
+ } catch (IOException e) {
+ return false;
+ }
+ }
+
+ @Override
+ protected void onPostExecute(Boolean success) {
+ listener.onNewTopicTaskFinished(success);
+ }
+
+ public interface NewTopicTaskCallbacks {
+ void onNewTopicTaskStarted();
+ void onNewTopicTaskFinished(boolean success);
+ }
+}
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
index 04a03503..9b905fb1 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
@@ -55,6 +55,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
private String boardUrl;
private String boardTitle;
private String parsedTitle;
+ private String newTopicUrl;
private int numberOfPages = -1;
private int pagesLoaded = 0;
@@ -104,7 +105,11 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
newTopicFAB.setOnClickListener(view -> {
if (sessionManager.isLoggedIn()) {
//TODO create topic
- startActivity(new Intent(this, CreateContentActivity.class));
+ if (newTopicUrl != null) {
+ Intent intent = new Intent(this, CreateContentActivity.class);
+ intent.putExtra(CreateContentActivity.EXTRA_NEW_TOPIC_URL, newTopicUrl);
+ startActivity(intent);
+ }
} else {
new AlertDialog.Builder(BoardActivity.this)
.setMessage("You need to be logged in to create a new topic!")
@@ -209,6 +214,13 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
//It just means this board has only one page of topics.
}
}
+
+ //Finds the url needed to create a new topic
+ Element newTopicButton = boardPage.select("a:has(img[alt=Start new topic])").first();
+ if (newTopicButton == null)
+ newTopicButton = boardPage.select("a:has(img[alt=Νέο θέμα])").first();
+ if (newTopicButton != null) newTopicUrl = newTopicButton.attr("href");
+
{ //Finds sub boards
Elements subBoardRows = boardPage.select("div.tborder>table>tbody>tr");
if (subBoardRows != null && !subBoardRows.isEmpty()) {
diff --git a/app/src/main/res/layout/activity_create_content.xml b/app/src/main/res/layout/activity_create_content.xml
index 35bb9143..220de6e4 100644
--- a/app/src/main/res/layout/activity_create_content.xml
+++ b/app/src/main/res/layout/activity_create_content.xml
@@ -1,33 +1,74 @@
-
-
-
-
-
+ android:layout_width="match_parent">
-
+ android:layout_height="match_parent">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ android:layout_height="@dimen/progress_bar_height"
+ android:indeterminate="true"
+ android:visibility="invisible"
+ app:layout_anchor="@id/appbar"
+ app:layout_anchorGravity="bottom|center"
+ app:mpb_indeterminateTint="@color/accent"
+ app:mpb_progressStyle="horizontal" />
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 4b8013a4..a5308050 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -180,4 +180,7 @@
Link URL
Link text
Required
+
+
+ New topic
From 5011fbf4ded8ac740f927969ddf28bc5b5560f1f Mon Sep 17 00:00:00 2001
From: Thodoris1999
Date: Tue, 4 Sep 2018 12:35:50 +0300
Subject: [PATCH 104/180] appbar fixes
---
app/src/main/AndroidManifest.xml | 6 +++++-
app/src/main/res/layout/activity_create_content.xml | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index decb9b42..b9c48bf4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -149,7 +149,11 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_create_content.xml b/app/src/main/res/layout/activity_create_content.xml
index 220de6e4..4e596664 100644
--- a/app/src/main/res/layout/activity_create_content.xml
+++ b/app/src/main/res/layout/activity_create_content.xml
@@ -5,7 +5,8 @@
xmlns:tools="http://schemas.android.com/tools"
tools:context=".activities.CreateContentActivity"
android:layout_height="match_parent"
- android:layout_width="match_parent">
+ android:layout_width="match_parent"
+ android:fitsSystemWindows="true">
Date: Tue, 4 Sep 2018 12:57:17 +0300
Subject: [PATCH 105/180] more appbar fixes
---
.../mthmmy/activities/CreateContentActivity.java | 14 ++++++++++----
.../main/res/layout/activity_create_content.xml | 3 ++-
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java
index 48610cb7..9b1bcede 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java
@@ -4,14 +4,13 @@ import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.inputmethod.InputConnection;
import android.widget.TextView;
import android.widget.Toast;
-import android.widget.Toolbar;
import gr.thmmy.mthmmy.R;
-import gr.thmmy.mthmmy.base.BaseApplication;
import gr.thmmy.mthmmy.editorview.EditorView;
import gr.thmmy.mthmmy.editorview.EmojiKeyboard;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
@@ -32,8 +31,15 @@ public class CreateContentActivity extends AppCompatActivity implements EmojiKey
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_content);
- TextView toolbarTitle = findViewById(R.id.toolbar_title);
- toolbarTitle.setText(R.string.new_topic_toolbar);
+ //Initialize toolbar
+ Toolbar toolbar = findViewById(R.id.toolbar);
+ toolbar.setTitle("Create topic");
+ setSupportActionBar(toolbar);
+ if (getSupportActionBar() != null) {
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setDisplayShowHomeEnabled(true);
+ }
+ ((TextView) findViewById(R.id.toolbar_title)).setText("Create topic");
progressBar = findViewById(R.id.progressBar);
diff --git a/app/src/main/res/layout/activity_create_content.xml b/app/src/main/res/layout/activity_create_content.xml
index 4e596664..9602df66 100644
--- a/app/src/main/res/layout/activity_create_content.xml
+++ b/app/src/main/res/layout/activity_create_content.xml
@@ -51,7 +51,8 @@
android:id="@+id/main_content_editorview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_below="@id/subject_input" />
+ android:layout_below="@id/subject_input"
+ app:hint="topic message"/>
Date: Wed, 5 Sep 2018 12:11:37 +0300
Subject: [PATCH 106/180] include app signature in new topic
---
.../mthmmy/activities/CreateContentActivity.java | 14 +++++++++++++-
.../gr/thmmy/mthmmy/activities/NewTopicTask.java | 9 +++++++--
.../mthmmy/activities/topic/tasks/ReplyTask.java | 2 +-
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java
index 9b1bcede..b46d401a 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java
@@ -1,7 +1,9 @@
package gr.thmmy.mthmmy.activities;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.os.Bundle;
+import android.preference.PreferenceManager;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
@@ -11,8 +13,11 @@ import android.widget.TextView;
import android.widget.Toast;
import gr.thmmy.mthmmy.R;
+import gr.thmmy.mthmmy.activities.settings.SettingsActivity;
+import gr.thmmy.mthmmy.base.BaseActivity;
import gr.thmmy.mthmmy.editorview.EditorView;
import gr.thmmy.mthmmy.editorview.EmojiKeyboard;
+import gr.thmmy.mthmmy.session.SessionManager;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
import timber.log.Timber;
@@ -55,7 +60,14 @@ public class CreateContentActivity extends AppCompatActivity implements EmojiKey
contentEditor.setEmojiKeyboardOwner(this);
contentEditor.setOnSubmitListener(v -> {
if (newTopicUrl != null) {
- new NewTopicTask(this).execute(newTopicUrl, subjectInput.getEditText().getText().toString(),
+ boolean includeAppSignature = true;
+ SessionManager sessionManager = BaseActivity.getSessionManager();
+ if (sessionManager.isLoggedIn()) {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ includeAppSignature = prefs.getBoolean(SettingsActivity.POSTING_APP_SIGNATURE_ENABLE_KEY, true);
+ }
+
+ new NewTopicTask(this, includeAppSignature).execute(newTopicUrl, subjectInput.getEditText().getText().toString(),
contentEditor.getText().toString());
}
});
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/NewTopicTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/NewTopicTask.java
index 322cac43..c8dc34d5 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/NewTopicTask.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/NewTopicTask.java
@@ -20,9 +20,11 @@ import static gr.thmmy.mthmmy.activities.topic.Posting.replyStatus;
public class NewTopicTask extends AsyncTask {
private NewTopicTaskCallbacks listener;
+ private boolean includeAppSignature;
- public NewTopicTask(NewTopicTaskCallbacks listener){
+ public NewTopicTask(NewTopicTaskCallbacks listener, boolean includeAppSignature){
this.listener = listener;
+ this.includeAppSignature = includeAppSignature;
}
@Override
@@ -49,9 +51,12 @@ public class NewTopicTask extends AsyncTask {
topic = document.select("input[name=topic]").first().attr("value");
createTopicUrl = document.select("form").first().attr("action");
+ final String appSignature = "\n[right][size=7pt][i]sent from [url=https://play.google.com/store/apps/" +
+ "details?id=gr.thmmy.mthmmy]mTHMMY[/url][/i][/size][/right]";
+
RequestBody postBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
- .addFormDataPart("message", strings[2])
+ .addFormDataPart("message", strings[2] + (includeAppSignature ? appSignature : ""))
.addFormDataPart("seqnum", seqnum)
.addFormDataPart("sc", sc)
.addFormDataPart("subject", strings[1])
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java
index 63c2955b..033316d2 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java
@@ -31,7 +31,7 @@ public class ReplyTask extends AsyncTask {
@Override
protected Boolean doInBackground(String... args) {
final String sentFrommTHMMY = includeAppSignature
- ? "\n[right][size=7pt][i]sent from [url=https://play.google.com/store/apps/details?id=gr.thmmy.mthmmy]mTHMMY[/url][/i] [/size][/right]"
+ ? "\n[right][size=7pt][i]sent from [url=https://play.google.com/store/apps/details?id=gr.thmmy.mthmmy]mTHMMY[/url][/i][/size][/right]"
: "";
RequestBody postBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
From c344016546142e965051a4c2d3aaa582dac92a83 Mon Sep 17 00:00:00 2001
From: Ezerous
Date: Thu, 6 Sep 2018 11:47:29 +0300
Subject: [PATCH 107/180] Settings strings minor changes
---
app/src/main/res/layout/activity_topic.xml | 2 +-
app/src/main/res/values/strings.xml | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/src/main/res/layout/activity_topic.xml b/app/src/main/res/layout/activity_topic.xml
index f331ceb9..242fb44e 100644
--- a/app/src/main/res/layout/activity_topic.xml
+++ b/app/src/main/res/layout/activity_topic.xml
@@ -6,6 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
+ android:background="@color/background"
tools:context=".activities.topic.TopicActivity">
App
Default home tab
- Select your preferred, home screen, default tab
+ Sets a home screen tab as default
Default home tab
Notifications
@@ -149,17 +149,17 @@
Toggle notifications state-->
Vibration
Notifications led
- Enables/disables notifications led, if your device has one
+ Enables/disables the notifications led (if the device has one)
Notifications sound
- Select your preferred notification sound
+ Sets your preferred notification sound
Posting
App signature
- If enabled, a \"sent from mTHMMY\" message will be inserted at the end of your posts
+ Appends a \"sent from mTHMMY\" message to your posts
Uploading
App signature
- If enabled, an \"uploaded from mTHMMY\" message will be inserted at the end of your uploads descriptions
+ Appends an \"uploaded from mTHMMY\" message to the descriptions of your uploads
Black
From 98e62f07ee8b201ab79efd12de49adbefbbe630c Mon Sep 17 00:00:00 2001
From: Thodoris1999
Date: Thu, 6 Sep 2018 13:30:54 +0300
Subject: [PATCH 108/180] minor UI adjustment
---
app/src/main/res/layout/activity_create_content.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/src/main/res/layout/activity_create_content.xml b/app/src/main/res/layout/activity_create_content.xml
index 9602df66..f3b77e09 100644
--- a/app/src/main/res/layout/activity_create_content.xml
+++ b/app/src/main/res/layout/activity_create_content.xml
@@ -40,6 +40,7 @@
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_below="@id/appbar"
+ android:layout_margin="16dp"
android:hint="@string/subject">
Date: Thu, 6 Sep 2018 16:09:52 +0300
Subject: [PATCH 109/180] colored letters and dot in color picker
---
.../thmmy/mthmmy/editorview/EditorView.java | 7 +++-
.../res/layout/editor_view_color_picker.xml | 42 ++++++++++++-------
app/src/main/res/values/colors.xml | 21 ++++++++++
3 files changed, 55 insertions(+), 15 deletions(-)
diff --git a/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java b/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java
index a4ccc119..4e01856d 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java
@@ -1,5 +1,6 @@
package gr.thmmy.mthmmy.editorview;
+import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
@@ -20,6 +21,7 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.ScrollView;
+import android.widget.TextView;
import java.util.Objects;
@@ -50,6 +52,7 @@ public class EditorView extends LinearLayout {
init(context, attrs);
}
+ @SuppressLint("SetTextI18n")
private void init(Context context, AttributeSet attrs) {
LayoutInflater.from(context).inflate(R.layout.editor_view, this, true);
setOrientation(VERTICAL);
@@ -142,7 +145,9 @@ public class EditorView extends LinearLayout {
LinearLayout colorPicker = (LinearLayout) colorPickerScrollview.getChildAt(0);
popupWindow.setContentView(colorPickerScrollview);
for (int i = 0; i < colorPicker.getChildCount(); i++) {
- colorPicker.getChildAt(i).setOnClickListener(v -> {
+ TextView child = (TextView) colorPicker.getChildAt(i);
+ child.setText("\u2B24 " + child.getText());
+ child.setOnClickListener(v -> {
boolean hadTextSelection = editText.hasSelection();
getText().insert(editText.getSelectionStart(), "[color=" + colors.get(v.getId()) + "]");
getText().insert(editText.getSelectionEnd(), "[/color]");
diff --git a/app/src/main/res/layout/editor_view_color_picker.xml b/app/src/main/res/layout/editor_view_color_picker.xml
index 0ac2d71b..b71214e1 100644
--- a/app/src/main/res/layout/editor_view_color_picker.xml
+++ b/app/src/main/res/layout/editor_view_color_picker.xml
@@ -13,71 +13,85 @@
+ android:text="@string/black"
+ android:textColor="@color/black"/>
+ android:text="@string/red"
+ android:textColor="@color/red"/>
+ android:text="@string/yellow"
+ android:textColor="@color/yellow"/>
+ android:text="@string/pink"
+ android:textColor="@color/pink"/>
+ android:text="@string/green"
+ android:textColor="@color/green"/>
+ android:text="@string/orange"
+ android:textColor="@color/orange"/>
+ android:text="@string/purple"
+ android:textColor="@color/purple"/>
+ android:text="@string/blue"
+ android:textColor="@color/blue"/>
+ android:text="@string/beige"
+ android:textColor="@color/beige"/>
+ android:text="@string/brown"
+ android:textColor="@color/brown"/>
+ android:text="@string/teal"
+ android:textColor="@color/teal"/>
+ android:text="@string/navy"
+ android:textColor="@color/navy"/>
+ android:text="@string/maroon"
+ android:textColor="@color/maroon"/>
+ android:text="@string/lime_green"
+ android:textColor="@color/lime_green"/>
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index c3bdac7a..f2209027 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -26,4 +26,25 @@
#D92B2B2B
#E91E63
@color/primary_text
+
+ #FF0000
+ #800000
+ #A52A2A
+ #FFA500
+ #FFFF00
+ #808000
+ #008000
+ #800080
+ #FF00FF
+ #FFC0CB
+ #F5F5DC
+ #00FF00
+ #32CD32
+ #008080
+ #00FFFF
+ #0000FF
+ #000080
+ #000000
+ #808080
+ #C0C0C0
From 9333b5d2b9bf306a458ff3251bd5c17afee4713d Mon Sep 17 00:00:00 2001
From: Thodoris1999
Date: Thu, 6 Sep 2018 18:44:34 +0300
Subject: [PATCH 110/180] no dots
---
app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java b/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java
index 4e01856d..44b649a9 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java
@@ -146,7 +146,6 @@ public class EditorView extends LinearLayout {
popupWindow.setContentView(colorPickerScrollview);
for (int i = 0; i < colorPicker.getChildCount(); i++) {
TextView child = (TextView) colorPicker.getChildAt(i);
- child.setText("\u2B24 " + child.getText());
child.setOnClickListener(v -> {
boolean hadTextSelection = editText.hasSelection();
getText().insert(editText.getSelectionStart(), "[color=" + colors.get(v.getId()) + "]");
From c4df3f38e7c561196a785336003bcf2a2cabb12e Mon Sep 17 00:00:00 2001
From: Thodoris1999
Date: Fri, 7 Sep 2018 14:11:35 +0300
Subject: [PATCH 111/180] project structure
---
app/src/main/AndroidManifest.xml | 2 +-
.../java/gr/thmmy/mthmmy/activities/board/BoardActivity.java | 2 +-
.../activities/{ => create_content}/CreateContentActivity.java | 3 ++-
.../mthmmy/activities/{ => create_content}/NewTopicTask.java | 2 +-
app/src/main/res/layout/activity_create_content.xml | 2 +-
5 files changed, 6 insertions(+), 5 deletions(-)
rename app/src/main/java/gr/thmmy/mthmmy/activities/{ => create_content}/CreateContentActivity.java (97%)
rename app/src/main/java/gr/thmmy/mthmmy/activities/{ => create_content}/NewTopicTask.java (98%)
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b9c48bf4..3b37c299 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -150,7 +150,7 @@
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
index 9b905fb1..556f23df 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
@@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.util.Objects;
import gr.thmmy.mthmmy.R;
-import gr.thmmy.mthmmy.activities.CreateContentActivity;
+import gr.thmmy.mthmmy.activities.create_content.CreateContentActivity;
import gr.thmmy.mthmmy.activities.LoginActivity;
import gr.thmmy.mthmmy.base.BaseActivity;
import gr.thmmy.mthmmy.model.Board;
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/CreateContentActivity.java
similarity index 97%
rename from app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java
rename to app/src/main/java/gr/thmmy/mthmmy/activities/create_content/CreateContentActivity.java
index b46d401a..44e025ed 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/CreateContentActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/CreateContentActivity.java
@@ -1,4 +1,4 @@
-package gr.thmmy.mthmmy.activities;
+package gr.thmmy.mthmmy.activities.create_content;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -13,6 +13,7 @@ import android.widget.TextView;
import android.widget.Toast;
import gr.thmmy.mthmmy.R;
+import gr.thmmy.mthmmy.activities.create_content.NewTopicTask;
import gr.thmmy.mthmmy.activities.settings.SettingsActivity;
import gr.thmmy.mthmmy.base.BaseActivity;
import gr.thmmy.mthmmy.editorview.EditorView;
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/NewTopicTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/NewTopicTask.java
similarity index 98%
rename from app/src/main/java/gr/thmmy/mthmmy/activities/NewTopicTask.java
rename to app/src/main/java/gr/thmmy/mthmmy/activities/create_content/NewTopicTask.java
index c8dc34d5..253280eb 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/NewTopicTask.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/NewTopicTask.java
@@ -1,4 +1,4 @@
-package gr.thmmy.mthmmy.activities;
+package gr.thmmy.mthmmy.activities.create_content;
import android.os.AsyncTask;
diff --git a/app/src/main/res/layout/activity_create_content.xml b/app/src/main/res/layout/activity_create_content.xml
index f3b77e09..9578bd2d 100644
--- a/app/src/main/res/layout/activity_create_content.xml
+++ b/app/src/main/res/layout/activity_create_content.xml
@@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
- tools:context=".activities.CreateContentActivity"
+ tools:context=".activities.create_content.CreateContentActivity"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:fitsSystemWindows="true">
From f3bb24fd1f54a50997cc1b036e482656b40d1f4c Mon Sep 17 00:00:00 2001
From: Thodoris1999
Date: Fri, 7 Sep 2018 14:14:46 +0300
Subject: [PATCH 112/180] minor stuff
---
.../activities/create_content/CreateContentActivity.java | 3 +--
app/src/main/res/values/strings.xml | 1 +
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/CreateContentActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/CreateContentActivity.java
index 44e025ed..524d022c 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/CreateContentActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/CreateContentActivity.java
@@ -13,7 +13,6 @@ import android.widget.TextView;
import android.widget.Toast;
import gr.thmmy.mthmmy.R;
-import gr.thmmy.mthmmy.activities.create_content.NewTopicTask;
import gr.thmmy.mthmmy.activities.settings.SettingsActivity;
import gr.thmmy.mthmmy.base.BaseActivity;
import gr.thmmy.mthmmy.editorview.EditorView;
@@ -45,7 +44,7 @@ public class CreateContentActivity extends AppCompatActivity implements EmojiKey
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
- ((TextView) findViewById(R.id.toolbar_title)).setText("Create topic");
+ ((TextView) findViewById(R.id.toolbar_title)).setText(R.string.create_topic);
progressBar = findViewById(R.id.progressBar);
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index a5308050..53cbb9b2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -183,4 +183,5 @@
New topic
+ Create topic
From 5ad072e417dca84934e3f73481baf4ab6842ebae Mon Sep 17 00:00:00 2001
From: Thodoris1999
Date: Fri, 7 Sep 2018 14:29:20 +0300
Subject: [PATCH 113/180] toolbar fix
---
.../activities/create_content/CreateContentActivity.java | 8 ++------
app/src/main/res/layout/activity_create_content.xml | 8 +-------
2 files changed, 3 insertions(+), 13 deletions(-)
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/CreateContentActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/CreateContentActivity.java
index 524d022c..781bb9f3 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/CreateContentActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/CreateContentActivity.java
@@ -5,11 +5,8 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.TextInputLayout;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.inputmethod.InputConnection;
-import android.widget.TextView;
import android.widget.Toast;
import gr.thmmy.mthmmy.R;
@@ -21,7 +18,7 @@ import gr.thmmy.mthmmy.session.SessionManager;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
import timber.log.Timber;
-public class CreateContentActivity extends AppCompatActivity implements EmojiKeyboard.EmojiKeyboardOwner,
+public class CreateContentActivity extends BaseActivity implements EmojiKeyboard.EmojiKeyboardOwner,
NewTopicTask.NewTopicTaskCallbacks {
public final static String EXTRA_NEW_TOPIC_URL = "new-topic-extra";
@@ -37,14 +34,13 @@ public class CreateContentActivity extends AppCompatActivity implements EmojiKey
setContentView(R.layout.activity_create_content);
//Initialize toolbar
- Toolbar toolbar = findViewById(R.id.toolbar);
+ toolbar = findViewById(R.id.toolbar);
toolbar.setTitle("Create topic");
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
- ((TextView) findViewById(R.id.toolbar_title)).setText(R.string.create_topic);
progressBar = findViewById(R.id.progressBar);
diff --git a/app/src/main/res/layout/activity_create_content.xml b/app/src/main/res/layout/activity_create_content.xml
index 9578bd2d..04af0ea4 100644
--- a/app/src/main/res/layout/activity_create_content.xml
+++ b/app/src/main/res/layout/activity_create_content.xml
@@ -24,14 +24,8 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
- app:contentInsetStartWithNavigation="0dp"
+ android:gravity="center"
app:popupTheme="@style/ToolbarTheme">
-
-
From d80d8a4d42d260ce7fe89f622244ebb3a498bfc5 Mon Sep 17 00:00:00 2001
From: Ezerous
Date: Mon, 10 Sep 2018 15:58:36 +0300
Subject: [PATCH 114/180] Ensure correct google-services.json is supplied when
building release APKs
---
app/build.gradle | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/app/build.gradle b/app/build.gradle
index 00e58bbd..5baea52e 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,7 +1,8 @@
+import groovy.json.JsonSlurper
+
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
-
android {
compileSdkVersion 27
@@ -34,6 +35,17 @@ android {
}
}
+tasks.whenTaskAdded { task ->
+ if (task.name.contains("assembleRelease")) {
+ task.getDependsOn().add({
+ def inputFile = new File("app/google-services.json")
+ def json = new JsonSlurper().parseText(inputFile.text)
+ if(json.project_info.project_id != "mthmmy-release-3aef0")
+ throw new GradleException('Please supply the correct google-services.json for release or manually change the id above!')
+ })
+ }
+}
+
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
@@ -44,7 +56,7 @@ dependencies {
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.google.firebase:firebase-core:16.0.3'
- implementation 'com.google.firebase:firebase-messaging:17.3.0'
+ implementation 'com.google.firebase:firebase-messaging:17.3.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
From b31ad5db0644f08454f7ad1f1cc992a948796d9e Mon Sep 17 00:00:00 2001
From: Apostolof
Date: Mon, 10 Sep 2018 20:36:21 +0300
Subject: [PATCH 115/180] UI fixes for topics activity
---
.../activities/topic/TopicActivity.java | 26 ++++++++++++--
app/src/main/res/layout/activity_topic.xml | 36 ++++++++++---------
app/src/main/res/values/strings.xml | 2 +-
3 files changed, 45 insertions(+), 19 deletions(-)
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
index 84f35817..953f7ad8 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
@@ -12,12 +12,17 @@ import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
+import android.support.v4.content.ContextCompat;
+import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.RecyclerView;
+import android.text.Spannable;
+import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
+import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@@ -62,7 +67,7 @@ import static gr.thmmy.mthmmy.services.NotificationService.NEW_POST_TAG;
*/
@SuppressWarnings("unchecked")
public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFocusChangeListener,
- EmojiKeyboard.EmojiKeyboardOwner{
+ EmojiKeyboard.EmojiKeyboardOwner {
//Activity's variables
/**
* The key to use when putting topic's url String to {@link TopicActivity}'s Bundle.
@@ -651,7 +656,15 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo
// no page has been loaded yet. Give user the ability to refresh
recyclerView.setVisibility(View.GONE);
TextView errorTextview = findViewById(R.id.error_textview);
- errorTextview.setText(getString(R.string.network_error_retry_prompt));
+
+ Spannable errorText = new SpannableString(getString(R.string.network_error_retry_prompt));
+ errorText.setSpan(
+ new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.accent, null)),
+ errorText.toString().indexOf("Tap to retry"),
+ errorText.length(),
+ Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+
+ errorTextview.setText(errorText);
errorTextview.setVisibility(View.VISIBLE);
errorTextview.setOnClickListener(view -> {
viewModel.reloadPage();
@@ -671,6 +684,15 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo
Timber.w("Requested topic was unauthorized");
recyclerView.setVisibility(View.GONE);
TextView errorTextview = findViewById(R.id.error_textview);
+
+ Spannable errorText = new SpannableString(getString(R.string.unauthorized_topic_error));
+ errorText.setSpan(
+ //TODO: maybe change the color to a red in order to indicate the error nature of the message
+ new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.accent, null)),
+ 0,
+ errorText.length(),
+ Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+
errorTextview.setText(getString(R.string.unauthorized_topic_error));
errorTextview.setVisibility(View.VISIBLE);
break;
diff --git a/app/src/main/res/layout/activity_topic.xml b/app/src/main/res/layout/activity_topic.xml
index 242fb44e..1ef0d0e7 100644
--- a/app/src/main/res/layout/activity_topic.xml
+++ b/app/src/main/res/layout/activity_topic.xml
@@ -5,13 +5,13 @@
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:fitsSystemWindows="true"
android:background="@color/background"
+ android:fitsSystemWindows="true"
tools:context=".activities.topic.TopicActivity">
+ android:layout_height="match_parent">
@@ -39,10 +40,11 @@
-
+ android:visibility="gone" />
-
+
+
Subject…
Submit
Message…
- Could not connect to thmmy.gr \n\n Tap to retry
+ Could not connect to thmmy.gr\n\nTap to retry
Network error
retry
This topic is either missing or off limits to you
From 0ff971c84061302fc2de700deae71c17f27874b6 Mon Sep 17 00:00:00 2001
From: Apostolof
Date: Mon, 10 Sep 2018 20:57:38 +0300
Subject: [PATCH 116/180] Fix greek parsing for mentions
---
.../main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java | 2 +-
app/src/main/res/layout/activity_topic.xml | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java
index e6970a80..b0132a14 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java
@@ -32,7 +32,7 @@ import timber.log.Timber;
*/
public class TopicParser {
private static Pattern mentionsPattern = Pattern.
- compile("