1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-26 04:52:29 +01:00

dont hardcode the buttons

This commit is contained in:
kapodamy 2019-08-03 12:33:54 -03:00
parent 0375194e7d
commit 2328ea6d07
2 changed files with 1 additions and 28 deletions

View File

@ -7,7 +7,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.IBinder;
import android.preference.PreferenceManager;
@ -171,15 +170,6 @@ public class MissionsFragment extends Fragment {
if (mAdapter != null) setAdapterButtons();
int max = getMaxActionButtons() - 1 /* grid button */;
if (max >= 2) {
// show start/pause downloads buttons in pair to avoid confusions
mStart.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
mPause.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
if (max > 3) mClear.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}
super.onPrepareOptionsMenu(menu);
}
@ -260,23 +250,6 @@ public class MissionsFragment extends Fragment {
);
}
public int getMaxActionButtons() {
Configuration configuration = mContext.getResources().getConfiguration();
int widthDp = configuration.screenWidthDp;
int heightDp = configuration.screenHeightDp;
int smallest = configuration.smallestScreenWidthDp;
if (smallest > 600 || widthDp > 600) {
return 5;
} else if (widthDp >= 500 || widthDp > 480 && heightDp > 640) {
return 4;
} else if (widthDp >= 360) {
return 3;
} else {
return 2;
}
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);

View File

@ -7,7 +7,7 @@
android:icon="?attr/ic_grid"
android:title="@string/grid"
tools:ignore="AlwaysShowAction"
app:showAsAction="always" />
app:showAsAction="ifRoom" />
<item android:id="@+id/start_downloads"
android:visible="false"