Browse Source

Activity about hidden gif, some parsing.

pull/24/head
Apostolos Fanakis 8 years ago
parent
commit
f85371ecfb
  1. 54
      app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java
  2. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java
  3. 11
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java
  4. BIN
      app/src/main/res/drawable/fun.gif
  5. 148
      app/src/main/res/layout/activity_about.xml
  6. 2
      app/src/main/res/layout/activity_profile.xml
  7. 3
      app/src/main/res/values/strings.xml

54
app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java

@ -1,14 +1,29 @@
package gr.thmmy.mthmmy.activities; package gr.thmmy.mthmmy.activities;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.widget.Toolbar; 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.TextView;
import android.widget.Toast;
import gr.thmmy.mthmmy.BuildConfig; import gr.thmmy.mthmmy.BuildConfig;
import gr.thmmy.mthmmy.R; 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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -16,6 +31,8 @@ public class AboutActivity extends BaseActivity
setContentView(R.layout.activity_about); setContentView(R.layout.activity_about);
String versionName = BuildConfig.VERSION_NAME; String versionName = BuildConfig.VERSION_NAME;
//Initialize appbar
appBar = (AppBarLayout) findViewById(R.id.appbar);
//Initialize toolbar //Initialize toolbar
toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.about); toolbar.setTitle(R.string.about);
@ -26,11 +43,33 @@ public class AboutActivity extends BaseActivity
createDrawer(); createDrawer();
drawer.setSelection(ABOUT_ID); 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); TextView tv = (TextView) findViewById(R.id.version);
if (tv != null) if (tv != null)
tv.setText(getString(R.string.version, versionName)); 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 //TODO: add licenses
} }
@ -39,4 +78,15 @@ public class AboutActivity extends BaseActivity
drawer.setSelection(ABOUT_ID); drawer.setSelection(ABOUT_ID);
super.onResume(); 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();
}
} }

2
app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java

