Kaydet (Commit) 95e95e0a authored tarafından Artur Dryomov's avatar Artur Dryomov

Add switching to the slides pager from the grid when selecting a slide.

Change-Id: I029c298a90ff7f0cbaada25388e3a758dc4d583e
üst 6d6017e3
...@@ -40,7 +40,7 @@ import org.libreoffice.impressremote.util.Preferences; ...@@ -40,7 +40,7 @@ import org.libreoffice.impressremote.util.Preferences;
import org.libreoffice.impressremote.util.SavedStates; import org.libreoffice.impressremote.util.SavedStates;
public class SlideShowActivity extends SherlockFragmentActivity implements ServiceConnection { public class SlideShowActivity extends SherlockFragmentActivity implements ServiceConnection {
private static enum Mode { public static enum Mode {
PAGER, GRID, EMPTY PAGER, GRID, EMPTY
} }
...@@ -160,6 +160,12 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi ...@@ -160,6 +160,12 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
@Override @Override
public void onReceive(Context aContext, Intent aIntent) { public void onReceive(Context aContext, Intent aIntent) {
if (Intents.Actions.SLIDE_SHOW_MODE_CHANGED.equals(aIntent.getAction())) {
Mode aMode = (Mode) aIntent.getSerializableExtra(Intents.Extras.MODE);
mSlideShowActivity.changeMode(aMode);
return;
}
if (Intents.Actions.SLIDE_CHANGED.equals(aIntent.getAction())) { if (Intents.Actions.SLIDE_CHANGED.equals(aIntent.getAction())) {
mSlideShowActivity.setUpSlideShowInformation(); mSlideShowActivity.setUpSlideShowInformation();
return; return;
...@@ -193,6 +199,7 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi ...@@ -193,6 +199,7 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
private IntentFilter buildIntentsReceiverFilter() { private IntentFilter buildIntentsReceiverFilter() {
IntentFilter aIntentFilter = new IntentFilter(); IntentFilter aIntentFilter = new IntentFilter();
aIntentFilter.addAction(Intents.Actions.SLIDE_SHOW_MODE_CHANGED);
aIntentFilter.addAction(Intents.Actions.SLIDE_CHANGED); aIntentFilter.addAction(Intents.Actions.SLIDE_CHANGED);
aIntentFilter.addAction(Intents.Actions.TIMER_UPDATED); aIntentFilter.addAction(Intents.Actions.TIMER_UPDATED);
aIntentFilter.addAction(Intents.Actions.TIMER_STARTED); aIntentFilter.addAction(Intents.Actions.TIMER_STARTED);
......
...@@ -24,6 +24,7 @@ import android.widget.AdapterView; ...@@ -24,6 +24,7 @@ import android.widget.AdapterView;
import android.widget.GridView; import android.widget.GridView;
import com.actionbarsherlock.app.SherlockFragment; import com.actionbarsherlock.app.SherlockFragment;
import org.libreoffice.impressremote.activity.SlideShowActivity;
import org.libreoffice.impressremote.communication.SlideShow; import org.libreoffice.impressremote.communication.SlideShow;
import org.libreoffice.impressremote.util.Intents; import org.libreoffice.impressremote.util.Intents;
import org.libreoffice.impressremote.R; import org.libreoffice.impressremote.R;
...@@ -86,7 +87,23 @@ public class SlidesGridFragment extends SherlockFragment implements ServiceConne ...@@ -86,7 +87,23 @@ public class SlidesGridFragment extends SherlockFragment implements ServiceConne
@Override @Override
public void onItemClick(AdapterView<?> aAdapterView, View aView, int aPosition, long aId) { public void onItemClick(AdapterView<?> aAdapterView, View aView, int aPosition, long aId) {
mCommunicationService.getCommandsTransmitter().setCurrentSlide(aPosition); changeCurrentSlide(aPosition);
changeSlideShowMode();
}
private void changeCurrentSlide(int aSlideIndex) {
mCommunicationService.getCommandsTransmitter().setCurrentSlide(aSlideIndex);
}
private void changeSlideShowMode() {
Intent aIntent = Intents.buildSlideShowModeChangedIntent(SlideShowActivity.Mode.PAGER);
getBroadcastManager().sendBroadcast(aIntent);
}
private LocalBroadcastManager getBroadcastManager() {
Context aContext = getActivity().getApplicationContext();
return LocalBroadcastManager.getInstance(aContext);
} }
@Override @Override
...@@ -138,12 +155,6 @@ public class SlidesGridFragment extends SherlockFragment implements ServiceConne ...@@ -138,12 +155,6 @@ public class SlidesGridFragment extends SherlockFragment implements ServiceConne
return aIntentFilter; return aIntentFilter;
} }
private LocalBroadcastManager getBroadcastManager() {
Context aContext = getActivity().getApplicationContext();
return LocalBroadcastManager.getInstance(aContext);
}
private void refreshSlidesGrid() { private void refreshSlidesGrid() {
getSlidesGrid().invalidateViews(); getSlidesGrid().invalidateViews();
} }
......
...@@ -38,6 +38,8 @@ public final class Intents { ...@@ -38,6 +38,8 @@ public final class Intents {
public static final String SLIDE_SHOW_RUNNING = "SLIDE_SHOW_RUNNING"; public static final String SLIDE_SHOW_RUNNING = "SLIDE_SHOW_RUNNING";
public static final String SLIDE_SHOW_STOPPED = "SLIDE_SHOW_STOPPED"; public static final String SLIDE_SHOW_STOPPED = "SLIDE_SHOW_STOPPED";
public static final String SLIDE_SHOW_MODE_CHANGED = "SLIDE_SHOW_MODE_CHANGED";
public static final String SLIDE_CHANGED = "SLIDE_CHANGED"; public static final String SLIDE_CHANGED = "SLIDE_CHANGED";
public static final String SLIDE_PREVIEW = "SLIDE_PREVIEW"; public static final String SLIDE_PREVIEW = "SLIDE_PREVIEW";
public static final String SLIDE_NOTES = "SLIDE_NOTES"; public static final String SLIDE_NOTES = "SLIDE_NOTES";
...@@ -53,12 +55,12 @@ public final class Intents { ...@@ -53,12 +55,12 @@ public final class Intents {
} }
public static final String MINUTES = "MINUTES"; public static final String MINUTES = "MINUTES";
public static final String MODE = "MODE";
public static final String PIN = "PIN"; public static final String PIN = "PIN";
public static final String SLIDE_INDEX = "SLIDE_INDEX";
public static final String SERVER = "SERVER"; public static final String SERVER = "SERVER";
public static final String SERVER_ADDRESS = "SERVER_ADDRESS"; public static final String SERVER_ADDRESS = "SERVER_ADDRESS";
public static final String SERVER_NAME = "SERVER_NAME"; public static final String SERVER_NAME = "SERVER_NAME";
public static final String SLIDE_INDEX = "SLIDE_INDEX";
} }
public static final class RequestCodes { public static final class RequestCodes {
...@@ -95,6 +97,13 @@ public final class Intents { ...@@ -95,6 +97,13 @@ public final class Intents {
return new Intent(Actions.SLIDE_SHOW_STOPPED); return new Intent(Actions.SLIDE_SHOW_STOPPED);
} }
public static Intent buildSlideShowModeChangedIntent(SlideShowActivity.Mode aMode) {
Intent aIntent = new Intent(Actions.SLIDE_SHOW_MODE_CHANGED);
aIntent.putExtra(Extras.MODE, aMode);
return aIntent;
}
public static Intent buildSlideChangedIntent(int aSlideIndex) { public static Intent buildSlideChangedIntent(int aSlideIndex) {
Intent aIntent = new Intent(Actions.SLIDE_CHANGED); Intent aIntent = new Intent(Actions.SLIDE_CHANGED);
aIntent.putExtra(Extras.SLIDE_INDEX, aSlideIndex); aIntent.putExtra(Extras.SLIDE_INDEX, aSlideIndex);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment