Merge pull request #2487 from kapodamy/buttons-hiding-fix-on-screen-off
fixup for #2149 (missing buttons)
This commit is contained in:
commit
5883f6e763
5 changed files with 15 additions and 22 deletions
|
@ -61,6 +61,7 @@ public class DownloadActivity extends AppCompatActivity {
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
super.onCreateOptionsMenu(menu);
|
super.onCreateOptionsMenu(menu);
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
@ -86,9 +87,4 @@ public class DownloadActivity extends AppCompatActivity {
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRestoreInstanceState(Bundle inState){
|
|
||||||
super.onRestoreInstanceState(inState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -666,9 +666,9 @@ public class DownloadManager {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (mission.running)
|
if (mission.running)
|
||||||
paused = true;
|
|
||||||
else
|
|
||||||
running = true;
|
running = true;
|
||||||
|
else
|
||||||
|
paused = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,14 +122,8 @@ public class MissionAdapter extends Adapter<ViewHolder> {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mStartButton != null && mPauseButton != null) switch (msg.what) {
|
if (mStartButton != null && mPauseButton != null)
|
||||||
case DownloadManagerService.MESSAGE_DELETED:
|
|
||||||
case DownloadManagerService.MESSAGE_ERROR:
|
|
||||||
case DownloadManagerService.MESSAGE_FINISHED:
|
|
||||||
case DownloadManagerService.MESSAGE_PAUSED:
|
|
||||||
checkMasterButtonsVisibility();
|
checkMasterButtonsVisibility();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -163,8 +157,7 @@ public class MissionAdapter extends Adapter<ViewHolder> {
|
||||||
mPendingDownloadsItems.remove(h);
|
mPendingDownloadsItems.remove(h);
|
||||||
if (mPendingDownloadsItems.size() < 1) {
|
if (mPendingDownloadsItems.size() < 1) {
|
||||||
setAutoRefresh(false);
|
setAutoRefresh(false);
|
||||||
if (mStartButton != null) mStartButton.setVisible(false);
|
checkMasterButtonsVisibility();
|
||||||
if (mPauseButton != null) mPauseButton.setVisible(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,11 +657,11 @@ public class MissionAdapter extends Adapter<ViewHolder> {
|
||||||
if (mEmptyMessage.getVisibility() != flag) mEmptyMessage.setVisibility(flag);
|
if (mEmptyMessage.getVisibility() != flag) mEmptyMessage.setVisibility(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkMasterButtonsVisibility() {
|
public void checkMasterButtonsVisibility() {
|
||||||
boolean[] state = mIterator.hasValidPendingMissions();
|
boolean[] state = mIterator.hasValidPendingMissions();
|
||||||
|
|
||||||
mStartButton.setVisible(state[0]);
|
mPauseButton.setVisible(state[0]);
|
||||||
mPauseButton.setVisible(state[1]);
|
mStartButton.setVisible(state[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ensurePausedMissions() {
|
public void ensurePausedMissions() {
|
||||||
|
|
|
@ -138,6 +138,7 @@ public class MissionsFragment extends Fragment {
|
||||||
* deprecated in API level 23,
|
* deprecated in API level 23,
|
||||||
* but must remain to allow compatibility with api<23
|
* but must remain to allow compatibility with api<23
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
|
@ -273,6 +274,7 @@ public class MissionsFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
mBinder.addMissionEventListener(mAdapter.getMessenger());
|
mBinder.addMissionEventListener(mAdapter.getMessenger());
|
||||||
|
mAdapter.checkMasterButtonsVisibility();
|
||||||
}
|
}
|
||||||
if (mBinder != null) mBinder.enableNotifications(false);
|
if (mBinder != null) mBinder.enableNotifications(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<item android:id="@+id/switch_mode"
|
<item android:id="@+id/switch_mode"
|
||||||
android:icon="?attr/ic_grid"
|
android:icon="?attr/ic_grid"
|
||||||
android:title="@string/grid"
|
android:title="@string/grid"
|
||||||
app:showAsAction="ifRoom" />
|
tools:ignore="AlwaysShowAction"
|
||||||
|
app:showAsAction="always" />
|
||||||
|
|
||||||
<item android:id="@+id/start_downloads"
|
<item android:id="@+id/start_downloads"
|
||||||
android:visible="false"
|
android:visible="false"
|
||||||
|
|
Loading…
Add table
Reference in a new issue