Skip to content
Snippets Groups Projects
Commit 658999c1 authored by Alexandre Lision's avatar Alexandre Lision
Browse files

* #36914: fix backstack issues, change selector of app sections

parent 18e30542
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:drawable="@color/darker_gray" android:state_pressed="true"/>
<item android:drawable="@color/lighter_gray" android:state_selected="true"/>
<item android:drawable="@color/lighter_gray" android:state_activated="true"/>
</selector>
\ No newline at end of file
......@@ -24,7 +24,6 @@
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/pts_main"
android:paddingBottom="@dimen/contact_drawer_handle_height" />
android:layout_below="@+id/pts_main" />
</RelativeLayout>
\ No newline at end of file
......@@ -35,8 +35,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/user_name"
android:layout_alignRight="@+id/user_name"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/user_name"
android:layout_below="@+id/user_name" >
<Spinner
......@@ -59,7 +59,9 @@
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
android:layout_height="wrap_content"
android:choiceMode="singleChoice"
android:listSelector="@drawable/navigation_selector" >
</ListView>
</LinearLayout>
\ No newline at end of file
......@@ -7,5 +7,6 @@
android:paddingBottom="10dip"
android:paddingLeft="15dip"
android:paddingTop="10dip"
android:background="?android:attr/activatedBackgroundIndicator"
android:textColor="@color/black"
android:textSize="20sp" />
......@@ -5,6 +5,7 @@
<item name="android:actionMenuTextAppearance">@style/MyActionBar.MenuTextStyle</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">@drawable/bg_72</item>
<item name="android:activatedBackgroundIndicator">@drawable/navigation_selector</item>
</style>
<style name="AppThemeWithoutOverlay" parent="android:Theme.Holo.Light">
......
......@@ -34,6 +34,7 @@ as that of the covered work.
<style name="AppTheme" parent="android:Theme.Light" >
<item name="android:background">@drawable/bg_72</item>
<item name="android:activatedBackgroundIndicator">@drawable/navigation_selector</item>
</style>
<style name="AccountFormContainer">
......
......@@ -333,7 +333,7 @@ public class HomeActivity extends FragmentActivity implements DialingFragment.Ca
fContent = getSupportFragmentManager().findFragmentByTag(entry.getName());
if(fContent == null)
Log.i(TAG, "Null frag");
getSupportFragmentManager().popBackStack();
getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
return;
}
......@@ -685,7 +685,10 @@ public class HomeActivity extends FragmentActivity implements DialingFragment.Ca
if (fContent instanceof HomeFragment)
break;
if(getSupportFragmentManager().getBackStackEntryCount() == 0)
break;
BackStackEntry entry = getSupportFragmentManager().getBackStackEntryAt(0);
fContent = getSupportFragmentManager().findFragmentByTag(entry.getName());
getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
......@@ -694,15 +697,15 @@ public class HomeActivity extends FragmentActivity implements DialingFragment.Ca
case 1:
if (fContent instanceof AccountsManagementFragment)
break;
Log.i(TAG, "BackStackEntries: " + getSupportFragmentManager().getBackStackEntryCount());
fContent = new AccountsManagementFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.main_frame, fContent, "Home").addToBackStack("Home").commit();
getSupportFragmentManager().beginTransaction().replace(R.id.main_frame, fContent, "Accounts").addToBackStack("Accounts").commit();
break;
case 2:
if (fContent instanceof AboutFragment)
break;
fContent = new AboutFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.main_frame, fContent, "Home").addToBackStack("Home").commit();
getSupportFragmentManager().beginTransaction().replace(R.id.main_frame, fContent, "About").addToBackStack("About").commit();
break;
}
......
......@@ -13,6 +13,12 @@ import android.widget.TextView;
public class AboutFragment extends Fragment {
@Override
public void onResume() {
super.onResume();
getActivity().getActionBar().setTitle(R.string.menu_item_about);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
View inflatedView = inflater.inflate(R.layout.frag_about, parent, false);
......@@ -21,7 +27,7 @@ public class AboutFragment extends Fragment {
String linkText = "<a href='http://sflphone.org/'>" + getResources().getString(R.string.web_site) + "</a>";
link.setText(Html.fromHtml(linkText));
link.setMovementMethod(LinkMovementMethod.getInstance());
getActivity().getActionBar().setTitle(R.string.menu_item_about);
return inflatedView;
}
......
......@@ -146,7 +146,6 @@ public class AccountsManagementFragment extends ListFragment implements LoaderCa
mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);
Log.i(TAG, "anim time: " + mShortAnimationDuration);
getActivity().getActionBar().setTitle(R.string.menu_item_accounts);
}
......@@ -204,11 +203,9 @@ public class AccountsManagementFragment extends ListFragment implements LoaderCa
intentFilter2.addAction(ConfigurationManagerCallback.ACCOUNTS_CHANGED);
getActivity().registerReceiver(accountReceiver, intentFilter2);
getActivity().getSupportLoaderManager().restartLoader(LoaderConstants.ACCOUNTS_LOADER, null, this);
getActivity().getActionBar().setTitle(R.string.menu_item_accounts);
}
@Override
public void onCreateOptionsMenu(Menu m, MenuInflater inf) {
super.onCreateOptionsMenu(m, inf);
......@@ -433,16 +430,13 @@ public class AccountsManagementFragment extends ListFragment implements LoaderCa
@Override
public void onLoaderReset(android.support.v4.content.Loader<Bundle> arg0) {
// TODO Stub de la méthode généré automatiquement
}
@Override
public android.support.v4.content.Loader<Bundle> onCreateLoader(int arg0, Bundle arg1) {
AccountsLoader l = new AccountsLoader(getActivity(), mCallbacks.getService());
l.forceLoad();
return l;
}
}
......@@ -45,13 +45,19 @@ import android.view.ViewGroup;
public class HomeFragment extends Fragment {
static final String TAG = HomeFragment.class.getSimpleName();
/**
* The {@link ViewPager} that will host the section contents.
*/
ViewPager mViewPager;
SectionsPagerAdapter mSectionsPagerAdapter = null;
@Override
public void onResume() {
super.onResume();
getActivity().getActionBar().setTitle(R.string.menu_item_home);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
......@@ -61,26 +67,21 @@ public class HomeFragment extends Fragment {
public void onDetach() {
super.onDetach();
}
@Override
public void onCreate(Bundle savedBundle){
public void onCreate(Bundle savedBundle) {
super.onCreate(savedBundle);
//FIXME : getFragmentManager does not handle nested fragments, pages are not saved!
mSectionsPagerAdapter = new SectionsPagerAdapter(getActivity(), getChildFragmentManager());
getActivity().getActionBar().setTitle(R.string.menu_item_home);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.frag_home, container, false);
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) rootView.findViewById(R.id.pager);
mViewPager.setPageTransformer(true, new ZoomOutPageTransformer(0.7f));
mViewPager.setOffscreenPageLimit(2);
mViewPager.setAdapter(mSectionsPagerAdapter);
mViewPager.setCurrentItem(1);
......@@ -96,7 +97,7 @@ public class HomeFragment extends Fragment {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
public class ZoomOutPageTransformer implements ViewPager.PageTransformer {
private static final float MIN_ALPHA = .6f;
......
......@@ -84,14 +84,14 @@ public class MenuFragment extends Fragment implements LoaderCallbacks<Bundle>, A
@Override
public void onSectionSelected(int pos) {
}
};
public interface Callbacks {
public ISipService getService();
public void onSectionSelected(int pos);
}
......@@ -111,7 +111,6 @@ public class MenuFragment extends Fragment implements LoaderCallbacks<Bundle>, A
} catch (Exception e1) {
}
}
......@@ -154,7 +153,7 @@ public class MenuFragment extends Fragment implements LoaderCallbacks<Bundle>, A
((ListView) inflatedView.findViewById(R.id.listView)).setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {
public void onItemClick(AdapterView<?> arg0, View selected, int pos, long arg3) {
mCallbacks.onSectionSelected(pos);
}
});
......@@ -192,24 +191,12 @@ public class MenuFragment extends Fragment implements LoaderCallbacks<Bundle>, A
@Override
public void onStart() {
super.onStart();
}
public Account getSelectedAccount() {
return mAccountAdapter.getSelectedAccount();
}
/**
* Called by activity to pass a reference to sipservice to Fragment.
*
* @param isip
*/
public void onServiceSipBinded(ISipService isip) {
}
public void updateAllAccounts() {
if (getActivity() != null)
getActivity().getSupportLoaderManager().restartLoader(LoaderConstants.ACCOUNTS_LOADER, null, this);
......@@ -234,23 +221,23 @@ public class MenuFragment extends Fragment implements LoaderCallbacks<Bundle>, A
@Override
public android.support.v4.content.Loader<Bundle> onCreateLoader(int arg0, Bundle arg1) {
AccountsLoader l = new AccountsLoader(getActivity(), mCallbacks.getService());
l.forceLoad();
return l;
AccountsLoader l = new AccountsLoader(getActivity(), mCallbacks.getService());
l.forceLoad();
return l;
}
@Override
public void onLoadFinished(android.support.v4.content.Loader<Bundle> arg0, Bundle bun) {
mAccountAdapter.removeAll();
ArrayList<Account> accounts = bun.getParcelableArrayList(AccountsLoader.ACCOUNTS);
mAccountAdapter.addAll(accounts);
mAccountAdapter.removeAll();
ArrayList<Account> accounts = bun.getParcelableArrayList(AccountsLoader.ACCOUNTS);
mAccountAdapter.addAll(accounts);
}
@Override
public void onLoaderReset(android.support.v4.content.Loader<Bundle> arg0) {
// TODO Stub de la méthode généré automatiquement
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment