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 de0c32fd..f88cd982 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java @@ -44,7 +44,7 @@ public class AboutActivity extends BaseActivity { drawer.setSelection(ABOUT_ID); final ScrollView mainContent = (ScrollView) findViewById(R.id.scrollview); - trollGif = (FrameLayout) findViewById(R.id.trollGifFrame); + trollGif = (FrameLayout) findViewById(R.id.trollPicFrame); TextView tv = (TextView) findViewById(R.id.version); if (tv != null) 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 bb8fc02d..7be5d9f9 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 @@ -89,7 +89,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF @Override public void onRecentFragmentInteraction(TopicSummary topicSummary) { Intent i = new Intent(MainActivity.this, TopicActivity.class); - i.putExtra(EXTRAS_TOPIC_URL, "https://www.thmmy.gr/smf/index.php?topic=67565.0"); + i.putExtra(EXTRAS_TOPIC_URL, topicSummary.getTopicUrl()); i.putExtra(EXTRAS_TOPIC_TITLE, topicSummary.getTitle()); startActivity(i); } 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 12999164..a9456960 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 @@ -312,7 +312,7 @@ public class TopicActivity extends BaseActivity { if (topicTask != null && topicTask.getStatus() != AsyncTask.Status.RUNNING) topicTask.cancel(true); - //topicTask = new TopicTask(); + topicTask = new TopicTask(); topicTask.execute(pagesUrls.get(pageRequested)); //Attempt data parsing } 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 1c55363a..892af27b 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 @@ -29,7 +29,6 @@ import android.widget.FrameLayout; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; @@ -612,7 +611,7 @@ class TopicAdapter extends RecyclerView.Adapter { @Override protected String doInBackground(ThmmyFile... files) { try { - File tempFile = files[0].download(PACKAGE_NAME); + File tempFile = files[0].download(); if (tempFile != null) { String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension( files[0].getExtension()); diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/FileManager/ThmmyFile.java b/app/src/main/java/gr/thmmy/mthmmy/utils/FileManager/ThmmyFile.java index f9a2a57a..2b9e34d8 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/FileManager/ThmmyFile.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/FileManager/ThmmyFile.java @@ -104,26 +104,11 @@ public class ThmmyFile { this.filePath = filePath; } - /** - * Used to download the file. If download is successful file's extension and path will be assigned - * to object's fields and can be accessed using getter methods. - *

File is stored in sdcard1/Android/data/Downloads/{@link #NO_PACKAGE_FOLDER_NAME}

- * - * @return the {@link File} if successful, null otherwise - * @throws IOException - * @throws SecurityException - */ - @Nullable - public File download() throws IOException, SecurityException { - return download(NO_PACKAGE_FOLDER_NAME); - } - /** * Used to download the file. If download is successful file's extension and path will be assigned * to object's fields and can be accessed using getter methods. *

File is stored in sdcard1/Android/data/Downloads/packageName

* - * @param packageName package's name to use as folder name for file's path * @return the {@link File} if successful, null otherwise * @throws IOException if the request could not be executed due to cancellation, a connectivity * problem or timeout. Because networks can fail during an exchange, it is possible that the @@ -131,7 +116,7 @@ public class ThmmyFile { * @throws SecurityException if the requested file is not hosted by the forum. */ @Nullable - public File download(final String packageName) throws IOException, SecurityException { + public File download() throws IOException, SecurityException { if (!Objects.equals(fileUrl.getHost(), "www.thmmy.gr")) throw new SecurityException("Downloading files from other sources is not supported"); @@ -141,7 +126,7 @@ public class ThmmyFile { if (!response.isSuccessful()) { throw new IOException("Failed to download file: " + response); } - file = getOutputMediaFile(packageName, filename); + file = getOutputMediaFile(filename); if (file == null) { Report.d(TAG, "Error creating media file, check storage permissions!"); } else { @@ -157,7 +142,7 @@ public class ThmmyFile { } @Nullable - private static File getOutputMediaFile(String packageName, String fileName) { + private static File getOutputMediaFile(String fileName) { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. File mediaStorageDir = new File(Environment.getExternalStorageDirectory() diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareLinearBehavior.java b/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareLinearBehavior.java new file mode 100644 index 00000000..0de9d16d --- /dev/null +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareLinearBehavior.java @@ -0,0 +1,122 @@ +package gr.thmmy.mthmmy.utils; + +import android.animation.Animator; +import android.content.Context; +import android.support.design.widget.CoordinatorLayout; +import android.support.v4.view.ViewCompat; +import android.support.v4.view.animation.FastOutSlowInInterpolator; +import android.util.AttributeSet; +import android.view.View; +import android.view.ViewPropertyAnimator; + +/** + * CoordinatorLayout Behavior for bottom navigation bar. + *

When a nested ScrollView is scrolled down, the view will disappear. + * When the ScrollView is scrolled back up, the view will reappear.

+ */ +public class ScrollAwareLinearBehavior extends CoordinatorLayout.Behavior { + private int mDySinceDirectionChange; + private boolean mIsShowing; + private boolean mIsHiding; + + public ScrollAwareLinearBehavior(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, View child, View directTargetChild, View target, int nestedScrollAxes) { + return (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0; + } + + @Override + public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, View child, View target, int dx, int dy, int[] consumed) { + if (dy > 0 && mDySinceDirectionChange < 0 + || dy < 0 && mDySinceDirectionChange > 0) { + child.animate().cancel(); + mDySinceDirectionChange = 0; + } + + mDySinceDirectionChange += dy; + + if (mDySinceDirectionChange > child.getHeight() + && child.getVisibility() == View.VISIBLE + && !mIsHiding) { + hide(child); + } else if (mDySinceDirectionChange < 0 + && child.getVisibility() == View.INVISIBLE + && !mIsShowing) { + show(child); + } + } + + private void hide(final View view) { + mIsHiding = true; + ViewPropertyAnimator animator = view.animate() + .translationY(view.getHeight()) + .setInterpolator(new FastOutSlowInInterpolator()) + .setDuration(100); + + animator.setListener(new Animator.AnimatorListener() { + @Override + public void onAnimationStart(Animator animator) { + } + + @Override + public void onAnimationEnd(Animator animator) { + // Prevent drawing the View after it is gone + mIsHiding = false; + view.setVisibility(View.INVISIBLE); + } + + @Override + public void onAnimationCancel(Animator animator) { + // Canceling a hide should show the view + mIsHiding = false; + if (!mIsShowing) { + show(view); + } + } + + @Override + public void onAnimationRepeat(Animator animator) { + } + }); + + animator.start(); + } + + private void show(final View view) { + mIsShowing = true; + ViewPropertyAnimator animator = view.animate() + .translationY(0) + .setInterpolator(new FastOutSlowInInterpolator()) + .setDuration(100); + + animator.setListener(new Animator.AnimatorListener() { + @Override + public void onAnimationStart(Animator animator) { + view.setVisibility(View.VISIBLE); + } + + @Override + public void onAnimationEnd(Animator animator) { + mIsShowing = false; + } + + @Override + public void onAnimationCancel(Animator animator) { + // Canceling a show should hide the view + mIsShowing = false; + if (!mIsHiding) { + hide(view); + } + } + + @Override + public void onAnimationRepeat(Animator animator) { + } + }); + + animator.start(); + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/fun.gif b/app/src/main/res/drawable/fun.gif deleted file mode 100644 index 57742c88..00000000 Binary files a/app/src/main/res/drawable/fun.gif and /dev/null differ diff --git a/app/src/main/res/drawable/fun.jpg b/app/src/main/res/drawable/fun.jpg new file mode 100644 index 00000000..c7f1a5f9 Binary files /dev/null and b/app/src/main/res/drawable/fun.jpg differ diff --git a/app/src/main/res/layout-v21/activity_profile.xml b/app/src/main/res/layout-v21/activity_profile.xml index e659787c..ddda7c59 100644 --- a/app/src/main/res/layout-v21/activity_profile.xml +++ b/app/src/main/res/layout-v21/activity_profile.xml @@ -73,18 +73,8 @@ - - + + - diff --git a/app/src/main/res/layout/activity_topic.xml b/app/src/main/res/layout/activity_topic.xml index 75ef4a45..28872028 100644 --- a/app/src/main/res/layout/activity_topic.xml +++ b/app/src/main/res/layout/activity_topic.xml @@ -30,20 +30,20 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="top|start" - android:layout_marginBottom="50dp" android:layout_marginTop="64dp" android:background="@color/background" android:scrollbars="none" tools:context="gr.thmmy.mthmmy.activities.topic.TopicActivity"> - + android:background="@color/primary" + app:elevation="8dp" + app:layout_behavior="gr.thmmy.mthmmy.utils.ScrollAwareLinearBehavior"> - + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index acb97405..9194ce44 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -5,24 +5,6 @@ in the style.css file! --> - - - #2B2B2B #333333 @@ -38,5 +20,5 @@ #FFFFFF #CCCCCC #E7E7E7 - #8026A69A + #D926A69A diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d8f09886..497f8dee 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -10,7 +10,7 @@ About v%1$s Logo - You should watch a funny gif! + You should watch a funny pic! Login Authenticating… Logout diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index b3a619f3..ad6de6d0 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -38,9 +38,9 @@