You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@taverna.apache.org by saketkumar95 <gi...@git.apache.org> on 2018/03/02 01:02:22 UTC
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
GitHub user saketkumar95 opened a pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66
Adds tutorial screens on first start of the app
This PR adds tutorial screens on first start of the app.
- [x] Apply the `AndroidStyle.xml` style template to your code in Android Studio.
- [x] Run the checks with `./gradlew check` to make sure you didn't break anything
- [x] If you have multiple commits please combine them into one commit by squashing them.
Here is the screenshots of all the slides.
<img width="366" alt="screen shot 2018-03-02 at 6 26 22 am" src="https://user-images.githubusercontent.com/21558765/36878077-5433d300-1de3-11e8-80ae-0ae7e379a483.png">
<img width="370" alt="screen shot 2018-03-02 at 6 26 43 am" src="https://user-images.githubusercontent.com/21558765/36878079-54b405a2-1de3-11e8-9a0f-7501ba45da7f.png">
<img width="367" alt="screen shot 2018-03-02 at 6 27 19 am" src="https://user-images.githubusercontent.com/21558765/36878080-54e790c0-1de3-11e8-926c-9eff65f92432.png">
<img width="370" alt="screen shot 2018-03-02 at 6 27 53 am" src="https://user-images.githubusercontent.com/21558765/36878081-551c676e-1de3-11e8-960a-12beaa19001c.png">
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/saketkumar95/incubator-taverna-mobile tutorials
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-taverna-mobile/pull/66.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #66
----
commit e8e62cd9ccbcef29efff8597db551a23f4cfddd0
Author: saketkumar95 <sa...@...>
Date: 2018-03-01T08:28:10Z
Adds tutorial screens on first start of the app
----
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173370978
--- Diff: app/src/main/res/layout/activity_tutorial.xml ---
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+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.
+-->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:showIn="@layout/activity_tutorial">
+
+
+ <android.support.v4.view.ViewPager
+ android:id="@+id/view_pager"
--- End diff --
make it meaningful
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r172019744
--- Diff: app/src/main/java/org/apache/taverna/mobile/ui/TutorialActivity.java ---
@@ -0,0 +1,218 @@
+/*
+ * 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.
+ */
+
+package org.apache.taverna.mobile.ui;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Color;
+import android.os.Build;
+import android.os.Bundle;
+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.view.Window;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import org.apache.taverna.mobile.R;
+import org.apache.taverna.mobile.utils.PreferencesManager;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+
+public class TutorialActivity extends AppCompatActivity {
+
+ @BindView(R.id.view_pager)
+ ViewPager viewPager;
+
+ @BindView(R.id.layoutDots)
+ LinearLayout dotsLayout;
+
+ @BindView(R.id.btn_skip)
+ Button bSkip;
+
+ @BindView(R.id.btn_next)
+ Button bNext;
+
+
+ ViewPagerAdapter viewPagerAdapter;
+ TextView[] dots;
+ int[] layouts;
+ PreferencesManager preferencesManager;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ preferencesManager = new PreferencesManager(this);
+ if (!preferencesManager.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 of all tutorial sliders
+ layouts = new int[]{
+ R.layout.tutorial_slide1,
+ R.layout.tutorial_slide2,
+ R.layout.tutorial_slide3,
+ R.layout.tutorial_slide4};
+
+ addBottomDots(0);
+
+ changeStatusBarColor();
+
+ viewPagerAdapter = new ViewPagerAdapter();
+ viewPager.setAdapter(viewPagerAdapter);
+ viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
+
+ bSkip.setOnClickListener(new View.OnClickListener() {
--- End diff --
use `@OnClick` butterknife function.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173627149
--- Diff: app/src/main/AndroidManifest.xml ---
@@ -19,63 +19,67 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.apache.taverna.mobile">
--- End diff --
Revert all unwanted changes. Change only that line which is required
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173696061
--- Diff: app/src/main/AndroidManifest.xml ---
@@ -37,14 +37,18 @@ limitations under the License.
android:label="@string/app_name">
</activity>
<activity
- android:name=".ui.FlashScreenActivity"
- android:label="@string/title_activity_flash_screen">
+ android:name=".ui.tutorial.TutorialActivity"
--- End diff --
Launcher activity should be `FlashScreenActivity`.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173626850
--- 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() {
--- End diff --
change this line to `slidePager.addOnPageChangeListener(this);` and impelement its interface to the class.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by saketkumar95 <gi...@git.apache.org>.
Github user saketkumar95 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173773188
--- Diff: app/src/main/java/org/apache/taverna/mobile/ui/tutorial/TutorialActivity.java ---
@@ -0,0 +1,161 @@
+/*
+ * 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.
+ */
+package org.apache.taverna.mobile.ui.tutorial;
+
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.v4.view.ViewPager;
+import android.support.v7.app.AppCompatActivity;
+import android.text.Html;
+import android.view.View;
+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 org.apache.taverna.mobile.ui.adapter.TutorialSliderAdapter;
+
+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();
--- End diff --
@sagar15795 Check this!
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173370197
--- Diff: app/src/main/java/org/apache/taverna/mobile/ui/tutorial/TutorialActivity.java ---
@@ -0,0 +1,204 @@
+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.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.view_pager)
+ ViewPager viewPager;
--- End diff --
make it more meaningful.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r176149524
--- Diff: app/src/main/res/layout/activity_tutorial.xml ---
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+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.
+-->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:showIn="@layout/activity_tutorial">
+
+
+ <android.support.v4.view.ViewPager
+ android:id="@+id/slide_pager"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <LinearLayout
+ android:id="@+id/layoutDots"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/dots_height"
+ android:layout_alignParentBottom="true"
+ android:layout_marginBottom="@dimen/dots_margin_bottom"
+ android:gravity="center"
+ android:orientation="horizontal">
+ </LinearLayout>
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
--- End diff --
Move it to `dimens.xml`
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/incubator-taverna-mobile/pull/66
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173696290
--- Diff: app/src/main/java/org/apache/taverna/mobile/ui/tutorial/TutorialActivity.java ---
@@ -0,0 +1,161 @@
+/*
+ * 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.
+ */
+package org.apache.taverna.mobile.ui.tutorial;
+
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.v4.view.ViewPager;
+import android.support.v7.app.AppCompatActivity;
+import android.text.Html;
+import android.view.View;
+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 org.apache.taverna.mobile.ui.adapter.TutorialSliderAdapter;
+
+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[]{
--- End diff --
use `TutorialSliderEnum`
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r176149784
--- Diff: app/src/main/res/layout/tutorial_slide1.xml ---
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+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.
+-->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/bg_screen1">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/slide_1_title"
+ android:textColor="@android:color/white"
+ android:textSize="@dimen/slide_title"
+ android:textStyle="bold" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="20dp"
--- End diff --
Move it to `dimens.xml`
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173370104
--- Diff: app/src/main/java/org/apache/taverna/mobile/data/local/PreferencesHelper.java ---
@@ -65,10 +65,14 @@
private final SharedPreferences sharedPref;
private Context mContext;
+ private SharedPreferences.Editor editor;
+
+ private static final String IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch";
public PreferencesHelper(Context context) {
sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
mContext = context;
+ editor = sharedPref.edit();
--- End diff --
remove and call it when it's needed
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173370378
--- Diff: app/src/main/java/org/apache/taverna/mobile/ui/tutorial/TutorialActivity.java ---
@@ -0,0 +1,204 @@
+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.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.view_pager)
+ ViewPager viewPager;
+
+ @BindView(R.id.layoutDots)
+ LinearLayout dotsLayout;
+
+ @BindView(R.id.btn_skip)
+ Button bSkip;
+
+ @BindView(R.id.btn_next)
+ Button bNext;
+
+
+ ViewPagerAdapter viewPagerAdapter;
+ TextView[] dots;
--- End diff --
Can we make it local variable?
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by saketkumar95 <gi...@git.apache.org>.
Github user saketkumar95 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173668561
--- Diff: app/src/main/AndroidManifest.xml ---
@@ -19,63 +19,67 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.apache.taverna.mobile">
--- End diff --
Done! 👍
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173370470
--- Diff: app/src/main/java/org/apache/taverna/mobile/ui/tutorial/TutorialActivity.java ---
@@ -0,0 +1,204 @@
+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.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.view_pager)
+ ViewPager viewPager;
+
+ @BindView(R.id.layoutDots)
+ LinearLayout dotsLayout;
+
+ @BindView(R.id.btn_skip)
+ Button bSkip;
+
+ @BindView(R.id.btn_next)
+ Button bNext;
+
+
+ ViewPagerAdapter viewPagerAdapter;
+ TextView[] dots;
+ int[] layouts;
+ PreferencesHelper preferencesHelper;
--- End diff --
make it private.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by saketkumar95 <gi...@git.apache.org>.
Github user saketkumar95 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173773510
--- Diff: app/src/main/AndroidManifest.xml ---
@@ -37,14 +37,18 @@ limitations under the License.
android:label="@string/app_name">
</activity>
<activity
- android:name=".ui.FlashScreenActivity"
- android:label="@string/title_activity_flash_screen">
+ android:name=".ui.tutorial.TutorialActivity"
--- End diff --
I have used the preference which checks if the app is first time launched or not.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173370457
--- Diff: app/src/main/java/org/apache/taverna/mobile/ui/tutorial/TutorialActivity.java ---
@@ -0,0 +1,204 @@
+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.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.view_pager)
+ ViewPager viewPager;
+
+ @BindView(R.id.layoutDots)
+ LinearLayout dotsLayout;
+
+ @BindView(R.id.btn_skip)
+ Button bSkip;
+
+ @BindView(R.id.btn_next)
+ Button bNext;
+
+
+ ViewPagerAdapter viewPagerAdapter;
+ TextView[] dots;
+ int[] layouts;
--- End diff --
make it private.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173370036
--- Diff: app/src/main/java/org/apache/taverna/mobile/data/local/PreferencesHelper.java ---
@@ -65,10 +65,14 @@
private final SharedPreferences sharedPref;
private Context mContext;
+ private SharedPreferences.Editor editor;
--- End diff --
This variable is not needed
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
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`.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by saketkumar95 <gi...@git.apache.org>.
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. 👍
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173862548
--- Diff: app/src/main/AndroidManifest.xml ---
@@ -37,14 +37,18 @@ limitations under the License.
android:label="@string/app_name">
</activity>
<activity
- android:name=".ui.FlashScreenActivity"
- android:label="@string/title_activity_flash_screen">
+ android:name=".ui.tutorial.TutorialActivity"
--- End diff --
But first show flash screen then tutorial. And manage first time launch in flash screen.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173370826
--- Diff: app/src/main/java/org/apache/taverna/mobile/ui/tutorial/TutorialActivity.java ---
@@ -0,0 +1,204 @@
+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.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.view_pager)
+ ViewPager viewPager;
+
+ @BindView(R.id.layoutDots)
+ LinearLayout dotsLayout;
+
+ @BindView(R.id.btn_skip)
+ Button bSkip;
+
+ @BindView(R.id.btn_next)
+ Button bNext;
+
+
+ ViewPagerAdapter viewPagerAdapter;
+ TextView[] dots;
+ int[] layouts;
+ 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);
+
+ viewPagerAdapter = new ViewPagerAdapter();
+ viewPager.setAdapter(viewPagerAdapter);
+ viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
+
+ }
+
+ @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) {
+ viewPager.setCurrentItem(current);
+ } else {
+ launchFlashScreen();
+ }
+ }
+
+ public void addBottomDots(int currentPage) {
+ 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 viewPager.getCurrentItem() + i;
+ }
+
+ public void launchFlashScreen() {
+ preferencesHelper.setFirstTimeLaunch(false);
+ startActivity(new Intent(TutorialActivity.this, FlashScreenActivity.class));
+ finish();
+ }
+
+ ViewPager.OnPageChangeListener viewPagerPageChangeListener =
--- End diff --
Implement this interface in place of the object.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r176150019
--- Diff: app/src/main/res/layout/tutorial_slide3.xml ---
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+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.
+-->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/bg_screen3">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/slide_3_title"
+ android:textColor="@android:color/white"
+ android:textSize="@dimen/slide_title"
+ android:textStyle="bold" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="20dp"
--- End diff --
Move it to `dimens.xml`
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173627173
--- 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 --
You have not moved this to the separate class
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173370231
--- Diff: app/src/main/java/org/apache/taverna/mobile/ui/tutorial/TutorialActivity.java ---
@@ -0,0 +1,204 @@
+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.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.view_pager)
+ ViewPager viewPager;
+
+ @BindView(R.id.layoutDots)
+ LinearLayout dotsLayout;
+
+ @BindView(R.id.btn_skip)
+ Button bSkip;
+
+ @BindView(R.id.btn_next)
+ Button bNext;
+
+
+ ViewPagerAdapter viewPagerAdapter;
--- End diff --
make it Private and meaningful name.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r172019875
--- Diff: app/src/main/java/org/apache/taverna/mobile/ui/TutorialActivity.java ---
@@ -0,0 +1,218 @@
+/*
+ * 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.
+ */
+
+package org.apache.taverna.mobile.ui;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Color;
+import android.os.Build;
+import android.os.Bundle;
+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.view.Window;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import org.apache.taverna.mobile.R;
+import org.apache.taverna.mobile.utils.PreferencesManager;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+
+public class TutorialActivity extends AppCompatActivity {
+
+ @BindView(R.id.view_pager)
+ ViewPager viewPager;
+
+ @BindView(R.id.layoutDots)
+ LinearLayout dotsLayout;
+
+ @BindView(R.id.btn_skip)
+ Button bSkip;
+
+ @BindView(R.id.btn_next)
+ Button bNext;
+
+
+ ViewPagerAdapter viewPagerAdapter;
+ TextView[] dots;
+ int[] layouts;
+ PreferencesManager preferencesManager;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ preferencesManager = new PreferencesManager(this);
+ if (!preferencesManager.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 of all tutorial sliders
+ layouts = new int[]{
+ R.layout.tutorial_slide1,
+ R.layout.tutorial_slide2,
+ R.layout.tutorial_slide3,
+ R.layout.tutorial_slide4};
+
+ addBottomDots(0);
+
+ changeStatusBarColor();
+
+ viewPagerAdapter = new ViewPagerAdapter();
+ viewPager.setAdapter(viewPagerAdapter);
+ viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
+
+ bSkip.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ launchFlashScreen();
+ }
+ });
+
+ bNext.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ int current = getItem(+1);
+ if (current < layouts.length) {
+ viewPager.setCurrentItem(current);
+ } else {
+ launchFlashScreen();
+ }
+ }
+ });
+ }
+
+ private void addBottomDots(int currentPage) {
+ 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]);
+ }
+
+ private int getItem(int i) {
+ return viewPager.getCurrentItem() + i;
+ }
+
+ private void launchFlashScreen() {
+ preferencesManager.setFirstTimeLaunch(false);
+ startActivity(new Intent(TutorialActivity.this, FlashScreenActivity.class));
+ finish();
+ }
+
+ ViewPager.OnPageChangeListener viewPagerPageChangeListener =
+ new ViewPager.OnPageChangeListener() {
+
+ @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 onPageScrolled(int arg0, float arg1, int arg2) {
+
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int arg0) {
+
+ }
+ };
+
+ private void changeStatusBarColor() {
--- End diff --
change status bar color on the basis of the theme not manually.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r176149908
--- Diff: app/src/main/res/layout/tutorial_slide2.xml ---
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+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.
+-->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/bg_screen2">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/slide_2_title"
+ android:textColor="@android:color/white"
+ android:textSize="@dimen/slide_title"
+ android:textStyle="bold" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="20dp"
--- End diff --
Move it to `dimens.xml`
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173627247
--- 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 --
https://www.bignerdranch.com/blog/viewpager-without-fragments/
This link might help.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173370010
--- Diff: app/src/main/java/org/apache/taverna/mobile/data/local/PreferencesHelper.java ---
@@ -157,6 +161,15 @@ private void setUserAvatar(String userAvatar) {
sharedPref.edit().putString(PREF_KEY_USER_AVATAR, userAvatar).apply();
}
+ public void setFirstTimeLaunch(boolean isFirstTime) {
+ editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime);
--- End diff --
replace `editor` with `sharedPref.edit()`
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by saketkumar95 <gi...@git.apache.org>.
Github user saketkumar95 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173622525
--- Diff: app/src/main/java/org/apache/taverna/mobile/ui/tutorial/TutorialActivity.java ---
@@ -0,0 +1,204 @@
+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.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.view_pager)
+ ViewPager viewPager;
+
+ @BindView(R.id.layoutDots)
+ LinearLayout dotsLayout;
+
+ @BindView(R.id.btn_skip)
+ Button bSkip;
+
+ @BindView(R.id.btn_next)
+ Button bNext;
+
+
+ ViewPagerAdapter viewPagerAdapter;
+ TextView[] dots;
+ int[] layouts;
+ 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);
+
+ viewPagerAdapter = new ViewPagerAdapter();
+ viewPager.setAdapter(viewPagerAdapter);
+ viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
+
+ }
+
+ @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) {
+ viewPager.setCurrentItem(current);
+ } else {
+ launchFlashScreen();
+ }
+ }
+
+ public void addBottomDots(int currentPage) {
+ 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 viewPager.getCurrentItem() + i;
+ }
+
+ public void launchFlashScreen() {
+ preferencesHelper.setFirstTimeLaunch(false);
+ startActivity(new Intent(TutorialActivity.this, FlashScreenActivity.class));
+ finish();
+ }
+
+ ViewPager.OnPageChangeListener viewPagerPageChangeListener =
+ new ViewPager.OnPageChangeListener() {
+
+ @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 onPageScrolled(int arg0, float arg1, int arg2) {
+
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int arg0) {
+
+ }
+ };
+
+ public class ViewPagerAdapter extends PagerAdapter {
--- End diff --
@sagar15795 layouts position will not be reachable by moving it in separate class. If there is any other way then do let me know. 👍
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173626750
--- Diff: app/src/main/java/org/apache/taverna/mobile/ui/tutorial/TutorialActivity.java ---
@@ -0,0 +1,204 @@
+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.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.view_pager)
+ ViewPager viewPager;
+
+ @BindView(R.id.layoutDots)
+ LinearLayout dotsLayout;
+
+ @BindView(R.id.btn_skip)
+ Button bSkip;
+
+ @BindView(R.id.btn_next)
+ Button bNext;
+
+
+ ViewPagerAdapter viewPagerAdapter;
+ TextView[] dots;
+ int[] layouts;
+ 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);
+
+ viewPagerAdapter = new ViewPagerAdapter();
+ viewPager.setAdapter(viewPagerAdapter);
+ viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
+
+ }
+
+ @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) {
+ viewPager.setCurrentItem(current);
+ } else {
+ launchFlashScreen();
+ }
+ }
+
+ public void addBottomDots(int currentPage) {
+ 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 viewPager.getCurrentItem() + i;
+ }
+
+ public void launchFlashScreen() {
+ preferencesHelper.setFirstTimeLaunch(false);
+ startActivity(new Intent(TutorialActivity.this, FlashScreenActivity.class));
+ finish();
+ }
+
+ ViewPager.OnPageChangeListener viewPagerPageChangeListener =
+ new ViewPager.OnPageChangeListener() {
+
+ @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 onPageScrolled(int arg0, float arg1, int arg2) {
+
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int arg0) {
+
+ }
+ };
+
+ public class ViewPagerAdapter extends PagerAdapter {
--- End diff --
https://www.bignerdranch.com/blog/viewpager-without-fragments/
This link might help.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r172019762
--- Diff: app/src/main/java/org/apache/taverna/mobile/ui/TutorialActivity.java ---
@@ -0,0 +1,218 @@
+/*
+ * 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.
+ */
+
+package org.apache.taverna.mobile.ui;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Color;
+import android.os.Build;
+import android.os.Bundle;
+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.view.Window;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import org.apache.taverna.mobile.R;
+import org.apache.taverna.mobile.utils.PreferencesManager;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+
+public class TutorialActivity extends AppCompatActivity {
+
+ @BindView(R.id.view_pager)
+ ViewPager viewPager;
+
+ @BindView(R.id.layoutDots)
+ LinearLayout dotsLayout;
+
+ @BindView(R.id.btn_skip)
+ Button bSkip;
+
+ @BindView(R.id.btn_next)
+ Button bNext;
+
+
+ ViewPagerAdapter viewPagerAdapter;
+ TextView[] dots;
+ int[] layouts;
+ PreferencesManager preferencesManager;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ preferencesManager = new PreferencesManager(this);
+ if (!preferencesManager.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 of all tutorial sliders
+ layouts = new int[]{
+ R.layout.tutorial_slide1,
+ R.layout.tutorial_slide2,
+ R.layout.tutorial_slide3,
+ R.layout.tutorial_slide4};
+
+ addBottomDots(0);
+
+ changeStatusBarColor();
+
+ viewPagerAdapter = new ViewPagerAdapter();
+ viewPager.setAdapter(viewPagerAdapter);
+ viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
+
+ bSkip.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ launchFlashScreen();
+ }
+ });
+
+ bNext.setOnClickListener(new View.OnClickListener() {
--- End diff --
use '@OnClick' butterknife function
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173370869
--- Diff: app/src/main/java/org/apache/taverna/mobile/ui/tutorial/TutorialActivity.java ---
@@ -0,0 +1,204 @@
+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.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.view_pager)
+ ViewPager viewPager;
+
+ @BindView(R.id.layoutDots)
+ LinearLayout dotsLayout;
+
+ @BindView(R.id.btn_skip)
+ Button bSkip;
+
+ @BindView(R.id.btn_next)
+ Button bNext;
+
+
+ ViewPagerAdapter viewPagerAdapter;
+ TextView[] dots;
+ int[] layouts;
+ 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);
+
+ viewPagerAdapter = new ViewPagerAdapter();
+ viewPager.setAdapter(viewPagerAdapter);
+ viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
+
+ }
+
+ @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) {
+ viewPager.setCurrentItem(current);
+ } else {
+ launchFlashScreen();
+ }
+ }
+
+ public void addBottomDots(int currentPage) {
+ 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 viewPager.getCurrentItem() + i;
+ }
+
+ public void launchFlashScreen() {
+ preferencesHelper.setFirstTimeLaunch(false);
+ startActivity(new Intent(TutorialActivity.this, FlashScreenActivity.class));
+ finish();
+ }
+
+ ViewPager.OnPageChangeListener viewPagerPageChangeListener =
+ new ViewPager.OnPageChangeListener() {
+
+ @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 onPageScrolled(int arg0, float arg1, int arg2) {
+
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int arg0) {
+
+ }
+ };
+
+ public class ViewPagerAdapter extends PagerAdapter {
--- End diff --
Move it to separate class.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r172019667
--- Diff: app/src/main/java/org/apache/taverna/mobile/utils/PreferencesManager.java ---
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+package org.apache.taverna.mobile.utils;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.content.SharedPreferences;
+
+
+public class PreferencesManager {
--- End diff --
We are using `PreferencesHelper` to manage all shared preferences. Please use it only.
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r176150157
--- Diff: app/src/main/res/layout/tutorial_slide4.xml ---
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/bg_screen4">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/slide_4_title"
+ android:textColor="@android:color/white"
+ android:textSize="@dimen/slide_title"
+ android:textStyle="bold" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="20dp"
--- End diff --
Move it to `dimens.xml`
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by saketkumar95 <gi...@git.apache.org>.
Github user saketkumar95 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173622568
--- Diff: app/src/main/java/org/apache/taverna/mobile/ui/tutorial/TutorialActivity.java ---
@@ -0,0 +1,204 @@
+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.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.view_pager)
+ ViewPager viewPager;
+
+ @BindView(R.id.layoutDots)
+ LinearLayout dotsLayout;
+
+ @BindView(R.id.btn_skip)
+ Button bSkip;
+
+ @BindView(R.id.btn_next)
+ Button bNext;
+
+
+ ViewPagerAdapter viewPagerAdapter;
+ TextView[] dots;
+ int[] layouts;
+ 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);
+
+ viewPagerAdapter = new ViewPagerAdapter();
+ viewPager.setAdapter(viewPagerAdapter);
+ viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
+
+ }
+
+ @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) {
+ viewPager.setCurrentItem(current);
+ } else {
+ launchFlashScreen();
+ }
+ }
+
+ public void addBottomDots(int currentPage) {
+ 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 viewPager.getCurrentItem() + i;
+ }
+
+ public void launchFlashScreen() {
+ preferencesHelper.setFirstTimeLaunch(false);
+ startActivity(new Intent(TutorialActivity.this, FlashScreenActivity.class));
+ finish();
+ }
+
+ ViewPager.OnPageChangeListener viewPagerPageChangeListener =
--- End diff --
I tried this but we need to have the selected page item in `viewpager.addOnPageChangeListener`
---
[GitHub] incubator-taverna-mobile pull request #66: Adds tutorial screens on first st...
Posted by saketkumar95 <gi...@git.apache.org>.
Github user saketkumar95 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173773226
--- Diff: app/src/main/AndroidManifest.xml ---
@@ -37,14 +37,18 @@ limitations under the License.
android:label="@string/app_name">
</activity>
<activity
- android:name=".ui.FlashScreenActivity"
- android:label="@string/title_activity_flash_screen">
+ android:name=".ui.tutorial.TutorialActivity"
--- End diff --
I have used the preference which checks if the app is first time launched or not.
---