From dev-return-4723-archive-asf-public=cust-asf.ponee.io@taverna.incubator.apache.org Sat Mar 10 17:24:31 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 52041180651 for ; Sat, 10 Mar 2018 17:24:31 +0100 (CET) Received: (qmail 26318 invoked by uid 500); 10 Mar 2018 16:24:30 -0000 Mailing-List: contact dev-help@taverna.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@taverna.incubator.apache.org Delivered-To: mailing list dev@taverna.incubator.apache.org Received: (qmail 26307 invoked by uid 99); 10 Mar 2018 16:24:29 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Mar 2018 16:24:29 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 535191A09F2 for ; Sat, 10 Mar 2018 16:24:29 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.03 X-Spam-Level: X-Spam-Status: No, score=-4.03 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id M60lMMBhimCN for ; Sat, 10 Mar 2018 16:24:27 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id C46FC5F4AA for ; Sat, 10 Mar 2018 16:24:26 +0000 (UTC) Received: (qmail 26281 invoked by uid 99); 10 Mar 2018 16:24:26 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Mar 2018 16:24:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E2B92E0916; Sat, 10 Mar 2018 16:24:25 +0000 (UTC) From: sagar15795 To: dev@taverna.incubator.apache.org Reply-To: dev@taverna.incubator.apache.org References: In-Reply-To: Subject: [GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st... Content-Type: text/plain Message-Id: <20180310162425.E2B92E0916@git1-us-west.apache.org> Date: Sat, 10 Mar 2018 16:24:25 +0000 (UTC) Github user sagar15795 commented on a diff in the pull request: https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173626652 --- Diff: app/src/main/java/org/apache/taverna/mobile/ui/tutorial/TutorialActivity.java --- @@ -0,0 +1,203 @@ +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 { + + @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; + + private TutorialSliderAdapter tutorialSliderAdapter; + 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 = new TutorialSliderAdapter(); + slidePager.setAdapter(tutorialSliderAdapter); + slidePager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { + @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) { + + } + }); + + } + + @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(); + } + + class TutorialSliderAdapter extends PagerAdapter { + private LayoutInflater layoutInflater; + + private TutorialSliderAdapter() { + } + + @NonNull + @Override + public Object instantiateItem(@NonNull ViewGroup container, int position) { + layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); + + assert layoutInflater != null; --- End diff -- `assert` will create runtime exception so use `if-else`. ---