Help button (#1415)

* Help button added to tutorial

* debug typo removed

* Help changed to more info

* More option moved to bottom

* Alignment changes made
This commit is contained in:
Balakrishnan S 2018-04-30 17:01:27 +05:30 committed by neslihanturan
parent 0223c5ab76
commit 6d2c41b91e
4 changed files with 68 additions and 9 deletions

View file

@ -1,5 +1,6 @@
package fr.free.nrw.commons; package fr.free.nrw.commons;
import android.net.Uri;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.view.PagerAdapter; import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -9,6 +10,7 @@ import android.widget.TextView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import butterknife.Optional;
public class WelcomePagerAdapter extends PagerAdapter { public class WelcomePagerAdapter extends PagerAdapter {
static final int[] PAGE_LAYOUTS = new int[]{ static final int[] PAGE_LAYOUTS = new int[]{
@ -20,6 +22,7 @@ public class WelcomePagerAdapter extends PagerAdapter {
}; };
private static final int PAGE_FINAL = 4; private static final int PAGE_FINAL = 4;
private Callback callback; private Callback callback;
private ViewGroup container;
/** /**
* Changes callback to provided one * Changes callback to provided one
@ -53,6 +56,7 @@ public class WelcomePagerAdapter extends PagerAdapter {
@Override @Override
public Object instantiateItem(ViewGroup container, int position) { public Object instantiateItem(ViewGroup container, int position) {
this.container=container;
LayoutInflater inflater = LayoutInflater.from(container.getContext()); LayoutInflater inflater = LayoutInflater.from(container.getContext());
ViewGroup layout = (ViewGroup) inflater.inflate(PAGE_LAYOUTS[position], container, false); ViewGroup layout = (ViewGroup) inflater.inflate(PAGE_LAYOUTS[position], container, false);
if( BuildConfig.FLAVOR == "beta"){ if( BuildConfig.FLAVOR == "beta"){
@ -102,5 +106,15 @@ public class WelcomePagerAdapter extends PagerAdapter {
} }
} }
@Optional
@OnClick(R.id.welcomeInfo)
void onHelpClicked () {
try {
Utils.handleWebUrl(container.getContext(),Uri.parse("https://commons.wikimedia.org/wiki/Help:Contents" ));
} catch (Exception e) {
e.printStackTrace();
}
}
} }
} }

View file

@ -1,13 +1,33 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#0c609c" android:background="#0c609c"
android:gravity="center"
>
>
<TextView
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="@dimen/large_gap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/welcome_help_button_text"
android:id="@+id/welcomeInfo"
android:layout_gravity="end|top"
android:layout_marginTop="@dimen/standard_gap"
android:layout_marginRight="@dimen/standard_gap"
android:layout_marginEnd="@dimen/standard_gap"
android:textSize="@dimen/normal_text"
android:textColor="@android:color/white"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center">
<!-- Sorry about the hardcoded sizes here. They're image-related. --> <!-- Sorry about the hardcoded sizes here. They're image-related. -->
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -59,6 +79,8 @@
android:textColor="#0c609c" android:textColor="#0c609c"
android:textStyle="bold" android:textStyle="bold"
/> />
</LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </RelativeLayout>

View file

@ -1,14 +1,18 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#0c609c" android:background="#0c609c"
android:gravity="center_vertical"
> >
<LinearLayout <LinearLayout
android:gravity="center" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical">
<LinearLayout
android:gravity="center_vertical"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_height="180dp" android:layout_height="180dp"
@ -60,4 +64,22 @@
android:textStyle="bold" android:textStyle="bold"
/> />
</LinearLayout> </LinearLayout>
<TextView
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:layout_marginTop="@dimen/standard_gap"
android:layout_marginRight="@dimen/standard_gap"
android:layout_marginEnd="@dimen/standard_gap"
android:id="@+id/welcomeInfo"
android:textSize="@dimen/normal_text"
android:textColor="@android:color/white"
android:text="@string/welcome_help_button_text"
android:layout_marginBottom="@dimen/large_gap"
android:paddingBottom="@dimen/large_gap"
/>
</RelativeLayout>

View file

@ -149,6 +149,7 @@
<string name="welcome_copyright_subtext">Avoid copyrighted materials you found from the Internet as well as images of posters, book covers, etc.</string> <string name="welcome_copyright_subtext">Avoid copyrighted materials you found from the Internet as well as images of posters, book covers, etc.</string>
<string name="welcome_final_text">You think you got it?</string> <string name="welcome_final_text">You think you got it?</string>
<string name="welcome_final_button_text">Yes!</string> <string name="welcome_final_button_text">Yes!</string>
<string name="welcome_help_button_text"><u>More Information</u></string>
<string name="detail_panel_cats_label">Categories</string> <string name="detail_panel_cats_label">Categories</string>
<string name="detail_panel_cats_loading">Loading…</string> <string name="detail_panel_cats_loading">Loading…</string>
<string name="detail_panel_cats_none">None selected</string> <string name="detail_panel_cats_none">None selected</string>