diff options
author | Artur Dryomov <artur.dryomov@gmail.com> | 2013-09-10 22:03:12 +0300 |
---|---|---|
committer | Artur Dryomov <artur.dryomov@gmail.com> | 2013-09-11 01:43:53 +0300 |
commit | ca5c6e9696048fca9cafba632b574ca4c351b4dd (patch) | |
tree | 98637c8c636740c50a83e01efb0e6af038b9acc8 /android/sdremote | |
parent | e9d61192574ea7de22beed2644868bfba319ff91 (diff) |
Add saving progress message state between orientation changes.
Change-Id: Ic74810e90ca882f734ae7d1fab4b250908ae9c49
Diffstat (limited to 'android/sdremote')
-rw-r--r-- | android/sdremote/src/org/libreoffice/impressremote/fragment/ComputersFragment.java | 34 | ||||
-rw-r--r-- | android/sdremote/src/org/libreoffice/impressremote/util/SavedStates.java | 2 |
2 files changed, 36 insertions, 0 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputersFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputersFragment.java index d24958891500..0c70f52b9b44 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputersFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputersFragment.java @@ -23,6 +23,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.support.v4.content.LocalBroadcastManager; +import android.text.TextUtils; import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.View; @@ -42,6 +43,7 @@ import org.libreoffice.impressremote.util.Intents; import org.libreoffice.impressremote.R; import org.libreoffice.impressremote.communication.CommunicationService; import org.libreoffice.impressremote.communication.Server; +import org.libreoffice.impressremote.util.SavedStates; public class ComputersFragment extends SherlockListFragment implements ServiceConnection, Runnable { private static final int SHOWING_PROGRESS_MESSAGE_DELAY_IN_SECONDS = 10; @@ -90,6 +92,25 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo } @Override + public void onViewStateRestored(Bundle aSavedInstanceState) { + super.onViewStateRestored(aSavedInstanceState); + + if (aSavedInstanceState == null) { + return; + } + + loadProgressMessage(aSavedInstanceState); + } + + private void loadProgressMessage(Bundle aSavedInstanceState) { + boolean aProgressMessageDisplayed = aSavedInstanceState.getBoolean(SavedStates.Keys.PROGRESS_MESSAGE); + + if (aProgressMessageDisplayed) { + showProgressMessage(); + } + } + + @Override public void onActivityCreated(Bundle aSavedInstanceState) { super.onActivityCreated(aSavedInstanceState); @@ -435,6 +456,19 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo } @Override + public void onSaveInstanceState(Bundle aOutState) { + super.onSaveInstanceState(aOutState); + + saveProgressMessage(aOutState); + } + + private void saveProgressMessage(Bundle aOutState) { + boolean aProgressMessageDisplayed = !TextUtils.isEmpty(getProgressMessageView().getText().toString()); + + aOutState.putBoolean(SavedStates.Keys.PROGRESS_MESSAGE, aProgressMessageDisplayed); + } + + @Override public void onDestroy() { super.onDestroy(); diff --git a/android/sdremote/src/org/libreoffice/impressremote/util/SavedStates.java b/android/sdremote/src/org/libreoffice/impressremote/util/SavedStates.java index c9339c8c1c01..0ec6b56c5f19 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/util/SavedStates.java +++ b/android/sdremote/src/org/libreoffice/impressremote/util/SavedStates.java @@ -8,6 +8,8 @@ public final class SavedStates { private Keys() { } + public static final String PROGRESS_MESSAGE = "PROGRESS_MESSAGE"; + public static final String LAYOUT_INDEX = "LAYOUT_INDEX"; public static final String PIN = "PIN"; |