diff --git a/OpenLP2.iml b/OpenLP2.iml index 0bb6048..09e9d22 100644 --- a/OpenLP2.iml +++ b/OpenLP2.iml @@ -1,9 +1,10 @@ - + @@ -15,5 +16,4 @@ - - + \ No newline at end of file diff --git a/app/app.iml b/app/app.iml index 8dece28..e153ea9 100644 --- a/app/app.iml +++ b/app/app.iml @@ -1,5 +1,5 @@ - + @@ -12,8 +12,9 @@ - - + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6e0cd60..1169814 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,7 +13,8 @@ android:theme="@style/AppTheme" > + android:label="@string/app_name" + android:configChanges="orientation"> diff --git a/app/src/main/java/org/openlp/android2/OpenLP.java b/app/src/main/java/org/openlp/android2/OpenLP.java index 0a639c7..bce4c50 100644 --- a/app/src/main/java/org/openlp/android2/OpenLP.java +++ b/app/src/main/java/org/openlp/android2/OpenLP.java @@ -18,24 +18,19 @@ *******************************************************************************/ package org.openlp.android2; -import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.Configuration; import android.preference.PreferenceManager; import android.support.v7.app.ActionBarActivity; import android.app.ActionBar; -import android.app.Fragment; import android.app.FragmentManager; - import android.os.Bundle; import android.util.Log; -import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.view.ViewGroup; import android.support.v4.widget.DrawerLayout; - import org.openlp.android2.activities.SettingsActivity; import org.openlp.android2.common.NavigationOptions; import org.openlp.android2.dialogs.AlertDisplayDialog; @@ -62,8 +57,6 @@ public class OpenLP extends ActionBarActivity */ private final String LOG_TAG = OpenLP.class.getName(); private CharSequence mTitle; - private boolean backArrowActive = false; - private Menu dropdownMenu; @Override protected void onCreate(Bundle savedInstanceState) { @@ -94,6 +87,12 @@ public class OpenLP extends ActionBarActivity } } + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + //here you can handle orientation change + Log.d(LOG_TAG, "Changed direction"); + } @Override public void onNavigationDrawerItemSelected(int position) { @@ -101,41 +100,66 @@ public class OpenLP extends ActionBarActivity FragmentManager fragmentManager = getFragmentManager(); switch (position) { case NavigationOptions.Home: + singleTab(); fragmentManager.beginTransaction() .replace(R.id.container, HomeFragment.newInstance()) .commit(); mTitle = getString(R.string.home); break; case NavigationOptions.ServiceList: + singleTab(); fragmentManager.beginTransaction() .replace(R.id.container, ServiceListFragment.newInstance()) .commit(); mTitle = getString(R.string.service_list); break; case NavigationOptions.LiveList: + duelTab(); fragmentManager.beginTransaction() - .replace(R.id.container, LiveListFragment.newInstance()) + .replace(R.id.container_left, ServiceListFragment.newInstance()) + .commit(); + fragmentManager.beginTransaction() + .replace(R.id.container_right, LiveListFragment.newInstance()) .commit(); mTitle = getString(R.string.live_list); break; case NavigationOptions.StageView: + singleTab(); fragmentManager.beginTransaction() .replace(R.id.container, StageWebFragment.newInstance()) .commit(); mTitle = getString(R.string.stage_view); break; case NavigationOptions.LiveView: + singleTab(); fragmentManager.beginTransaction() .replace(R.id.container, LiveWebFragment.newInstance()) .commit(); mTitle = getString(R.string.live_view); break; } - menuVisible(); + } + + protected void duelTab(){ + toggerContainer(R.id.container, View.GONE); + toggerContainer(R.id.container_right, View.VISIBLE); + toggerContainer(R.id.container_left, View.VISIBLE); + } + + protected void singleTab(){ + toggerContainer(R.id.container_right, View.GONE); + toggerContainer(R.id.container_left, View.GONE); + toggerContainer(R.id.container, View.VISIBLE); + } + + protected void toggerContainer(int container, int direction){ + View cTainer = this.findViewById(container); + if (cTainer != null) { + cTainer.setVisibility(direction); + } } public void restoreActionBar() { - try { ActionBar actionBar = getActionBar(); //actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); @@ -146,25 +170,6 @@ public class OpenLP extends ActionBarActivity } } - public void setMenuActive(){ - backArrowActive = true; - } - - public void menuVisible() { - if (dropdownMenu != null){ - MenuItem checkable = dropdownMenu.findItem(R.id.action_back); - if (checkable != null) { - if (backArrowActive) { - checkable.setVisible(true); - } else { - checkable.setVisible(false); - } - } - } - backArrowActive = false; - //restoreActionBar(); - } - @Override public boolean onCreateOptionsMenu(Menu menu) { if (!mNavigationDrawerFragment.isDrawerOpen()) { @@ -185,22 +190,16 @@ public class OpenLP extends ActionBarActivity // as you specify a parent activity in AndroidManifest.xml. Intent intent; switch (item.getItemId()) { - case R.id.action_back: - onNavigationDrawerItemSelected(NavigationOptions.ServiceList); - return true; case R.id.action_preferences: intent = new Intent(this, SettingsActivity.class); startActivity(intent); return true; case R.id.action_refresh: if (this.mTitle.equals(getString(R.string.service_list))) { - ServiceListFragment fragment = (ServiceListFragment) - getFragmentManager().findFragmentById(R.id.container); - fragment.refreshDisplay(); + refreshServiceFragment(R.id.container); } else if (this.mTitle.equals(getString(R.string.live_list)) ) { - LiveListFragment fragment = (LiveListFragment) - getFragmentManager().findFragmentById(R.id.container); - fragment.refreshDisplay(); + refreshServiceFragment(R.id.container_left); + refreshLiveFragment(R.id.container_right); } return true; case R.id.action_blank: @@ -216,43 +215,18 @@ public class OpenLP extends ActionBarActivity return super.onOptionsItemSelected(item); } } - - /** - * A placeholder fragment containing a simple view. - */ - public static class PlaceholderFragment extends Fragment { - /** - * The fragment argument representing the section number for this - * fragment. - */ - private static final String ARG_SECTION_NUMBER = "section_number"; - - /** - * Returns a new instance of this fragment for the given section - * number. - */ - public static PlaceholderFragment newInstance(int sectionNumber) { - PlaceholderFragment fragment = new PlaceholderFragment(); - Bundle args = new Bundle(); - args.putInt(ARG_SECTION_NUMBER, sectionNumber); - fragment.setArguments(args); - return fragment; + public void refreshLiveFragment(int container){ + LiveListFragment fragment = (LiveListFragment) + getFragmentManager().findFragmentById(container); + if (fragment != null) { + fragment.refreshDisplay(); } - - public PlaceholderFragment() { - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_main, container, false); - } - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - //((OpenLP) activity).onSectionAttached( - // getArguments().getInt(ARG_SECTION_NUMBER)); + } + public void refreshServiceFragment(int container){ + ServiceListFragment fragment = (ServiceListFragment) + getFragmentManager().findFragmentById(container); + if (fragment != null) { + fragment.refreshDisplay(); } } diff --git a/app/src/main/java/org/openlp/android2/fragments/LiveListFragment.java b/app/src/main/java/org/openlp/android2/fragments/LiveListFragment.java index 04d09e8..b575069 100644 --- a/app/src/main/java/org/openlp/android2/fragments/LiveListFragment.java +++ b/app/src/main/java/org/openlp/android2/fragments/LiveListFragment.java @@ -46,9 +46,6 @@ import org.openlp.android2.common.OpenLPHttpClient; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Timer; -import java.util.TimerTask; - public class LiveListFragment extends OpenLPFragment { @@ -134,6 +131,8 @@ public class LiveListFragment extends OpenLPFragment { if (selected == position) { text2.setTextColor(Color.parseColor("#000000")); text2.setTypeface(null, Typeface.BOLD_ITALIC); + } else{ + text2.setTypeface(null, Typeface.NORMAL); } return view; @@ -160,6 +159,7 @@ public class LiveListFragment extends OpenLPFragment { public void processUpdate(String response, boolean inError) { triggerTextRequest(Api.LIVE_TEXT); + } public void itemClicked(int position) { diff --git a/app/src/main/java/org/openlp/android2/fragments/ServiceListFragment.java b/app/src/main/java/org/openlp/android2/fragments/ServiceListFragment.java index 279e357..46a93d6 100644 --- a/app/src/main/java/org/openlp/android2/fragments/ServiceListFragment.java +++ b/app/src/main/java/org/openlp/android2/fragments/ServiceListFragment.java @@ -36,7 +36,6 @@ import org.openlp.android2.R; import org.openlp.android2.api.Api; import org.openlp.android2.common.JsonHelpers; -import org.openlp.android2.common.NavigationOptions; import org.openlp.android2.common.OpenLPFragment; import org.openlp.android2.common.OpenLPHttpClient; @@ -72,21 +71,6 @@ public class ServiceListFragment extends OpenLPFragment { @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - - AdapterView.OnItemLongClickListener listener = new AdapterView.OnItemLongClickListener() { - @Override - public boolean onItemLongClick(AdapterView arg0, View arg1, int position, long id) { - Toast.makeText(getActivity().getBaseContext(), "Long Clicked ", Toast.LENGTH_SHORT).show(); - itemClicked(position); - noScreenUpdate = true; - isDoubleClick = true; - ((OpenLP) getActivity()).setMenuActive(); - ((OpenLP) getActivity()).onNavigationDrawerItemSelected(NavigationOptions.LiveList); - ((OpenLP) getActivity()).restoreActionBar(); - return false; - } - }; - getListView().setOnItemLongClickListener(listener); } @Override @@ -115,6 +99,7 @@ public class ServiceListFragment extends OpenLPFragment { public void processUpdate(String response, boolean inError) { triggerTextRequest(Api.SERVICE_LIST); + ((OpenLP) getActivity()).refreshLiveFragment(R.id.container_right); } @Override @@ -200,5 +185,4 @@ public class ServiceListFragment extends OpenLPFragment { Toast.makeText(context, "Request Failed", Toast.LENGTH_SHORT).show(); } } - } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 28033a0..684abf0 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -12,6 +12,26 @@ android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" /> + + + + +