Implemented rotation of slideshow view.
Change-Id: Ib518e1609d21463273a00fcf161f20c80eae6a67
This commit is contained in:
@@ -20,21 +20,14 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
|
||||||
android:name=".communication.TestClient"
|
|
||||||
android:label="Remote--Direct" >
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<service android:name=".communication.CommunicationService" >
|
<service android:name=".communication.CommunicationService" >
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<activity android:name=".PairingActivity" >
|
<activity android:name=".PairingActivity" >
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name=".StartPresentationActivity" >
|
||||||
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".PresentationActivity"
|
android:name=".PresentationActivity"
|
||||||
android:label="@string/title_activity_presentation" >
|
android:label="@string/title_activity_presentation" >
|
||||||
|
BIN
android/sdremote/res/drawable/image_loading.png
Normal file
BIN
android/sdremote/res/drawable/image_loading.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 287 B |
@@ -13,8 +13,8 @@
|
|||||||
<pl.polidea.coverflow.CoverFlow
|
<pl.polidea.coverflow.CoverFlow
|
||||||
xmlns:coverflow="http://schemas.android.com/apk/res/org.libreoffice.impressremote"
|
xmlns:coverflow="http://schemas.android.com/apk/res/org.libreoffice.impressremote"
|
||||||
android:id="@+id/presentation_coverflow"
|
android:id="@+id/presentation_coverflow"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="5dip"
|
android:layout_marginTop="5dip"
|
||||||
coverflow:imageHeight="150dip"
|
coverflow:imageHeight="150dip"
|
||||||
coverflow:imageWidth="180dip"
|
coverflow:imageWidth="180dip"
|
||||||
@@ -42,8 +42,8 @@
|
|||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:id="@+id/presentation_scrollview"
|
android:id="@+id/presentation_scrollview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" >
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
<WebView
|
<WebView
|
||||||
android:id="@+id/presentation_notes"
|
android:id="@+id/presentation_notes"
|
||||||
|
22
android/sdremote/res/layout/activity_startpresentation.xml
Normal file
22
android/sdremote/res/layout/activity_startpresentation.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/startpresentation_instruction"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_margin="5dip"
|
||||||
|
android:text="@string/startpresentation_instruction" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/startpresentation_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:text="@string/startpresentation_button" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@@ -24,7 +24,9 @@
|
|||||||
<string name="wifi">WI-FI</string>
|
<string name="wifi">WI-FI</string>
|
||||||
<string name="selector_noservers">Searching for computers…</string>
|
<string name="selector_noservers">Searching for computers…</string>
|
||||||
<string name="pairing_instructions_1">In Impress, click on the "Slideshow" menu and select "Impress Remote".</string>
|
<string name="pairing_instructions_1">In Impress, click on the "Slideshow" menu and select "Impress Remote".</string>
|
||||||
<string name="pairing_instructions_2_deviceName">Choose "{1}" as your device.</string>
|
<string name="pairing_instructions_2_deviceName">Choose \"{0}\" as your device.</string>
|
||||||
<string name="pairing_instructions_3">Then input this PIN:</string>
|
<string name="pairing_instructions_3">Then input this PIN:</string>
|
||||||
|
<string name="startpresentation_instruction">No presentation is currently running.</string>
|
||||||
|
<string name="startpresentation_button">Start Presentation</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@@ -39,21 +39,12 @@ public class PairingActivity extends Activity {
|
|||||||
Context.BIND_IMPORTANT);
|
Context.BIND_IMPORTANT);
|
||||||
mIsBound = true;
|
mIsBound = true;
|
||||||
|
|
||||||
mPinText = (TextView) findViewById(R.id.pairing_pin);
|
|
||||||
|
|
||||||
IntentFilter aFilter = new IntentFilter(
|
IntentFilter aFilter = new IntentFilter(
|
||||||
CommunicationService.MSG_PAIRING_STARTED);
|
CommunicationService.MSG_PAIRING_STARTED);
|
||||||
aFilter.addAction(CommunicationService.MSG_PAIRING_SUCCESSFUL);
|
aFilter.addAction(CommunicationService.MSG_PAIRING_SUCCESSFUL);
|
||||||
LocalBroadcastManager.getInstance(this).registerReceiver(mListener,
|
LocalBroadcastManager.getInstance(this).registerReceiver(mListener,
|
||||||
aFilter);
|
aFilter);
|
||||||
|
|
||||||
// mBluetoothContainer = findViewById(R.id.selector_container_bluetooth);
|
|
||||||
// mBluetoothList = (LinearLayout) findViewById(R.id.selector_list_bluetooth);
|
|
||||||
// mNetworkContainer = findViewById(R.id.selector_container_network);
|
|
||||||
// mNetworkList = (LinearLayout) findViewById(R.id.selector_list_network);
|
|
||||||
// mNoServerLabel = (TextView) findViewById(R.id.selector_label_none);
|
|
||||||
//
|
|
||||||
// refreshLists();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceConnection mConnection = new ServiceConnection() {
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
@@ -61,7 +52,9 @@ public class PairingActivity extends Activity {
|
|||||||
public void onServiceConnected(ComponentName aClassName,
|
public void onServiceConnected(ComponentName aClassName,
|
||||||
IBinder aService) {
|
IBinder aService) {
|
||||||
setContentView(R.layout.activity_pairing);
|
setContentView(R.layout.activity_pairing);
|
||||||
|
mPinText = (TextView) findViewById(R.id.pairing_pin);
|
||||||
|
mCommunicationService = ((CommunicationService.CBinder) aService)
|
||||||
|
.getService();
|
||||||
((TextView) findViewById(R.id.pairing_instruction2_deviceName))
|
((TextView) findViewById(R.id.pairing_instruction2_deviceName))
|
||||||
.setText(MessageFormat
|
.setText(MessageFormat
|
||||||
.format(getResources()
|
.format(getResources()
|
||||||
@@ -69,8 +62,6 @@ public class PairingActivity extends Activity {
|
|||||||
mCommunicationService
|
mCommunicationService
|
||||||
.getDeviceName()));
|
.getDeviceName()));
|
||||||
|
|
||||||
mCommunicationService = ((CommunicationService.CBinder) aService)
|
|
||||||
.getService();
|
|
||||||
if (mCommunicationService.getState() == State.CONNECTING) {
|
if (mCommunicationService.getState() == State.CONNECTING) {
|
||||||
mPinText.setText(mCommunicationService.getPairingPin());
|
mPinText.setText(mCommunicationService.getPairingPin());
|
||||||
}
|
}
|
||||||
@@ -94,7 +85,9 @@ public class PairingActivity extends Activity {
|
|||||||
// refreshLists();
|
// refreshLists();
|
||||||
} else if (aIntent.getAction().equals(
|
} else if (aIntent.getAction().equals(
|
||||||
CommunicationService.MSG_PAIRING_SUCCESSFUL)) {
|
CommunicationService.MSG_PAIRING_SUCCESSFUL)) {
|
||||||
mPinText.setText("Paired!");
|
Intent nIntent = new Intent(PairingActivity.this,
|
||||||
|
StartPresentationActivity.class);
|
||||||
|
startActivity(nIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,6 @@ import java.util.TimeZone;
|
|||||||
import org.libreoffice.impressremote.communication.CommunicationService;
|
import org.libreoffice.impressremote.communication.CommunicationService;
|
||||||
import org.libreoffice.impressremote.communication.SlideShow.Timer;
|
import org.libreoffice.impressremote.communication.SlideShow.Timer;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.FragmentManager;
|
import android.app.FragmentManager;
|
||||||
@@ -20,8 +19,6 @@ import android.content.SharedPreferences;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Message;
|
|
||||||
import android.os.Messenger;
|
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@@ -38,446 +35,450 @@ import android.widget.TextView;
|
|||||||
import android.widget.ToggleButton;
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
public class PresentationActivity extends Activity {
|
public class PresentationActivity extends Activity {
|
||||||
private CommunicationService mCommunicationService;
|
private CommunicationService mCommunicationService;
|
||||||
private boolean mIsBound = false;
|
private boolean mIsBound = false;
|
||||||
private FrameLayout mLayout;
|
private FrameLayout mLayout;
|
||||||
private FrameLayout mOuterLayout;
|
private FrameLayout mOuterLayout;
|
||||||
private ThumbnailFragment mThumbnailFragment;
|
private ThumbnailFragment mThumbnailFragment;
|
||||||
private PresentationFragment mPresentationFragment;
|
private PresentationFragment mPresentationFragment;
|
||||||
private ActionBarManager mActionBarManager;
|
private ActionBarManager mActionBarManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
bindService(new Intent(this, CommunicationService.class), mConnection,
|
bindService(new Intent(this, CommunicationService.class), mConnection,
|
||||||
Context.BIND_IMPORTANT);
|
Context.BIND_IMPORTANT);
|
||||||
mIsBound = true;
|
mIsBound = true;
|
||||||
|
|
||||||
setContentView(R.layout.activity_presentation);
|
setContentView(R.layout.activity_presentation);
|
||||||
mOuterLayout = (FrameLayout) findViewById(R.id.framelayout);
|
mOuterLayout = (FrameLayout) findViewById(R.id.framelayout);
|
||||||
mLayout = new InterceptorLayout(this);
|
mOuterLayout.removeAllViews();
|
||||||
mOuterLayout.addView(mLayout);
|
mLayout = new InterceptorLayout(this);
|
||||||
mLayout.setId(R.id.presentation_innerFrame);
|
mOuterLayout.addView(mLayout);
|
||||||
// ((FrameLayout) findViewById(R.id.framelayout)).addView(mLayout);
|
mLayout.setId(R.id.presentation_innerFrame);
|
||||||
mThumbnailFragment = new ThumbnailFragment();
|
|
||||||
mPresentationFragment = new PresentationFragment();
|
|
||||||
|
|
||||||
FragmentManager fragmentManager = getFragmentManager();
|
//((FrameLayout) findViewById(R.id.framelayout)).addView(mLayout);
|
||||||
FragmentTransaction fragmentTransaction = fragmentManager
|
mThumbnailFragment = new ThumbnailFragment();
|
||||||
.beginTransaction();
|
mPresentationFragment = new PresentationFragment();
|
||||||
fragmentTransaction.add(R.id.presentation_innerFrame,
|
|
||||||
mPresentationFragment, "fragment_presentation");
|
|
||||||
fragmentTransaction.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
FragmentManager fragmentManager = getFragmentManager();
|
||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
FragmentTransaction fragmentTransaction = fragmentManager
|
||||||
SharedPreferences aPref = PreferenceManager
|
.beginTransaction();
|
||||||
.getDefaultSharedPreferences(this);
|
fragmentTransaction.add(R.id.presentation_innerFrame,
|
||||||
boolean aVolumeSwitching = aPref.getBoolean("option_volumeswitching",
|
mPresentationFragment, "fragment_presentation");
|
||||||
false);
|
fragmentTransaction.commit();
|
||||||
boolean aRelevantFragmentVisible = mPresentationFragment.isVisible()
|
|
||||||
|| mThumbnailFragment.isVisible();
|
|
||||||
if (aVolumeSwitching && aRelevantFragmentVisible) {
|
|
||||||
|
|
||||||
int action = event.getAction();
|
}
|
||||||
int keyCode = event.getKeyCode();
|
|
||||||
switch (keyCode) {
|
|
||||||
case KeyEvent.KEYCODE_VOLUME_UP:
|
|
||||||
if (action == KeyEvent.ACTION_UP) {
|
|
||||||
mCommunicationService.getTransmitter().nextTransition();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
|
||||||
if (action == KeyEvent.ACTION_DOWN) {
|
|
||||||
mCommunicationService.getTransmitter().previousTransition();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.dispatchKeyEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ServiceConnection mConnection = new ServiceConnection() {
|
@Override
|
||||||
@Override
|
protected void onDestroy() {
|
||||||
public void onServiceConnected(ComponentName aClassName,
|
mActionBarManager.stop();
|
||||||
IBinder aService) {
|
super.onDestroy();
|
||||||
mCommunicationService = ((CommunicationService.CBinder) aService)
|
}
|
||||||
.getService();
|
|
||||||
mCommunicationService.setActivityMessenger(mMessenger);
|
|
||||||
|
|
||||||
mPresentationFragment
|
@Override
|
||||||
.setCommunicationService(mCommunicationService);
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||||
mThumbnailFragment.setCommunicationService(mCommunicationService);
|
SharedPreferences aPref = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences(this);
|
||||||
|
boolean aVolumeSwitching = aPref.getBoolean("option_volumeswitching",
|
||||||
|
false);
|
||||||
|
boolean aRelevantFragmentVisible = mPresentationFragment.isVisible()
|
||||||
|
|| mThumbnailFragment.isVisible();
|
||||||
|
if (aVolumeSwitching && aRelevantFragmentVisible) {
|
||||||
|
|
||||||
}
|
int action = event.getAction();
|
||||||
|
int keyCode = event.getKeyCode();
|
||||||
|
switch (keyCode) {
|
||||||
|
case KeyEvent.KEYCODE_VOLUME_UP:
|
||||||
|
if (action == KeyEvent.ACTION_UP) {
|
||||||
|
mCommunicationService.getTransmitter().nextTransition();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
||||||
|
if (action == KeyEvent.ACTION_DOWN) {
|
||||||
|
mCommunicationService.getTransmitter().previousTransition();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.dispatchKeyEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
public void onServiceDisconnected(ComponentName aClassName) {
|
@Override
|
||||||
mCommunicationService = null;
|
public void onServiceConnected(ComponentName aClassName,
|
||||||
}
|
IBinder aService) {
|
||||||
};
|
mCommunicationService = ((CommunicationService.CBinder) aService)
|
||||||
|
.getService();
|
||||||
|
|
||||||
final Messenger mMessenger = new Messenger(new MessageHandler());
|
mPresentationFragment
|
||||||
|
.setCommunicationService(mCommunicationService);
|
||||||
|
mThumbnailFragment.setCommunicationService(mCommunicationService);
|
||||||
|
|
||||||
@SuppressLint("HandlerLeak")
|
}
|
||||||
protected class MessageHandler extends Handler {
|
|
||||||
@Override
|
|
||||||
public void handleMessage(Message aMessage) {
|
|
||||||
mPresentationFragment.handleMessage(aMessage);
|
|
||||||
mThumbnailFragment.handleMessage(aMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------- ACTION BAR ---------------
|
@Override
|
||||||
@Override
|
public void onServiceDisconnected(ComponentName aClassName) {
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
mCommunicationService = null;
|
||||||
getMenuInflater().inflate(R.menu.actionbar_presentation, menu);
|
}
|
||||||
mActionBarManager = new ActionBarManager();
|
};
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
// ---------------------------------------------- ACTION BAR ---------------
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
@Override
|
||||||
Intent aIntent;
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
switch (item.getItemId()) {
|
getMenuInflater().inflate(R.menu.actionbar_presentation, menu);
|
||||||
case R.id.actionbar_presentation_submenu_options:
|
mActionBarManager = new ActionBarManager();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
aIntent = new Intent(this, SettingsActivity.class);
|
@Override
|
||||||
startActivity(aIntent);
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
return true;
|
Intent aIntent;
|
||||||
case R.id.actionbar_presentation_submenu_blank:
|
switch (item.getItemId()) {
|
||||||
boolean aRelevantFragmentVisible = mPresentationFragment
|
case R.id.actionbar_presentation_submenu_options:
|
||||||
.isVisible() || mThumbnailFragment.isVisible();
|
|
||||||
if (aRelevantFragmentVisible) {
|
|
||||||
|
|
||||||
BlankScreenFragment aFragment = new BlankScreenFragment(
|
aIntent = new Intent(this, SettingsActivity.class);
|
||||||
mCommunicationService);
|
startActivity(aIntent);
|
||||||
|
return true;
|
||||||
|
case R.id.actionbar_presentation_submenu_blank:
|
||||||
|
boolean aRelevantFragmentVisible = mPresentationFragment
|
||||||
|
.isVisible() || mThumbnailFragment.isVisible();
|
||||||
|
if (aRelevantFragmentVisible) {
|
||||||
|
|
||||||
FragmentTransaction ft = getFragmentManager()
|
BlankScreenFragment aFragment = new BlankScreenFragment(
|
||||||
.beginTransaction();
|
mCommunicationService);
|
||||||
ft.replace(R.id.presentation_innerFrame, aFragment);
|
|
||||||
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
|
|
||||||
ft.addToBackStack(null);
|
|
||||||
ft.commit();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ActionBarManager implements OnClickListener,
|
FragmentTransaction ft = getFragmentManager()
|
||||||
FragmentManager.OnBackStackChangedListener,
|
.beginTransaction();
|
||||||
TextView.OnEditorActionListener {
|
ft.replace(R.id.presentation_innerFrame, aFragment);
|
||||||
|
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
|
||||||
|
ft.addToBackStack(null);
|
||||||
|
ft.commit();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private ToggleButton mTimeLabel;
|
private class ActionBarManager implements OnClickListener,
|
||||||
private ToggleButton mThumbnailButton;
|
FragmentManager.OnBackStackChangedListener,
|
||||||
|
TextView.OnEditorActionListener {
|
||||||
|
|
||||||
private View mDropdownOptions;
|
private Handler timerHandler = new Handler();
|
||||||
private View mDropdownBlank;
|
|
||||||
|
|
||||||
// ------- CLOCKBAR
|
private ToggleButton mTimeLabel;
|
||||||
private View mClockBar;
|
private ToggleButton mThumbnailButton;
|
||||||
private ToggleButton mClockBar_clockButton;
|
|
||||||
private ToggleButton mClockBar_stopwatchButton;
|
|
||||||
private ToggleButton mClockBar_countdownButton;
|
|
||||||
|
|
||||||
// ------- STOPWATCH BAR
|
private View mDropdownOptions;
|
||||||
private View mStopwatchBar;
|
private View mDropdownBlank;
|
||||||
private Button mStopwatchButtonRun;
|
|
||||||
private Button mStopwatchButtonReset;
|
|
||||||
|
|
||||||
// ------- COUNTDOWN BAR
|
// ------- CLOCKBAR
|
||||||
private View mCountdownBar;
|
private View mClockBar;
|
||||||
private EditText mCountdownEntry;
|
private ToggleButton mClockBar_clockButton;
|
||||||
private Button mCountdownButton;
|
private ToggleButton mClockBar_stopwatchButton;
|
||||||
|
private ToggleButton mClockBar_countdownButton;
|
||||||
|
|
||||||
private String aTimeFormat = getResources().getString(
|
// ------- STOPWATCH BAR
|
||||||
R.string.actionbar_timeformat);
|
private View mStopwatchBar;
|
||||||
private String aTimerFormat = getResources().getString(
|
private Button mStopwatchButtonRun;
|
||||||
R.string.actionbar_timerformat);
|
private Button mStopwatchButtonReset;
|
||||||
/*
|
|
||||||
* True if the timer is being used as a timer, false if we are showing a
|
|
||||||
* clock.
|
|
||||||
*/
|
|
||||||
private boolean mTimerOn = false;
|
|
||||||
|
|
||||||
public ActionBarManager() {
|
// ------- COUNTDOWN BAR
|
||||||
|
private View mCountdownBar;
|
||||||
|
private EditText mCountdownEntry;
|
||||||
|
private Button mCountdownButton;
|
||||||
|
|
||||||
ActionBar aBar = getActionBar();
|
private String aTimeFormat = getResources().getString(
|
||||||
aBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
R.string.actionbar_timeformat);
|
||||||
aBar.setCustomView(R.layout.presentation_actionbar);
|
private String aTimerFormat = getResources().getString(
|
||||||
|
R.string.actionbar_timerformat);
|
||||||
|
/*
|
||||||
|
* True if the timer is being used as a timer, false if we are showing a
|
||||||
|
* clock.
|
||||||
|
*/
|
||||||
|
private boolean mTimerOn = false;
|
||||||
|
|
||||||
mThumbnailButton = (ToggleButton) aBar.getCustomView()
|
public void stop() {
|
||||||
.findViewById(R.id.actionbar_thumbnailtoggle);
|
timerHandler.removeCallbacks(timerUpdateThread);
|
||||||
mThumbnailButton.setOnClickListener(this);
|
}
|
||||||
|
|
||||||
mTimeLabel = (ToggleButton) aBar.getCustomView().findViewById(
|
public ActionBarManager() {
|
||||||
R.id.actionbar_time);
|
|
||||||
mTimeLabel.setOnClickListener(this);
|
|
||||||
|
|
||||||
setupClockBar();
|
ActionBar aBar = getActionBar();
|
||||||
|
aBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||||
|
aBar.setCustomView(R.layout.presentation_actionbar);
|
||||||
|
|
||||||
getFragmentManager().addOnBackStackChangedListener(this);
|
mThumbnailButton = (ToggleButton) aBar.getCustomView()
|
||||||
|
.findViewById(R.id.actionbar_thumbnailtoggle);
|
||||||
|
mThumbnailButton.setOnClickListener(this);
|
||||||
|
|
||||||
timerHandler.removeCallbacks(timerUpdateThread);
|
mTimeLabel = (ToggleButton) aBar.getCustomView().findViewById(
|
||||||
timerHandler.postDelayed(timerUpdateThread, 50);
|
R.id.actionbar_time);
|
||||||
|
mTimeLabel.setOnClickListener(this);
|
||||||
|
|
||||||
}
|
setupClockBar();
|
||||||
|
|
||||||
public void hidePopups() {
|
getFragmentManager().addOnBackStackChangedListener(this);
|
||||||
if (mClockBar.getVisibility() == View.VISIBLE) {
|
|
||||||
mClockBar.setVisibility(View.INVISIBLE);
|
|
||||||
mStopwatchBar.setVisibility(View.INVISIBLE);
|
|
||||||
mCountdownBar.setVisibility(View.INVISIBLE);
|
|
||||||
mTimeLabel.setChecked(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupClockBar() {
|
timerHandler.removeCallbacks(timerUpdateThread);
|
||||||
// ClockBar
|
timerHandler.postDelayed(timerUpdateThread, 50);
|
||||||
LayoutInflater aInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
aInflater.inflate(R.layout.presentation_clockbar, mOuterLayout);
|
|
||||||
mClockBar = mOuterLayout.findViewById(R.id.clockbar);
|
|
||||||
|
|
||||||
mClockBar_clockButton = (ToggleButton) mClockBar
|
}
|
||||||
.findViewById(R.id.clockbar_toggle_clockmode);
|
|
||||||
mClockBar_stopwatchButton = (ToggleButton) mClockBar
|
|
||||||
.findViewById(R.id.clockbar_toggle_stopwatchmode);
|
|
||||||
mClockBar_countdownButton = (ToggleButton) mClockBar
|
|
||||||
.findViewById(R.id.clockbar_toggle_countdownmode);
|
|
||||||
mClockBar_clockButton.setOnClickListener(this);
|
|
||||||
mClockBar_stopwatchButton.setOnClickListener(this);
|
|
||||||
mClockBar_countdownButton.setOnClickListener(this);
|
|
||||||
|
|
||||||
// Stopwatch bar
|
public void hidePopups() {
|
||||||
aInflater.inflate(R.layout.presentation_clockbar_stopwatchbar,
|
if (mClockBar.getVisibility() == View.VISIBLE) {
|
||||||
mOuterLayout);
|
mClockBar.setVisibility(View.INVISIBLE);
|
||||||
mStopwatchBar = mOuterLayout
|
mStopwatchBar.setVisibility(View.INVISIBLE);
|
||||||
.findViewById(R.id.clockbar_stopwatchbar);
|
mCountdownBar.setVisibility(View.INVISIBLE);
|
||||||
|
mTimeLabel.setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mStopwatchButtonRun = (Button) mStopwatchBar
|
private void setupClockBar() {
|
||||||
.findViewById(R.id.clockbar_stopwatch_run);
|
// ClockBar
|
||||||
mStopwatchButtonReset = (Button) mStopwatchBar
|
LayoutInflater aInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
.findViewById(R.id.clockbar_stopwatch_reset);
|
aInflater.inflate(R.layout.presentation_clockbar, mOuterLayout);
|
||||||
mStopwatchButtonRun.setOnClickListener(this);
|
mClockBar = mOuterLayout.findViewById(R.id.clockbar);
|
||||||
mStopwatchButtonReset.setOnClickListener(this);
|
|
||||||
|
|
||||||
// Countdown bar
|
mClockBar_clockButton = (ToggleButton) mClockBar
|
||||||
aInflater.inflate(R.layout.presentation_clockbar_countdownbar,
|
.findViewById(R.id.clockbar_toggle_clockmode);
|
||||||
mOuterLayout);
|
mClockBar_stopwatchButton = (ToggleButton) mClockBar
|
||||||
mCountdownBar = mOuterLayout
|
.findViewById(R.id.clockbar_toggle_stopwatchmode);
|
||||||
.findViewById(R.id.clockbar_countdownbar);
|
mClockBar_countdownButton = (ToggleButton) mClockBar
|
||||||
|
.findViewById(R.id.clockbar_toggle_countdownmode);
|
||||||
|
mClockBar_clockButton.setOnClickListener(this);
|
||||||
|
mClockBar_stopwatchButton.setOnClickListener(this);
|
||||||
|
mClockBar_countdownButton.setOnClickListener(this);
|
||||||
|
|
||||||
mCountdownEntry = (EditText) mCountdownBar
|
// Stopwatch bar
|
||||||
.findViewById(R.id.clockbar_countdown_time);
|
aInflater.inflate(R.layout.presentation_clockbar_stopwatchbar,
|
||||||
mCountdownButton = (Button) mCountdownBar
|
mOuterLayout);
|
||||||
.findViewById(R.id.clockbar_countdown_button);
|
mStopwatchBar = mOuterLayout
|
||||||
mCountdownButton.setOnClickListener(this);
|
.findViewById(R.id.clockbar_stopwatchbar);
|
||||||
mCountdownEntry.setOnEditorActionListener(this);
|
|
||||||
|
|
||||||
updateClockBar();
|
mStopwatchButtonRun = (Button) mStopwatchBar
|
||||||
hidePopups();
|
.findViewById(R.id.clockbar_stopwatch_run);
|
||||||
|
mStopwatchButtonReset = (Button) mStopwatchBar
|
||||||
|
.findViewById(R.id.clockbar_stopwatch_reset);
|
||||||
|
mStopwatchButtonRun.setOnClickListener(this);
|
||||||
|
mStopwatchButtonReset.setOnClickListener(this);
|
||||||
|
|
||||||
}
|
// Countdown bar
|
||||||
|
aInflater.inflate(R.layout.presentation_clockbar_countdownbar,
|
||||||
|
mOuterLayout);
|
||||||
|
mCountdownBar = mOuterLayout
|
||||||
|
.findViewById(R.id.clockbar_countdownbar);
|
||||||
|
|
||||||
private void updateClockBar() {
|
mCountdownEntry = (EditText) mCountdownBar
|
||||||
mClockBar_clockButton.setChecked(!mTimerOn);
|
.findViewById(R.id.clockbar_countdown_time);
|
||||||
|
mCountdownButton = (Button) mCountdownBar
|
||||||
|
.findViewById(R.id.clockbar_countdown_button);
|
||||||
|
mCountdownButton.setOnClickListener(this);
|
||||||
|
mCountdownEntry.setOnEditorActionListener(this);
|
||||||
|
|
||||||
mCountdownBar.setY(mClockBar.getHeight());
|
updateClockBar();
|
||||||
mStopwatchBar.setY(mClockBar.getHeight());
|
hidePopups();
|
||||||
|
|
||||||
boolean aIsCountdown = mCommunicationService.getSlideShow()
|
}
|
||||||
.getTimer().isCountdown();
|
|
||||||
// Stopwatch
|
|
||||||
boolean aStopwatchMode = mTimerOn && !aIsCountdown;
|
|
||||||
mClockBar_stopwatchButton.setChecked(aStopwatchMode);
|
|
||||||
mStopwatchBar.setVisibility(aStopwatchMode ? View.VISIBLE
|
|
||||||
: View.INVISIBLE);
|
|
||||||
mStopwatchBar.bringToFront();
|
|
||||||
if (aStopwatchMode) {
|
|
||||||
Timer aTimer = mCommunicationService.getSlideShow().getTimer();
|
|
||||||
if (aTimer.isRunning()) {
|
|
||||||
mStopwatchButtonRun.setText(R.string.clock_timer_pause);
|
|
||||||
mStopwatchButtonReset.setText(R.string.clock_timer_restart);
|
|
||||||
} else {
|
|
||||||
mStopwatchButtonRun.setText(R.string.clock_timer_start);
|
|
||||||
mStopwatchButtonReset.setText(R.string.clock_timer_reset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Countdown
|
private void updateClockBar() {
|
||||||
boolean aCountdownMode = mTimerOn && aIsCountdown;
|
if (mCommunicationService == null) {
|
||||||
mClockBar_countdownButton.setChecked(mTimerOn && aIsCountdown);
|
return;
|
||||||
mCountdownBar.setVisibility(mTimerOn && aIsCountdown ? View.VISIBLE
|
}
|
||||||
: View.INVISIBLE);
|
mClockBar_clockButton.setChecked(!mTimerOn);
|
||||||
mCountdownBar.bringToFront();
|
|
||||||
if (aCountdownMode) {
|
|
||||||
Timer aTimer = mCommunicationService.getSlideShow().getTimer();
|
|
||||||
if (aTimer.isRunning()) {
|
|
||||||
mCountdownButton.setText(R.string.clock_timer_pause);
|
|
||||||
} else {
|
|
||||||
mCountdownButton.setText(R.string.clock_timer_resume);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
mCountdownBar.setY(mClockBar.getHeight());
|
||||||
|
mStopwatchBar.setY(mClockBar.getHeight());
|
||||||
|
|
||||||
private Handler timerHandler = new Handler();
|
boolean aIsCountdown = mCommunicationService.getSlideShow()
|
||||||
|
.getTimer().isCountdown();
|
||||||
|
// Stopwatch
|
||||||
|
boolean aStopwatchMode = mTimerOn && !aIsCountdown;
|
||||||
|
mClockBar_stopwatchButton.setChecked(aStopwatchMode);
|
||||||
|
mStopwatchBar.setVisibility(aStopwatchMode ? View.VISIBLE
|
||||||
|
: View.INVISIBLE);
|
||||||
|
mStopwatchBar.bringToFront();
|
||||||
|
if (aStopwatchMode) {
|
||||||
|
Timer aTimer = mCommunicationService.getSlideShow().getTimer();
|
||||||
|
if (aTimer.isRunning()) {
|
||||||
|
mStopwatchButtonRun.setText(R.string.clock_timer_pause);
|
||||||
|
mStopwatchButtonReset.setText(R.string.clock_timer_restart);
|
||||||
|
} else {
|
||||||
|
mStopwatchButtonRun.setText(R.string.clock_timer_start);
|
||||||
|
mStopwatchButtonReset.setText(R.string.clock_timer_reset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Thread timerUpdateThread = new Thread() {
|
// Countdown
|
||||||
|
boolean aCountdownMode = mTimerOn && aIsCountdown;
|
||||||
|
mClockBar_countdownButton.setChecked(mTimerOn && aIsCountdown);
|
||||||
|
mCountdownBar.setVisibility(mTimerOn && aIsCountdown ? View.VISIBLE
|
||||||
|
: View.INVISIBLE);
|
||||||
|
mCountdownBar.bringToFront();
|
||||||
|
if (aCountdownMode) {
|
||||||
|
Timer aTimer = mCommunicationService.getSlideShow().getTimer();
|
||||||
|
if (aTimer.isRunning()) {
|
||||||
|
mCountdownButton.setText(R.string.clock_timer_pause);
|
||||||
|
} else {
|
||||||
|
mCountdownButton.setText(R.string.clock_timer_resume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public void run() {
|
|
||||||
// invalidateOptionsMenu();
|
|
||||||
CharSequence aTimeString;
|
|
||||||
long aTime = mCommunicationService.getSlideShow().getTimer()
|
|
||||||
.getTimeMillis();
|
|
||||||
if (mTimerOn) {
|
|
||||||
aTimeString = DateFormat.format(aTimerFormat, aTime);
|
|
||||||
} else {
|
|
||||||
aTimeString = DateFormat.format(aTimeFormat,
|
|
||||||
System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
mTimeLabel.setText(aTimeString);
|
|
||||||
// TODO: set the string
|
|
||||||
timerHandler.postDelayed(this, 50);
|
|
||||||
|
|
||||||
}
|
private Thread timerUpdateThread = new Thread() {
|
||||||
|
|
||||||
};
|
@Override
|
||||||
|
public void run() {
|
||||||
|
//invalidateOptionsMenu();
|
||||||
|
CharSequence aTimeString;
|
||||||
|
long aTime = mCommunicationService.getSlideShow().getTimer()
|
||||||
|
.getTimeMillis();
|
||||||
|
if (mTimerOn) {
|
||||||
|
aTimeString = DateFormat.format(aTimerFormat, aTime);
|
||||||
|
} else {
|
||||||
|
aTimeString = DateFormat.format(aTimeFormat,
|
||||||
|
System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
mTimeLabel.setText(aTimeString);
|
||||||
|
// TODO: set the string
|
||||||
|
timerHandler.postDelayed(this, 50);
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public void onClick(View aSource) {
|
|
||||||
Timer aTimer = mCommunicationService.getSlideShow().getTimer();
|
|
||||||
// --------------------------------- ACTIONBAR BUTTONS -------------
|
|
||||||
if (aSource == mThumbnailButton) {
|
|
||||||
if (!mThumbnailFragment.isVisible()) {
|
|
||||||
FragmentTransaction ft = getFragmentManager()
|
|
||||||
.beginTransaction();
|
|
||||||
ft.replace(R.id.presentation_innerFrame, mThumbnailFragment);
|
|
||||||
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
|
|
||||||
ft.addToBackStack(null);
|
|
||||||
ft.commit();
|
|
||||||
} else {
|
|
||||||
getFragmentManager().popBackStack();
|
|
||||||
}
|
|
||||||
} else if (aSource == mTimeLabel) {
|
|
||||||
if (mClockBar.getVisibility() == View.VISIBLE) {
|
|
||||||
hidePopups();
|
|
||||||
} else {
|
|
||||||
mClockBar.setVisibility(View.VISIBLE);
|
|
||||||
updateClockBar();
|
|
||||||
mClockBar.bringToFront();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ------------------------------------ CLOCKBAR BUTTONS -----------
|
|
||||||
else if (aSource == mClockBar_clockButton) {
|
|
||||||
mTimerOn = false;
|
|
||||||
updateClockBar();
|
|
||||||
} else if (aSource == mClockBar_stopwatchButton) {
|
|
||||||
mTimerOn = true;
|
|
||||||
if (aTimer.isCountdown()) { // Changing mode.
|
|
||||||
aTimer.reset();
|
|
||||||
}
|
|
||||||
aTimer.setCountdown(false);
|
|
||||||
updateClockBar();
|
|
||||||
} else if (aSource == mClockBar_countdownButton) {
|
|
||||||
mTimerOn = true;
|
|
||||||
if (!aTimer.isCountdown()) { // Changing mode
|
|
||||||
aTimer.reset();
|
|
||||||
}
|
|
||||||
aTimer.setCountdown(true);
|
|
||||||
updateClockBar();
|
|
||||||
}
|
|
||||||
// ------------------------------------- TIMER BUTTONS
|
|
||||||
else if (aSource == mStopwatchButtonRun) {
|
|
||||||
if (aTimer.isRunning()) {
|
|
||||||
aTimer.stopTimer();
|
|
||||||
} else {
|
|
||||||
aTimer.startTimer();
|
|
||||||
}
|
|
||||||
updateClockBar();
|
|
||||||
} else if (aSource == mStopwatchButtonReset) {
|
|
||||||
if (aTimer.isRunning()) {
|
|
||||||
aTimer.reset();
|
|
||||||
aTimer.startTimer();
|
|
||||||
} else {
|
|
||||||
aTimer.reset();
|
|
||||||
}
|
|
||||||
updateClockBar();
|
|
||||||
} else if (aSource == mCountdownButton) {
|
|
||||||
if (aTimer.isRunning()) {
|
|
||||||
aTimer.stopTimer();
|
|
||||||
} else {
|
|
||||||
aTimer.startTimer();
|
|
||||||
}
|
|
||||||
updateClockBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackStackChanged() {
|
public void onClick(View aSource) {
|
||||||
if (getFragmentManager().getBackStackEntryCount() == 0) {
|
Timer aTimer = mCommunicationService.getSlideShow().getTimer();
|
||||||
mThumbnailButton.setChecked(false);
|
// --------------------------------- ACTIONBAR BUTTONS -------------
|
||||||
}
|
if (aSource == mThumbnailButton) {
|
||||||
}
|
if (!mThumbnailFragment.isVisible()) {
|
||||||
|
FragmentTransaction ft = getFragmentManager()
|
||||||
|
.beginTransaction();
|
||||||
|
ft.replace(R.id.presentation_innerFrame, mThumbnailFragment);
|
||||||
|
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
|
||||||
|
ft.addToBackStack(null);
|
||||||
|
ft.commit();
|
||||||
|
} else {
|
||||||
|
getFragmentManager().popBackStack();
|
||||||
|
}
|
||||||
|
} else if (aSource == mTimeLabel) {
|
||||||
|
if (mClockBar.getVisibility() == View.VISIBLE) {
|
||||||
|
hidePopups();
|
||||||
|
} else {
|
||||||
|
mClockBar.setVisibility(View.VISIBLE);
|
||||||
|
updateClockBar();
|
||||||
|
mClockBar.bringToFront();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ------------------------------------ CLOCKBAR BUTTONS -----------
|
||||||
|
else if (aSource == mClockBar_clockButton) {
|
||||||
|
mTimerOn = false;
|
||||||
|
updateClockBar();
|
||||||
|
} else if (aSource == mClockBar_stopwatchButton) {
|
||||||
|
mTimerOn = true;
|
||||||
|
if (aTimer.isCountdown()) { // Changing mode.
|
||||||
|
aTimer.reset();
|
||||||
|
}
|
||||||
|
aTimer.setCountdown(false);
|
||||||
|
updateClockBar();
|
||||||
|
} else if (aSource == mClockBar_countdownButton) {
|
||||||
|
mTimerOn = true;
|
||||||
|
if (!aTimer.isCountdown()) { // Changing mode
|
||||||
|
aTimer.reset();
|
||||||
|
}
|
||||||
|
aTimer.setCountdown(true);
|
||||||
|
updateClockBar();
|
||||||
|
}
|
||||||
|
// ------------------------------------- TIMER BUTTONS
|
||||||
|
else if (aSource == mStopwatchButtonRun) {
|
||||||
|
if (aTimer.isRunning()) {
|
||||||
|
aTimer.stopTimer();
|
||||||
|
} else {
|
||||||
|
aTimer.startTimer();
|
||||||
|
}
|
||||||
|
updateClockBar();
|
||||||
|
} else if (aSource == mStopwatchButtonReset) {
|
||||||
|
if (aTimer.isRunning()) {
|
||||||
|
aTimer.reset();
|
||||||
|
aTimer.startTimer();
|
||||||
|
} else {
|
||||||
|
aTimer.reset();
|
||||||
|
}
|
||||||
|
updateClockBar();
|
||||||
|
} else if (aSource == mCountdownButton) {
|
||||||
|
if (aTimer.isRunning()) {
|
||||||
|
aTimer.stopTimer();
|
||||||
|
} else {
|
||||||
|
aTimer.startTimer();
|
||||||
|
}
|
||||||
|
updateClockBar();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public boolean onEditorAction(TextView tv, int aID, KeyEvent aEvent) {
|
|
||||||
if (aEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
|
|
||||||
|
|
||||||
long aTime = 0;
|
@Override
|
||||||
try {
|
public void onBackStackChanged() {
|
||||||
SimpleDateFormat aFormat = new SimpleDateFormat("HH:mm:ss");
|
if (getFragmentManager().getBackStackEntryCount() == 0) {
|
||||||
aFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
mThumbnailButton.setChecked(false);
|
||||||
aTime = aFormat.parse(mCountdownEntry.getText().toString())
|
}
|
||||||
.getTime();
|
}
|
||||||
} catch (ParseException e) {
|
|
||||||
}
|
|
||||||
if (aTime == 0) {
|
|
||||||
try {
|
|
||||||
SimpleDateFormat aFormat = new SimpleDateFormat("mm:ss");
|
|
||||||
aFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
|
||||||
aTime = aFormat.parse(
|
|
||||||
mCountdownEntry.getText().toString())
|
|
||||||
.getTime();
|
|
||||||
} catch (ParseException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mCommunicationService.getSlideShow().getTimer()
|
|
||||||
.setCountdownTime(aTime);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Intermediate layout that catches all touches, used in order to hide
|
public boolean onEditorAction(TextView tv, int aID, KeyEvent aEvent) {
|
||||||
* the clock menu as appropriate.
|
if (aEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
|
||||||
* @author andy
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private class InterceptorLayout extends FrameLayout {
|
|
||||||
|
|
||||||
public InterceptorLayout(Context context) {
|
long aTime = 0;
|
||||||
super(context);
|
try {
|
||||||
}
|
SimpleDateFormat aFormat = new SimpleDateFormat("HH:mm:ss");
|
||||||
|
aFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
aTime = aFormat.parse(mCountdownEntry.getText().toString())
|
||||||
|
.getTime();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
}
|
||||||
|
if (aTime == 0) {
|
||||||
|
try {
|
||||||
|
SimpleDateFormat aFormat = new SimpleDateFormat("mm:ss");
|
||||||
|
aFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
aTime = aFormat.parse(
|
||||||
|
mCountdownEntry.getText().toString())
|
||||||
|
.getTime();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mCommunicationService.getSlideShow().getTimer()
|
||||||
|
.setCountdownTime(aTime);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public boolean onInterceptTouchEvent(MotionEvent aEvent) {
|
* Intermediate layout that catches all touches, used in order to hide
|
||||||
mActionBarManager.hidePopups();
|
* the clock menu as appropriate.
|
||||||
return super.onInterceptTouchEvent(aEvent);
|
* @author andy
|
||||||
}
|
*
|
||||||
|
*/
|
||||||
|
private class InterceptorLayout extends FrameLayout {
|
||||||
|
|
||||||
@Override
|
public InterceptorLayout(Context context) {
|
||||||
public boolean onTouchEvent(MotionEvent aEvent) {
|
super(context);
|
||||||
return super.onTouchEvent(aEvent);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public boolean onInterceptTouchEvent(MotionEvent aEvent) {
|
||||||
|
mActionBarManager.hidePopups();
|
||||||
|
return super.onInterceptTouchEvent(aEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onTouchEvent(MotionEvent aEvent) {
|
||||||
|
return super.onTouchEvent(aEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,10 @@ import org.libreoffice.impressremote.communication.SlideShow;
|
|||||||
import pl.polidea.coverflow.AbstractCoverFlowImageAdapter;
|
import pl.polidea.coverflow.AbstractCoverFlowImageAdapter;
|
||||||
import pl.polidea.coverflow.CoverFlow;
|
import pl.polidea.coverflow.CoverFlow;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
@@ -14,7 +17,7 @@ import android.graphics.Color;
|
|||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Message;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -47,8 +50,8 @@ public class PresentationFragment extends Fragment {
|
|||||||
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
mContext = container.getContext();
|
mContext = getActivity().getApplicationContext();
|
||||||
|
container.removeAllViews();
|
||||||
View v = inflater.inflate(R.layout.fragment_presentation, container,
|
View v = inflater.inflate(R.layout.fragment_presentation, container,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
@@ -85,9 +88,26 @@ public class PresentationFragment extends Fragment {
|
|||||||
// We need to update the view now
|
// We need to update the view now
|
||||||
aAdapter.notifyDataSetChanged();
|
aAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IntentFilter aFilter = new IntentFilter(
|
||||||
|
CommunicationService.MSG_SLIDE_CHANGED);
|
||||||
|
aFilter.addAction(CommunicationService.MSG_SLIDE_NOTES);
|
||||||
|
aFilter.addAction(CommunicationService.MSG_SLIDE_PREVIEW);
|
||||||
|
LocalBroadcastManager
|
||||||
|
.getInstance(getActivity().getApplicationContext())
|
||||||
|
.registerReceiver(mListener, aFilter);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
LocalBroadcastManager
|
||||||
|
.getInstance(getActivity().getApplicationContext())
|
||||||
|
.unregisterReceiver(mListener);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void updateSlideNumberDisplay() {
|
private void updateSlideNumberDisplay() {
|
||||||
int aSlide = mSlideShow.getCurrentSlide();
|
int aSlide = mSlideShow.getCurrentSlide();
|
||||||
mNumberText.setText((aSlide + 1) + "/" + mSlideShow.getSize());
|
mNumberText.setText((aSlide + 1) + "/" + mSlideShow.getSize());
|
||||||
@@ -204,23 +224,28 @@ public class PresentationFragment extends Fragment {
|
|||||||
updateSlideNumberDisplay();
|
updateSlideNumberDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleMessage(Message aMessage) {
|
private BroadcastReceiver mListener = new BroadcastReceiver() {
|
||||||
Bundle aData = aMessage.getData();
|
|
||||||
switch (aMessage.what) {
|
@Override
|
||||||
case CommunicationService.MSG_SLIDE_CHANGED:
|
public void onReceive(Context aContext, Intent aIntent) {
|
||||||
int aSlide = aData.getInt("slide_number");
|
if (aIntent.getAction().equals(
|
||||||
mTopView.setSelection(aSlide, true);
|
CommunicationService.MSG_SLIDE_CHANGED)) {
|
||||||
updateSlideNumberDisplay();
|
int aSlide = aIntent.getExtras().getInt("slide_number");
|
||||||
break;
|
mTopView.setSelection(aSlide, true);
|
||||||
case CommunicationService.MSG_SLIDE_PREVIEW:
|
updateSlideNumberDisplay();
|
||||||
int aNSlide = aData.getInt("slide_number");
|
} else if (aIntent.getAction().equals(
|
||||||
if (mTopView.getSelectedItemPosition() == aNSlide) {
|
CommunicationService.MSG_SLIDE_PREVIEW)) {
|
||||||
// mTopView. // TODO: update the current item
|
int aNSlide = aIntent.getExtras().getInt("slide_number");
|
||||||
|
if (mTopView.getSelectedItemPosition() == aNSlide) {
|
||||||
|
mTopView.setSelection(aNSlide);
|
||||||
|
}
|
||||||
|
} else if (aIntent.getAction().equals(
|
||||||
|
CommunicationService.MSG_SLIDE_NOTES)) {
|
||||||
|
// TODO: update me
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// ------------------------------------------------- THUMBNAIL ADAPTER ----
|
// ------------------------------------------------- THUMBNAIL ADAPTER ----
|
||||||
protected class ThumbnailAdapter extends AbstractCoverFlowImageAdapter {
|
protected class ThumbnailAdapter extends AbstractCoverFlowImageAdapter {
|
||||||
|
@@ -61,6 +61,12 @@ public class SelectorActivity extends Activity {
|
|||||||
refreshLists();
|
refreshLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(mListener);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
mCommunicationService.stopFindingServers();
|
mCommunicationService.stopFindingServers();
|
||||||
|
@@ -0,0 +1,91 @@
|
|||||||
|
package org.libreoffice.impressremote;
|
||||||
|
|
||||||
|
import org.libreoffice.impressremote.communication.CommunicationService;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.content.ServiceConnection;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
|
||||||
|
public class StartPresentationActivity extends Activity {
|
||||||
|
private CommunicationService mCommunicationService = null;
|
||||||
|
private boolean mIsBound = false;
|
||||||
|
|
||||||
|
/** Called when the activity is first created. */
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_startpresentation);
|
||||||
|
bindService(new Intent(this, CommunicationService.class), mConnection,
|
||||||
|
Context.BIND_IMPORTANT);
|
||||||
|
mIsBound = true;
|
||||||
|
|
||||||
|
IntentFilter aFilter = new IntentFilter(
|
||||||
|
CommunicationService.MSG_SLIDESHOW_STARTED);
|
||||||
|
LocalBroadcastManager.getInstance(this).registerReceiver(mListener,
|
||||||
|
aFilter);
|
||||||
|
|
||||||
|
findViewById(R.id.startpresentation_button).setOnClickListener(
|
||||||
|
mClickListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(mListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
@Override
|
||||||
|
public void onServiceConnected(ComponentName aClassName,
|
||||||
|
IBinder aService) {
|
||||||
|
|
||||||
|
mCommunicationService = ((CommunicationService.CBinder) aService)
|
||||||
|
.getService();
|
||||||
|
|
||||||
|
if (mCommunicationService.isSlideShowRunning()) {
|
||||||
|
Intent nIntent = new Intent(StartPresentationActivity.this,
|
||||||
|
PresentationActivity.class);
|
||||||
|
startActivity(nIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServiceDisconnected(ComponentName aClassName) {
|
||||||
|
mCommunicationService = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private OnClickListener mClickListener = new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (mCommunicationService != null) {
|
||||||
|
mCommunicationService.getTransmitter().startPresentation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private BroadcastReceiver mListener = new BroadcastReceiver() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context aContext, Intent aIntent) {
|
||||||
|
if (aIntent.getAction().equals(
|
||||||
|
CommunicationService.MSG_SLIDESHOW_STARTED)) {
|
||||||
|
Intent nIntent = new Intent(StartPresentationActivity.this,
|
||||||
|
PresentationActivity.class);
|
||||||
|
startActivity(nIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@@ -12,11 +12,14 @@ import org.libreoffice.impressremote.communication.CommunicationService;
|
|||||||
import org.libreoffice.impressremote.communication.SlideShow;
|
import org.libreoffice.impressremote.communication.SlideShow;
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
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.Message;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -29,194 +32,204 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
public class ThumbnailFragment extends Fragment {
|
public class ThumbnailFragment extends Fragment {
|
||||||
|
|
||||||
private CommunicationService mCommunicationService;
|
private CommunicationService mCommunicationService;
|
||||||
|
|
||||||
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;
|
private Context mContext;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View v = inflater
|
container.removeAllViews();
|
||||||
.inflate(R.layout.fragment_thumbnail, container, false);
|
View v = inflater
|
||||||
|
.inflate(R.layout.fragment_thumbnail, container, false);
|
||||||
|
|
||||||
mGrid = (GridView) v.findViewById(R.id.thumbnail_grid);
|
mGrid = (GridView) v.findViewById(R.id.thumbnail_grid);
|
||||||
|
|
||||||
mGrid.setOnItemClickListener(new ClickListener());
|
mGrid.setOnItemClickListener(new ClickListener());
|
||||||
mContext = container.getContext();
|
mContext = getActivity().getApplicationContext();
|
||||||
|
|
||||||
if (mCommunicationService != null && mSlideShow != null) {
|
if (mCommunicationService != null && mSlideShow != null) {
|
||||||
mGrid.setAdapter(new ThumbnailAdapter(mContext, mSlideShow));
|
mGrid.setAdapter(new ThumbnailAdapter(mContext, mSlideShow));
|
||||||
}
|
}
|
||||||
|
|
||||||
return v;
|
IntentFilter aFilter = new IntentFilter(
|
||||||
}
|
CommunicationService.MSG_SLIDE_CHANGED);
|
||||||
|
aFilter.addAction(CommunicationService.MSG_SLIDE_PREVIEW);
|
||||||
|
LocalBroadcastManager
|
||||||
|
.getInstance(getActivity().getApplicationContext())
|
||||||
|
.registerReceiver(mListener, aFilter);
|
||||||
|
|
||||||
@Override
|
return v;
|
||||||
public void onDestroyView() {
|
}
|
||||||
super.onDestroyView();
|
|
||||||
mGrid = null;
|
|
||||||
mContext = null;
|
|
||||||
mCurrentImage = null;
|
|
||||||
mCurrentText = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onDestroyView() {
|
||||||
super.onCreate(savedInstanceState);
|
super.onDestroyView();
|
||||||
|
LocalBroadcastManager
|
||||||
|
.getInstance(getActivity().getApplicationContext())
|
||||||
|
.unregisterReceiver(mListener);
|
||||||
|
mGrid = null;
|
||||||
|
mContext = null;
|
||||||
|
mCurrentImage = null;
|
||||||
|
mCurrentText = null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setSelected(int position) {
|
@Override
|
||||||
formatUnselected(mCurrentImage, mCurrentText);
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
if (mGrid == null) {
|
private void setSelected(int position) {
|
||||||
return;
|
formatUnselected(mCurrentImage, mCurrentText);
|
||||||
}
|
|
||||||
|
|
||||||
View aV = mGrid.getChildAt(position);
|
if (mGrid == null) {
|
||||||
if (aV != null) {
|
return;
|
||||||
mCurrentImage = (ImageView) aV.findViewById(R.id.sub_thumbnail);
|
}
|
||||||
mCurrentText = (TextView) aV.findViewById(R.id.sub_number);
|
|
||||||
|
|
||||||
formatSelected(mCurrentImage, mCurrentText);
|
View aV = mGrid.getChildAt(position);
|
||||||
}
|
if (aV != null) {
|
||||||
}
|
mCurrentImage = (ImageView) aV.findViewById(R.id.sub_thumbnail);
|
||||||
|
mCurrentText = (TextView) aV.findViewById(R.id.sub_number);
|
||||||
|
|
||||||
private void formatUnselected(ImageView aImage, TextView aText) {
|
formatSelected(mCurrentImage, mCurrentText);
|
||||||
if (aImage != null) {
|
}
|
||||||
aImage.setBackgroundColor(getResources().getColor(
|
}
|
||||||
R.color.thumbnail_border));
|
|
||||||
}
|
|
||||||
if (aText != null) {
|
|
||||||
aText.setTypeface(Typeface.create(aText.getTypeface(),
|
|
||||||
Typeface.NORMAL));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void formatSelected(ImageView aImage, TextView aText) {
|
private void formatUnselected(ImageView aImage, TextView aText) {
|
||||||
if (aImage != null) {
|
if (aImage != null) {
|
||||||
aImage.setBackgroundColor(getResources().getColor(
|
aImage.setBackgroundColor(getResources().getColor(
|
||||||
R.color.thumbnail_border_selected));
|
R.color.thumbnail_border));
|
||||||
}
|
}
|
||||||
if (aText != null) {
|
if (aText != null) {
|
||||||
aText.setTypeface(Typeface.create(aText.getTypeface(),
|
aText.setTypeface(Typeface.create(aText.getTypeface(),
|
||||||
Typeface.BOLD));
|
Typeface.NORMAL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------- CLICK LISTENER ----
|
private void formatSelected(ImageView aImage, TextView aText) {
|
||||||
protected class ClickListener implements AdapterView.OnItemClickListener {
|
if (aImage != null) {
|
||||||
public void onItemClick(AdapterView<?> parent, View v, int position,
|
aImage.setBackgroundColor(getResources().getColor(
|
||||||
long id) {
|
R.color.thumbnail_border_selected));
|
||||||
if (mCommunicationService != null)
|
}
|
||||||
mCommunicationService.getTransmitter().gotoSlide(position);
|
if (aText != null) {
|
||||||
}
|
aText.setTypeface(Typeface.create(aText.getTypeface(),
|
||||||
}
|
Typeface.BOLD));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------- MESSAGE HANDLER ----
|
// ----------------------------------------------------- CLICK LISTENER ----
|
||||||
|
protected class ClickListener implements AdapterView.OnItemClickListener {
|
||||||
|
public void onItemClick(AdapterView<?> parent, View v, int position,
|
||||||
|
long id) {
|
||||||
|
if (mCommunicationService != null)
|
||||||
|
mCommunicationService.getTransmitter().gotoSlide(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setCommunicationService(
|
// ---------------------------------------------------- MESSAGE HANDLER ----
|
||||||
CommunicationService aCommunicationService) {
|
|
||||||
mCommunicationService = aCommunicationService;
|
|
||||||
mSlideShow = mCommunicationService.getSlideShow();
|
|
||||||
if (mGrid != null) {
|
|
||||||
mGrid.setAdapter(new ThumbnailAdapter(mContext, mSlideShow));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleMessage(Message aMessage) {
|
public void setCommunicationService(
|
||||||
if (!isVisible()) {
|
CommunicationService aCommunicationService) {
|
||||||
return;
|
mCommunicationService = aCommunicationService;
|
||||||
}
|
mSlideShow = mCommunicationService.getSlideShow();
|
||||||
|
if (mGrid != null) {
|
||||||
|
mGrid.setAdapter(new ThumbnailAdapter(mContext, mSlideShow));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Bundle aData = aMessage.getData();
|
private BroadcastReceiver mListener = new BroadcastReceiver() {
|
||||||
switch (aMessage.what) {
|
|
||||||
case CommunicationService.MSG_SLIDE_CHANGED:
|
|
||||||
int aSlide = aData.getInt("slide_number");
|
|
||||||
break;
|
|
||||||
case CommunicationService.MSG_SLIDE_PREVIEW:
|
|
||||||
mGrid.invalidateViews();
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
@Override
|
||||||
}
|
public void onReceive(Context aContext, Intent aIntent) {
|
||||||
|
if (aIntent.getAction().equals(
|
||||||
|
CommunicationService.MSG_SLIDE_CHANGED)) {
|
||||||
|
int aSlide = aIntent.getExtras().getInt("slide_number");
|
||||||
|
setSelected(aSlide);
|
||||||
|
} else if (aIntent.getAction().equals(
|
||||||
|
CommunicationService.MSG_SLIDE_PREVIEW)) {
|
||||||
|
mGrid.invalidateViews();
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------- THUMBNAIL ADAPTER ----
|
}
|
||||||
protected class ThumbnailAdapter extends BaseAdapter {
|
};
|
||||||
|
|
||||||
private Context mContext;
|
// ------------------------------------------------- THUMBNAIL ADAPTER ----
|
||||||
|
protected class ThumbnailAdapter extends BaseAdapter {
|
||||||
|
|
||||||
private SlideShow mSlideShow;
|
private Context mContext;
|
||||||
|
|
||||||
public ThumbnailAdapter(Context aContext, SlideShow aSlideShow) {
|
private SlideShow mSlideShow;
|
||||||
mContext = aContext;
|
|
||||||
mSlideShow = aSlideShow;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public ThumbnailAdapter(Context aContext, SlideShow aSlideShow) {
|
||||||
public int getCount() {
|
mContext = aContext;
|
||||||
return mSlideShow.getSize();
|
mSlideShow = aSlideShow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getItem(int arg0) {
|
public int getCount() {
|
||||||
return null;
|
return mSlideShow.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getItemId(int position) {
|
public Object getItem(int arg0) {
|
||||||
return 0;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public long getItemId(int position) {
|
||||||
LayoutInflater aInflater = (LayoutInflater) mContext
|
return 0;
|
||||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
}
|
||||||
View v = aInflater.inflate(R.layout.slide_thumbnail, null);
|
|
||||||
|
|
||||||
ImageView aImage = (ImageView) v.findViewById(R.id.sub_thumbnail);
|
@Override
|
||||||
TextView aText = (TextView) v.findViewById(R.id.sub_number);
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
LayoutInflater aInflater = (LayoutInflater) mContext
|
||||||
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
View v = aInflater.inflate(R.layout.slide_thumbnail, null);
|
||||||
|
|
||||||
// Do the image & number styling
|
ImageView aImage = (ImageView) v.findViewById(R.id.sub_thumbnail);
|
||||||
int aBorderWidth = getResources().getInteger(
|
TextView aText = (TextView) v.findViewById(R.id.sub_number);
|
||||||
R.integer.thumbnail_border_width);
|
|
||||||
aImage.setPadding(aBorderWidth, aBorderWidth, aBorderWidth,
|
|
||||||
aBorderWidth);
|
|
||||||
|
|
||||||
if ((mSlideShow != null)
|
// Do the image & number styling
|
||||||
&& (position == mSlideShow.getCurrentSlide())) {
|
int aBorderWidth = getResources().getInteger(
|
||||||
formatSelected(aImage, aText);
|
R.integer.thumbnail_border_width);
|
||||||
mCurrentImage = aImage;
|
aImage.setPadding(aBorderWidth, aBorderWidth, aBorderWidth,
|
||||||
mCurrentText = aText;
|
aBorderWidth);
|
||||||
} else {
|
|
||||||
formatUnselected(aImage, aText);
|
|
||||||
}
|
|
||||||
|
|
||||||
Bitmap aBitmap = mSlideShow.getImage(position);
|
if ((mSlideShow != null)
|
||||||
// Width
|
&& (position == mSlideShow.getCurrentSlide())) {
|
||||||
int aWidth = (mGrid.getWidth()) / 3 - 20;
|
formatSelected(aImage, aText);
|
||||||
aImage.setMaxWidth(aWidth);
|
mCurrentImage = aImage;
|
||||||
aImage.setScaleType(ScaleType.FIT_CENTER);
|
mCurrentText = aText;
|
||||||
|
} else {
|
||||||
|
formatUnselected(aImage, aText);
|
||||||
|
}
|
||||||
|
|
||||||
if (aBitmap != null) {
|
Bitmap aBitmap = mSlideShow.getImage(position);
|
||||||
aImage.setImageBitmap(aBitmap);
|
// Width
|
||||||
}
|
int aWidth = (mGrid.getWidth()) / 3 - 20;
|
||||||
|
aImage.setMaxWidth(aWidth);
|
||||||
|
aImage.setScaleType(ScaleType.FIT_CENTER);
|
||||||
|
|
||||||
aText.setText(String.valueOf(position + 1));
|
if (aBitmap != null) {
|
||||||
|
aImage.setImageBitmap(aBitmap);
|
||||||
|
}
|
||||||
|
|
||||||
return v;
|
aText.setText(String.valueOf(position + 1));
|
||||||
}
|
|
||||||
}
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@@ -34,6 +34,8 @@ public abstract class Client {
|
|||||||
protected OutputStream mOutputStream;
|
protected OutputStream mOutputStream;
|
||||||
protected String mPin = "";
|
protected String mPin = "";
|
||||||
|
|
||||||
|
private static Client latestInstance = null;
|
||||||
|
|
||||||
public abstract void closeConnection();
|
public abstract void closeConnection();
|
||||||
|
|
||||||
private Receiver mReceiver;
|
private Receiver mReceiver;
|
||||||
@@ -42,6 +44,7 @@ public abstract class Client {
|
|||||||
|
|
||||||
public Client(Context aContext) {
|
public Client(Context aContext) {
|
||||||
mContext = aContext;
|
mContext = aContext;
|
||||||
|
latestInstance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReceiver(Receiver aReceiver) {
|
public void setReceiver(Receiver aReceiver) {
|
||||||
@@ -77,11 +80,16 @@ public abstract class Client {
|
|||||||
// TODO stream couldn't be opened.
|
// TODO stream couldn't be opened.
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
|
latestInstance = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPin() {
|
public static String getPin() {
|
||||||
return mPin;
|
if (latestInstance != null) {
|
||||||
|
return latestInstance.mPin;
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -12,7 +12,6 @@ import android.app.Service;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Messenger;
|
|
||||||
|
|
||||||
public class CommunicationService extends Service implements Runnable {
|
public class CommunicationService extends Service implements Runnable {
|
||||||
|
|
||||||
@@ -32,10 +31,7 @@ public class CommunicationService extends Service implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getPairingPin() {
|
public String getPairingPin() {
|
||||||
if (mClient != null)
|
return Client.getPin();
|
||||||
return mClient.getPin();
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDeviceName() {
|
public String getDeviceName() {
|
||||||
@@ -67,6 +63,7 @@ public class CommunicationService extends Service implements Runnable {
|
|||||||
mState = State.DISCONNECTED;
|
mState = State.DISCONNECTED;
|
||||||
}
|
}
|
||||||
if (mStateDesired == State.CONNECTED) {
|
if (mStateDesired == State.CONNECTED) {
|
||||||
|
mState = State.CONNECTING;
|
||||||
switch (mServerDesired.getProtocol()) {
|
switch (mServerDesired.getProtocol()) {
|
||||||
case NETWORK:
|
case NETWORK:
|
||||||
mClient = new NetworkClient(
|
mClient = new NetworkClient(
|
||||||
@@ -138,10 +135,10 @@ public class CommunicationService extends Service implements Runnable {
|
|||||||
|
|
||||||
private final IBinder mBinder = new CBinder();
|
private final IBinder mBinder = new CBinder();
|
||||||
|
|
||||||
public static final int MSG_SLIDESHOW_STARTED = 1;
|
public static final String MSG_SLIDESHOW_STARTED = "SLIDESHOW_STARTED";
|
||||||
public static final int MSG_SLIDE_CHANGED = 2;
|
public static final String MSG_SLIDE_CHANGED = "SLIDE_CHANGED";
|
||||||
public static final int MSG_SLIDE_PREVIEW = 3;
|
public static final String MSG_SLIDE_PREVIEW = "SLIDE_PREVIEW";
|
||||||
public static final int MSG_SLIDE_NOTES = 4;
|
public static final String MSG_SLIDE_NOTES = "SLIDE_NOTES";
|
||||||
|
|
||||||
public static final String MSG_SERVERLIST_CHANGED = "SERVERLIST_CHANGED";
|
public static final String MSG_SERVERLIST_CHANGED = "SERVERLIST_CHANGED";
|
||||||
public static final String MSG_PAIRING_STARTED = "PAIRING_STARTED";
|
public static final String MSG_PAIRING_STARTED = "PAIRING_STARTED";
|
||||||
@@ -151,14 +148,10 @@ public class CommunicationService extends Service implements Runnable {
|
|||||||
|
|
||||||
private Client mClient;
|
private Client mClient;
|
||||||
|
|
||||||
private Receiver mReceiver = new Receiver();
|
private Receiver mReceiver = new Receiver(this);
|
||||||
|
|
||||||
private ServerFinder mFinder = new ServerFinder(this);
|
private ServerFinder mFinder = new ServerFinder(this);
|
||||||
|
|
||||||
public void setActivityMessenger(Messenger aActivityMessenger) {
|
|
||||||
mReceiver.setActivityMessenger(aActivityMessenger);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinder onBind(Intent intent) {
|
public IBinder onBind(Intent intent) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
@@ -201,5 +194,9 @@ public class CommunicationService extends Service implements Runnable {
|
|||||||
return mReceiver.getSlideShow();
|
return mReceiver.getSlideShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSlideShowRunning() {
|
||||||
|
return mReceiver.isSlideShowRunning();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@@ -10,112 +10,87 @@ package org.libreoffice.impressremote.communication;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.content.Context;
|
||||||
import android.os.Message;
|
import android.content.Intent;
|
||||||
import android.os.Messenger;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.os.RemoteException;
|
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
|
|
||||||
public class Receiver {
|
public class Receiver {
|
||||||
|
|
||||||
private Messenger mActivityMessenger;
|
public Receiver(Context aContext) {
|
||||||
|
mContext = aContext;
|
||||||
|
mSlideShow = new SlideShow(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
private SlideShow mSlideShow = new SlideShow();
|
private Context mContext;
|
||||||
|
|
||||||
public SlideShow getSlideShow() {
|
private SlideShow mSlideShow;
|
||||||
return mSlideShow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActivityMessenger(Messenger aActivityMessenger) {
|
public SlideShow getSlideShow() {
|
||||||
mActivityMessenger = aActivityMessenger;
|
return mSlideShow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void parseCommand(ArrayList<String> aCommand) {
|
public boolean isSlideShowRunning() {
|
||||||
if (mActivityMessenger == null) {
|
return (mSlideShow.getSize() > 0);
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
String aInstruction = aCommand.get(0);
|
|
||||||
if (aInstruction.equals("slideshow_started")) {
|
|
||||||
int aSlideShowlength = Integer.parseInt(aCommand.get(1));
|
|
||||||
int aCurrentSlide = Integer.parseInt(aCommand.get(2));
|
|
||||||
mSlideShow.setLength(aSlideShowlength);
|
|
||||||
mSlideShow.setCurrentSlide(aCurrentSlide);
|
|
||||||
|
|
||||||
Message aMessage = Message.obtain(null,
|
public void parseCommand(ArrayList<String> aCommand) {
|
||||||
CommunicationService.MSG_SLIDESHOW_STARTED);
|
String aInstruction = aCommand.get(0);
|
||||||
Bundle aData = new Bundle();
|
if (aInstruction.equals("slideshow_started")) {
|
||||||
aMessage.setData(aData);
|
int aSlideShowlength = Integer.parseInt(aCommand.get(1));
|
||||||
try {
|
int aCurrentSlide = Integer.parseInt(aCommand.get(2));
|
||||||
mActivityMessenger.send(aMessage);
|
mSlideShow.setLength(aSlideShowlength);
|
||||||
} catch (RemoteException e) {
|
mSlideShow.setCurrentSlide(aCurrentSlide);
|
||||||
// Dead Handler -- i.e. Activity gone.
|
Intent aIntent = new Intent(
|
||||||
}
|
CommunicationService.MSG_SLIDESHOW_STARTED);
|
||||||
} else {
|
LocalBroadcastManager.getInstance(mContext).sendBroadcast(aIntent);
|
||||||
if (mSlideShow == null)
|
} else {
|
||||||
return;
|
if (mSlideShow == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (aInstruction.equals("slide_updated")) {
|
if (aInstruction.equals("slide_updated")) {
|
||||||
|
|
||||||
int aSlideNumber = Integer.parseInt(aCommand.get(1));
|
int aSlideNumber = Integer.parseInt(aCommand.get(1));
|
||||||
|
|
||||||
mSlideShow.setCurrentSlide(aSlideNumber);
|
mSlideShow.setCurrentSlide(aSlideNumber);
|
||||||
|
|
||||||
Message aMessage = Message.obtain(null,
|
Intent aIntent = new Intent(
|
||||||
CommunicationService.MSG_SLIDE_CHANGED);
|
CommunicationService.MSG_SLIDE_CHANGED);
|
||||||
Bundle aData = new Bundle();
|
aIntent.putExtra("slide_number", aSlideNumber);
|
||||||
aData.putInt("slide_number", aSlideNumber);
|
LocalBroadcastManager.getInstance(mContext).sendBroadcast(
|
||||||
aMessage.setData(aData);
|
aIntent);
|
||||||
try {
|
} else if (aInstruction.equals("slide_preview")) {
|
||||||
mActivityMessenger.send(aMessage);
|
int aSlideNumber = Integer.parseInt(aCommand.get(1));
|
||||||
} catch (RemoteException e) {
|
String aImageString = aCommand.get(2);
|
||||||
// Dead Handler -- i.e. Activity gone.
|
byte[] aImage = Base64.decode(aImageString, Base64.DEFAULT);
|
||||||
}
|
|
||||||
} else if (aInstruction.equals("slide_preview")) {
|
|
||||||
int aSlideNumber = Integer.parseInt(aCommand.get(1));
|
|
||||||
String aImageString = aCommand.get(2);
|
|
||||||
byte[] aImage = Base64.decode(aImageString, Base64.DEFAULT);
|
|
||||||
|
|
||||||
// Store image internally
|
// Store image internally
|
||||||
mSlideShow.putImage(aSlideNumber, aImage);
|
mSlideShow.putImage(aSlideNumber, aImage);
|
||||||
|
|
||||||
// Notify the frontend
|
Intent aIntent = new Intent(
|
||||||
Message aMessage = Message.obtain(null,
|
CommunicationService.MSG_SLIDE_PREVIEW);
|
||||||
CommunicationService.MSG_SLIDE_PREVIEW);
|
aIntent.putExtra("slide_number", aSlideNumber);
|
||||||
Bundle aData = new Bundle();
|
LocalBroadcastManager.getInstance(mContext).sendBroadcast(
|
||||||
aData.putInt("slide_number", aSlideNumber);
|
aIntent);
|
||||||
aMessage.setData(aData);
|
} else if (aInstruction.equals("slide_notes")) {
|
||||||
try {
|
int aSlideNumber = Integer.parseInt(aCommand.get(1));
|
||||||
mActivityMessenger.send(aMessage);
|
String aNotes = new String();
|
||||||
} catch (RemoteException e) {
|
for (int i = 2; i < aCommand.size(); i++) {
|
||||||
// TODO Auto-generated catch block
|
aNotes += aCommand.get(i);
|
||||||
e.printStackTrace();
|
}
|
||||||
}
|
|
||||||
} else if (aInstruction.equals("slide_notes")) {
|
|
||||||
int aSlideNumber = Integer.parseInt(aCommand.get(1));
|
|
||||||
String aNotes = new String();
|
|
||||||
for (int i = 2; i < aCommand.size(); i++) {
|
|
||||||
aNotes += aCommand.get(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store image internally
|
// Store image internally
|
||||||
mSlideShow.putNotes(aSlideNumber, aNotes);
|
mSlideShow.putNotes(aSlideNumber, aNotes);
|
||||||
|
|
||||||
// Notify the frontend
|
Intent aIntent = new Intent(
|
||||||
Message aMessage = Message.obtain(null,
|
CommunicationService.MSG_SLIDE_NOTES);
|
||||||
CommunicationService.MSG_SLIDE_NOTES);
|
aIntent.putExtra("slide_number", aSlideNumber);
|
||||||
Bundle aData = new Bundle();
|
LocalBroadcastManager.getInstance(mContext).sendBroadcast(
|
||||||
aData.putInt("slide_number", aSlideNumber);
|
aIntent);
|
||||||
aMessage.setData(aData);
|
}
|
||||||
try {
|
|
||||||
mActivityMessenger.send(aMessage);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@@ -8,160 +8,169 @@
|
|||||||
*/
|
*/
|
||||||
package org.libreoffice.impressremote.communication;
|
package org.libreoffice.impressremote.communication;
|
||||||
|
|
||||||
|
import org.libreoffice.impressremote.R;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
|
||||||
public class SlideShow {
|
public class SlideShow {
|
||||||
|
|
||||||
private SparseArray<byte[]> mPreviewImages = new SparseArray<byte[]>();
|
private SparseArray<byte[]> mPreviewImages = new SparseArray<byte[]>();
|
||||||
private SparseArray<String> mNotes = new SparseArray<String>();
|
private SparseArray<String> mNotes = new SparseArray<String>();
|
||||||
|
|
||||||
private int mSize = 0;
|
private int mSize = 0;
|
||||||
private int mCurrentSlide = 0;
|
private int mCurrentSlide = 0;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
protected SlideShow() {
|
protected SlideShow(Context aContext) {
|
||||||
}
|
mContext = aContext;
|
||||||
|
}
|
||||||
|
|
||||||
protected void setLength(int aSize) {
|
protected void setLength(int aSize) {
|
||||||
mSize = aSize;
|
mSize = aSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return mSize;
|
return mSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCurrentSlide() {
|
public int getCurrentSlide() {
|
||||||
return mCurrentSlide;
|
return mCurrentSlide;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setCurrentSlide(int aSlide) {
|
protected void setCurrentSlide(int aSlide) {
|
||||||
mCurrentSlide = aSlide;
|
mCurrentSlide = aSlide;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void putImage(int aSlide, byte[] aImage) {
|
protected void putImage(int aSlide, byte[] aImage) {
|
||||||
mPreviewImages.put(aSlide, aImage);
|
mPreviewImages.put(aSlide, aImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap getImage(int aSlide) {
|
public Bitmap getImage(int aSlide) {
|
||||||
byte[] aImage = mPreviewImages.get(aSlide);
|
byte[] aImage = mPreviewImages.get(aSlide);
|
||||||
return BitmapFactory.decodeByteArray(aImage, 0, aImage.length);
|
if (aImage == null) {
|
||||||
}
|
return BitmapFactory.decodeResource(mContext.getResources(),
|
||||||
|
R.drawable.image_loading);
|
||||||
|
}
|
||||||
|
return BitmapFactory.decodeByteArray(aImage, 0, aImage.length);
|
||||||
|
}
|
||||||
|
|
||||||
protected void putNotes(int aSlide, String aNotes) {
|
protected void putNotes(int aSlide, String aNotes) {
|
||||||
mNotes.put(aSlide, aNotes);
|
mNotes.put(aSlide, aNotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNotes(int aSlide) {
|
public String getNotes(int aSlide) {
|
||||||
return mNotes.get(aSlide);
|
return mNotes.get(aSlide);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------- TIMER --------------
|
// ---------------------------------------------------- TIMER --------------
|
||||||
private Timer mTimer = new Timer();
|
private Timer mTimer = new Timer();
|
||||||
|
|
||||||
public Timer getTimer() {
|
public Timer getTimer() {
|
||||||
return mTimer;
|
return mTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Timer {
|
public class Timer {
|
||||||
/**
|
/**
|
||||||
* This stores the starting time of the timer if running.
|
* This stores the starting time of the timer if running.
|
||||||
*
|
*
|
||||||
* If paused this stores how long the timer was previously running.
|
* If paused this stores how long the timer was previously running.
|
||||||
*/
|
*/
|
||||||
private long aTime = 0;
|
private long aTime = 0;
|
||||||
|
|
||||||
private long mCountdownTime = 0;
|
private long mCountdownTime = 0;
|
||||||
|
|
||||||
private boolean mIsRunning = false;
|
private boolean mIsRunning = false;
|
||||||
|
|
||||||
private boolean mIsCountdown = false;
|
private boolean mIsCountdown = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether this timer should be a normal or a countdown timer.
|
* Set whether this timer should be a normal or a countdown timer.
|
||||||
* @param aIsCountdown
|
* @param aIsCountdown
|
||||||
* Whether this should be a countdown timer.
|
* Whether this should be a countdown timer.
|
||||||
*/
|
*/
|
||||||
public void setCountdown(boolean aIsCountdown) {
|
public void setCountdown(boolean aIsCountdown) {
|
||||||
mIsCountdown = aIsCountdown;
|
mIsCountdown = aIsCountdown;
|
||||||
if (mIsRunning) {
|
if (mIsRunning) {
|
||||||
mIsRunning = false;
|
mIsRunning = false;
|
||||||
aTime = 0;
|
aTime = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the countdown time. Can be set, and isn't lost, whatever mode
|
* Set the countdown time. Can be set, and isn't lost, whatever mode
|
||||||
* the timer is running in.
|
* the timer is running in.
|
||||||
* @param aCountdownTime
|
* @param aCountdownTime
|
||||||
* The countdown time.
|
* The countdown time.
|
||||||
*/
|
*/
|
||||||
public void setCountdownTime(long aCountdownTime) {
|
public void setCountdownTime(long aCountdownTime) {
|
||||||
mCountdownTime = aCountdownTime;
|
mCountdownTime = aCountdownTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCountdownTime() {
|
public long getCountdownTime() {
|
||||||
return mCountdownTime;
|
return mCountdownTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCountdown() {
|
public boolean isCountdown() {
|
||||||
return mIsCountdown;
|
return mIsCountdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRunning() {
|
public boolean isRunning() {
|
||||||
return mIsRunning;
|
return mIsRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the timer, and stop it it was running.
|
* Reset the timer, and stop it it was running.
|
||||||
*/
|
*/
|
||||||
public void reset() {
|
public void reset() {
|
||||||
mIsRunning = false;
|
mIsRunning = false;
|
||||||
aTime = 0;
|
aTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startTimer() {
|
public void startTimer() {
|
||||||
if (mIsRunning)
|
if (mIsRunning)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
aTime = System.currentTimeMillis() - aTime;
|
aTime = System.currentTimeMillis() - aTime;
|
||||||
mIsRunning = true;
|
mIsRunning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer() {
|
public void stopTimer() {
|
||||||
if (!mIsRunning)
|
if (!mIsRunning)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
aTime = System.currentTimeMillis() - aTime;
|
aTime = System.currentTimeMillis() - aTime;
|
||||||
mIsRunning = false;
|
mIsRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get either how long this timer has been running, or how long the
|
* Get either how long this timer has been running, or how long the
|
||||||
* timer still has left to run.
|
* timer still has left to run.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public long getTimeMillis() {
|
public long getTimeMillis() {
|
||||||
long aTimeRunning;
|
long aTimeRunning;
|
||||||
// Determine how long we've been going.
|
// Determine how long we've been going.
|
||||||
if (mIsRunning) {
|
if (mIsRunning) {
|
||||||
aTimeRunning = System.currentTimeMillis() - aTime;
|
aTimeRunning = System.currentTimeMillis() - aTime;
|
||||||
} else {
|
} else {
|
||||||
aTimeRunning = aTime;
|
aTimeRunning = aTime;
|
||||||
}
|
}
|
||||||
// And give the time going, or time left
|
// And give the time going, or time left
|
||||||
if (!mIsCountdown) {
|
if (!mIsCountdown) {
|
||||||
return aTimeRunning;
|
return aTimeRunning;
|
||||||
} else {
|
} else {
|
||||||
long aRet = mCountdownTime - aTimeRunning;
|
long aRet = mCountdownTime - aTimeRunning;
|
||||||
if (aRet < 0) { // We have completed!
|
if (aRet < 0) { // We have completed!
|
||||||
mIsRunning = false;
|
mIsRunning = false;
|
||||||
aRet = 0;
|
aRet = 0;
|
||||||
}
|
}
|
||||||
return aRet;
|
return aRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@@ -1,197 +1,197 @@
|
|||||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
///* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
/*
|
///*
|
||||||
* This file is part of the LibreOffice project.
|
// * This file is part of the LibreOffice project.
|
||||||
*
|
// *
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
// * This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
// * License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// * file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
// */
|
||||||
package org.libreoffice.impressremote.communication;
|
//package org.libreoffice.impressremote.communication;
|
||||||
|
//
|
||||||
import org.libreoffice.impressremote.PresentationActivity;
|
//import org.libreoffice.impressremote.PresentationActivity;
|
||||||
import org.libreoffice.impressremote.R;
|
//import org.libreoffice.impressremote.R;
|
||||||
import org.libreoffice.impressremote.communication.Server.Protocol;
|
//import org.libreoffice.impressremote.communication.Server.Protocol;
|
||||||
|
//
|
||||||
import android.app.Activity;
|
//import android.app.Activity;
|
||||||
import android.content.ComponentName;
|
//import android.content.ComponentName;
|
||||||
import android.content.Context;
|
//import android.content.Context;
|
||||||
import android.content.Intent;
|
//import android.content.Intent;
|
||||||
import android.content.ServiceConnection;
|
//import android.content.ServiceConnection;
|
||||||
import android.graphics.Bitmap;
|
//import android.graphics.Bitmap;
|
||||||
import android.os.Bundle;
|
//import android.os.Bundle;
|
||||||
import android.os.Handler;
|
//import android.os.Handler;
|
||||||
import android.os.IBinder;
|
//import android.os.IBinder;
|
||||||
import android.os.Message;
|
//import android.os.Message;
|
||||||
import android.os.Messenger;
|
//import android.os.Messenger;
|
||||||
import android.view.View;
|
//import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
//import android.view.View.OnClickListener;
|
||||||
import android.widget.Button;
|
//import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
//import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
//import android.widget.TextView;
|
||||||
|
//
|
||||||
public class TestClient extends Activity {
|
//public class TestClient extends Activity {
|
||||||
|
//
|
||||||
private boolean mCurrentPreviewImageMissing = false;
|
// private boolean mCurrentPreviewImageMissing = false;
|
||||||
|
//
|
||||||
private boolean mIsBound = false;
|
// private boolean mIsBound = false;
|
||||||
|
//
|
||||||
private CommunicationService mCommunicationService;
|
// private CommunicationService mCommunicationService;
|
||||||
|
//
|
||||||
final Messenger mMessenger = new Messenger(new MessageHandler());
|
// final Messenger mMessenger = new Messenger(new MessageHandler());
|
||||||
|
//
|
||||||
/** Called when the activity is first created. */
|
// /** Called when the activity is first created. */
|
||||||
@Override
|
// @Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
// public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
// super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.testlayout);
|
// setContentView(R.layout.testlayout);
|
||||||
setupUI();
|
// setupUI();
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
protected void onResume() {
|
// protected void onResume() {
|
||||||
super.onResume();
|
// super.onResume();
|
||||||
doBindService();
|
// doBindService();
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// FIXME: move all necessary code to CommunicationService.onUnbind
|
// // FIXME: move all necessary code to CommunicationService.onUnbind
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
protected void onPause() {
|
// protected void onPause() {
|
||||||
super.onPause();
|
// super.onPause();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onBackPressed() {
|
// public void onBackPressed() {
|
||||||
// TODO Auto-generated method stub
|
// // TODO Auto-generated method stub
|
||||||
mCommunicationService.disconnect();
|
// mCommunicationService.disconnect();
|
||||||
stopService(new Intent(this, CommunicationService.class));
|
// stopService(new Intent(this, CommunicationService.class));
|
||||||
doUnbindService();
|
// doUnbindService();
|
||||||
finish();
|
// finish();
|
||||||
super.onBackPressed();
|
// super.onBackPressed();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
protected void onStop() {
|
// protected void onStop() {
|
||||||
// TODO Auto-generated method stub
|
// // TODO Auto-generated method stub
|
||||||
super.onStop();
|
// super.onStop();
|
||||||
// mCommunicationService.disconnect();
|
// // mCommunicationService.disconnect();
|
||||||
// stopService(new Intent(this, CommunicationService.class));
|
// // stopService(new Intent(this, CommunicationService.class));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private ServiceConnection mConnection = new ServiceConnection() {
|
// private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
@Override
|
// @Override
|
||||||
public void onServiceConnected(ComponentName aClassName,
|
// public void onServiceConnected(ComponentName aClassName,
|
||||||
IBinder aService) {
|
// IBinder aService) {
|
||||||
mCommunicationService = ((CommunicationService.CBinder) aService)
|
// mCommunicationService = ((CommunicationService.CBinder) aService)
|
||||||
.getService();
|
// .getService();
|
||||||
mCommunicationService.connectTo(new Server(Protocol.NETWORK,
|
// mCommunicationService.connectTo(new Server(Protocol.NETWORK,
|
||||||
"10.0.2.2", "TestServer", 0l));
|
// "10.0.2.2", "TestServer", 0l));
|
||||||
mCommunicationService.setActivityMessenger(mMessenger);
|
// mCommunicationService.setActivityMessenger(mMessenger);
|
||||||
enableButtons(true);
|
// enableButtons(true);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onServiceDisconnected(ComponentName aClassName) {
|
// public void onServiceDisconnected(ComponentName aClassName) {
|
||||||
mCommunicationService = null;
|
// mCommunicationService = null;
|
||||||
enableButtons(false);
|
// enableButtons(false);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
void doBindService() {
|
// void doBindService() {
|
||||||
Intent aIntent = new Intent(this, CommunicationService.class);
|
// Intent aIntent = new Intent(this, CommunicationService.class);
|
||||||
startService(aIntent);
|
// startService(aIntent);
|
||||||
bindService(aIntent, mConnection, Context.BIND_IMPORTANT);
|
// bindService(aIntent, mConnection, Context.BIND_IMPORTANT);
|
||||||
mIsBound = true;
|
// mIsBound = true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
void doUnbindService() {
|
// void doUnbindService() {
|
||||||
mCommunicationService.setActivityMessenger(null);
|
// mCommunicationService.setActivityMessenger(null);
|
||||||
if (mIsBound) {
|
// if (mIsBound) {
|
||||||
unbindService(mConnection);
|
// unbindService(mConnection);
|
||||||
mIsBound = false;
|
// mIsBound = false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private Button mButtonNext;
|
// private Button mButtonNext;
|
||||||
|
//
|
||||||
private Button mButtonPrevious;
|
// private Button mButtonPrevious;
|
||||||
|
//
|
||||||
private ImageView mImageView;
|
// private ImageView mImageView;
|
||||||
|
//
|
||||||
private TextView mSlideLabel;
|
// private TextView mSlideLabel;
|
||||||
|
//
|
||||||
private void setupUI() {
|
// private void setupUI() {
|
||||||
mButtonNext = (Button) findViewById(R.id.button_next);
|
// mButtonNext = (Button) findViewById(R.id.button_next);
|
||||||
mButtonPrevious = (Button) findViewById(R.id.button_previous);
|
// mButtonPrevious = (Button) findViewById(R.id.button_previous);
|
||||||
mImageView = (ImageView) findViewById(R.id.image_preview);
|
// mImageView = (ImageView) findViewById(R.id.image_preview);
|
||||||
mSlideLabel = (TextView) findViewById(R.id.label_curSlide);
|
// mSlideLabel = (TextView) findViewById(R.id.label_curSlide);
|
||||||
|
//
|
||||||
enableButtons(false);
|
// enableButtons(false);
|
||||||
|
//
|
||||||
mButtonNext.setOnClickListener(new OnClickListener() {
|
// mButtonNext.setOnClickListener(new OnClickListener() {
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onClick(View v) {
|
// public void onClick(View v) {
|
||||||
mCommunicationService.getTransmitter().nextTransition();
|
// mCommunicationService.getTransmitter().nextTransition();
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
mButtonPrevious.setOnClickListener(new OnClickListener() {
|
// mButtonPrevious.setOnClickListener(new OnClickListener() {
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onClick(View v) {
|
// public void onClick(View v) {
|
||||||
mCommunicationService.getTransmitter().previousTransition();
|
// mCommunicationService.getTransmitter().previousTransition();
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
Button mThumbnailButton = (Button) findViewById(R.id.button_thumbnail);
|
// Button mThumbnailButton = (Button) findViewById(R.id.button_thumbnail);
|
||||||
|
//
|
||||||
mThumbnailButton.setOnClickListener(new OnClickListener() {
|
// mThumbnailButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
// @Override
|
||||||
public void onClick(View v) {
|
// public void onClick(View v) {
|
||||||
Intent aIntent = new Intent(TestClient.this,
|
// Intent aIntent = new Intent(TestClient.this,
|
||||||
PresentationActivity.class);
|
// PresentationActivity.class);
|
||||||
startActivity(aIntent);
|
// startActivity(aIntent);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void enableButtons(boolean aEnabled) {
|
// private void enableButtons(boolean aEnabled) {
|
||||||
mButtonNext.setEnabled(aEnabled);
|
// mButtonNext.setEnabled(aEnabled);
|
||||||
mButtonPrevious.setEnabled(aEnabled);
|
// mButtonPrevious.setEnabled(aEnabled);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
class MessageHandler extends Handler {
|
// class MessageHandler extends Handler {
|
||||||
@Override
|
// @Override
|
||||||
public void handleMessage(Message aMessage) {
|
// public void handleMessage(Message aMessage) {
|
||||||
Bundle aData = aMessage.getData();
|
// Bundle aData = aMessage.getData();
|
||||||
switch (aMessage.what) {
|
// switch (aMessage.what) {
|
||||||
case CommunicationService.MSG_SLIDE_CHANGED:
|
// case CommunicationService.MSG_SLIDE_CHANGED:
|
||||||
int newSlide = aData.getInt("slide_number");
|
// int newSlide = aData.getInt("slide_number");
|
||||||
mSlideLabel.setText("Slide " + newSlide);
|
// mSlideLabel.setText("Slide " + newSlide);
|
||||||
mCurrentPreviewImageMissing = true;
|
// mCurrentPreviewImageMissing = true;
|
||||||
// We continue on to try and update the image.
|
// // We continue on to try and update the image.
|
||||||
case CommunicationService.MSG_SLIDE_PREVIEW:
|
// case CommunicationService.MSG_SLIDE_PREVIEW:
|
||||||
int aSlideNumber = aData.getInt("slide_number");
|
// int aSlideNumber = aData.getInt("slide_number");
|
||||||
if (mCurrentPreviewImageMissing) {
|
// if (mCurrentPreviewImageMissing) {
|
||||||
Bitmap aImage = mCommunicationService.getSlideShow()
|
// Bitmap aImage = mCommunicationService.getSlideShow()
|
||||||
.getImage(aSlideNumber);
|
// .getImage(aSlideNumber);
|
||||||
if (aImage != null) {
|
// if (aImage != null) {
|
||||||
mImageView.setImageBitmap(aImage);
|
// mImageView.setImageBitmap(aImage);
|
||||||
mCurrentPreviewImageMissing = false;
|
// mCurrentPreviewImageMissing = false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
///* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
Reference in New Issue
Block a user