1
0
mirror of https://github.com/nerzhul/ownCloud-SMS-App.git synced 2025-06-07 16:06:18 +00:00

Add a basic main activity for ownCloud SMS beginers. We need to have a good tutorial, this is a poc

This commit is contained in:
Loïc Blot (@U-Exp) 2015-01-18 19:17:19 +01:00
parent 6480b3dbbd
commit b8f8d3d23f
9 changed files with 474 additions and 47 deletions

View File

@ -3,10 +3,11 @@
package="fr.unix_experience.owncloud_sms"
android:versionCode="17"
android:versionName="0.16.1" >
<!-- From Android 3.0 to 5.0 -->
<!-- From Android 3.0 to 5.0 -->
<uses-sdk
android:minSdkVersion="11"
android:maxSdkVersion="21"
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.READ_SMS" />
@ -19,8 +20,8 @@
<uses-permission android:name="android.permission.READ_SYNC_STATS" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- For account management -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
@ -35,13 +36,13 @@
android:theme="@style/AppTheme" >
<!-- Related to periodic sync -->
<service android:name=".observers.SmsObserverService"
<service
android:name=".observers.SmsObserverService"
android:exported="false" />
<service
<service
android:name=".sync_adapters.SmsSyncService"
android:exported="true"
android:process=":sync">
android:process=":sync" >
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
@ -53,10 +54,10 @@
<provider
android:name=".providers.SmsDataProvider"
android:label="@string/pref_title_sync"
android:authorities="@string/account_authority">
android:authorities="@string/account_authority"
android:label="@string/pref_title_sync" >
</provider>
<!--
<service
android:name=".sync_adapters.SmsSlowSyncService"
@ -78,8 +79,9 @@
</provider>
-->
<!-- Related to Login -->
<service android:name=".authenticators.OwnCloudAuthenticatorService">
<service android:name=".authenticators.OwnCloudAuthenticatorService" >
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
@ -89,15 +91,14 @@
android:resource="@xml/owncloud_account_authenticator" />
</service>
<receiver android:name=".broadcast_receivers.IncomingSms">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<receiver android:name=".broadcast_receivers.ConnectivityChanged">
<receiver android:name=".broadcast_receivers.IncomingSms" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<receiver android:name=".broadcast_receivers.ConnectivityChanged" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
@ -106,9 +107,18 @@
android:label="@string/title_activity_login" >
</activity>
<activity
android:name="fr.unix_experience.owncloud_sms.activities.GeneralSettingsActivity"
android:name=".activities.GeneralSettingsActivity"
android:label="@string/title_activity_general_settings" >
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -1,6 +1,6 @@
<!--
/*
* Copyright (c) 2014, Loic Blot <loic.blot@unix-experience.fr>
* Copyright (c) 2014-2015, Loic Blot <loic.blot@unix-experience.fr>
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions

View File

@ -0,0 +1,33 @@
<!--
/*
* Copyright (c) 2014-2015, Loic Blot <loic.blot@unix-experience.fr>
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-->
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="fr.unix_experience.owncloud_sms.MainActivity" />

View File

@ -0,0 +1,74 @@
<!--
/*
* Copyright (c) 2014-2015, Loic Blot <loic.blot@unix-experience.fr>
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="fr.unix_experience.owncloud_sms.MainActivity$PlaceholderFragment" >
<TextView
android:id="@+id/main_tv_accounts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Add an account"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/mail_button_accounts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/main_tv_accounts"
android:layout_centerHorizontal="true"
android:layout_marginTop="26dp"
android:text="Go to Accounts and Sync" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/main_button_settings"
android:layout_alignLeft="@+id/main_tv_accounts"
android:layout_marginBottom="25dp"
android:text="Change app settings"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/main_button_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Go to Settings" />
</RelativeLayout>

View File

@ -0,0 +1,61 @@
<!--
/*
* Copyright (c) 2014-2015, Loic Blot <loic.blot@unix-experience.fr>
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="fr.unix_experience.owncloud_sms.MainActivity$PlaceholderFragment" >
<TextView
android:id="@+id/section_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/main_title_welcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Welcome"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/main_tv_welcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/section_label"
android:layout_below="@+id/section_label"
android:layout_marginTop="16dp"
android:text="Welcome to ownCloud SMS application. This application let you synchronise your SMS to your ownCloud instance using SMS app."
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>

View File

@ -0,0 +1,87 @@
<!--
/*
* Copyright (c) 2014-2015, Loic Blot <loic.blot@unix-experience.fr>
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="fr.unix_experience.owncloud_sms.MainActivity$PlaceholderFragment" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="22dp"
android:minHeight="36dp"
android:text="Rate us !"
android:textAlignment="center" />
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Thanks to"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/tv_rateUs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/TextView01"
android:layout_marginTop="14dp"
android:text="ownCloud developpers"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_centerVertical="true"
android:text="If you like this application, please give rate us on Google Play Store"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView1"
android:layout_alignLeft="@+id/tv_rateUs"
android:layout_marginBottom="18dp"
android:text="Rate us !"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>

View File

@ -8,6 +8,5 @@
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never"/>
<item android:id="@+id/sync_now" android:title="@string/sync_now"></item>
</menu>

View File

@ -26,22 +26,22 @@
*/
-->
<resources>
<!-- Translation version, reference for translators -->
<string name="translation_version">3</string>
<!-- System strings, do not translate -->
<!-- Translation version, reference for translators -->
<string name="translation_version">3</string>
<!-- System strings, do not translate -->
<string name="app_name">ownCloud-SMS</string>
<string name="account_type">fr.unix_experience.owncloud_sms</string>
<string name="account_authority">fr.unix_experience.owncloud_sms.datasync.provider</string>
<string name="slowsync_account_authority">fr.unix_experience.owncloud_sms.datasync.slowsync_provider</string>
<string name="target_package">fr.unix_experience.owncloud_sms</string>
<string name="login_logo">Login logo</string>
<!-- System strings: preferences -->
<string name="shared_preference_file">ownCloudSMSPrefs</string>
<string name="pref_lastmsgdate">last_message_date</string>
<!-- Translations must begin there -->
<!-- Preferences -->
<string name="pref_title_sync">SMS - Fast</string>
@ -51,17 +51,14 @@
<string name="action_settings">Settings</string>
<string name="sync_now">Synchronize now</string>
<string name="pref_category_sync">Synchronization</string>
<string name="title_global_pref_to_general_prefs">General preferences</string>
<string name="summary_global_pref_to_general_prefs">Sync options</string>
<string name="summary_notif_prefs">Notifications</string>
<string name="title_global_pref_to_general_prefs">General preferences</string>
<string name="summary_global_pref_to_general_prefs">Sync options</string>
<string name="summary_notif_prefs">Notifications</string>
<string name="pref_header_data_sync">Data &amp; sync</string>
<string name="title_activity_general_settings">General Settings</string>
<string name="title_activity_general_settings">General Settings</string>
<string-array name="pref_sync_frequency_titles">
<item>5 minutes</item>
<item>5 minutes</item>
<item>15 minutes</item>
<item>30 minutes</item>
<item>1 hour</item>
@ -72,7 +69,7 @@
<item>Never</item>
</string-array>
<string-array name="pref_sync_frequency_values">
<item>5</item>
<item>5</item>
<item>15</item>
<item>30</item>
<item>60</item>
@ -82,7 +79,6 @@
<item>1440</item>
<item>-1</item>
</string-array>
<string-array name="pref_slow_sync_frequency_titles">
<item>1 hour</item>
<item>3 hours</item>
@ -91,7 +87,6 @@
<item>24 hours</item>
<item>Never</item>
</string-array>
<string-array name="pref_slow_sync_frequency_values">
<item>60</item>
<item>180</item>
@ -100,7 +95,7 @@
<item>1440</item>
<item>-1</item>
</string-array>
<string name="title_activity_login">Sign in</string>
<!-- Login -->
@ -115,18 +110,17 @@
<string name="error_invalid_server_address">Invalid server address</string>
<string name="error_connection_failed">Connection failed, ensure this is the right server</string>
<string name="error_http_connection_failed">Unable to perform a HTTP connection. Please ensure there is a web server</string>
<string-array name="protocol_array">
<item>https://</item>
<item>https://</item>
<item>http://</item>
</string-array>
<!-- Notifications -->
<string name="sync_title">Sync process</string>
<string name="sync_inprogress">Sync in progress...</string>
<string name="fatal_error">Fatal error ! </string>
<!-- Errors -->
<string name="err_sync_get_smslist">Error #1: Invalid data received from server when getting previous messages</string>
<string name="err_sync_craft_http_request">Error #2: Error while crafting HTTP request</string>
@ -143,5 +137,10 @@
<string name="err_sync_http_request_resp">Error #14: Unable to parse server response</string>
<string name="err_sync_http_request_parse_resp">Error #15: Unable to parse server response</string>
<string name="err_sync_no_connection_available">Error #16: No data connection available</string>
<string name="title_activity_main">MainActivity</string>
<string name="title_section1">Section 1</string>
<string name="title_section2">Section 2</string>
<string name="title_section3">Section 3</string>
<string name="hello_world">Hello world!</string>
</resources>

