diff --git a/app/build.gradle b/app/build.gradle index ecbd4dbc..11baff14 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,7 +41,7 @@ tasks.whenTaskAdded { task -> 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") + 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!') }) } @@ -49,13 +49,13 @@ tasks.whenTaskAdded { task -> dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation 'com.android.support:design:28.0.0' - implementation 'com.android.support:preference-v7:28.0.0' - implementation 'com.android.support:preference-v14:28.0.0' - implementation 'com.android.support:support-v4:28.0.0' - implementation 'com.android.support:cardview-v7:28.0.0' - implementation 'com.android.support:recyclerview-v7:28.0.0' + implementation 'androidx.appcompat:appcompat:1.0.0' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.preference:preference:1.0.0' + implementation 'androidx.legacy:legacy-preference-v14:1.0.0' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'androidx.cardview:cardview:1.0.0' + implementation 'androidx.recyclerview:recyclerview:1.0.0' implementation 'com.google.firebase:firebase-core:16.0.4' implementation 'com.google.firebase:firebase-messaging:17.3.3' implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5' @@ -77,7 +77,9 @@ dependencies { implementation "ru.noties:markwon:2.0.0" implementation 'net.gotev:uploadservice:3.4.2' implementation 'net.gotev:uploadservice-okhttp:3.4.2' - implementation 'android.arch.lifecycle:extensions:1.1.1' + implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' } apply plugin: 'com.google.gms.google-services' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 19f47c62..eef46aad 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -136,7 +136,7 @@ @@ -158,6 +158,14 @@ android:configChanges="orientation|screenSize" android:parentActivityName=".activities.main.MainActivity" android:theme="@style/AppTheme.NoActionBar" /> + + + \ No newline at end of file diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java index 34ed4c32..0fac281f 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java @@ -2,10 +2,11 @@ package gr.thmmy.mthmmy.activities; import android.content.pm.ActivityInfo; import android.os.Bundle; -import android.support.design.widget.AppBarLayout; -import android.support.design.widget.CoordinatorLayout; -import android.support.v4.widget.DrawerLayout; -import android.support.v7.app.AlertDialog; +import com.google.android.material.appbar.AppBarLayout; +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.drawerlayout.widget.DrawerLayout; +import androidx.appcompat.app.AlertDialog; + import android.text.SpannableString; import android.text.method.LinkMovementMethod; import android.text.style.UnderlineSpan; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java index 1a5ad05f..ba423202 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java @@ -3,8 +3,8 @@ package gr.thmmy.mthmmy.activities; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; -import android.support.v7.preference.PreferenceManager; -import android.support.v7.widget.AppCompatButton; +import androidx.preference.PreferenceManager; +import androidx.appcompat.widget.AppCompatButton; import android.view.View; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; 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 d3a74098..addf7ff5 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 @@ -4,11 +4,11 @@ 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; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import androidx.appcompat.app.AlertDialog; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.view.View; import android.widget.ProgressBar; import android.widget.Toast; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java index 09734606..6b0c7267 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java @@ -5,7 +5,7 @@ import android.content.Intent; import android.graphics.Typeface; import android.os.Build; import android.os.Bundle; -import android.support.v7.widget.RecyclerView; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BoardBookmarksFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BoardBookmarksFragment.java index 6c7db47f..b191aebd 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BoardBookmarksFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BoardBookmarksFragment.java @@ -5,9 +5,8 @@ import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.graphics.drawable.VectorDrawableCompat; -import android.support.v4.app.Fragment; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -17,6 +16,7 @@ import android.widget.TextView; import java.util.ArrayList; +import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat; import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.model.Bookmark; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarkActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarkActivity.java index 164e8f3f..57cec031 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarkActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarkActivity.java @@ -2,11 +2,12 @@ package gr.thmmy.mthmmy.activities.bookmarks; import android.content.Intent; import android.os.Bundle; -import android.support.design.widget.TabLayout; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.ViewPager; +import com.google.android.material.tabs.TabLayout; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentPagerAdapter; +import androidx.fragment.app.FragmentStatePagerAdapter; +import androidx.viewpager.widget.ViewPager; import android.widget.Toast; import java.util.ArrayList; @@ -110,7 +111,7 @@ public class BookmarkActivity extends BaseActivity { * A {@link FragmentPagerAdapter} that returns a fragment corresponding to * one of the sections/tabs/pages. If it becomes too memory intensive, * it may be best to switch to a - * {@link android.support.v4.app.FragmentStatePagerAdapter}. + * {@link FragmentStatePagerAdapter}. */ private class SectionsPagerAdapter extends FragmentPagerAdapter { private final List fragmentList = new ArrayList<>(); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/TopicBookmarksFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/TopicBookmarksFragment.java index 54659baa..d57cba4e 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/TopicBookmarksFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/TopicBookmarksFragment.java @@ -5,9 +5,9 @@ import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.graphics.drawable.VectorDrawableCompat; -import android.support.v4.app.Fragment; +import androidx.annotation.NonNull; +import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; 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 b770b7b5..bc9b3382 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 @@ -4,7 +4,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; -import android.support.design.widget.TextInputLayout; +import com.google.android.material.textfield.TextInputLayout; import android.text.InputType; import android.text.TextUtils; import android.view.View; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java index 076cefe9..0d9cfd26 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java @@ -1,14 +1,8 @@ package gr.thmmy.mthmmy.activities.downloads; -import android.content.Intent; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; -import android.support.v7.widget.DividerItemDecoration; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.view.Menu; -import android.view.MenuItem; import android.widget.ProgressBar; import android.widget.Toast; @@ -19,8 +13,10 @@ import org.jsoup.select.Elements; import java.util.ArrayList; import java.util.Objects; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import gr.thmmy.mthmmy.R; -import gr.thmmy.mthmmy.activities.upload.UploadActivity; import gr.thmmy.mthmmy.base.BaseActivity; import gr.thmmy.mthmmy.base.BaseApplication; import gr.thmmy.mthmmy.model.Download; @@ -33,8 +29,6 @@ import okhttp3.Request; import okhttp3.Response; import timber.log.Timber; -import static gr.thmmy.mthmmy.activities.upload.UploadActivity.BUNDLE_UPLOAD_CATEGORY; - public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.OnLoadMoreListener { /** * The key to use when putting download's url String to {@link DownloadsActivity}'s Bundle. diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java index 34a583e0..5f38aea5 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java @@ -5,7 +5,7 @@ import android.content.Intent; import android.graphics.Typeface; import android.os.Build; import android.os.Bundle; -import android.support.v7.widget.RecyclerView; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; 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 67f99897..4a64499f 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 @@ -4,17 +4,19 @@ import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; -import android.support.design.widget.TabLayout; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v7.preference.PreferenceManager; import android.widget.Toast; +import com.google.android.material.tabs.TabLayout; + import java.util.ArrayList; import java.util.List; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentPagerAdapter; +import androidx.fragment.app.FragmentStatePagerAdapter; +import androidx.preference.PreferenceManager; +import androidx.viewpager.widget.ViewPager; import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.activities.LoginActivity; import gr.thmmy.mthmmy.activities.board.BoardActivity; @@ -23,6 +25,7 @@ import gr.thmmy.mthmmy.activities.main.forum.ForumFragment; import gr.thmmy.mthmmy.activities.main.recent.RecentFragment; import gr.thmmy.mthmmy.activities.main.unread.UnreadFragment; import gr.thmmy.mthmmy.activities.profile.ProfileActivity; +import gr.thmmy.mthmmy.activities.settings.SettingsActivity; import gr.thmmy.mthmmy.activities.topic.TopicActivity; import gr.thmmy.mthmmy.base.BaseActivity; import gr.thmmy.mthmmy.model.Board; @@ -37,7 +40,6 @@ import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWN import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL; import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; -import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.DEFAULT_HOME_TAB; import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; @@ -50,6 +52,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF private long mBackPressed; private SectionsPagerAdapter sectionsPagerAdapter; private ViewPager viewPager; + private TabLayout tabLayout; @Override protected void onCreate(Bundle savedInstanceState) { @@ -82,15 +85,23 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF //Set up the ViewPager with the sections adapter. viewPager = findViewById(R.id.container); viewPager.setAdapter(sectionsPagerAdapter); - - TabLayout tabLayout = findViewById(R.id.tabs); + tabLayout = findViewById(R.id.tabs); tabLayout.setupWithViewPager(viewPager); sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); - int preferredTab = Integer.parseInt(sharedPrefs.getString(DEFAULT_HOME_TAB, "0")); - if (preferredTab != 3 || sessionManager.isLoggedIn()) { + int preferredTab = Integer.parseInt(sharedPrefs.getString(SettingsActivity.DEFAULT_HOME_TAB, "0")); + if ((preferredTab != 3 && preferredTab != 4) || sessionManager.isLoggedIn()) { tabLayout.getTabAt(preferredTab).select(); } + for (int i = 0; i < tabLayout.getTabCount(); i++) { + if (i == 0) { + tabLayout.getTabAt(i).setIcon(getResources().getDrawable(R.drawable.ic_access_time_white_24dp)); + } else if (i == 1) { + tabLayout.getTabAt(i).setIcon(getResources().getDrawable(R.drawable.ic_forum_white_24dp)); + }else if (i == 2) { + tabLayout.getTabAt(i).setIcon(getResources().getDrawable(R.drawable.ic_fiber_new_white_24dp)); + } + } setMainActivity(this); } @@ -105,7 +116,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF @Override protected void onResume() { drawer.setSelection(HOME_ID); - if(!sharedPrefs.getBoolean(DRAWER_INTRO, false)){ + if (!sharedPrefs.getBoolean(DRAWER_INTRO, false)) { drawer.openDrawer(); sharedPrefs.edit().putBoolean(DRAWER_INTRO, true).apply(); } @@ -161,7 +172,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF * A {@link FragmentPagerAdapter} that returns a fragment corresponding to * one of the sections/tabs/pages. If it becomes too memory intensive, * it may be best to switch to a - * {@link android.support.v4.app.FragmentStatePagerAdapter}. + * {@link FragmentStatePagerAdapter}. */ private class SectionsPagerAdapter extends FragmentPagerAdapter { private final List fragmentList = new ArrayList<>(); @@ -209,10 +220,13 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF } public void updateTabs() { - if (!sessionManager.isLoggedIn() && sectionsPagerAdapter.getCount() == 3) + if (!sessionManager.isLoggedIn() && sectionsPagerAdapter.getCount() == 3) { sectionsPagerAdapter.removeFragment(2); - else if (sessionManager.isLoggedIn() && sectionsPagerAdapter.getCount() == 2) + } + else if (sessionManager.isLoggedIn() && sectionsPagerAdapter.getCount() == 2) { sectionsPagerAdapter.addFragment(UnreadFragment.newInstance(3), "UNREAD"); + tabLayout.getTabAt(2).setIcon(R.drawable.ic_fiber_new_white_24dp); + } } //-------------------------------FragmentPagerAdapter END------------------------------------------- diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumAdapter.java index 5b2f4c93..1890ff8f 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumAdapter.java @@ -1,8 +1,8 @@ package gr.thmmy.mthmmy.activities.main.forum; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.v7.widget.RecyclerView; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java index a85eca23..5b1aa286 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java @@ -2,9 +2,9 @@ package gr.thmmy.mthmmy.activities.main.forum; import android.os.AsyncTask; import android.os.Bundle; -import android.support.v4.widget.SwipeRefreshLayout; -import android.support.v7.widget.DividerItemDecoration; -import android.support.v7.widget.LinearLayoutManager; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentAdapter.java index de128cb1..7a05cb3e 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentAdapter.java @@ -1,8 +1,8 @@ package gr.thmmy.mthmmy.activities.main.recent; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.v7.widget.RecyclerView; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java index 65b0d315..34175435 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java @@ -2,9 +2,9 @@ package gr.thmmy.mthmmy.activities.main.recent; import android.os.AsyncTask; import android.os.Bundle; -import android.support.v4.widget.SwipeRefreshLayout; -import android.support.v7.widget.DividerItemDecoration; -import android.support.v7.widget.LinearLayoutManager; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java index 65100922..826e37fb 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java @@ -1,7 +1,7 @@ package gr.thmmy.mthmmy.activities.main.unread; -import android.support.annotation.NonNull; -import android.support.v7.widget.RecyclerView; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java index 0747b4bf..18ff8039 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java @@ -2,10 +2,10 @@ package gr.thmmy.mthmmy.activities.main.unread; import android.os.AsyncTask; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.widget.SwipeRefreshLayout; -import android.support.v7.widget.DividerItemDecoration; -import android.support.v7.widget.LinearLayoutManager; +import androidx.annotation.NonNull; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java index 19680329..ce19849d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java @@ -7,14 +7,14 @@ import android.net.Uri; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; -import android.support.design.widget.FloatingActionButton; -import android.support.design.widget.TabLayout; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.content.res.ResourcesCompat; -import android.support.v4.view.ViewPager; -import android.support.v7.app.AppCompatDelegate; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.tabs.TabLayout; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentPagerAdapter; +import androidx.core.content.res.ResourcesCompat; +import androidx.viewpager.widget.ViewPager; +import androidx.appcompat.app.AppCompatDelegate; import android.text.Spannable; import android.text.SpannableString; import android.text.Spanned; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java index b7162495..31ec223d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java @@ -1,6 +1,6 @@ package gr.thmmy.mthmmy.activities.profile.latestPosts; -import android.support.v7.widget.RecyclerView; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java index 277b01a0..356fbab7 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java @@ -2,9 +2,9 @@ package gr.thmmy.mthmmy.activities.profile.latestPosts; import android.os.AsyncTask; import android.os.Bundle; -import android.support.v7.widget.DividerItemDecoration; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java index 5822d635..2ae7140a 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java @@ -4,7 +4,7 @@ import android.graphics.Color; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; -import android.support.v4.app.Fragment; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java index 76380576..f3d68fe4 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java @@ -4,7 +4,7 @@ import android.graphics.Color; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; -import android.support.v4.app.Fragment; +import androidx.fragment.app.Fragment; import android.text.Html; import android.text.method.LinkMovementMethod; import android.view.LayoutInflater; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsActivity.java index 4383732b..cc2a7f6d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsActivity.java @@ -1,7 +1,7 @@ package gr.thmmy.mthmmy.activities.settings; import android.os.Bundle; -import android.support.v4.app.FragmentTransaction; +import androidx.fragment.app.FragmentTransaction; import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.base.BaseActivity; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java index df97ad07..5956e79a 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java @@ -8,10 +8,10 @@ import android.media.RingtoneManager; import android.net.Uri; import android.os.Bundle; import android.provider.Settings; -import android.support.annotation.NonNull; -import android.support.v7.preference.ListPreference; -import android.support.v7.preference.Preference; -import android.support.v7.preference.PreferenceFragmentCompat; +import androidx.annotation.NonNull; +import androidx.preference.ListPreference; +import androidx.preference.Preference; +import androidx.preference.PreferenceFragmentCompat; import android.view.View; import android.widget.Toast; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/SendShoutTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/SendShoutTask.java new file mode 100644 index 00000000..3b2af22f --- /dev/null +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/SendShoutTask.java @@ -0,0 +1,50 @@ +package gr.thmmy.mthmmy.activities.shoutbox; + +import org.jsoup.nodes.Document; + +import java.io.IOException; + +import gr.thmmy.mthmmy.utils.NetworkResultCodes; +import gr.thmmy.mthmmy.utils.NetworkTask; +import okhttp3.MultipartBody; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; + +public class SendShoutTask extends NetworkTask { + + public SendShoutTask(OnTaskStartedListener onTaskStartedListener, OnNetworkTaskFinishedListener onNetworkTaskFinishedListener) { + super(onTaskStartedListener, onNetworkTaskFinishedListener); + } + + @Override + protected Response sendRequest(OkHttpClient client, String... input) throws IOException { + MultipartBody.Builder postBodyBuilder = new MultipartBody.Builder() + .setType(MultipartBody.FORM) + .addFormDataPart("sc", input[2]) + .addFormDataPart("tp-shout", input[1]) + .addFormDataPart("tp-shout-name", input[3]) + .addFormDataPart("shout_send", input[4]) + .addFormDataPart("tp-shout-url", input[5]); + + Request voteRequest = new Request.Builder() + .url(input[0]) + .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(postBodyBuilder.build()) + .build(); + client.newCall(voteRequest).execute(); + return client.newCall(voteRequest).execute(); + } + + + + @Override + protected Void performTask(Document document, Response response) { + return null; + } + + @Override + protected int getResultCode(Response response, Void data) { + return NetworkResultCodes.SUCCESSFUL; + } +} diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutAdapter.java new file mode 100644 index 00000000..7d041a32 --- /dev/null +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutAdapter.java @@ -0,0 +1,154 @@ +package gr.thmmy.mthmmy.activities.shoutbox; + +import android.annotation.TargetApi; +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.webkit.WebResourceRequest; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import gr.thmmy.mthmmy.R; +import gr.thmmy.mthmmy.activities.board.BoardActivity; +import gr.thmmy.mthmmy.activities.profile.ProfileActivity; +import gr.thmmy.mthmmy.activities.topic.TopicActivity; +import gr.thmmy.mthmmy.model.Shout; +import gr.thmmy.mthmmy.model.ThmmyPage; +import gr.thmmy.mthmmy.utils.CustomRecyclerView; + +import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; +import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; + +public class ShoutAdapter extends CustomRecyclerView.Adapter { + private Context context; + private Shout[] shouts; + + public ShoutAdapter(Context context, Shout[] shouts) { + this.context = context; + this.shouts = shouts; + } + + public void setShouts(Shout[] shouts) { + this.shouts = shouts; + } + + @NonNull + @Override + public ShoutViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.fragment_shoutbox_shout_row, parent, false); + return new ShoutViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull ShoutViewHolder holder, int position) { + Shout currentShout = shouts[position]; + holder.author.setText(currentShout.getShouter()); + if (currentShout.isMemberOfTheMonth()) holder.author.setTextColor(context.getResources().getColor(R.color.member_of_the_month)); + else holder.author.setTextColor(context.getResources().getColor(R.color.accent)); + holder.author.setOnClickListener(view -> { + Intent intent = new Intent(context, ProfileActivity.class); + Bundle extras = new Bundle(); + extras.putString(BUNDLE_PROFILE_URL, shouts[holder.getAdapterPosition()].getShouterProfileURL()); + extras.putString(BUNDLE_PROFILE_THUMBNAIL_URL, ""); + extras.putString(BUNDLE_PROFILE_USERNAME, ""); + intent.putExtras(extras); + intent.setFlags(FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + }); + holder.dateTime.setText(currentShout.getDate()); + holder.shoutContent.setClickable(true); + holder.shoutContent.setWebViewClient(new LinkLauncher()); + holder.shoutContent.loadDataWithBaseURL("file:///android_asset/", currentShout.getShout(), + "text/html", "UTF-8", null); + } + + @Override + public int getItemCount() { + return shouts.length; + } + + static class ShoutViewHolder extends CustomRecyclerView.ViewHolder { + + TextView author, dateTime; + WebView shoutContent; + + ShoutViewHolder(@NonNull View itemView) { + super(itemView); + + author = itemView.findViewById(R.id.author_textview); + dateTime = itemView.findViewById(R.id.date_time_textview); + shoutContent = itemView.findViewById(R.id.shout_content); + } + } + + class LinkLauncher extends WebViewClient { + + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + @Override + public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { + final Uri uri = request.getUrl(); + return handleUri(uri); + } + + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + final Uri uri = Uri.parse(url); + return handleUri(uri); + } + + private boolean handleUri(Uri uri) { + final String uriString = uri.toString(); + + ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory(uri); + if (target.is(ThmmyPage.PageCategory.TOPIC)) { + //This url points to a topic + Intent intent = new Intent(context, TopicActivity.class); + Bundle extras = new Bundle(); + extras.putString(BUNDLE_TOPIC_URL, uriString); + intent.putExtras(extras); + intent.setFlags(FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + return true; + } else if (target.is(ThmmyPage.PageCategory.BOARD)) { + Intent intent = new Intent(context, BoardActivity.class); + Bundle extras = new Bundle(); + extras.putString(BUNDLE_BOARD_URL, uriString); + extras.putString(BUNDLE_BOARD_TITLE, ""); + intent.putExtras(extras); + intent.setFlags(FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + return true; + } else if (target.is(ThmmyPage.PageCategory.PROFILE)) { + Intent intent = new Intent(context, ProfileActivity.class); + Bundle extras = new Bundle(); + extras.putString(BUNDLE_PROFILE_URL, uriString); + extras.putString(BUNDLE_PROFILE_THUMBNAIL_URL, ""); + extras.putString(BUNDLE_PROFILE_USERNAME, ""); + intent.putExtras(extras); + intent.setFlags(FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + return true; + } + + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + intent.setFlags(FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + + //Method always returns true as no url should be loaded in the WebViews + return true; + } + } +} diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxActivity.java new file mode 100644 index 00000000..fffc8079 --- /dev/null +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxActivity.java @@ -0,0 +1,39 @@ +package gr.thmmy.mthmmy.activities.shoutbox; + +import android.os.Bundle; + +import gr.thmmy.mthmmy.R; +import gr.thmmy.mthmmy.base.BaseActivity; + +public class ShoutboxActivity extends BaseActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_shoutbox); + + //Initialize toolbar + toolbar = findViewById(R.id.toolbar); + toolbar.setTitle("Shoutbox"); + setSupportActionBar(toolbar); + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayShowHomeEnabled(true); + } + + createDrawer(); + drawer.setSelection(SHOUTBOX_ID); + + if (savedInstanceState == null) { + getSupportFragmentManager().beginTransaction() + .replace(R.id.container, ShoutboxFragment.newInstance()) + .commitNow(); + } + } + + @Override + protected void onResume() { + drawer.setSelection(SHOUTBOX_ID); + super.onResume(); + } +} diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java new file mode 100644 index 00000000..22d3dbf3 --- /dev/null +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java @@ -0,0 +1,182 @@ +package gr.thmmy.mthmmy.activities.shoutbox; + +import android.app.Activity; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.view.inputmethod.InputConnection; +import android.view.inputmethod.InputMethodManager; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.lifecycle.ViewModelProviders; +import androidx.recyclerview.widget.LinearLayoutManager; +import gr.thmmy.mthmmy.R; +import gr.thmmy.mthmmy.editorview.EditorView; +import gr.thmmy.mthmmy.editorview.EmojiKeyboard; +import gr.thmmy.mthmmy.model.Shout; +import gr.thmmy.mthmmy.model.Shoutbox; +import gr.thmmy.mthmmy.session.SessionManager; +import gr.thmmy.mthmmy.utils.CustomRecyclerView; +import gr.thmmy.mthmmy.utils.NetworkResultCodes; +import gr.thmmy.mthmmy.viewmodel.ShoutboxViewModel; +import me.zhanghai.android.materialprogressbar.MaterialProgressBar; +import timber.log.Timber; + +public class ShoutboxFragment extends Fragment implements EmojiKeyboard.EmojiKeyboardOwner { + + private MaterialProgressBar progressBar; + private ShoutboxTask shoutboxTask; + private ShoutAdapter shoutAdapter; + private EmojiKeyboard emojiKeyboard; + private EditorView editorView; + + private ShoutboxViewModel shoutboxViewModel; + + public static ShoutboxFragment newInstance() { + return new ShoutboxFragment(); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + final View rootView = inflater.inflate(R.layout.fragment_shoutbox, container, false); + setHasOptionsMenu(true); + + progressBar = rootView.findViewById(R.id.progressBar); + CustomRecyclerView recyclerView = rootView.findViewById(R.id.shoutbox_recyclerview); + shoutAdapter = new ShoutAdapter(getContext(), new Shout[0]); + recyclerView.setAdapter(shoutAdapter); + LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); + layoutManager.setReverseLayout(true); + recyclerView.setLayoutManager(layoutManager); + recyclerView.setOnTouchListener((view, motionEvent) -> { + editorView.hideMarkdown(); + InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Activity.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(editorView.getWindowToken(), 0); + return false; + }); + + emojiKeyboard = rootView.findViewById(R.id.emoji_keyboard); + editorView = rootView.findViewById(R.id.edior_view); + editorView.setEmojiKeyboardOwner(this); + InputConnection ic = editorView.getInputConnection(); + setEmojiKeyboardInputConnection(ic); + editorView.setOnSubmitListener(view -> { + if (shoutboxViewModel.getShoutboxMutableLiveData().getValue() == null) return; + if (editorView.getText().toString().isEmpty()) { + editorView.setError("Required"); + return; + } + shoutboxViewModel.sendShout(editorView.getText().toString()); + }); + editorView.hideMarkdown(); + editorView.setOnTouchListener((view, motionEvent) -> { + editorView.showMarkdown(); + return false; + }); + editorView.setMarkdownVisible(false); + editorView.showMarkdownOnfocus(); + + return rootView; + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + inflater.inflate(R.menu.shoutbox_menu, menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == R.id.menu_refresh) { + shoutboxViewModel.loadShoutbox(); + return true; + } else { + return false; + } + } + + @Override + public void onActivityCreated(@Nullable Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + shoutboxViewModel = ViewModelProviders.of(this).get(ShoutboxViewModel.class); + shoutboxViewModel.getShoutboxMutableLiveData().observe(this, shoutbox -> { + if (shoutbox != null) { + Timber.i("Shoutbox loaded successfully"); + shoutAdapter.setShouts(shoutbox.getShouts()); + shoutAdapter.notifyDataSetChanged(); + } + }); + shoutboxViewModel.setOnShoutboxTaskStarted(this::onShoutboxTaskSarted); + shoutboxViewModel.setOnShoutboxTaskFinished(this::onShoutboxTaskFinished); + shoutboxViewModel.setOnSendShoutTaskStarted(this::onSendShoutTaskStarted); + shoutboxViewModel.setOnSendShoutTaskFinished(this::onSendShoutTaskFinished); + + shoutboxViewModel.loadShoutbox(); + } + + private void onShoutboxTaskSarted() { + Timber.i("Starting shoutbox task..."); + progressBar.setVisibility(View.VISIBLE); + } + + private void onSendShoutTaskStarted() { + Timber.i("Start sending a shout..."); + editorView.setAlpha(0.5f); + editorView.setEnabled(false); + setEmojiKeyboardVisible(false); + progressBar.setVisibility(View.VISIBLE); + } + + private void onSendShoutTaskFinished(int resultCode, Void ignored) { + editorView.setAlpha(1f); + editorView.setEnabled(true); + progressBar.setVisibility(View.INVISIBLE); + if (resultCode == NetworkResultCodes.SUCCESSFUL) { + Timber.i("Shout was sent successfully"); + editorView.getEditText().getText().clear(); + shoutboxTask = new ShoutboxTask(ShoutboxFragment.this::onShoutboxTaskSarted, ShoutboxFragment.this::onShoutboxTaskFinished); + shoutboxTask.execute(SessionManager.shoutboxUrl.toString()); + } else if (resultCode == NetworkResultCodes.NETWORK_ERROR) { + Timber.w("Failed to send shout"); + Toast.makeText(getContext(), "NetworkError", Toast.LENGTH_SHORT).show(); + } + } + + private void onShoutboxTaskFinished(int resultCode, Shoutbox shoutbox) { + progressBar.setVisibility(View.INVISIBLE); + if (resultCode == NetworkResultCodes.SUCCESSFUL) { + shoutboxViewModel.setShoutbox(shoutbox); + if (shoutbox.getShoutSend() != null) + editorView.setVisibility(View.VISIBLE); + } else if (resultCode == NetworkResultCodes.NETWORK_ERROR) { + Timber.w("Failed to retreive shoutbox due to network error"); + Toast.makeText(getContext(), "NetworkError", Toast.LENGTH_SHORT).show(); + } else { + Timber.wtf("Failed to retreive shoutbox due to unknown error"); + Toast.makeText(getContext(), "Failed to retrieve shoutbox, please contact mthmmy developer team", Toast.LENGTH_LONG).show(); + } + } + + @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); + } +} diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxTask.java new file mode 100644 index 00000000..59797774 --- /dev/null +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxTask.java @@ -0,0 +1,61 @@ +package gr.thmmy.mthmmy.activities.shoutbox; + +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; + +import java.util.ArrayList; + +import gr.thmmy.mthmmy.model.Shout; +import gr.thmmy.mthmmy.model.Shoutbox; +import gr.thmmy.mthmmy.utils.NetworkResultCodes; +import gr.thmmy.mthmmy.utils.parsing.NewParseTask; +import gr.thmmy.mthmmy.utils.parsing.ParseException; +import gr.thmmy.mthmmy.utils.parsing.ParseHelpers; +import okhttp3.Response; + +public class ShoutboxTask extends NewParseTask { + + public ShoutboxTask(OnTaskStartedListener onTaskStartedListener, OnNetworkTaskFinishedListener onParseTaskFinishedListener) { + super(onTaskStartedListener, onParseTaskFinishedListener); + } + + @Override + protected Shoutbox parse(Document document, Response response) throws ParseException { + // fragment_shoutbox_shout_row container: document.select("div[class=smalltext]" && div.text().contains("Τελευταίες 75 φωνές:") η στα αγγλικα + Element shoutboxContainer = document.select("table.windowbg").first(); + ArrayList shouts = new ArrayList<>(); + for (Element shout : shoutboxContainer.select("div[style=margin: 4px;]")) { + Element user = shout.child(0); + Element link = user.select("a").first(); + String profileUrl = link.attr("href"); + String profileName = link.text(); + boolean memberOfTheMonth = link.attr("style").contains("#EA00FF"); + + Element date = shout.child(1); + String dateString = date.text(); + + Element content = shout.child(2); + content.removeAttr("style"); + String shoutContent = "" + + ParseHelpers.youtubeEmbeddedFix(content); + shouts.add(new Shout(profileName, profileUrl, dateString, shoutContent, memberOfTheMonth)); + } + + Element shoutboxForm = document.select("form[name=tp-shoutbox]").first(); + String formUrl = shoutboxForm.attr("action"); + String sc = shoutboxForm.select("input[name=sc]").first().attr("value"); + String shoutName = shoutboxForm.select("input[name=tp-shout-name]").first().attr("value"); + // TODO: make shout send nullable and disable shouting + Element shoutSendInput = shoutboxForm.select("input[name=shout_send]").first(); + String shoutSend = null; + if (shoutSendInput != null) + shoutSend = shoutSendInput.attr("value"); + String shoutUrl = shoutboxForm.select("input[name=tp-shout-url]").first().attr("value"); + return new Shoutbox(shouts.toArray(new Shout[0]), sc, formUrl, shoutName, shoutSend, shoutUrl); + } + + @Override + protected int getResultCode(Response response, Shoutbox data) { + return NetworkResultCodes.SUCCESSFUL; + } +} 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 4d03649d..ae692219 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 @@ -2,7 +2,7 @@ package gr.thmmy.mthmmy.activities.topic; import android.annotation.SuppressLint; import android.app.NotificationManager; -import android.arch.lifecycle.ViewModelProviders; +import androidx.lifecycle.ViewModelProviders; import android.content.Context; import android.content.Intent; import android.graphics.Rect; @@ -10,12 +10,12 @@ import android.net.Uri; import android.os.Build; 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.res.ResourcesCompat; -import android.support.v7.app.AlertDialog; -import android.support.v7.app.AppCompatDelegate; -import android.support.v7.widget.RecyclerView; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.snackbar.Snackbar; +import androidx.core.content.res.ResourcesCompat; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatDelegate; +import androidx.recyclerview.widget.RecyclerView; import android.text.Spannable; import android.text.SpannableString; import android.text.SpannableStringBuilder; 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 bfc26961..1c32ce2d 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 @@ -2,7 +2,7 @@ package gr.thmmy.mthmmy.activities.topic; import android.annotation.SuppressLint; import android.annotation.TargetApi; -import android.arch.lifecycle.ViewModelProviders; +import androidx.lifecycle.ViewModelProviders; import android.content.Context; import android.content.Intent; import android.graphics.Color; @@ -11,12 +11,13 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.content.res.ResourcesCompat; -import android.support.v7.app.AlertDialog; -import android.support.v7.content.res.AppCompatResources; -import android.support.v7.widget.AppCompatButton; -import android.support.v7.widget.RecyclerView; +import androidx.annotation.NonNull; +import androidx.core.content.res.ResourcesCompat; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.content.res.AppCompatResources; +import androidx.appcompat.widget.AppCompatButton; +import androidx.recyclerview.widget.RecyclerView; + import android.text.Html; import android.text.InputType; import android.text.TextUtils; @@ -81,7 +82,7 @@ import static gr.thmmy.mthmmy.activities.topic.TopicParser.USER_COLOR_YELLOW; import static gr.thmmy.mthmmy.base.BaseActivity.getSessionManager; /** - * Custom {@link android.support.v7.widget.RecyclerView.Adapter} used for topics. + * Custom {@link RecyclerView.Adapter} used for topics. */ class TopicAdapter extends RecyclerView.Adapter { /** diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java index ce93b6b1..a7d7dc22 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java @@ -11,11 +11,11 @@ import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.provider.MediaStore; -import android.support.design.widget.FloatingActionButton; -import android.support.v7.content.res.AppCompatResources; -import android.support.v7.preference.PreferenceManager; -import android.support.v7.widget.AppCompatButton; -import android.support.v7.widget.AppCompatTextView; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import androidx.appcompat.content.res.AppCompatResources; +import androidx.preference.PreferenceManager; +import androidx.appcompat.widget.AppCompatButton; +import androidx.appcompat.widget.AppCompatTextView; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadFieldsBuilderActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadFieldsBuilderActivity.java index c5ab4829..fffb5064 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadFieldsBuilderActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadFieldsBuilderActivity.java @@ -3,9 +3,9 @@ package gr.thmmy.mthmmy.activities.upload; import android.app.Activity; import android.content.Intent; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; import android.view.View; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadsHelper.java b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadsHelper.java index 9529d402..0da38a6e 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadsHelper.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadsHelper.java @@ -10,8 +10,8 @@ import android.media.ExifInterface; import android.net.Uri; import android.os.Environment; import android.provider.OpenableColumns; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import android.widget.Toast; import java.io.BufferedInputStream; 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 61b6e3ae..485596fe 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java @@ -2,7 +2,6 @@ package gr.thmmy.mthmmy.base; import android.Manifest; import android.app.ProgressDialog; -import android.arch.lifecycle.ViewModelProviders; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -11,14 +10,6 @@ import android.net.Uri; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.design.widget.BottomSheetDialog; -import android.support.v4.content.ContextCompat; -import android.support.v4.content.FileProvider; -import android.support.v7.app.AlertDialog; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.preference.PreferenceManager; -import android.support.v7.widget.Toolbar; import android.view.MenuItem; import android.view.View; import android.widget.Button; @@ -26,6 +17,7 @@ import android.widget.ImageButton; import android.widget.TextView; import android.widget.Toast; +import com.google.android.material.bottomsheet.BottomSheetDialog; import com.google.firebase.messaging.FirebaseMessaging; import com.mikepenz.fontawesome_typeface_library.FontAwesome; import com.mikepenz.google_material_typeface_library.GoogleMaterial; @@ -43,6 +35,14 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.core.content.ContextCompat; +import androidx.core.content.FileProvider; +import androidx.lifecycle.ViewModelProviders; +import androidx.preference.PreferenceManager; import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.activities.AboutActivity; import gr.thmmy.mthmmy.activities.LoginActivity; @@ -51,6 +51,7 @@ 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.activities.shoutbox.ShoutboxActivity; import gr.thmmy.mthmmy.model.Bookmark; import gr.thmmy.mthmmy.model.ThmmyFile; import gr.thmmy.mthmmy.services.DownloadHelper; @@ -156,6 +157,7 @@ public abstract class BaseActivity extends AppCompatActivity { protected static final int LOG_ID = 4; protected static final int ABOUT_ID = 5; protected static final int SETTINGS_ID = 6; + protected static final int SHOUTBOX_ID = 7; private AccountHeader accountHeader; private ProfileDrawerItem profileDrawerItem; @@ -170,7 +172,7 @@ public abstract class BaseActivity extends AppCompatActivity { final int selectedPrimaryColor = ContextCompat.getColor(this, R.color.primary_dark); final int selectedSecondaryColor = ContextCompat.getColor(this, R.color.accent); - PrimaryDrawerItem homeItem, bookmarksItem, settingsItem, aboutItem; + PrimaryDrawerItem homeItem, bookmarksItem, settingsItem, aboutItem, shoutboxItem; IconicsDrawable homeIcon, homeIconSelected, downloadsIcon, downloadsIconSelected, uploadIcon, uploadIconSelected, settingsIcon, settingsIconSelected, bookmarksIcon, bookmarksIconSelected, aboutIcon, aboutIconSelected; @@ -258,6 +260,16 @@ public abstract class BaseActivity extends AppCompatActivity { // .withIcon(uploadIcon) // .withSelectedIcon(uploadIconSelected); + shoutboxItem = new PrimaryDrawerItem() + .withTextColor(primaryColor) + .withSelectedColor(selectedPrimaryColor) + .withSelectedTextColor(selectedSecondaryColor) + .withIdentifier(SHOUTBOX_ID) + .withName(R.string.shoutbox) + .withIcon(R.drawable.ic_announcement) + .withIconColor(primaryColor) + .withSelectedIconColor(selectedSecondaryColor); + if (sessionManager.isLoggedIn()) //When logged in { loginLogoutItem = new PrimaryDrawerItem() @@ -346,6 +358,11 @@ public abstract class BaseActivity extends AppCompatActivity { Intent intent = new Intent(BaseActivity.this, MainActivity.class); startActivity(intent); } + } else if (drawerItem.equals(SHOUTBOX_ID)) { + if (!(BaseActivity.this instanceof ShoutboxActivity)) { + Intent intent = new Intent(BaseActivity.this, ShoutboxActivity.class); + startActivity(intent); + } } else if (drawerItem.equals(DOWNLOADS_ID)) { if (!(BaseActivity.this instanceof DownloadsActivity)) { Intent intent = new Intent(BaseActivity.this, DownloadsActivity.class); @@ -390,9 +407,9 @@ public abstract class BaseActivity extends AppCompatActivity { }); if (sessionManager.isLoggedIn()) - drawerBuilder.addDrawerItems(homeItem, bookmarksItem, downloadsItem, settingsItem, loginLogoutItem, aboutItem); + drawerBuilder.addDrawerItems(homeItem, shoutboxItem, bookmarksItem, downloadsItem, settingsItem, loginLogoutItem, aboutItem); else - drawerBuilder.addDrawerItems(homeItem, bookmarksItem, settingsItem, loginLogoutItem, aboutItem); + drawerBuilder.addDrawerItems(homeItem, shoutboxItem, bookmarksItem, settingsItem, loginLogoutItem, aboutItem); drawer = drawerBuilder.build(); 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 e1a33b30..a6cf97eb 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java @@ -6,8 +6,7 @@ import android.content.SharedPreferences; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; -import android.preference.PreferenceManager; -import android.support.v4.content.ContextCompat; +import androidx.core.content.ContextCompat; import android.util.DisplayMetrics; import android.widget.ImageView; @@ -30,6 +29,7 @@ import net.gotev.uploadservice.okhttp.OkHttpStack; import java.util.Objects; import java.util.concurrent.TimeUnit; +import androidx.preference.PreferenceManager; import gr.thmmy.mthmmy.BuildConfig; import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.session.SessionManager; diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java index d6f69297..960834e0 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java @@ -2,8 +2,8 @@ package gr.thmmy.mthmmy.base; import android.content.Context; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; import okhttp3.OkHttpClient; 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 fb82337a..5adf4aa7 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java +++ b/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java @@ -1,23 +1,20 @@ package gr.thmmy.mthmmy.editorview; +import android.animation.Animator; import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; -import android.support.annotation.Nullable; -import android.support.design.widget.TextInputEditText; -import android.support.design.widget.TextInputLayout; -import android.support.v7.widget.AppCompatImageButton; -import android.support.v7.widget.GridLayoutManager; -import android.support.v7.widget.RecyclerView; import android.text.Editable; import android.text.TextUtils; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.SparseArray; import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewPropertyAnimator; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; @@ -27,12 +24,21 @@ import android.widget.PopupWindow; import android.widget.ScrollView; import android.widget.TextView; +import com.google.android.material.textfield.TextInputEditText; +import com.google.android.material.textfield.TextInputLayout; + import java.util.Objects; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatImageButton; +import androidx.interpolator.view.animation.FastOutSlowInInterpolator; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import gr.thmmy.mthmmy.R; public class EditorView extends LinearLayout implements EmojiInputField { + private static final int ANIMATION_DURATION = 100; private SparseArray colors = new SparseArray<>(); private TextInputLayout edittextWrapper; @@ -40,6 +46,7 @@ public class EditorView extends LinearLayout implements EmojiInputField { private AppCompatImageButton emojiButton; private AppCompatImageButton submitButton; private IEmojiKeyboard emojiKeyboard; + private RecyclerView formatButtonsRecyclerview; public EditorView(Context context) { super(context); @@ -61,6 +68,7 @@ public class EditorView extends LinearLayout implements EmojiInputField { LayoutInflater.from(context).inflate(R.layout.editor_view, this, true); setOrientation(VERTICAL); + formatButtonsRecyclerview = findViewById(R.id.buttons_recyclerview); edittextWrapper = findViewById(R.id.editor_edittext_wrapper); editText = findViewById(R.id.editor_edittext); editText.setOnFocusChangeListener((view, focused) -> { @@ -79,6 +87,7 @@ public class EditorView extends LinearLayout implements EmojiInputField { requestEditTextFocus(); } }); + editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.EditorView, 0, 0); try { @@ -110,7 +119,6 @@ public class EditorView extends LinearLayout implements EmojiInputField { colors.append(R.id.maroon, "maroon"); colors.append(R.id.lime_green, "limegreen"); - RecyclerView formatButtonsRecyclerview = findViewById(R.id.buttons_recyclerview); DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); float itemWidth = getResources().getDimension(R.dimen.editor_format_button_size) + getResources().getDimension(R.dimen.editor_format_button_margin_between); @@ -300,6 +308,93 @@ public class EditorView extends LinearLayout implements EmojiInputField { this.emojiKeyboard = emojiKeyboard; } + public void setMarkdownVisible(boolean visible) { + formatButtonsRecyclerview.setVisibility(visible ? VISIBLE : GONE); + } + + public void showMarkdownOnfocus() { + edittextWrapper.setOnClickListener(view -> { + showMarkdown(); + }); + editText.setOnClickListener(view -> { + showMarkdown(); + }); + edittextWrapper.setOnFocusChangeListener((view, b) -> { + if (b) showMarkdown(); + else hideMarkdown(); + }); + editText.setOnFocusChangeListener((view, b) -> { + if (b) showMarkdown(); + else hideMarkdown(); + }); + } + + /** + * Animates the hiding of the markdown options. + * + */ + public void hideMarkdown() { + if (formatButtonsRecyclerview.getVisibility() == GONE) return; + ViewPropertyAnimator animator = formatButtonsRecyclerview.animate() + .translationY(formatButtonsRecyclerview.getHeight()) + .setInterpolator(new FastOutSlowInInterpolator()) + .setDuration(ANIMATION_DURATION); + + animator.setListener(new Animator.AnimatorListener() { + @Override + public void onAnimationStart(Animator animator) { + } + + @Override + public void onAnimationEnd(Animator animator) { + formatButtonsRecyclerview.setVisibility(View.GONE); + } + + @Override + public void onAnimationCancel(Animator animator) { + } + + @Override + public void onAnimationRepeat(Animator animator) { + } + }); + + animator.start(); + } + + /** + * Animates the showing of the markdown options. + * + */ + public void showMarkdown() { + if (formatButtonsRecyclerview.getVisibility() == VISIBLE) return; + ViewPropertyAnimator animator = formatButtonsRecyclerview.animate() + .translationY(0) + .setInterpolator(new FastOutSlowInInterpolator()) + .setDuration(ANIMATION_DURATION); + + animator.setListener(new Animator.AnimatorListener() { + @Override + public void onAnimationStart(Animator animator) { + formatButtonsRecyclerview.setVisibility(View.VISIBLE); + } + + @Override + public void onAnimationEnd(Animator animator) { + } + + @Override + public void onAnimationCancel(Animator animator) { + } + + @Override + public void onAnimationRepeat(Animator animator) { + } + }); + + animator.start(); + } + public TextInputEditText getEditText() { return editText; } diff --git a/app/src/main/java/gr/thmmy/mthmmy/editorview/EmojiKeyboard.java b/app/src/main/java/gr/thmmy/mthmmy/editorview/EmojiKeyboard.java index 856498ec..717aedf0 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/editorview/EmojiKeyboard.java +++ b/app/src/main/java/gr/thmmy/mthmmy/editorview/EmojiKeyboard.java @@ -2,9 +2,9 @@ package gr.thmmy.mthmmy.editorview; import android.content.Context; import android.os.Handler; -import android.support.v7.widget.AppCompatImageButton; -import android.support.v7.widget.GridLayoutManager; -import android.support.v7.widget.RecyclerView; +import androidx.appcompat.widget.AppCompatImageButton; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.text.TextUtils; import android.util.AttributeSet; import android.view.LayoutInflater; diff --git a/app/src/main/java/gr/thmmy/mthmmy/editorview/EmojiKeyboardAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/editorview/EmojiKeyboardAdapter.java index 40fe4db5..39e81c06 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/editorview/EmojiKeyboardAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/editorview/EmojiKeyboardAdapter.java @@ -1,9 +1,9 @@ package gr.thmmy.mthmmy.editorview; import android.graphics.drawable.AnimationDrawable; -import android.support.annotation.NonNull; -import android.support.v7.widget.AppCompatImageButton; -import android.support.v7.widget.RecyclerView; +import androidx.annotation.NonNull; +import androidx.appcompat.widget.AppCompatImageButton; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/gr/thmmy/mthmmy/editorview/FormatButtonsAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/editorview/FormatButtonsAdapter.java index 469cf2f6..6daa6ccc 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/editorview/FormatButtonsAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/editorview/FormatButtonsAdapter.java @@ -1,8 +1,8 @@ package gr.thmmy.mthmmy.editorview; -import android.support.annotation.NonNull; -import android.support.v7.widget.AppCompatImageButton; -import android.support.v7.widget.RecyclerView; +import androidx.annotation.NonNull; +import androidx.appcompat.widget.AppCompatImageButton; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/gr/thmmy/mthmmy/model/Bookmark.java b/app/src/main/java/gr/thmmy/mthmmy/model/Bookmark.java index 1f383462..6c07448b 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/model/Bookmark.java +++ b/app/src/main/java/gr/thmmy/mthmmy/model/Bookmark.java @@ -1,7 +1,7 @@ package gr.thmmy.mthmmy.model; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import java.util.ArrayList; import java.util.Objects; diff --git a/app/src/main/java/gr/thmmy/mthmmy/model/Post.java b/app/src/main/java/gr/thmmy/mthmmy/model/Post.java index 1113ffbc..ce212d3b 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/model/Post.java +++ b/app/src/main/java/gr/thmmy/mthmmy/model/Post.java @@ -1,6 +1,6 @@ package gr.thmmy.mthmmy.model; -import android.support.annotation.Nullable; +import androidx.annotation.Nullable; import java.util.ArrayList; import java.util.Objects; diff --git a/app/src/main/java/gr/thmmy/mthmmy/model/Shout.java b/app/src/main/java/gr/thmmy/mthmmy/model/Shout.java new file mode 100644 index 00000000..98ccb535 --- /dev/null +++ b/app/src/main/java/gr/thmmy/mthmmy/model/Shout.java @@ -0,0 +1,34 @@ +package gr.thmmy.mthmmy.model; + +public class Shout { + private final String shouter, shouterProfileURL, date, shout; + private final boolean memberOfTheMonth; + + public Shout(String shouter, String shouterProfileURL, String date, String shout, boolean memberOfTheMonth) { + this.shouter = shouter; + this.shouterProfileURL = shouterProfileURL; + this.date = date; + this.shout = shout; + this.memberOfTheMonth = memberOfTheMonth; + } + + public String getShouter() { + return shouter; + } + + public String getShouterProfileURL() { + return shouterProfileURL; + } + + public String getDate() { + return date; + } + + public String getShout() { + return shout; + } + + public boolean isMemberOfTheMonth() { + return memberOfTheMonth; + } +} diff --git a/app/src/main/java/gr/thmmy/mthmmy/model/Shoutbox.java b/app/src/main/java/gr/thmmy/mthmmy/model/Shoutbox.java new file mode 100644 index 00000000..73f0cc3e --- /dev/null +++ b/app/src/main/java/gr/thmmy/mthmmy/model/Shoutbox.java @@ -0,0 +1,42 @@ +package gr.thmmy.mthmmy.model; + +import androidx.annotation.NonNull; +import timber.log.Timber; + +public class Shoutbox { + private Shout[] shouts; + private String sc, sendShoutUrl, shoutName, shoutSend, shoutUrl; + + public Shoutbox(Shout[] shouts, String sc, String sendShoutUrl, String shoutName, String shoutSend, String shoutUrl) { + this.shouts = shouts; + this.sc = sc; + this.sendShoutUrl = sendShoutUrl; + this.shoutName = shoutName; + this.shoutSend = shoutSend; + this.shoutUrl = shoutUrl; + } + + public Shout[] getShouts() { + return shouts; + } + + public String getSc() { + return sc; + } + + public String getSendShoutUrl() { + return sendShoutUrl; + } + + public String getShoutName() { + return shoutName; + } + + public String getShoutSend() { + return shoutSend; + } + + public String getShoutUrl() { + return shoutUrl; + } +} 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 39e34062..eadda267 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java +++ b/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java @@ -12,9 +12,9 @@ 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 androidx.annotation.RequiresApi; +import androidx.core.app.NotificationCompat; +import androidx.preference.PreferenceManager; import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; @@ -29,7 +29,7 @@ import gr.thmmy.mthmmy.model.Bookmark; import gr.thmmy.mthmmy.model.PostNotification; import timber.log.Timber; -import static android.support.v4.app.NotificationCompat.PRIORITY_MAX; +import static androidx.core.app.NotificationCompat.PRIORITY_MAX; import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.NOTIFICATION_LED_KEY; import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.NOTIFICATION_VIBRATION_KEY; import static gr.thmmy.mthmmy.activities.settings.SettingsFragment.SELECTED_RINGTONE; diff --git a/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java b/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java index 9168ebf3..4811195d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java +++ b/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java @@ -1,8 +1,8 @@ package gr.thmmy.mthmmy.session; import android.content.SharedPreferences; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import com.franmontiel.persistentcookiejar.PersistentCookieJar; import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor; @@ -37,6 +37,7 @@ public class SessionManager { public static final HttpUrl forumUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=forum;theme=4"); private static final HttpUrl loginUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=login2"); public static final HttpUrl unreadUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=unread;all;start=0;theme=4"); + public static final HttpUrl shoutboxUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=tpmod;sa=shoutbox;theme=4"); private static final String guestName = "Guest"; //Response Codes diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/AppCompatSpinnerWithoutDefault.java b/app/src/main/java/gr/thmmy/mthmmy/utils/AppCompatSpinnerWithoutDefault.java index 74bed048..e4848661 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/AppCompatSpinnerWithoutDefault.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/AppCompatSpinnerWithoutDefault.java @@ -2,7 +2,7 @@ package gr.thmmy.mthmmy.utils; import android.annotation.SuppressLint; import android.content.Context; -import android.support.v7.widget.AppCompatSpinner; +import androidx.appcompat.widget.AppCompatSpinner; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/CenterVerticalSpan.java b/app/src/main/java/gr/thmmy/mthmmy/utils/CenterVerticalSpan.java index 12f0a9e6..5038fe19 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/CenterVerticalSpan.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/CenterVerticalSpan.java @@ -3,7 +3,7 @@ package gr.thmmy.mthmmy.utils; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Rect; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import android.text.style.ReplacementSpan; public class CenterVerticalSpan extends ReplacementSpan { diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/CustomLinearLayoutManager.java b/app/src/main/java/gr/thmmy/mthmmy/utils/CustomLinearLayoutManager.java index 52a5302e..8e8cf800 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/CustomLinearLayoutManager.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/CustomLinearLayoutManager.java @@ -1,8 +1,8 @@ package gr.thmmy.mthmmy.utils; import android.content.Context; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import timber.log.Timber; diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/CustomRecyclerView.java b/app/src/main/java/gr/thmmy/mthmmy/utils/CustomRecyclerView.java index af29a9bd..828b7dab 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/CustomRecyclerView.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/CustomRecyclerView.java @@ -1,9 +1,9 @@ package gr.thmmy.mthmmy.utils; import android.content.Context; -import android.support.annotation.Nullable; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.util.AttributeSet; //Custom RecyclerView, so EdgeEffect and SwipeRefresh both work diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/FileUtils.java b/app/src/main/java/gr/thmmy/mthmmy/utils/FileUtils.java index 9f2d4757..b9121a7b 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/FileUtils.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/FileUtils.java @@ -1,6 +1,6 @@ package gr.thmmy.mthmmy.utils; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import android.webkit.MimeTypeMap; import java.io.File; diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareFABBehavior.java b/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareFABBehavior.java index 9f843c20..d832c6f2 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareFABBehavior.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareFABBehavior.java @@ -1,11 +1,11 @@ package gr.thmmy.mthmmy.utils; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.design.widget.CoordinatorLayout; -import android.support.design.widget.FloatingActionButton; -import android.support.design.widget.Snackbar; -import android.support.v4.view.ViewCompat; +import androidx.annotation.NonNull; +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.snackbar.Snackbar; +import androidx.core.view.ViewCompat; import android.util.AttributeSet; import android.view.View; diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareLinearBehavior.java b/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareLinearBehavior.java index 2f9fb5b9..c5dfa227 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareLinearBehavior.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareLinearBehavior.java @@ -2,11 +2,11 @@ package gr.thmmy.mthmmy.utils; import android.animation.Animator; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.design.widget.CoordinatorLayout; -import android.support.design.widget.Snackbar; -import android.support.v4.view.ViewCompat; -import android.support.v4.view.animation.FastOutSlowInInterpolator; +import androidx.annotation.NonNull; +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import com.google.android.material.snackbar.Snackbar; +import androidx.core.view.ViewCompat; +import androidx.interpolator.view.animation.FastOutSlowInInterpolator; import android.util.AttributeSet; import android.view.View; import android.view.ViewPropertyAnimator; diff --git a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/BaseViewModel.java b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/BaseViewModel.java index 53ed84ef..5787b36d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/BaseViewModel.java +++ b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/BaseViewModel.java @@ -1,8 +1,8 @@ package gr.thmmy.mthmmy.viewmodel; -import android.arch.lifecycle.LiveData; -import android.arch.lifecycle.MutableLiveData; -import android.arch.lifecycle.ViewModel; +import androidx.lifecycle.LiveData; +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; import gr.thmmy.mthmmy.model.Bookmark; diff --git a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/ShoutboxViewModel.java b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/ShoutboxViewModel.java new file mode 100644 index 00000000..5aa92f65 --- /dev/null +++ b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/ShoutboxViewModel.java @@ -0,0 +1,58 @@ +package gr.thmmy.mthmmy.viewmodel; + +import android.os.AsyncTask; + +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; +import gr.thmmy.mthmmy.activities.shoutbox.SendShoutTask; +import gr.thmmy.mthmmy.activities.shoutbox.ShoutboxTask; +import gr.thmmy.mthmmy.model.Shoutbox; +import gr.thmmy.mthmmy.session.SessionManager; + +public class ShoutboxViewModel extends ViewModel { + private MutableLiveData shoutboxMutableLiveData = new MutableLiveData<>(); + private ShoutboxTask shoutboxTask; + private ShoutboxTask.OnTaskStartedListener onShoutboxTaskStarted; + private ShoutboxTask.OnNetworkTaskFinishedListener onShoutboxTaskFinished; + private SendShoutTask.OnTaskStartedListener onSendShoutTaskStarted; + private SendShoutTask.OnNetworkTaskFinishedListener onSendShoutTaskFinished; + + public void loadShoutbox() { + if (shoutboxTask != null && shoutboxTask.getStatus() == AsyncTask.Status.RUNNING) + shoutboxTask.cancel(true); + shoutboxTask = new ShoutboxTask(onShoutboxTaskStarted, onShoutboxTaskFinished); + shoutboxTask.execute(SessionManager.shoutboxUrl.toString()); + } + + public void sendShout(String shout) { + if (shoutboxMutableLiveData.getValue() == null) throw new IllegalStateException("Shoutbox task has not finished yet!"); + Shoutbox shoutbox = shoutboxMutableLiveData.getValue(); + new SendShoutTask(onSendShoutTaskStarted, onSendShoutTaskFinished) + .execute(shoutbox.getSendShoutUrl(), shout, shoutbox.getSc(), + shoutbox.getShoutName(), shoutbox.getShoutSend(), shoutbox.getShoutUrl()); + } + + public void setShoutbox(Shoutbox shoutbox) { + shoutboxMutableLiveData.setValue(shoutbox); + } + + public MutableLiveData getShoutboxMutableLiveData() { + return shoutboxMutableLiveData; + } + + public void setOnSendShoutTaskFinished(SendShoutTask.OnNetworkTaskFinishedListener onSendShoutTaskFinished) { + this.onSendShoutTaskFinished = onSendShoutTaskFinished; + } + + public void setOnSendShoutTaskStarted(SendShoutTask.OnTaskStartedListener onSendShoutTaskStarted) { + this.onSendShoutTaskStarted = onSendShoutTaskStarted; + } + + public void setOnShoutboxTaskFinished(ShoutboxTask.OnNetworkTaskFinishedListener onShoutboxTaskFinished) { + this.onShoutboxTaskFinished = onShoutboxTaskFinished; + } + + public void setOnShoutboxTaskStarted(ShoutboxTask.OnTaskStartedListener onShoutboxTaskStarted) { + this.onShoutboxTaskStarted = onShoutboxTaskStarted; + } +} diff --git a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java index 530cdc9d..200ac80d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java +++ b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java @@ -1,6 +1,6 @@ package gr.thmmy.mthmmy.viewmodel; -import android.arch.lifecycle.MutableLiveData; +import androidx.lifecycle.MutableLiveData; import android.content.Context; import android.content.SharedPreferences; import android.os.AsyncTask; diff --git a/app/src/main/res/color/activity_main_tabs_selector.xml b/app/src/main/res/color/activity_main_tabs_selector.xml new file mode 100644 index 00000000..c1433b72 --- /dev/null +++ b/app/src/main/res/color/activity_main_tabs_selector.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_access_time_white_24dp.xml b/app/src/main/res/drawable/ic_access_time_white_24dp.xml new file mode 100644 index 00000000..87e8fdaa --- /dev/null +++ b/app/src/main/res/drawable/ic_access_time_white_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_announcement.xml b/app/src/main/res/drawable/ic_announcement.xml new file mode 100644 index 00000000..8a402416 --- /dev/null +++ b/app/src/main/res/drawable/ic_announcement.xml @@ -0,0 +1,7 @@ + + + diff --git a/app/src/main/res/drawable/ic_fiber_new_white_24dp.xml b/app/src/main/res/drawable/ic_fiber_new_white_24dp.xml new file mode 100644 index 00000000..be966efc --- /dev/null +++ b/app/src/main/res/drawable/ic_fiber_new_white_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_forum_white_24dp.xml b/app/src/main/res/drawable/ic_forum_white_24dp.xml new file mode 100644 index 00000000..55b04ab1 --- /dev/null +++ b/app/src/main/res/drawable/ic_forum_white_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_refresh_white_24dp.xml b/app/src/main/res/drawable/ic_refresh_white_24dp.xml new file mode 100644 index 00000000..cc2d1e04 --- /dev/null +++ b/app/src/main/res/drawable/ic_refresh_white_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout-v21/activity_profile.xml b/app/src/main/res/layout-v21/activity_profile.xml index 22f819cc..85b16af6 100644 --- a/app/src/main/res/layout-v21/activity_profile.xml +++ b/app/src/main/res/layout-v21/activity_profile.xml @@ -1,5 +1,5 @@ - - - - + - - + - - + - - - + diff --git a/app/src/main/res/layout-v21/activity_topic_post_row.xml b/app/src/main/res/layout-v21/activity_topic_post_row.xml index ad66a8a7..a71a353d 100644 --- a/app/src/main/res/layout-v21/activity_topic_post_row.xml +++ b/app/src/main/res/layout-v21/activity_topic_post_row.xml @@ -9,7 +9,7 @@ android:paddingStart="4dp" tools:ignore="SmallSp"> - - + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index c4ecc43d..d76174db 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -1,5 +1,5 @@ - - - - + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_board.xml b/app/src/main/res/layout/activity_board.xml index 517c48a3..d538bdf7 100644 --- a/app/src/main/res/layout/activity_board.xml +++ b/app/src/main/res/layout/activity_board.xml @@ -1,5 +1,5 @@ - - - - - + + - - + - - + diff --git a/app/src/main/res/layout/activity_bookmark.xml b/app/src/main/res/layout/activity_bookmark.xml index d35191dd..8aeccae1 100644 --- a/app/src/main/res/layout/activity_bookmark.xml +++ b/app/src/main/res/layout/activity_bookmark.xml @@ -1,5 +1,5 @@ - - - - + - - + - - \ No newline at end of file + \ 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 60028c0c..7e6a9b40 100644 --- a/app/src/main/res/layout/activity_create_content.xml +++ b/app/src/main/res/layout/activity_create_content.xml @@ -1,5 +1,5 @@ - - - - - + + - - - + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_downloads.xml b/app/src/main/res/layout/activity_downloads.xml index 0856b9c3..0473b34f 100644 --- a/app/src/main/res/layout/activity_downloads.xml +++ b/app/src/main/res/layout/activity_downloads.xml @@ -1,5 +1,6 @@ + - - - - - + + - - + - - - - + diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 52bdc281..9ac472f0 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -41,7 +41,7 @@ android:layout_weight="0.45"/> - @@ -51,7 +51,7 @@ android:layout_height="wrap_content" android:hint="@string/hint_username" android:inputType="textPersonName"/> - + - @@ -70,7 +70,7 @@ android:layout_height="wrap_content" android:hint="@string/hint_password" android:inputType="textPassword"/> - + - - - - - - - + app:tabTextColor="@color/white" + app:tabIconTint="@color/activity_main_tabs_selector" /> + - - + diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml index dcd3770c..1c6cdb6d 100644 --- a/app/src/main/res/layout/activity_profile.xml +++ b/app/src/main/res/layout/activity_profile.xml @@ -1,5 +1,5 @@ - - - - + - - + - - + - - - + diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 76fea163..97676cc6 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1,5 +1,5 @@ - - - - + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_shoutbox.xml b/app/src/main/res/layout/activity_shoutbox.xml new file mode 100644 index 00000000..e98e8fd6 --- /dev/null +++ b/app/src/main/res/layout/activity_shoutbox.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_topic.xml b/app/src/main/res/layout/activity_topic.xml index ac653015..aaa13e4b 100644 --- a/app/src/main/res/layout/activity_topic.xml +++ b/app/src/main/res/layout/activity_topic.xml @@ -1,5 +1,5 @@ - - - - - + + - - - + diff --git a/app/src/main/res/layout/activity_topic_edit_row.xml b/app/src/main/res/layout/activity_topic_edit_row.xml index 2feeaa0d..60d2953d 100644 --- a/app/src/main/res/layout/activity_topic_edit_row.xml +++ b/app/src/main/res/layout/activity_topic_edit_row.xml @@ -8,7 +8,7 @@ android:paddingEnd="4dp" android:paddingStart="4dp"> - - + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_topic_poll.xml b/app/src/main/res/layout/activity_topic_poll.xml index 60b7c96d..056ae2ca 100644 --- a/app/src/main/res/layout/activity_topic_poll.xml +++ b/app/src/main/res/layout/activity_topic_poll.xml @@ -41,7 +41,7 @@ android:layout_height="wrap_content" android:layout_weight="1"/> - - - - - + android:textSize="11sp" + tools:text="date"/> - + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_topic_quick_reply_row.xml b/app/src/main/res/layout/activity_topic_quick_reply_row.xml index 84ff1b6a..fa677c33 100644 --- a/app/src/main/res/layout/activity_topic_quick_reply_row.xml +++ b/app/src/main/res/layout/activity_topic_quick_reply_row.xml @@ -8,7 +8,7 @@ android:paddingEnd="4dp" android:paddingStart="4dp"> - - + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_upload.xml b/app/src/main/res/layout/activity_upload.xml index d2f81b4c..8639fd8c 100644 --- a/app/src/main/res/layout/activity_upload.xml +++ b/app/src/main/res/layout/activity_upload.xml @@ -1,5 +1,5 @@ - - - - + - - - + - - + - - - - - + - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_upload_fields_builder.xml b/app/src/main/res/layout/activity_upload_fields_builder.xml index af3daae6..0583b601 100644 --- a/app/src/main/res/layout/activity_upload_fields_builder.xml +++ b/app/src/main/res/layout/activity_upload_fields_builder.xml @@ -1,5 +1,5 @@ - - - - + - - - - - - - - + - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_create_link.xml b/app/src/main/res/layout/dialog_create_link.xml index 1901ed8b..e4283781 100644 --- a/app/src/main/res/layout/dialog_create_link.xml +++ b/app/src/main/res/layout/dialog_create_link.xml @@ -5,23 +5,23 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - + - - - + \ No newline at end of file diff --git a/app/src/main/res/layout/editor_view.xml b/app/src/main/res/layout/editor_view.xml index b95ecc61..3f47e85a 100644 --- a/app/src/main/res/layout/editor_view.xml +++ b/app/src/main/res/layout/editor_view.xml @@ -4,7 +4,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content"> - @@ -15,7 +15,7 @@ android:orientation="horizontal" android:layout_marginTop="4dp"> - - - + - - - - - - - - + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_forum.xml b/app/src/main/res/layout/fragment_forum.xml index 04c4ec4e..2f5de239 100644 --- a/app/src/main/res/layout/fragment_forum.xml +++ b/app/src/main/res/layout/fragment_forum.xml @@ -6,7 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - @@ -21,7 +21,7 @@ android:paddingTop="4dp" app:layoutManager="LinearLayoutManager" tools:context=".activities.main.forum.ForumFragment" /> - + - - + - @@ -22,7 +22,7 @@ app:layoutManager="LinearLayoutManager" tools:context=".activities.main.recent.RecentFragment" tools:listitem="@layout/fragment_recent_row"/> - + - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_shoutbox.xml b/app/src/main/res/layout/fragment_shoutbox.xml new file mode 100644 index 00000000..c593aeb0 --- /dev/null +++ b/app/src/main/res/layout/fragment_shoutbox.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_shoutbox_shout_row.xml b/app/src/main/res/layout/fragment_shoutbox_shout_row.xml new file mode 100644 index 00000000..9d606e5d --- /dev/null +++ b/app/src/main/res/layout/fragment_shoutbox_shout_row.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_stats.xml b/app/src/main/res/layout/fragment_stats.xml index e19d83dd..7b5edb41 100644 --- a/app/src/main/res/layout/fragment_stats.xml +++ b/app/src/main/res/layout/fragment_stats.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - + - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_unread.xml b/app/src/main/res/layout/fragment_unread.xml index 846fb7cb..fc412190 100644 --- a/app/src/main/res/layout/fragment_unread.xml +++ b/app/src/main/res/layout/fragment_unread.xml @@ -6,7 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - @@ -22,7 +22,7 @@ app:layoutManager="LinearLayoutManager" tools:context=".activities.main.unread.UnreadFragment" tools:listitem="@layout/fragment_unread_row"/> - + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index ea69690c..f8c62284 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -11,4 +11,5 @@ 24sp 24dp 6dp + 12dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bc145117..30cd4fe3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -17,6 +17,13 @@ "To use mTHMMY you have to agree to our Privacy Policy by choosing one of the options below. Choose \"Yes, I want to help\", if you consent to the collection of anonymized data that will help us improve the app. Otherwise, choose \"Nope, leave me alone\". You can change your preferences any time through the app's Settings. user_consent_shared_preference_key + + Recent + Forum + Unread + Shoutbox + Refresh + thmmy.gr Username diff --git a/app/src/main/res/xml/app_preferences_user.xml b/app/src/main/res/xml/app_preferences_user.xml index 4c7c7f6b..9778f340 100644 --- a/app/src/main/res/xml/app_preferences_user.xml +++ b/app/src/main/res/xml/app_preferences_user.xml @@ -1,8 +1,8 @@ - + - - + - + - - + - - + - - - + - + --> - - - - + - \ No newline at end of file + \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index aac7c9b4..9e6fce10 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,8 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode.