From dd1dd70aa4c67b2a59b89d17d6408daa630da618 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 25 Apr 2016 18:48:23 +0200 Subject: [PATCH] allow using the app in landscape orientation too --- app/src/main/AndroidManifest.xml | 7 ++----- .../simplemobiletools/gallery/ViewPagerFragment.java | 11 ++++++++++- .../gallery/activities/MainActivity.java | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3143652b2..25e2da3f7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,8 +12,7 @@ android:supportsRtl="true" android:theme="@style/AppTheme"> + android:name=".activities.MainActivity"> @@ -22,12 +21,10 @@ + android:name=".activities.PhotosActivity"/> diff --git a/app/src/main/java/com/simplemobiletools/gallery/ViewPagerFragment.java b/app/src/main/java/com/simplemobiletools/gallery/ViewPagerFragment.java index 1e4e49d86..8d43b27e3 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/ViewPagerFragment.java +++ b/app/src/main/java/com/simplemobiletools/gallery/ViewPagerFragment.java @@ -8,10 +8,10 @@ import android.view.ViewGroup; import com.davemorrissey.labs.subscaleview.ImageSource; import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; - import com.simplemobiletools.gallery.activities.ViewPagerActivity; public class ViewPagerFragment extends Fragment implements View.OnClickListener { + private static final String PATH = "path"; private String path; public void setPath(String path) { @@ -21,6 +21,9 @@ public class ViewPagerFragment extends Fragment implements View.OnClickListener @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.pager_item, container, false); + if (savedInstanceState != null) { + path = savedInstanceState.getString(PATH); + } if (path != null) { final SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) view.findViewById(R.id.photo); @@ -33,6 +36,12 @@ public class ViewPagerFragment extends Fragment implements View.OnClickListener return view; } + @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString(PATH, path); + } + @Override public void onClick(View v) { ((ViewPagerActivity) getActivity()).photoClicked(); diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java index 5963cc587..227f45b91 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java @@ -43,7 +43,7 @@ import java.util.Map; public class MainActivity extends AppCompatActivity implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener, MediaScannerConnection.OnScanCompletedListener { - private final int STORAGE_PERMISSION = 1; + private static final int STORAGE_PERMISSION = 1; private List dirs; private GridView gridView; private int selectedItemsCnt;