mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-13 17:51:57 +00:00
Add Intro before login
This commit is contained in:
parent
905568821f
commit
2c982d5fb0
14 changed files with 299 additions and 7 deletions
|
|
@ -50,6 +50,11 @@
|
||||||
android:windowSoftInputMode="adjustResize"
|
android:windowSoftInputMode="adjustResize"
|
||||||
android:screenOrientation="portrait">
|
android:screenOrientation="portrait">
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".ui.activities.IntroActivity"
|
||||||
|
android:windowSoftInputMode="adjustResize"
|
||||||
|
android:screenOrientation="portrait">
|
||||||
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activities.SkillTasksActivity"
|
android:name=".ui.activities.SkillTasksActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,8 @@ dependencies {
|
||||||
//Material Dialogs
|
//Material Dialogs
|
||||||
compile('com.github.afollestad.material-dialogs:core:0.8.5.0@aar')
|
compile('com.github.afollestad.material-dialogs:core:0.8.5.0@aar')
|
||||||
|
|
||||||
|
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar'
|
||||||
|
|
||||||
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
|
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
|
||||||
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
|
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
Habitica/res/drawable-hdpi/intro_2.png
Normal file
BIN
Habitica/res/drawable-hdpi/intro_2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
BIN
Habitica/res/drawable-mdpi/intro_2.png
Normal file
BIN
Habitica/res/drawable-mdpi/intro_2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
BIN
Habitica/res/drawable-xhdpi/intro_2.png
Normal file
BIN
Habitica/res/drawable-xhdpi/intro_2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 63 KiB |
BIN
Habitica/res/drawable/intro_1.png
Normal file
BIN
Habitica/res/drawable/intro_1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.7 KiB |
BIN
Habitica/res/drawable/intro_3.png
Normal file
BIN
Habitica/res/drawable/intro_3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.1 KiB |
BIN
Habitica/res/drawable/intro_background.png
Normal file
BIN
Habitica/res/drawable/intro_background.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 168 KiB |
44
Habitica/res/layout/activity_intro.xml
Normal file
44
Habitica/res/layout/activity_intro.xml
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical" android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@drawable/intro_background">
|
||||||
|
<android.support.v4.view.ViewPager
|
||||||
|
android:id="@+id/view_pager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
<com.viewpagerindicator.CirclePageIndicator
|
||||||
|
android:id="@+id/view_pager_indicator"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_marginBottom="16dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/skip"
|
||||||
|
android:id="@+id/skipButton"
|
||||||
|
android:layout_alignParentBottom="false"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_marginRight="6dp"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:backgroundTint="@color/brand_100" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/intro_finish_button"
|
||||||
|
android:id="@+id/finishButton"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_marginRight="6dp"
|
||||||
|
android:layout_marginBottom="6dp"
|
||||||
|
android:backgroundTint="@color/brand_100"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:visibility="gone" />
|
||||||
|
</RelativeLayout>
|
||||||
31
Habitica/res/layout/fragment_intro.xml
Normal file
31
Habitica/res/layout/fragment_intro.xml
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical" android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
|
android:id="@+id/titleTextView"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_margin="24dp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/imageView"
|
||||||
|
android:layout_gravity="center_horizontal" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/descriptionTextView"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:layout_margin="24dp"
|
||||||
|
android:gravity="center_horizontal" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
@ -167,4 +167,12 @@
|
||||||
<string name="sidebar_help"><![CDATA[Help & FAQ]]></string>
|
<string name="sidebar_help"><![CDATA[Help & FAQ]]></string>
|
||||||
<string name="complete_tutorial">Got it!</string>
|
<string name="complete_tutorial">Got it!</string>
|
||||||
<string name="dismiss_tutorial">Remind me again</string>
|
<string name="dismiss_tutorial">Remind me again</string>
|
||||||
|
<string name="intro_1_title">Welcome to Habitica</string>
|
||||||
|
<string name="intro_1_description">Join over 900,000 people having fun while getting things done. Create an avatar and track your real-life tasks.</string>
|
||||||
|
<string name="intro_2_title">Game Progress = Life Progress</string>
|
||||||
|
<string name="intro_2_description">Unlock features in the game by checking off your real-life tasks. Earn armor, pets, and more to reward you for meeting your goals!</string>
|
||||||
|
<string name="intro_3_title">Get Social and Fight Monsters</string>
|
||||||
|
<string name="intro_3_description">Keep your goals on track with help from your friends. Support each other in life and in battle as you improve together!</string>
|
||||||
|
<string name="skip">Skip</string>
|
||||||
|
<string name="intro_finish_button">Get Started</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -17,6 +17,7 @@ import android.util.Log;
|
||||||
import com.crashlytics.android.Crashlytics;
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.core.CrashlyticsCore;
|
import com.crashlytics.android.core.CrashlyticsCore;
|
||||||
import com.facebook.FacebookSdk;
|
import com.facebook.FacebookSdk;
|
||||||
|
import com.habitrpg.android.habitica.ui.activities.IntroActivity;
|
||||||
import com.habitrpg.android.habitica.ui.activities.LoginActivity;
|
import com.habitrpg.android.habitica.ui.activities.LoginActivity;
|
||||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||||
import com.raizlabs.android.dbflow.config.FlowManager;
|
import com.raizlabs.android.dbflow.config.FlowManager;
|
||||||
|
|
@ -214,17 +215,12 @@ public class HabiticaApplication extends Application {
|
||||||
editor.putBoolean("use_reminder", use_reminder);
|
editor.putBoolean("use_reminder", use_reminder);
|
||||||
editor.putString("reminder_time", reminder_time);
|
editor.putString("reminder_time", reminder_time);
|
||||||
editor.commit();
|
editor.commit();
|
||||||
Intent intent = new Intent(context, LoginActivity.class);
|
startActivity(LoginActivity.class, context);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkUserAuthentication(Context context, HostConfig hostConfig) {
|
public static boolean checkUserAuthentication(Context context, HostConfig hostConfig) {
|
||||||
if (hostConfig == null || hostConfig.getApi() == null || hostConfig.getApi().equals("") || hostConfig.getUser() == null || hostConfig.getUser().equals("")) {
|
if (hostConfig == null || hostConfig.getApi() == null || hostConfig.getApi().equals("") || hostConfig.getUser() == null || hostConfig.getUser().equals("")) {
|
||||||
Intent intent = new Intent(context, LoginActivity.class);
|
startActivity(IntroActivity.class, context);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
|
|
||||||
context.startActivity(intent);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -232,6 +228,12 @@ public class HabiticaApplication extends Application {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void startActivity(Class activityClass, Context context) {
|
||||||
|
Intent intent = new Intent(context, activityClass);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region IAP - Specific
|
// region IAP - Specific
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,121 @@
|
||||||
|
package com.habitrpg.android.habitica.ui.activities;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.PersistableBundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
import com.habitrpg.android.habitica.R;
|
||||||
|
import com.habitrpg.android.habitica.ui.fragments.IntroFragment;
|
||||||
|
import com.viewpagerindicator.CirclePageIndicator;
|
||||||
|
|
||||||
|
import butterknife.Bind;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
|
public class IntroActivity extends AppCompatActivity implements View.OnClickListener, ViewPager.OnPageChangeListener {
|
||||||
|
|
||||||
|
@Bind(R.id.view_pager)
|
||||||
|
ViewPager pager;
|
||||||
|
|
||||||
|
@Bind(R.id.view_pager_indicator)
|
||||||
|
CirclePageIndicator indicator;
|
||||||
|
|
||||||
|
@Bind(R.id.skipButton)
|
||||||
|
Button skipButton;
|
||||||
|
|
||||||
|
@Bind(R.id.finishButton)
|
||||||
|
Button finishButton;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_intro);
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
setupIntro();
|
||||||
|
indicator.setViewPager(pager);
|
||||||
|
|
||||||
|
this.skipButton.setOnClickListener(this);
|
||||||
|
this.finishButton.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupIntro() {
|
||||||
|
android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
|
|
||||||
|
pager.setAdapter(new FragmentPagerAdapter(fragmentManager) {
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int position) {
|
||||||
|
IntroFragment fragment = new IntroFragment();
|
||||||
|
|
||||||
|
switch (position) {
|
||||||
|
case 0: {
|
||||||
|
fragment.setImage(getResources().getDrawable(R.drawable.intro_1));
|
||||||
|
fragment.setTitle(getString(R.string.intro_1_title));
|
||||||
|
fragment.setDescription(getString(R.string.intro_1_description));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
fragment.setImage(getResources().getDrawable(R.drawable.intro_2));
|
||||||
|
fragment.setTitle(getString(R.string.intro_2_title));
|
||||||
|
fragment.setDescription(getString(R.string.intro_2_description));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
fragment.setImage(getResources().getDrawable(R.drawable.intro_3));
|
||||||
|
fragment.setTitle(getString(R.string.intro_3_title));
|
||||||
|
fragment.setDescription(getString(R.string.intro_3_description));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
pager.addOnPageChangeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finishIntro();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void finishIntro() {
|
||||||
|
Intent intent = new Intent(this, LoginActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
|
||||||
|
this.startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
if (position == 2) {
|
||||||
|
this.finishButton.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
this.finishButton.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int state) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.habitrpg.android.habitica.ui.fragments;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.habitrpg.android.habitica.R;
|
||||||
|
|
||||||
|
import butterknife.Bind;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
|
public class IntroFragment extends Fragment {
|
||||||
|
|
||||||
|
|
||||||
|
@Bind(R.id.titleTextView)
|
||||||
|
TextView titleTextView;
|
||||||
|
|
||||||
|
@Bind(R.id.descriptionTextView)
|
||||||
|
TextView descriptionTextView;
|
||||||
|
|
||||||
|
@Bind(R.id.imageView)
|
||||||
|
ImageView imageView;
|
||||||
|
|
||||||
|
Drawable image;
|
||||||
|
String title;
|
||||||
|
String description;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
View v = inflater.inflate(R.layout.fragment_intro, container, false);
|
||||||
|
|
||||||
|
ButterKnife.bind(this, v);
|
||||||
|
|
||||||
|
if (this.image != null) {
|
||||||
|
this.imageView.setImageDrawable(this.image);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.title != null) {
|
||||||
|
this.titleTextView.setText(this.title);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.description != null) {
|
||||||
|
this.descriptionTextView.setText(this.description);
|
||||||
|
}
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImage(Drawable image) {
|
||||||
|
this.image = image;
|
||||||
|
if (this.imageView != null && image != null) {
|
||||||
|
this.imageView.setImageDrawable(image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String text) {
|
||||||
|
this.title = text;
|
||||||
|
if (this.titleTextView != null && text != null) {
|
||||||
|
this.titleTextView.setText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String text) {
|
||||||
|
this.description = text;
|
||||||
|
if (this.descriptionTextView != null && text != null) {
|
||||||
|
this.descriptionTextView.setText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue