1
0
mirror of https://gitlab.com/openlp/android.git synced 2024-12-22 11:52:49 +00:00

More screens and icons

This commit is contained in:
Tim Bentley 2014-11-24 21:35:52 +00:00
parent f2d2656cc6
commit 3e69c02900
45 changed files with 173 additions and 225 deletions

View File

@ -21,17 +21,12 @@
package org.openlp.android2;
import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Intent;
import android.os.Bundle;
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.ConnectionActivity;
import org.openlp.android2.activities.SettingsActivity;
@ -78,7 +73,7 @@ public class OpenLP extends Activity
fragmentManager.beginTransaction()
.replace(R.id.container, HomeFragment.newInstance())
.commit();
mTitle = getString(R.string.service_list);
mTitle = getString(R.string.home);
break;
case NavigationOptions.ServiceList:
fragmentManager.beginTransaction()
@ -107,26 +102,6 @@ public class OpenLP extends Activity
}
}
public void onSectionAttached(int number) {
switch (number) {
case 0:
mTitle = getString(R.string.service_list);
break;
case 1:
mTitle = getString(R.string.service_list);
break;
case 2:
mTitle = getString(R.string.live_list);
break;
case 3:
mTitle = getString(R.string.stage_view);
break;
case 4:
mTitle = getString(R.string.live_view);
break;
}
}
public void restoreActionBar() {
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
@ -164,6 +139,13 @@ public class OpenLP extends Activity
intent = new Intent(this, ConnectionActivity.class);
startActivity(intent);
return true;
case R.id.action_refresh:
if (mTitle.equals(R.string.service_list)){
ServiceListFragment fragment = (ServiceListFragment)
getFragmentManager().findFragmentByTag("ServiceListFragment");
fragment.refreshDisplay();
}
return true;
case R.id.action_blank:
new BlankDisplayDialog().show(getFragmentManager(), "BlankDialog");
return true;
@ -179,44 +161,4 @@ public class OpenLP extends Activity
}
}
/**
* 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";
public PlaceholderFragment() {
}
/**
* 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;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_service_list, container, false);
return rootView;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
((OpenLP) activity).onSectionAttached(
getArguments().getInt(ARG_SECTION_NUMBER));
}
}
}

View File

@ -56,6 +56,7 @@ abstract public class OpenLPFragment extends ListFragment{
private static AsyncHttpClient client = new AsyncHttpClient();
protected void refreshDisplay(){}
protected void populateDisplay(String responseString) {}
protected void processUpdate(String responseString) {}
protected void errorDisplay(int statusCode, String responseString) {}

View File

@ -20,52 +20,39 @@
*******************************************************************************/
package org.openlp.android2.fragments;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.app.Fragment;
import android.content.SharedPreferences;
import android.text.Html;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.openlp.android2.R;
import org.openlp.android2.api.Api;
import org.openlp.android2.common.JsonHelpers;
import org.openlp.android2.common.OpenLPFragment;
import org.openlp.android2.common.OpenLPHttpClient;
import org.openlp.android2.fragments.dummy.DummyContent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class LiveListFragment extends Fragment implements AbsListView.OnItemClickListener {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
public class LiveListFragment extends OpenLPFragment {
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private String LOG_TAG = LiveListFragment.class.getName();
private OnFragmentInteractionListener mListener;
/**
* The fragment's ListView/GridView.
*/
private AbsListView mListView;
/**
* The Adapter which will be used to populate the ListView/GridView with
* Views.
*/
private ListAdapter mAdapter;
// TODO: Rename and change types of parameters
public static LiveListFragment newInstance() {
LiveListFragment fragment = new LiveListFragment();
Bundle args = new Bundle();
//args.putString(ARG_PARAM1, param1);
//args.putString(ARG_PARAM2, param2);
//fragment.setArguments(args);
return fragment;
}
@ -79,85 +66,106 @@ public class LiveListFragment extends Fragment implements AbsListView.OnItemClic
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
// TODO: Change Adapter to display your content
mAdapter = new ArrayAdapter<DummyContent.DummyItem>(getActivity(),
android.R.layout.simple_list_item_1, android.R.id.text1, DummyContent.ITEMS);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_livelist, container, false);
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
context = getActivity();
updateUrl = Api.LIVE_TEXT;
httpClient = new OpenLPHttpClient(context);
return super.onCreateView(inflater, container, savedInstanceState);
}
// Set the adapter
mListView = (AbsListView) view.findViewById(android.R.id.list);
((AdapterView<ListAdapter>) mListView).setAdapter(mAdapter);
@Override
public void populateDisplay(String json) {
Log.i(LOG_TAG, "populate_display - entry");
List<HashMap<String, String>> aList = new ArrayList<HashMap<String, String>>();
int selected = 0;
// Set OnItemClickListener so we can be notified on item clicks
mListView.setOnItemClickListener(this);
try {
JSONArray items = new JSONObject(json).getJSONObject("results").getJSONArray("slides");
for (int i = 0; i < items.length(); ++i) {
JSONObject item = items.getJSONObject(i);
HashMap<String, String> hm = new HashMap<String, String>();
hm.put("tag", item.getString("tag"));
if (item.getString("selected").equals("true")) {
hm.put("liveListNormal", Html.fromHtml(item.getString("html")).toString());
selected = i;
} else {
hm.put("liveListSelected", Html.fromHtml(item.getString("html")).toString());
}
aList.add(hm);
}
} catch (JSONException e) {
e.printStackTrace();
}
// Keys used in Hashmap
String[] from = {"tag", "liveListNormal", "liveListSelected"};
// Ids of views in live_list_fragment
int[] to = {R.id.tag, R.id.liveListNormal, R.id.liveListSelected};
SharedPreferences prefs = context.getSharedPreferences(
context.getString(R.string.keySharedPreferences),
Context.MODE_PRIVATE);
final int size = Integer.parseInt(prefs.getString(
context.getString(R.string.keyTextSize),
String.valueOf(context.getResources().getInteger(
R.integer.textSizeDefaultValue))));
// Instantiating an adapter to store each items
ListAdapter adapter = new SimpleAdapter(getActivity().getBaseContext(), aList,
R.layout.fragment_livelist, from, to){
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView text1 = (TextView) view.findViewById(R.id.liveListNormal);
text1.setTextSize(TypedValue.COMPLEX_UNIT_SP, size);
TextView text2 = (TextView) view.findViewById(R.id.liveListSelected);
text2.setTextSize(TypedValue.COMPLEX_UNIT_SP, size);
TextView text3 = (TextView) view.findViewById(R.id.tag);
text3.setTextSize(TypedValue.COMPLEX_UNIT_SP, size);
return view;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
//try {
// mListener = (OnFragmentInteractionListener) activity;
//} catch (ClassCastException e) {
// throw new ClassCastException(activity.toString()
// + " must implement OnFragmentInteractionListener");
//}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
};
};
setListAdapter(adapter);
getListView().setSelection(selected - 1);
Log.i(LOG_TAG, "populate_display - exit");
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (null != mListener) {
// Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that an item has been selected.
mListener.onFragmentInteraction(DummyContent.ITEMS.get(position).id);
}
public void refreshDisplay(){
Log.d(LOG_TAG, "Resuming...");
triggerTextRequest(Api.LIVE_TEXT);
}
/**
* The default content for this Fragment has a TextView that is shown when
* the list is empty. If you would like to change the text, call this method
* to supply the text it should use.
*/
public void setEmptyText(CharSequence emptyText) {
View emptyView = mListView.getEmptyView();
if (emptyText instanceof TextView) {
((TextView) emptyView).setText(emptyText);
}
@Override
public void onResume() {
super.onResume();
Log.d(LOG_TAG, "Resuming...");
triggerTextRequest(Api.LIVE_TEXT);
Log.d(LOG_TAG, "Resumed...");
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
public void onFragmentInteraction(String id);
public void processUpdate(String response) {
triggerTextRequest(Api.LIVE_TEXT);
}
public void itemClicked(int position) {
try {
String request = JsonHelpers.createRequestJSON("id", Integer.toString(position));
triggerTextRequest(String.format("%s%s", Api.LIVE_SET, request));
Log.d(LOG_TAG, String.format("Setting list data. apiBase(%s), position(%s)",
Api.LIVE_SET, position));
Toast.makeText(getActivity().getBaseContext(), "Display Item selected", Toast.LENGTH_SHORT).show();
} catch (JsonHelpers.JSONHandlerException e) {
e.printStackTrace();
Toast.makeText(getActivity().getBaseContext(), "Request Failed", Toast.LENGTH_SHORT).show();
}
}
}

View File

@ -33,13 +33,14 @@ import android.widget.*;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.openlp.android2.OpenLP;
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;
import org.openlp.android2.fragments.dummy.DummyContent;
import java.util.ArrayList;
import java.util.HashMap;
@ -52,31 +53,11 @@ public class ServiceListFragment extends OpenLPFragment {
private boolean noScreenUpdate = false;
private boolean isDoubleClick = false;
/**
* The fragment's ListView/GridView.
*/
private AbsListView mListView;
/**
* The Adapter which will be used to populate the ListView/GridView with
* Views.
*/
private ListAdapter mAdapter;
/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public ServiceListFragment() {
}
// TODO: Rename and change types of parameters
public static ServiceListFragment newInstance() {
ServiceListFragment fragment = new ServiceListFragment();
Bundle args = new Bundle();
//args.putString(ARG_PARAM1, param1);
//args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@ -103,7 +84,8 @@ public class ServiceListFragment extends OpenLPFragment {
isDoubleClick = true;
//((OpenLP) getActivity()).makeBackArrowVisible(true);
//((OpenLP) getActivity()).menuVisible(R.id.action_back);
//((OpenLP) getActivity()).selectItem(NavigationOptions.LiveList);
((OpenLP) getActivity()).onNavigationDrawerItemSelected(NavigationOptions.LiveList);
((OpenLP) getActivity()).restoreActionBar();
return false;
}
};
@ -120,6 +102,12 @@ public class ServiceListFragment extends OpenLPFragment {
super.onDetach();
}
@Override
public void refreshDisplay(){
Log.d(LOG_TAG, "Resuming...");
triggerTextRequest(Api.SERVICE_LIST);
}
@Override
public void onResume() {
super.onResume();
@ -127,6 +115,7 @@ public class ServiceListFragment extends OpenLPFragment {
triggerTextRequest(Api.SERVICE_LIST);
Log.d(LOG_TAG, "Resumed...");
}
public void processUpdate(String response) {
triggerTextRequest(Api.SERVICE_LIST);
}
@ -198,19 +187,6 @@ public class ServiceListFragment extends OpenLPFragment {
Log.i(LOG_TAG, "populate_display - exit");
}
/**
* The default content for this Fragment has a TextView that is shown when
* the list is empty. If you would like to change the text, call this method
* to supply the text it should use.
*/
public void setEmptyText(CharSequence emptyText) {
View emptyView = mListView.getEmptyView();
if (emptyText instanceof TextView) {
((TextView) emptyView).setText(emptyText);
}
}
public void itemClicked(int position) {
try {
noScreenUpdate = true;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 683 B

After

Width:  |  Height:  |  Size: 909 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 B

After

Width:  |  Height:  |  Size: 341 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 337 B

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 B

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 B

After

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 531 B

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 355 B

After

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 588 B

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 B

After

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 264 B

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 287 B

After

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 B

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 312 B

After

Width:  |  Height:  |  Size: 317 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 422 B

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 B

After

Width:  |  Height:  |  Size: 423 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

After

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 713 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 337 B

After

Width:  |  Height:  |  Size: 419 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 470 B

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 339 B

After

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 693 B

After

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 731 B

After

Width:  |  Height:  |  Size: 734 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 479 B

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 377 B

After

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 366 B

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 568 B

After

Width:  |  Height:  |  Size: 629 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 B

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 404 B

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 B

After

Width:  |  Height:  |  Size: 561 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 875 B

After

Width:  |  Height:  |  Size: 644 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 871 B

After

Width:  |  Height:  |  Size: 881 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 512 B

After

Width:  |  Height:  |  Size: 637 B

View File

@ -1,19 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/live_list_fragment_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="org.openlp.android2.fragments.LiveListFragment">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:orientation="horizontal"
android:smoothScrollbar="true"
android:clickable="false"
android:longClickable="false">
<TextView
android:id="@android:id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" />
</FrameLayout>
android:id="@+id/tag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:paddingTop="10dp"
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:paddingBottom="10dp"
/>
<TextView
android:id="@+id/liveListNormal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff6c6c6c"
android:textSize="14dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
/>
<TextView
android:id="@+id/liveListSelected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="14dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
/>
</LinearLayout>