2013-10-25 15:19:00 +00:00
|
|
|
/*
|
2013-12-20 19:25:49 +00:00
|
|
|
* This is the source code of Telegram for Android v. 1.3.2.
|
2013-10-25 15:19:00 +00:00
|
|
|
* It is licensed under GNU GPL v. 2 or later.
|
|
|
|
* You should have received a copy of the license in this archive (see LICENSE).
|
|
|
|
*
|
|
|
|
* Copyright Nikolai Kudashov, 2013.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui;
|
|
|
|
|
2014-06-04 00:24:06 +00:00
|
|
|
import android.app.Activity;
|
2013-10-25 15:19:00 +00:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Parcelable;
|
|
|
|
import android.support.v4.view.PagerAdapter;
|
|
|
|
import android.support.v4.view.ViewPager;
|
|
|
|
import android.text.Html;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.view.animation.Animation;
|
|
|
|
import android.view.animation.AnimationUtils;
|
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2014-03-22 22:31:55 +00:00
|
|
|
import org.telegram.messenger.LocaleController;
|
2013-10-25 15:19:00 +00:00
|
|
|
import org.telegram.messenger.R;
|
2014-02-04 18:36:55 +00:00
|
|
|
import org.telegram.messenger.Utilities;
|
2013-10-25 15:19:00 +00:00
|
|
|
|
2014-06-04 00:24:06 +00:00
|
|
|
public class IntroActivity extends Activity {
|
2013-10-25 15:19:00 +00:00
|
|
|
private ViewPager viewPager;
|
|
|
|
private ImageView topImage1;
|
|
|
|
private ImageView topImage2;
|
2013-12-20 19:25:49 +00:00
|
|
|
private ViewGroup bottomPages;
|
2013-10-25 15:19:00 +00:00
|
|
|
private int lastPage = 0;
|
|
|
|
private boolean justCreated = false;
|
|
|
|
private boolean startPressed = false;
|
|
|
|
private int[] icons;
|
|
|
|
private int[] titles;
|
|
|
|
private int[] messages;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
2014-06-04 00:24:06 +00:00
|
|
|
setTheme(R.style.Theme_TMessages);
|
2013-10-25 15:19:00 +00:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
setContentView(R.layout.intro_layout);
|
|
|
|
|
2014-03-25 00:25:32 +00:00
|
|
|
if (LocaleController.isRTL) {
|
2013-10-25 15:19:00 +00:00
|
|
|
icons = new int[] {
|
2013-12-20 19:25:49 +00:00
|
|
|
R.drawable.intro7,
|
|
|
|
R.drawable.intro6,
|
|
|
|
R.drawable.intro5,
|
|
|
|
R.drawable.intro4,
|
|
|
|
R.drawable.intro3,
|
|
|
|
R.drawable.intro2,
|
|
|
|
R.drawable.intro1
|
2013-10-25 15:19:00 +00:00
|
|
|
};
|
|
|
|
titles = new int[] {
|
2013-12-20 19:25:49 +00:00
|
|
|
R.string.Page7Title,
|
2013-10-25 15:19:00 +00:00
|
|
|
R.string.Page6Title,
|
|
|
|
R.string.Page5Title,
|
|
|
|
R.string.Page4Title,
|
|
|
|
R.string.Page3Title,
|
|
|
|
R.string.Page2Title,
|
|
|
|
R.string.Page1Title
|
|
|
|
};
|
|
|
|
messages = new int[] {
|
2013-12-20 19:25:49 +00:00
|
|
|
R.string.Page7Message,
|
2013-10-25 15:19:00 +00:00
|
|
|
R.string.Page6Message,
|
|
|
|
R.string.Page5Message,
|
|
|
|
R.string.Page4Message,
|
|
|
|
R.string.Page3Message,
|
|
|
|
R.string.Page2Message,
|
|
|
|
R.string.Page1Message
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
icons = new int[] {
|
2013-12-20 19:25:49 +00:00
|
|
|
R.drawable.intro1,
|
|
|
|
R.drawable.intro2,
|
|
|
|
R.drawable.intro3,
|
|
|
|
R.drawable.intro4,
|
|
|
|
R.drawable.intro5,
|
|
|
|
R.drawable.intro6,
|
|
|
|
R.drawable.intro7
|
2013-10-25 15:19:00 +00:00
|
|
|
};
|
|
|
|
titles = new int[] {
|
|
|
|
R.string.Page1Title,
|
|
|
|
R.string.Page2Title,
|
|
|
|
R.string.Page3Title,
|
|
|
|
R.string.Page4Title,
|
|
|
|
R.string.Page5Title,
|
2013-12-20 19:25:49 +00:00
|
|
|
R.string.Page6Title,
|
|
|
|
R.string.Page7Title
|
2013-10-25 15:19:00 +00:00
|
|
|
};
|
|
|
|
messages = new int[] {
|
|
|
|
R.string.Page1Message,
|
|
|
|
R.string.Page2Message,
|
|
|
|
R.string.Page3Message,
|
|
|
|
R.string.Page4Message,
|
|
|
|
R.string.Page5Message,
|
2013-12-20 19:25:49 +00:00
|
|
|
R.string.Page6Message,
|
|
|
|
R.string.Page7Message
|
2013-10-25 15:19:00 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
viewPager = (ViewPager)findViewById(R.id.intro_view_pager);
|
2013-12-26 16:46:13 +00:00
|
|
|
TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button);
|
2014-03-22 22:31:55 +00:00
|
|
|
startMessagingButton.setText(LocaleController.getString("StartMessaging", R.string.StartMessaging));
|
2013-10-25 15:19:00 +00:00
|
|
|
topImage1 = (ImageView)findViewById(R.id.icon_image1);
|
|
|
|
topImage2 = (ImageView)findViewById(R.id.icon_image2);
|
2013-12-20 19:25:49 +00:00
|
|
|
bottomPages = (ViewGroup)findViewById(R.id.bottom_pages);
|
2013-10-25 15:19:00 +00:00
|
|
|
topImage2.setVisibility(View.GONE);
|
|
|
|
viewPager.setAdapter(new IntroAdapter());
|
|
|
|
viewPager.setPageMargin(0);
|
|
|
|
viewPager.setOffscreenPageLimit(1);
|
|
|
|
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
2013-12-20 19:25:49 +00:00
|
|
|
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPageSelected(int i) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPageScrollStateChanged(int i) {
|
|
|
|
if (i == ViewPager.SCROLL_STATE_IDLE || i == ViewPager.SCROLL_STATE_SETTLING) {
|
|
|
|
if (lastPage != viewPager.getCurrentItem()) {
|
|
|
|
lastPage = viewPager.getCurrentItem();
|
|
|
|
|
|
|
|
final ImageView fadeoutImage;
|
|
|
|
final ImageView fadeinImage;
|
|
|
|
if (topImage1.getVisibility() == View.VISIBLE) {
|
|
|
|
fadeoutImage = topImage1;
|
|
|
|
fadeinImage = topImage2;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
fadeoutImage = topImage2;
|
|
|
|
fadeinImage = topImage1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fadeinImage.bringToFront();
|
|
|
|
fadeinImage.setImageResource(icons[lastPage]);
|
|
|
|
fadeinImage.clearAnimation();
|
|
|
|
fadeoutImage.clearAnimation();
|
|
|
|
|
|
|
|
|
|
|
|
Animation outAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_out);
|
|
|
|
outAnimation.setAnimationListener(new Animation.AnimationListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationStart(Animation animation) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animation animation) {
|
|
|
|
fadeoutImage.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationRepeat(Animation animation) {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Animation inAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_in);
|
|
|
|
inAnimation.setAnimationListener(new Animation.AnimationListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationStart(Animation animation) {
|
|
|
|
fadeinImage.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animation animation) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationRepeat(Animation animation) {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
fadeoutImage.startAnimation(outAnimation);
|
|
|
|
fadeinImage.startAnimation(inAnimation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
startMessagingButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
if (startPressed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
startPressed = true;
|
2014-06-03 23:31:48 +00:00
|
|
|
Intent intent2 = new Intent(IntroActivity.this, LaunchActivity.class);
|
|
|
|
intent2.putExtra("fromIntro", true);
|
2013-10-25 15:19:00 +00:00
|
|
|
startActivity(intent2);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
justCreated = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onResume() {
|
|
|
|
super.onResume();
|
|
|
|
if (justCreated) {
|
2014-03-25 00:25:32 +00:00
|
|
|
if (LocaleController.isRTL) {
|
2013-12-20 19:25:49 +00:00
|
|
|
viewPager.setCurrentItem(6);
|
|
|
|
lastPage = 6;
|
2013-10-25 15:19:00 +00:00
|
|
|
} else {
|
|
|
|
viewPager.setCurrentItem(0);
|
|
|
|
lastPage = 0;
|
|
|
|
}
|
|
|
|
justCreated = false;
|
|
|
|
}
|
2014-05-16 23:05:49 +00:00
|
|
|
Utilities.checkForCrashes(this);
|
|
|
|
Utilities.checkForUpdates(this);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private class IntroAdapter extends PagerAdapter {
|
|
|
|
@Override
|
|
|
|
public int getCount() {
|
2013-12-20 19:25:49 +00:00
|
|
|
return 7;
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object instantiateItem(ViewGroup container, int position) {
|
|
|
|
View view = View.inflate(container.getContext(), R.layout.intro_view_layout, null);
|
|
|
|
TextView headerTextView = (TextView)view.findViewById(R.id.header_text);
|
|
|
|
TextView messageTextView = (TextView)view.findViewById(R.id.message_text);
|
|
|
|
container.addView(view, 0);
|
|
|
|
|
|
|
|
headerTextView.setText(getString(titles[position]));
|
|
|
|
messageTextView.setText(Html.fromHtml(getString(messages[position])));
|
|
|
|
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void destroyItem(ViewGroup container, int position, Object object) {
|
|
|
|
container.removeView((View) object);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setPrimaryItem(ViewGroup container, int position, Object object) {
|
|
|
|
super.setPrimaryItem(container, position, object);
|
2013-12-20 19:25:49 +00:00
|
|
|
int count = bottomPages.getChildCount();
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
View child = bottomPages.getChildAt(a);
|
|
|
|
if (a == position) {
|
|
|
|
child.setBackgroundColor(0xff2ca5e0);
|
|
|
|
} else {
|
|
|
|
child.setBackgroundColor(0xffbbbbbb);
|
|
|
|
}
|
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isViewFromObject(View view, Object object) {
|
|
|
|
return view.equals(object);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void finishUpdate(View arg0) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void restoreState(Parcelable arg0, ClassLoader arg1) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Parcelable saveState() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void startUpdate(View arg0) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|