Remove hiding notes section when there are no notes.

Show warning instead. This change should help avoiding users confusing
when they see half of the screen empty without any reason.

Change-Id: Ic229e80fc56a9ad8a419dc19b0784213b1fe3a68
This commit is contained in:
Artur Dryomov
2013-09-10 12:24:19 +03:00
parent 2dfaabc1ba
commit 54433a11e7
3 changed files with 44 additions and 59 deletions

View File

@@ -13,59 +13,46 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp"/> android:layout_height="0dp"/>
<ViewAnimator <LinearLayout
android:id="@+id/view_animator" android:id="@+id/layout_notes"
android:inAnimation="@android:anim/fade_in" android:orientation="vertical"
android:outAnimation="@android:anim/fade_out" android:paddingLeft="@dimen/padding_slides_pager"
android:paddingRight="@dimen/padding_slides_pager"
android:layout_weight="3" android:layout_weight="3"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp"> android:layout_height="0dp">
<View <TextView
android:id="@+id/view_empty" style="@style/SectionHeader"
android:layout_width="match_parent" android:text="@string/header_notes"
android:layout_height="match_parent"/> android:paddingTop="@dimen/padding_header"/>
<LinearLayout <ScrollView
android:id="@+id/layout_notes" android:layout_width="wrap_content"
android:orientation="vertical" android:layout_height="wrap_content">
android:paddingLeft="@dimen/padding_slides_pager"
android:paddingRight="@dimen/padding_slides_pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView <TextSwitcher
style="@style/SectionHeader" android:id="@+id/text_switcher_notes"
android:text="@string/header_notes" android:inAnimation="@android:anim/fade_in"
android:paddingTop="@dimen/padding_header"/> android:outAnimation="@android:anim/fade_out"
android:paddingTop="@dimen/padding_slide_notes"
<ScrollView android:paddingLeft="@dimen/padding_slide_notes"
android:layout_width="wrap_content" android:paddingRight="@dimen/padding_slide_notes"
android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<TextSwitcher <TextView
android:id="@+id/text_switcher_notes"
android:inAnimation="@android:anim/fade_in"
android:outAnimation="@android:anim/fade_out"
android:paddingTop="@dimen/padding_slide_notes"
android:paddingLeft="@dimen/padding_slide_notes"
android:paddingRight="@dimen/padding_slide_notes"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"/>
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</TextSwitcher> </TextSwitcher>
</ScrollView> </ScrollView>
</LinearLayout> </LinearLayout>
</ViewAnimator>
</LinearLayout> </LinearLayout>

View File

@@ -43,6 +43,7 @@
<string name="message_search_wifi">Make sure LibreOffice is running on a computer on the same WiFi network.</string> <string name="message_search_wifi">Make sure LibreOffice is running on a computer on the same WiFi network.</string>
<string name="message_search_bluetooth">Make sure LibreOffice is running on a computer with Bluetooth enabled.</string> <string name="message_search_bluetooth">Make sure LibreOffice is running on a computer with Bluetooth enabled.</string>
<string name="message_paused">Paused</string> <string name="message_paused">Paused</string>
<string name="message_notes_empty">Nothing here.</string>
<string name="hint_ip_address">IP address</string> <string name="hint_ip_address">IP address</string>
<string name="hint_name">Name (optional)</string> <string name="hint_name">Name (optional)</string>

View File

@@ -21,12 +21,10 @@ import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.text.Html; import android.text.Html;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextSwitcher; import android.widget.TextSwitcher;
import android.widget.ViewAnimator;
import com.actionbarsherlock.app.SherlockFragment; import com.actionbarsherlock.app.SherlockFragment;
import org.libreoffice.impressremote.communication.SlideShow; import org.libreoffice.impressremote.communication.SlideShow;
@@ -84,6 +82,7 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn
aSlidesPager.setOnPageChangeListener(this); aSlidesPager.setOnPageChangeListener(this);
setUpCurrentSlide(); setUpCurrentSlide();
setUpCurrentSlideNotes();
} }
private ViewPager getSlidesPager() { private ViewPager getSlidesPager() {
@@ -106,6 +105,12 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn
getSlidesPager().setCurrentItem(aSlideShow.getCurrentSlideIndex()); getSlidesPager().setCurrentItem(aSlideShow.getCurrentSlideIndex());
} }
private void setUpCurrentSlideNotes() {
SlideShow aSlideShow = mCommunicationService.getSlideShow();
setUpSlideNotes(aSlideShow.getCurrentSlideIndex());
}
@Override @Override
public void onPageSelected(int aPosition) { public void onPageSelected(int aPosition) {
mCommunicationService.getTransmitter().setCurrentSlide(aPosition); mCommunicationService.getTransmitter().setCurrentSlide(aPosition);
@@ -129,28 +134,20 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn
} }
private void showSlideNotes(int aSlideIndex) { private void showSlideNotes(int aSlideIndex) {
ViewAnimator aViewAnimator = (ViewAnimator) getView().findViewById(R.id.view_animator); TextSwitcher aSlideNotesSwitcher = getSlideNotesSwitcher();
ViewGroup aNotesLayout = (ViewGroup) getView().findViewById(R.id.layout_notes);
if (aViewAnimator.getDisplayedChild() != aViewAnimator.indexOfChild(aNotesLayout)) {
aViewAnimator.setDisplayedChild(aViewAnimator.indexOfChild(aNotesLayout));
}
setSlideNotes(aSlideIndex);
}
private void setSlideNotes(int aSlideIndex) {
TextSwitcher aSlideNotesTextSwitcher = (TextSwitcher) getView().findViewById(R.id.text_switcher_notes);
String aSlideNotes = mCommunicationService.getSlideShow().getSlideNotes(aSlideIndex); String aSlideNotes = mCommunicationService.getSlideShow().getSlideNotes(aSlideIndex);
aSlideNotesTextSwitcher.setText(Html.fromHtml(aSlideNotes)); aSlideNotesSwitcher.setText(Html.fromHtml(aSlideNotes));
}
private TextSwitcher getSlideNotesSwitcher() {
return (TextSwitcher) getView().findViewById(R.id.text_switcher_notes);
} }
private void hideSlideNotes() { private void hideSlideNotes() {
ViewAnimator aViewAnimator = (ViewAnimator) getView().findViewById(R.id.view_animator); TextSwitcher aSlideNotesSwitcher = getSlideNotesSwitcher();
View aEmptyView = getView().findViewById(R.id.view_empty);
aViewAnimator.setDisplayedChild(aViewAnimator.indexOfChild(aEmptyView)); aSlideNotesSwitcher.setText(getString(R.string.message_notes_empty));
} }
@Override @Override