@ -75,7 +75,7 @@ public class ProfileActivity extends BaseActivity {
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//getSupportActionBar().setDisplayShowHomeEnabled(true);
createDrawer(); createDrawer();

11
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java

@ -17,6 +17,7 @@ import gr.thmmy.mthmmy.data.Post;
class TopicParser { class TopicParser {
//Parsing variables //Parsing variables
private static String usersViewingTopic;
private static String currentPage; private static String currentPage;
private static String postRowSelection; private static String postRowSelection;
private static String userNameSelection; private static String userNameSelection;
@ -42,6 +43,12 @@ class TopicParser {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final String TAG = "TopicParser"; 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) { static int parseCurrentPageIndex(Document doc) {
defineLanguage(doc); defineLanguage(doc);
@ -286,6 +293,7 @@ class TopicParser {
private static void defineLanguage(Document doc){ private static void defineLanguage(Document doc){
//English parsing variables //English parsing variables
final String en_usersViewingTopic = "are viewing this topic";
final String en_currentPage = "Pages:"; final String en_currentPage = "Pages:";
final String en_postRowSelection = "on"; final String en_postRowSelection = "on";
final String en_userNameSelection = "View the profile of"; final String en_userNameSelection = "View the profile of";
@ -299,6 +307,7 @@ class TopicParser {
final String en_genderAltFemale = "Female"; final String en_genderAltFemale = "Female";
//Greek parsing variables //Greek parsing variables
final String gr_usersViewingTopic = "διαβάζουν αυτό το θέμα";
final String gr_currentPage = "Σελίδες:"; final String gr_currentPage = "Σελίδες:";
final String gr_postRowSelection = "στις"; final String gr_postRowSelection = "στις";
final String gr_userNameSelection = "Εμφάνιση προφίλ του μέλους"; final String gr_userNameSelection = "Εμφάνιση προφίλ του μέλους";
@ -312,6 +321,7 @@ class TopicParser {
final String gr_genderAltFemale = "Γυναίκα"; final String gr_genderAltFemale = "Γυναίκα";
if(doc.select("h3").text().contains("Καλώς ορίσατε")){ if(doc.select("h3").text().contains("Καλώς ορίσατε")){
usersViewingTopic = gr_usersViewingTopic;
currentPage = gr_currentPage; currentPage = gr_currentPage;
postRowSelection = gr_postRowSelection; postRowSelection = gr_postRowSelection;
userNameSelection = gr_userNameSelection; userNameSelection = gr_userNameSelection;
@ -327,6 +337,7 @@ class TopicParser {
genderAltFemale = gr_genderAltFemale; genderAltFemale = gr_genderAltFemale;
} }
else{ //Default is english (eg. guest's language) else{ //Default is english (eg. guest's language)
usersViewingTopic = en_usersViewingTopic;
currentPage = en_currentPage; currentPage = en_currentPage;
postRowSelection = en_postRowSelection; postRowSelection = en_postRowSelection;
userNameSelection = en_userNameSelection; userNameSelection = en_userNameSelection;

BIN
app/src/main/res/drawable/fun.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 MiB

148
app/src/main/res/layout/activity_about.xml

@ -1,73 +1,105 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".activities.topic.TopicActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/ToolbarTheme">
<android.support.design.widget.AppBarLayout <android.support.v7.widget.Toolbar
android:id="@+id/appbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="?attr/actionBarSize"
android:paddingTop="@dimen/appbar_padding_top" android:background="?attr/colorPrimary"
android:theme="@style/ToolbarTheme"> app:popupTheme="@style/ToolbarTheme">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ToolbarTheme">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout> <ScrollView
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="64dp"
android:background="@color/background">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.eternalpixels.toinfinity.Info">
<ScrollView android:layout_marginTop="64dp"
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <pl.droidsonroids.gif.GifImageView
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/logoView"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin" android:layout_alignParentTop="true"
android:paddingLeft="@dimen/activity_horizontal_margin" android:layout_centerHorizontal="true"
android:paddingRight="@dimen/activity_horizontal_margin" android:contentDescription="@string/logo"
android:paddingTop="@dimen/activity_vertical_margin" android:src="@drawable/logo_animated"
tools:context="com.eternalpixels.toinfinity.Info"> />
<TextView <Space
android:id="@+id/appName" android:id="@+id/space"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="50dp"
android:layout_alignParentTop="true" android:layout_below="@+id/logoView"/>
android:layout_centerHorizontal="true"
android:text="@string/app_name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold"/>
<TextView <TextView
android:id="@+id/version" android:id="@+id/appName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/appName" android:layout_below="@id/space"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:textAppearance="?android:attr/textAppearanceSmall" android:text="@string/app_name"
android:textStyle="italic"/> android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="25sp"
android:textStyle="bold"/>
<ImageView <TextView
android:id="@+id/logoView" android:id="@+id/version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/appName"
android:layout_centerHorizontal="true"
android:clickable="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/accent"
android:textStyle="italic"/>
</RelativeLayout>
</ScrollView>
<FrameLayout
android:id="@+id/trollGifFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:visibility="gone">
<pl.droidsonroids.gif.GifImageView
android:id="@+id/trollGif"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/version" android:layout_gravity="center"
android:layout_centerHorizontal="true" android:contentDescription="@string/trollGif"
android:layout_margin="15dp" android:foregroundGravity="center"
android:contentDescription="@string/logo" android:src="@drawable/fun"
android:src="@mipmap/ic_launcher"/> />
</RelativeLayout> </FrameLayout>
</ScrollView> </android.support.design.widget.CoordinatorLayout>
</LinearLayout>

2
app/src/main/res/layout/activity_profile.xml

@ -70,9 +70,7 @@
android:layout_gravity="center" android:layout_gravity="center"
android:textColor="@color/accent" android:textColor="@color/accent"
android:textSize="25sp"/> android:textSize="25sp"/>
</android.support.v7.widget.Toolbar> </android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout> </android.support.design.widget.AppBarLayout>
<ProgressBar <ProgressBar

3
app/src/main/res/values/strings.xml

@ -9,7 +9,8 @@
<string name="about">About</string> <string name="about">About</string>
<string name="version">v%1$s</string> <string name="version">v%1$s</string>
<string name="logo">logo</string> <string name="logo">Logo</string>
<string name="trollGif">You should watch a funny gif!</string>
<string name="login">Login</string> <string name="login">Login</string>
<string name="login_spinner">Authenticating&#8230;</string> <string name="login_spinner">Authenticating&#8230;</string>
<string name="logout">Logout</string> <string name="logout">Logout</string>

Loading…
Cancel
Save