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;
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();
}
}

2
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();

11
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;

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"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
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_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:id="@+id/appbar"
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/ToolbarTheme">
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
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"
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">
<pl.droidsonroids.gif.GifImageView
android:id="@+id/logoView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:contentDescription="@string/logo"
android:src="@drawable/logo_animated"
/>
<TextView
android:id="@+id/appName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="@string/app_name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold"/>
<Space
android:id="@+id/space"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@+id/logoView"/>
<TextView
android:id="@+id/version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/appName"
android:layout_centerHorizontal="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="italic"/>
<TextView
android:id="@+id/appName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/space"
android:layout_centerHorizontal="true"
android:text="@string/app_name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="25sp"
android:textStyle="bold"/>
<ImageView
android:id="@+id/logoView"
<TextView
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_height="wrap_content"
android:layout_below="@id/version"
android:layout_centerHorizontal="true"
android:layout_margin="15dp"
android:contentDescription="@string/logo"
android:src="@mipmap/ic_launcher"/>
</RelativeLayout>
</ScrollView>
</LinearLayout>
android:layout_gravity="center"
android:contentDescription="@string/trollGif"
android:foregroundGravity="center"
android:src="@drawable/fun"
/>
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>

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

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

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

@ -9,7 +9,8 @@
<string name="about">About</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_spinner">Authenticating&#8230;</string>
<string name="logout">Logout</string>

Loading…
Cancel
Save