use 10cols on landscape, 6 on portrait

This commit is contained in:
tobiasKaminsky 2017-05-19 11:34:49 +02:00
parent 1ab754278e
commit ba14880f3d
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
2 changed files with 25 additions and 2 deletions

View file

@ -19,7 +19,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.owncloud.android"
android:versionCode="10040299"
android:versionName="1.4.2">
@ -72,6 +71,7 @@
<activity
android:name=".ui.activity.FileDisplayActivity"
android:label="@string/app_name"
android:configChanges="orientation|screenSize"
android:theme="@style/Theme.ownCloud.Toolbar.Drawer">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View file

@ -23,6 +23,7 @@ package com.owncloud.android.ui.fragment;
import android.animation.LayoutTransition;
import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@ -96,7 +97,10 @@ public class ExtendedListFragment extends Fragment
private static final String KEY_EMPTY_LIST_MESSAGE = "EMPTY_LIST_MESSAGE";
private static final String KEY_IS_GRID_VISIBLE = "IS_GRID_VISIBLE";
public static final float minColumnSize = 2.0f;
public static final float maxColumnSize = 10.0f;
private int maxColumnSize = 6;
private int maxColumnSizePortrait = 6;
private int maxColumnSizeLandscape = 10;
private ScaleGestureDetector mScaleGestureDetector = null;
protected SwipeRefreshLayout mRefreshListLayout;
@ -475,6 +479,8 @@ public class ExtendedListFragment extends Fragment
PreferenceManager.setGridColumns(getContext(), mScale);
mAdapter.notifyDataSetChanged();
return true;
}
}
@ -875,4 +881,21 @@ public class ExtendedListFragment extends Fragment
}
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
maxColumnSize = maxColumnSizeLandscape;
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
maxColumnSize = maxColumnSizePortrait;
} else {
maxColumnSize = maxColumnSizePortrait;
}
if (mGridView.getNumColumns() > maxColumnSize) {
mGridView.setNumColumns(maxColumnSize);
mGridView.invalidateViews();
}
}
}