allow using the app in landscape orientation too

This commit is contained in:
tibbi 2016-04-25 18:48:23 +02:00
parent 4abe15564d
commit dd1dd70aa4
3 changed files with 13 additions and 7 deletions

View file

@ -12,8 +12,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".activities.MainActivity"
android:screenOrientation="portrait">
android:name=".activities.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
@ -22,12 +21,10 @@
</activity>
<activity
android:name=".activities.PhotosActivity"
android:screenOrientation="portrait"/>
android:name=".activities.PhotosActivity"/>
<activity
android:name=".activities.ViewPagerActivity"
android:screenOrientation="portrait"
android:theme="@style/FullScreenTheme"/>
</application>
</manifest>

View file

@ -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();

View file

@ -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<Directory> dirs;
private GridView gridView;
private int selectedItemsCnt;