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 3614e32c..500aeb59 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java @@ -1,14 +1,29 @@ package gr.thmmy.mthmmy.activities; +import android.content.pm.ActivityInfo; +import android.content.res.Configuration; import android.os.Bundle; +import android.support.design.widget.AppBarLayout; +import android.support.v4.widget.DrawerLayout; import android.support.v7.widget.Toolbar; +import android.view.Gravity; +import android.view.View; +import android.widget.FrameLayout; +import android.widget.ScrollView; import android.widget.TextView; +import android.widget.Toast; import gr.thmmy.mthmmy.BuildConfig; import gr.thmmy.mthmmy.R; -public class AboutActivity extends BaseActivity -{ +public class AboutActivity extends BaseActivity { + private static final int TIME_INTERVAL = 1000; + private static final int TIMES_TO_PRESS = 4; + private long mVersionLastPressedTime; + private int mVersionPressedCounter; + + private AppBarLayout appBar; + private FrameLayout trollGif; @Override protected void onCreate(Bundle savedInstanceState) { @@ -16,6 +31,8 @@ public class AboutActivity extends BaseActivity setContentView(R.layout.activity_about); String versionName = BuildConfig.VERSION_NAME; + //Initialize appbar + appBar = (AppBarLayout) findViewById(R.id.appbar); //Initialize toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(R.string.about); @@ -26,11 +43,33 @@ public class AboutActivity extends BaseActivity createDrawer(); drawer.setSelection(ABOUT_ID); + final ScrollView mainContent = (ScrollView) findViewById(R.id.scrollview); + trollGif = (FrameLayout) findViewById(R.id.trollGifFrame); TextView tv = (TextView) findViewById(R.id.version); if (tv != null) tv.setText(getString(R.string.version, versionName)); + tv.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (mVersionLastPressedTime + TIME_INTERVAL > System.currentTimeMillis()) { + if (mVersionPressedCounter == TIMES_TO_PRESS) { + appBar.setVisibility(View.INVISIBLE); + mainContent.setVisibility(View.INVISIBLE); + trollGif.setVisibility(View.VISIBLE); + drawer.getDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + } + mVersionLastPressedTime = System.currentTimeMillis(); + ++mVersionPressedCounter; + } else { + mVersionLastPressedTime = System.currentTimeMillis(); + mVersionPressedCounter = 0; + } + } + }); + //TODO: add licenses } @@ -39,4 +78,15 @@ public class AboutActivity extends BaseActivity drawer.setSelection(ABOUT_ID); super.onResume(); } + + @Override + public void onBackPressed() { + if (trollGif.getVisibility() == View.VISIBLE) { + Toast toast = Toast.makeText(this, "NO EXIT FROM HERE!!\n\nHA HA HA!", Toast.LENGTH_SHORT); + TextView v = (TextView) toast.getView().findViewById(android.R.id.message); + if (v != null) v.setGravity(Gravity.CENTER); + toast.show(); + } else + super.onBackPressed(); + } } 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 43ca3ef0..56bf936d 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 @@ -75,7 +75,7 @@ public class ProfileActivity extends BaseActivity { setSupportActionBar(toolbar); getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - //getSupportActionBar().setDisplayShowHomeEnabled(true); + createDrawer(); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java index c327e0a8..804229d6 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java @@ -17,6 +17,7 @@ import gr.thmmy.mthmmy.data.Post; class TopicParser { //Parsing variables + private static String usersViewingTopic; private static String currentPage; private static String postRowSelection; private static String userNameSelection; @@ -42,6 +43,12 @@ class TopicParser { @SuppressWarnings("unused") private static final String TAG = "TopicParser"; + static String parseUsersViewingThisTopic(Document doc){ + defineLanguage(doc); + Log.d(TAG, doc.select("td:containsOwn(" + usersViewingTopic + ")").first().text()); + return doc.select("td:containsOwn(" + usersViewingTopic + ")").first().html(); + } + static int parseCurrentPageIndex(Document doc) { defineLanguage(doc); @@ -286,6 +293,7 @@ class TopicParser { private static void defineLanguage(Document doc){ //English parsing variables + final String en_usersViewingTopic = "are viewing this topic"; final String en_currentPage = "Pages:"; final String en_postRowSelection = "on"; final String en_userNameSelection = "View the profile of"; @@ -299,6 +307,7 @@ class TopicParser { final String en_genderAltFemale = "Female"; //Greek parsing variables + final String gr_usersViewingTopic = "διαβάζουν αυτό το θέμα"; final String gr_currentPage = "Σελίδες:"; final String gr_postRowSelection = "στις"; final String gr_userNameSelection = "Εμφάνιση προφίλ του μέλους"; @@ -312,6 +321,7 @@ class TopicParser { final String gr_genderAltFemale = "Γυναίκα"; if(doc.select("h3").text().contains("Καλώς ορίσατε")){ + usersViewingTopic = gr_usersViewingTopic; currentPage = gr_currentPage; postRowSelection = gr_postRowSelection; userNameSelection = gr_userNameSelection; @@ -327,6 +337,7 @@ class TopicParser { genderAltFemale = gr_genderAltFemale; } else{ //Default is english (eg. guest's language) + usersViewingTopic = en_usersViewingTopic; currentPage = en_currentPage; postRowSelection = en_postRowSelection; userNameSelection = en_userNameSelection; diff --git a/app/src/main/res/drawable/fun.gif b/app/src/main/res/drawable/fun.gif new file mode 100644 index 00000000..57742c88 Binary files /dev/null and b/app/src/main/res/drawable/fun.gif differ diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index eccc23ab..2a3e7698 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -1,73 +1,105 @@ - - - + android:layout_height="match_parent" + android:fitsSystemWindows="true" + tools:context=".activities.topic.TopicActivity"> + + - + android:layout_height="?attr/actionBarSize" + android:background="?attr/colorPrimary" + app:popupTheme="@style/ToolbarTheme"> + + - - - + + - - + - + - + - + + + + + + - - - \ No newline at end of file + android:layout_gravity="center" + android:contentDescription="@string/trollGif" + android:foregroundGravity="center" + android:src="@drawable/fun" + /> + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml index 249506c9..61058489 100644 --- a/app/src/main/res/layout/activity_profile.xml +++ b/app/src/main/res/layout/activity_profile.xml @@ -70,9 +70,7 @@ android:layout_gravity="center" android:textColor="@color/accent" android:textSize="25sp"/> - - About v%1$s - logo + Logo + You should watch a funny gif! Login Authenticating… Logout