Github user saketkumar95 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173668552
--- Diff:
app/src/main/java/org/apache/taverna/mobile/ui/tutorial/TutorialActivity.java
---
@@ -0,0 +1,200 @@
+package org.apache.taverna.mobile.ui.tutorial;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v4.view.PagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.support.v7.app.AppCompatActivity;
+import android.text.Html;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import org.apache.taverna.mobile.R;
+import org.apache.taverna.mobile.data.local.PreferencesHelper;
+import org.apache.taverna.mobile.ui.FlashScreenActivity;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+
+
+public class TutorialActivity extends AppCompatActivity implements
ViewPager.OnPageChangeListener {
+
+ @BindView(R.id.slide_pager)
+ ViewPager slidePager;
+
+ @BindView(R.id.layoutDots)
+ LinearLayout dotsLayout;
+
+ @BindView(R.id.btn_skip)
+ Button bSkip;
+
+ @BindView(R.id.btn_next)
+ Button bNext;
+
+ int[] layouts;
+ private PreferencesHelper preferencesHelper;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ preferencesHelper = new PreferencesHelper(this);
+ if (!preferencesHelper.isFirstTimeLaunch()) {
+ launchFlashScreen();
+ finish();
+ }
+
+ setContentView(R.layout.activity_tutorial);
+
+ ButterKnife.bind(this);
+
+
+ if (Build.VERSION.SDK_INT >= 21) {
+ getWindow().getDecorView()
+
.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
+ }
+
+ layouts = new int[]{
+ R.layout.tutorial_slide1,
+ R.layout.tutorial_slide2,
+ R.layout.tutorial_slide3,
+ R.layout.tutorial_slide4};
+
+ addBottomDots(0);
+
+ TutorialSliderAdapter tutorialSliderAdapter = new
TutorialSliderAdapter();
+ slidePager.setAdapter(tutorialSliderAdapter);
+ slidePager.addOnPageChangeListener(this);
+
+ }
+
+ @OnClick(R.id.btn_skip)
+ public void skipClick(View v) {
+ launchFlashScreen();
+ }
+
+ @OnClick(R.id.btn_next)
+ public void nextClick(View v) {
+ int current = getItem(+1);
+ if (current < layouts.length) {
+ slidePager.setCurrentItem(current);
+ } else {
+ launchFlashScreen();
+ }
+ }
+
+ public void addBottomDots(int currentPage) {
+ TextView[] dots = new TextView[layouts.length];
+
+ int[] colorsActive =
getResources().getIntArray(R.array.array_dot_active);
+ int[] colorsInactive =
getResources().getIntArray(R.array.array_dot_inactive);
+
+ dotsLayout.removeAllViews();
+ for (int i = 0; i < dots.length; i++) {
+ dots[i] = new TextView(this);
+ dots[i].setText(Html.fromHtml("•"));
+ dots[i].setTextSize(35);
+ dots[i].setTextColor(colorsInactive[currentPage]);
+ dotsLayout.addView(dots[i]);
+ }
+
+ if (dots.length > 0)
+ dots[currentPage].setTextColor(colorsActive[currentPage]);
+ }
+
+ public int getItem(int i) {
+ return slidePager.getCurrentItem() + i;
+ }
+
+ public void launchFlashScreen() {
+ preferencesHelper.setFirstTimeLaunch(false);
+ startActivity(new Intent(TutorialActivity.this,
FlashScreenActivity.class));
+ finish();
+ }
+
+ @Override
+ public void onPageScrolled(int position, float positionOffset, int
positionOffsetPixels) {
+
+ }
+
+ @Override
+ public void onPageSelected(int position) {
+ addBottomDots(position);
+
+ if (position == layouts.length - 1) {
+ bNext.setText(getString(R.string.start));
+ bSkip.setVisibility(View.GONE);
+ } else {
+ bNext.setText(getString(R.string.next));
+ bSkip.setVisibility(View.VISIBLE);
+ }
+
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int state) {
+
+ }
+
+ class TutorialSliderAdapter extends PagerAdapter {
--- End diff --
@sagar15795 This helped me alot. Thanks I updated this. ð
---