2016-04-22 01:28:01 +02:00
|
|
|
package org.schabi.newpipe.download;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
2016-05-02 15:19:58 +02:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuInflater;
|
2016-04-22 01:28:01 +02:00
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.ViewTreeObserver;
|
|
|
|
|
2020-03-31 19:20:15 +02:00
|
|
|
import androidx.appcompat.app.ActionBar;
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
2020-08-27 22:56:12 +02:00
|
|
|
import androidx.fragment.app.FragmentTransaction;
|
2020-03-31 19:20:15 +02:00
|
|
|
|
2017-01-17 11:37:36 +01:00
|
|
|
import org.schabi.newpipe.R;
|
2020-10-31 09:11:01 +01:00
|
|
|
import org.schabi.newpipe.databinding.ActivityDownloaderBinding;
|
2020-07-21 00:43:49 +02:00
|
|
|
import org.schabi.newpipe.util.DeviceUtils;
|
2017-02-27 12:55:15 +01:00
|
|
|
import org.schabi.newpipe.util.ThemeHelper;
|
2019-09-23 09:17:03 +02:00
|
|
|
import org.schabi.newpipe.views.FocusOverlayView;
|
2016-04-22 01:28:01 +02:00
|
|
|
|
|
|
|
import us.shandian.giga.service.DownloadManagerService;
|
|
|
|
import us.shandian.giga.ui.fragment.MissionsFragment;
|
2017-01-10 11:41:24 +01:00
|
|
|
|
2020-01-28 20:48:42 +01:00
|
|
|
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
2020-01-09 09:40:05 +01:00
|
|
|
|
2017-06-29 12:02:21 +02:00
|
|
|
public class DownloadActivity extends AppCompatActivity {
|
2016-04-22 01:28:01 +02:00
|
|
|
|
2018-06-11 14:44:00 +02:00
|
|
|
private static final String MISSIONS_FRAGMENT_TAG = "fragment_tag";
|
|
|
|
|
2016-04-22 01:28:01 +02:00
|
|
|
@Override
|
2020-03-31 19:20:15 +02:00
|
|
|
protected void onCreate(final Bundle savedInstanceState) {
|
2016-04-22 01:28:01 +02:00
|
|
|
// Service
|
2020-08-16 10:24:58 +02:00
|
|
|
final Intent i = new Intent();
|
2016-04-22 01:28:01 +02:00
|
|
|
i.setClass(this, DownloadManagerService.class);
|
|
|
|
startService(i);
|
|
|
|
|
2020-01-28 20:48:42 +01:00
|
|
|
assureCorrectAppLanguage(this);
|
2017-04-26 21:32:04 +02:00
|
|
|
ThemeHelper.setTheme(this);
|
2020-10-31 09:11:01 +01:00
|
|
|
|
2016-04-22 01:28:01 +02:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
2020-10-31 09:11:01 +01:00
|
|
|
final ActivityDownloaderBinding downloaderBinding =
|
|
|
|
ActivityDownloaderBinding.inflate(getLayoutInflater());
|
|
|
|
setContentView(downloaderBinding.getRoot());
|
|
|
|
|
|
|
|
setSupportActionBar(downloaderBinding.toolbarLayout.toolbar);
|
2016-05-25 23:51:22 +02:00
|
|
|
|
2020-08-16 10:24:58 +02:00
|
|
|
final ActionBar actionBar = getSupportActionBar();
|
2017-04-26 21:32:04 +02:00
|
|
|
if (actionBar != null) {
|
|
|
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
|
actionBar.setTitle(R.string.downloads_title);
|
|
|
|
actionBar.setDisplayShowTitleEnabled(true);
|
|
|
|
}
|
2016-04-22 01:28:01 +02:00
|
|
|
|
2020-03-31 19:20:15 +02:00
|
|
|
getWindow().getDecorView().getViewTreeObserver()
|
|
|
|
.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
2018-09-23 20:12:23 +02:00
|
|
|
@Override
|
|
|
|
public void onGlobalLayout() {
|
|
|
|
updateFragments();
|
2019-03-05 18:05:44 +01:00
|
|
|
getWindow().getDecorView().getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
2018-09-23 20:12:23 +02:00
|
|
|
}
|
|
|
|
});
|
2019-09-23 09:17:03 +02:00
|
|
|
|
2020-07-21 00:43:49 +02:00
|
|
|
if (DeviceUtils.isTv(this)) {
|
2019-09-23 09:17:03 +02:00
|
|
|
FocusOverlayView.setupFocusObserver(this);
|
|
|
|
}
|
2018-06-11 14:44:00 +02:00
|
|
|
}
|
2016-04-22 01:28:01 +02:00
|
|
|
|
2018-06-11 14:44:00 +02:00
|
|
|
private void updateFragments() {
|
2020-08-16 10:24:58 +02:00
|
|
|
final MissionsFragment fragment = new MissionsFragment();
|
2018-06-11 14:44:00 +02:00
|
|
|
|
2019-04-05 19:45:39 +02:00
|
|
|
getSupportFragmentManager().beginTransaction()
|
2018-06-11 14:44:00 +02:00
|
|
|
.replace(R.id.frame, fragment, MISSIONS_FRAGMENT_TAG)
|
2016-04-22 01:28:01 +02:00
|
|
|
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
|
|
|
.commit();
|
|
|
|
}
|
|
|
|
|
2019-08-01 23:55:37 +02:00
|
|
|
@Override
|
2020-03-31 19:20:15 +02:00
|
|
|
public boolean onCreateOptionsMenu(final Menu menu) {
|
2016-05-02 15:19:58 +02:00
|
|
|
super.onCreateOptionsMenu(menu);
|
2020-08-16 10:24:58 +02:00
|
|
|
final MenuInflater inflater = getMenuInflater();
|
2016-05-02 15:19:58 +02:00
|
|
|
|
|
|
|
inflater.inflate(R.menu.download_menu, menu);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-23 12:22:29 +02:00
|
|
|
@Override
|
2020-03-31 19:20:15 +02:00
|
|
|
public boolean onOptionsItemSelected(final MenuItem item) {
|
2017-06-29 12:02:21 +02:00
|
|
|
switch (item.getItemId()) {
|
2020-02-22 10:36:10 +01:00
|
|
|
case android.R.id.home:
|
2017-02-19 16:07:45 +01:00
|
|
|
onBackPressed();
|
2016-05-02 15:19:58 +02:00
|
|
|
return true;
|
|
|
|
default:
|
2017-01-19 19:38:33 +01:00
|
|
|
return super.onOptionsItemSelected(item);
|
2016-04-23 12:22:29 +02:00
|
|
|
}
|
|
|
|
}
|
2016-04-22 01:28:01 +02:00
|
|
|
}
|