View File

@ -0,0 +1,164 @@
package fr.unix_experience.owncloud_sms;
/*
* Copyright (c) 2014-2015, Loic Blot <loic.blot@unix-experience.fr>
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
import java.util.List;
import java.util.Vector;
import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
public class MainActivity extends ActionBarActivity {
/**
* The {@link android.support.v4.view.PagerAdapter} that will provide
* fragments for each of the sections. We use a {@link FragmentPagerAdapter}
* derivative, which will keep every loaded fragment in memory. If this
* becomes too memory intensive, it may be best to switch to a
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/
MainPagerAdapter mPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
List<Fragment> fragments = new Vector<Fragment>();
/*
* Add the Main tabs here
*/
fragments.add(Fragment.instantiate(this,StarterFragment.class.getName()));
fragments.add(Fragment.instantiate(this,SecondTestFragment.class.getName()));
fragments.add(Fragment.instantiate(this,ThanksAndRateFragment.class.getName()));
mPagerAdapter = new MainPagerAdapter(getSupportFragmentManager(), fragments);
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mPagerAdapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public class MainPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragments;
public MainPagerAdapter(FragmentManager fm, List<Fragment> fragments) {
super(fm);
mFragments = fragments;
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class
// below).
return mFragments.get(position);
}
@Override
public int getCount() {
// Show 3 total pages.
return mFragments.size();
}
}
/**
* Fragments for activity must be there
*/
public static class StarterFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_mainactivity_main, container,
false);
return rootView;
}
}
public static class SecondTestFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_mainactivity_gotosettings, container,
false);
return rootView;
}
}
public static class ThanksAndRateFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_mainactivity_thanks_note, container,
false);
return rootView;
}
}
}