Fixed thumbnail control. Changed thumbnail activity to fragment.
Change-Id: I4e8a9d37f3b418728404b7fab4f7b6e3c3b5e5b9
This commit is contained in:
committed by
Michael Meeks
parent
3e0b7a7141
commit
c67a772da6
@@ -1,14 +1,7 @@
|
|||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" >
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/framelayout" >
|
||||||
|
|
||||||
<TextView
|
</FrameLayout>
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:text="@string/hello_world"
|
|
||||||
tools:context=".PresentationActivity" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
@@ -1,20 +1,98 @@
|
|||||||
package org.libreoffice.impressremote;
|
package org.libreoffice.impressremote;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import org.libreoffice.impressremote.communication.CommunicationService;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.FragmentManager;
|
||||||
|
import android.app.FragmentTransaction;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.ServiceConnection;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.os.Messenger;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
public class PresentationActivity extends Activity {
|
public class PresentationActivity extends Activity {
|
||||||
|
private CommunicationService mCommunicationService;
|
||||||
|
private boolean mIsBound = false;
|
||||||
|
private FrameLayout mLayout;
|
||||||
|
ThumbnailActivity mThumbnailFragment;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_presentation);
|
setContentView(R.layout.activity_presentation);
|
||||||
|
|
||||||
|
bindService(new Intent(this, CommunicationService.class), mConnection,
|
||||||
|
Context.BIND_IMPORTANT);
|
||||||
|
|
||||||
|
FragmentManager fragmentManager = getFragmentManager();
|
||||||
|
FragmentTransaction fragmentTransaction = fragmentManager
|
||||||
|
.beginTransaction();
|
||||||
|
mThumbnailFragment = new ThumbnailActivity();
|
||||||
|
fragmentTransaction.add(R.id.framelayout, mThumbnailFragment,
|
||||||
|
"fragment_thumbnail");
|
||||||
|
fragmentTransaction.commit();
|
||||||
|
|
||||||
|
mLayout = (FrameLayout) findViewById(R.id.framelayout);
|
||||||
|
|
||||||
|
mIsBound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
// MenuInflater inflater = getMenuInflater();
|
||||||
|
// inflater.inflate(R.menu.main_activity, menu);
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.activity_presentation, menu);
|
getMenuInflater().inflate(R.menu.activity_presentation, menu);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
@Override
|
||||||
|
public void onServiceConnected(ComponentName aClassName,
|
||||||
|
IBinder aService) {
|
||||||
|
mCommunicationService = ((CommunicationService.CBinder) aService)
|
||||||
|
.getService();
|
||||||
|
mCommunicationService.setActivityMessenger(mMessenger);
|
||||||
|
mThumbnailFragment.setCommunicationService(mCommunicationService);
|
||||||
|
// TODO: add mCommunicationSercie to all fragments.
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServiceDisconnected(ComponentName aClassName) {
|
||||||
|
mCommunicationService = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
final Messenger mMessenger = new Messenger(new MessageHandler());
|
||||||
|
|
||||||
|
protected class MessageHandler extends Handler {
|
||||||
|
@Override
|
||||||
|
public void handleMessage(Message aMessage) {
|
||||||
|
mThumbnailFragment.handleMessage(aMessage);
|
||||||
|
// Bundle aData = aMessage.getData();
|
||||||
|
// TODO: pass to fragments
|
||||||
|
// switch (aMessage.what) {
|
||||||
|
// case CommunicationService.MSG_SLIDE_CHANGED:
|
||||||
|
// int aSlide = aData.getInt("slide_number");
|
||||||
|
// break;
|
||||||
|
// case CommunicationService.MSG_SLIDE_PREVIEW:
|
||||||
|
// // int aNSlide = aData.getInt("slide_number");
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -151,7 +151,7 @@ public class TestClient extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent aIntent = new Intent(TestClient.this,
|
Intent aIntent = new Intent(TestClient.this,
|
||||||
ThumbnailActivity.class);
|
PresentationActivity.class);
|
||||||
startActivity(aIntent);
|
startActivity(aIntent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -11,18 +11,12 @@ package org.libreoffice.impressremote;
|
|||||||
import org.libreoffice.impressremote.communication.CommunicationService;
|
import org.libreoffice.impressremote.communication.CommunicationService;
|
||||||
import org.libreoffice.impressremote.communication.SlideShow;
|
import org.libreoffice.impressremote.communication.SlideShow;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Fragment;
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.ServiceConnection;
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Messenger;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -32,47 +26,42 @@ import android.widget.GridView;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class ThumbnailActivity extends Activity {
|
public class ThumbnailActivity extends Fragment {
|
||||||
|
|
||||||
private CommunicationService mCommunicationService;
|
private CommunicationService mCommunicationService;
|
||||||
private boolean mIsBound = false;
|
|
||||||
|
|
||||||
private GridView mGrid;
|
private GridView mGrid;
|
||||||
private ImageView mCurrentImage;
|
private ImageView mCurrentImage;
|
||||||
private TextView mCurrentText;
|
private TextView mCurrentText;
|
||||||
|
|
||||||
private SlideShow mSlideShow;
|
private SlideShow mSlideShow;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
View v = inflater
|
||||||
|
.inflate(R.layout.fragment_thumbnail, container, false);
|
||||||
|
|
||||||
|
mGrid = (GridView) v.findViewById(R.id.thumbnail_grid);
|
||||||
|
|
||||||
|
mGrid.setOnItemClickListener(new ClickListener());
|
||||||
|
mContext = container.getContext();
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_thumbnail);
|
|
||||||
|
|
||||||
bindService(new Intent(this, CommunicationService.class), mConnection,
|
|
||||||
Context.BIND_ADJUST_WITH_ACTIVITY);
|
|
||||||
mIsBound = true;
|
|
||||||
|
|
||||||
mGrid = (GridView) findViewById(R.id.thumbnail_grid);
|
|
||||||
|
|
||||||
mGrid.setOnItemClickListener(new ClickListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mCommunicationService.setActivityMessenger(null);
|
|
||||||
if (mIsBound) {
|
|
||||||
unbindService(mConnection);
|
|
||||||
mIsBound = false;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
// MenuInflater inflater = getMenuInflater();
|
|
||||||
// inflater.inflate(R.menu.main_activity, menu);
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
private void setSelected(int position) {
|
private void setSelected(int position) {
|
||||||
formatUnselected(mCurrentImage, mCurrentText);
|
formatUnselected(mCurrentImage, mCurrentText);
|
||||||
@@ -92,7 +81,7 @@ public class ThumbnailActivity extends Activity {
|
|||||||
R.color.thumbnail_border));
|
R.color.thumbnail_border));
|
||||||
}
|
}
|
||||||
if (aText != null) {
|
if (aText != null) {
|
||||||
aText.setTypeface(Typeface.create(mCurrentText.getTypeface(),
|
aText.setTypeface(Typeface.create(aText.getTypeface(),
|
||||||
Typeface.NORMAL));
|
Typeface.NORMAL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,43 +92,31 @@ public class ThumbnailActivity extends Activity {
|
|||||||
R.color.thumbnail_border_selected));
|
R.color.thumbnail_border_selected));
|
||||||
}
|
}
|
||||||
if (aText != null) {
|
if (aText != null) {
|
||||||
aText.setTypeface(Typeface.create(mCurrentText.getTypeface(),
|
aText.setTypeface(Typeface.create(aText.getTypeface(),
|
||||||
Typeface.BOLD));
|
Typeface.BOLD));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------- SERVICE CONNECTION ----
|
// ------------------------------------------------- SERVICE CONNECTION ----
|
||||||
final Messenger mMessenger = new Messenger(new MessageHandler());
|
|
||||||
|
|
||||||
private ServiceConnection mConnection = new ServiceConnection() {
|
|
||||||
@Override
|
|
||||||
public void onServiceConnected(ComponentName aClassName,
|
|
||||||
IBinder aService) {
|
|
||||||
mCommunicationService = ((CommunicationService.CBinder) aService)
|
|
||||||
.getService();
|
|
||||||
mCommunicationService.setActivityMessenger(mMessenger);
|
|
||||||
mSlideShow = mCommunicationService.getSlideShow();
|
|
||||||
mGrid.setAdapter(new ThumbnailAdapter(ThumbnailActivity.this,
|
|
||||||
mSlideShow));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onServiceDisconnected(ComponentName aClassName) {
|
|
||||||
mCommunicationService = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ----------------------------------------------------- CLICK LISTENER ----
|
// ----------------------------------------------------- CLICK LISTENER ----
|
||||||
protected class ClickListener implements AdapterView.OnItemClickListener {
|
protected class ClickListener implements AdapterView.OnItemClickListener {
|
||||||
public void onItemClick(AdapterView<?> parent, View v, int position,
|
public void onItemClick(AdapterView<?> parent, View v, int position,
|
||||||
long id) {
|
long id) {
|
||||||
|
if (mCommunicationService != null)
|
||||||
mCommunicationService.getTransmitter().gotoSlide(position);
|
mCommunicationService.getTransmitter().gotoSlide(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------- MESSAGE HANDLER ----
|
// ---------------------------------------------------- MESSAGE HANDLER ----
|
||||||
protected class MessageHandler extends Handler {
|
|
||||||
@Override
|
public void setCommunicationService(
|
||||||
|
CommunicationService aCommunicationService) {
|
||||||
|
mCommunicationService = aCommunicationService;
|
||||||
|
mSlideShow = mCommunicationService.getSlideShow();
|
||||||
|
mGrid.setAdapter(new ThumbnailAdapter(mContext, mSlideShow));
|
||||||
|
}
|
||||||
|
|
||||||
public void handleMessage(Message aMessage) {
|
public void handleMessage(Message aMessage) {
|
||||||
Bundle aData = aMessage.getData();
|
Bundle aData = aMessage.getData();
|
||||||
switch (aMessage.what) {
|
switch (aMessage.what) {
|
||||||
@@ -148,13 +125,11 @@ public class ThumbnailActivity extends Activity {
|
|||||||
setSelected(aSlide);
|
setSelected(aSlide);
|
||||||
break;
|
break;
|
||||||
case CommunicationService.MSG_SLIDE_PREVIEW:
|
case CommunicationService.MSG_SLIDE_PREVIEW:
|
||||||
// int aNSlide = aData.getInt("slide_number");
|
|
||||||
mGrid.invalidateViews();
|
mGrid.invalidateViews();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------- THUMBNAIL ADAPTER ----
|
// ------------------------------------------------- THUMBNAIL ADAPTER ----
|
||||||
protected class ThumbnailAdapter extends BaseAdapter {
|
protected class ThumbnailAdapter extends BaseAdapter {
|
||||||
@@ -201,6 +176,8 @@ public class ThumbnailActivity extends Activity {
|
|||||||
if ((mSlideShow != null)
|
if ((mSlideShow != null)
|
||||||
&& (position == mSlideShow.getCurrentSlide())) {
|
&& (position == mSlideShow.getCurrentSlide())) {
|
||||||
formatSelected(aImage, aText);
|
formatSelected(aImage, aText);
|
||||||
|
mCurrentImage = aImage;
|
||||||
|
mCurrentText = aText;
|
||||||
} else {
|
} else {
|
||||||
formatUnselected(aImage, aText);
|
formatUnselected(aImage, aText);
|
||||||
}
|
}
|
||||||
|
@@ -67,10 +67,6 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_filters_test, \
|
|||||||
$(gb_STDLIBS) \
|
$(gb_STDLIBS) \
|
||||||
))
|
))
|
||||||
|
|
||||||
$(eval $(call gb_CppunitTest_add_libs,sd_filters_test,\
|
|
||||||
$(shell pkg-config --libs glib-2.0 json-glib-1.0) \
|
|
||||||
))
|
|
||||||
|
|
||||||
$(eval $(call gb_CppunitTest_set_include,sd_filters_test,\
|
$(eval $(call gb_CppunitTest_set_include,sd_filters_test,\
|
||||||
-I$(SRCDIR)/sd/source/ui/inc \
|
-I$(SRCDIR)/sd/source/ui/inc \
|
||||||
-I$(SRCDIR)/sd/inc \
|
-I$(SRCDIR)/sd/inc \
|
||||||
|
@@ -41,10 +41,6 @@ $(eval $(call gb_CppunitTest_use_api,sd_uimpress,\
|
|||||||
udkapi \
|
udkapi \
|
||||||
))
|
))
|
||||||
|
|
||||||
$(eval $(call gb_CppunitTest_add_libs,sd_uimpress,\
|
|
||||||
$(shell pkg-config --libs glib-2.0 json-glib-1.0) \
|
|
||||||
))
|
|
||||||
|
|
||||||
$(eval $(call gb_CppunitTest_use_library_objects,sd_uimpress,sd))
|
$(eval $(call gb_CppunitTest_use_library_objects,sd_uimpress,sd))
|
||||||
|
|
||||||
$(eval $(call gb_CppunitTest_use_libraries,sd_uimpress,\
|
$(eval $(call gb_CppunitTest_use_libraries,sd_uimpress,\
|
||||||
|
@@ -58,7 +58,7 @@ void ImagePreparer::execute()
|
|||||||
void ImagePreparer::sendPreview( sal_uInt32 aSlideNumber )
|
void ImagePreparer::sendPreview( sal_uInt32 aSlideNumber )
|
||||||
{
|
{
|
||||||
sal_uInt64 aSize;
|
sal_uInt64 aSize;
|
||||||
uno::Sequence<sal_Int8> aImageData = preparePreview( aSlideNumber, 160, 120,
|
uno::Sequence<sal_Int8> aImageData = preparePreview( aSlideNumber, 140, 100,
|
||||||
aSize );
|
aSize );
|
||||||
if ( !xController->isRunning() )
|
if ( !xController->isRunning() )
|
||||||
return;
|
return;
|
||||||
|
@@ -39,4 +39,3 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
#endif // _SD_IMPRESSREMOTE_RECEIVER_HXX
|
#endif // _SD_IMPRESSREMOTE_RECEIVER_HXX
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
||||||
|
Reference in New Issue
Block a user