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

View file

@ -8,10 +8,10 @@ import android.view.ViewGroup;
import com.davemorrissey.labs.subscaleview.ImageSource; import com.davemorrissey.labs.subscaleview.ImageSource;
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
import com.simplemobiletools.gallery.activities.ViewPagerActivity; import com.simplemobiletools.gallery.activities.ViewPagerActivity;
public class ViewPagerFragment extends Fragment implements View.OnClickListener { public class ViewPagerFragment extends Fragment implements View.OnClickListener {
private static final String PATH = "path";
private String path; private String path;
public void setPath(String path) { public void setPath(String path) {
@ -21,6 +21,9 @@ public class ViewPagerFragment extends Fragment implements View.OnClickListener
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.pager_item, container, false); final View view = inflater.inflate(R.layout.pager_item, container, false);
if (savedInstanceState != null) {
path = savedInstanceState.getString(PATH);
}
if (path != null) { if (path != null) {
final SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) view.findViewById(R.id.photo); final SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) view.findViewById(R.id.photo);
@ -33,6 +36,12 @@ public class ViewPagerFragment extends Fragment implements View.OnClickListener
return view; return view;
} }
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(PATH, path);
}
@Override @Override
public void onClick(View v) { public void onClick(View v) {
((ViewPagerActivity) getActivity()).photoClicked(); ((ViewPagerActivity) getActivity()).photoClicked();

View file

@ -43,7 +43,7 @@ import java.util.Map;
public class MainActivity extends AppCompatActivity public class MainActivity extends AppCompatActivity
implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener, implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener,
MediaScannerConnection.OnScanCompletedListener { MediaScannerConnection.OnScanCompletedListener {
private final int STORAGE_PERMISSION = 1; private static final int STORAGE_PERMISSION = 1;
private List<Directory> dirs; private List<Directory> dirs;
private GridView gridView; private GridView gridView;
private int selectedItemsCnt; private int selectedItemsCnt;