2016-08-02 01:26:12 +02:00
|
|
|
package org.schabi.newpipe;
|
|
|
|
|
2016-08-02 15:06:02 +02:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.media.AudioManager;
|
|
|
|
import android.support.v4.app.Fragment;
|
|
|
|
import android.support.v4.app.NavUtils;
|
2016-08-02 01:26:12 +02:00
|
|
|
import android.os.Bundle;
|
2017-02-15 15:21:36 +01:00
|
|
|
import android.util.Log;
|
2016-08-02 15:06:02 +02:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuInflater;
|
|
|
|
import android.view.MenuItem;
|
2017-02-15 15:21:36 +01:00
|
|
|
import android.view.View;
|
|
|
|
import android.widget.AdapterView;
|
2016-08-02 15:06:02 +02:00
|
|
|
|
2017-02-15 15:21:36 +01:00
|
|
|
import org.schabi.newpipe.download.DownloadActivity;
|
2016-08-02 21:17:54 +02:00
|
|
|
import org.schabi.newpipe.settings.SettingsActivity;
|
2017-01-10 11:41:24 +01:00
|
|
|
import org.schabi.newpipe.util.PermissionHelper;
|
2016-08-02 15:06:02 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Christian Schabesberger on 02.08.16.
|
2016-09-12 00:33:11 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
2016-09-27 21:33:26 +02:00
|
|
|
* DownloadActivity.java is part of NewPipe.
|
2016-09-12 00:33:11 +02:00
|
|
|
*
|
|
|
|
* NewPipe is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* NewPipe is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
2016-08-02 15:06:02 +02:00
|
|
|
*/
|
2016-08-02 01:26:12 +02:00
|
|
|
|
2017-01-22 13:48:50 +01:00
|
|
|
public class MainActivity extends ThemableActivity {
|
2016-08-02 15:06:02 +02:00
|
|
|
private Fragment mainFragment = null;
|
2017-02-15 15:21:36 +01:00
|
|
|
private static final String TAG = MainActivity.class.toString();
|
2016-08-02 15:06:02 +02:00
|
|
|
|
2016-08-02 01:26:12 +02:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.activity_main);
|
2016-08-02 15:06:02 +02:00
|
|
|
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
|
|
|
mainFragment = getSupportFragmentManager()
|
|
|
|
.findFragmentById(R.id.search_fragment);
|
|
|
|
}
|
|
|
|
|
2016-12-07 22:11:39 +01:00
|
|
|
@Override
|
2016-08-02 15:06:02 +02:00
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
super.onCreateOptionsMenu(menu);
|
|
|
|
MenuInflater inflater = getMenuInflater();
|
|
|
|
|
|
|
|
inflater.inflate(R.menu.main_menu, menu);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
int id = item.getItemId();
|
|
|
|
|
2017-02-15 15:21:36 +01:00
|
|
|
switch (id) {
|
2016-08-02 15:06:02 +02:00
|
|
|
case android.R.id.home: {
|
2016-08-02 20:59:53 +02:00
|
|
|
Intent intent = new Intent(this, MainActivity.class);
|
2016-08-02 15:06:02 +02:00
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
|
NavUtils.navigateUpTo(this, intent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case R.id.action_settings: {
|
|
|
|
Intent intent = new Intent(this, SettingsActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case R.id.action_show_downloads: {
|
2017-02-15 15:21:36 +01:00
|
|
|
if (!PermissionHelper.checkStoragePermissions(this)) {
|
2017-01-10 11:41:24 +01:00
|
|
|
return false;
|
|
|
|
}
|
2017-02-15 15:21:36 +01:00
|
|
|
Intent intent = new Intent(this, DownloadActivity.class);
|
2016-08-02 15:06:02 +02:00
|
|
|
startActivity(intent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
default:
|
2017-01-19 19:38:33 +01:00
|
|
|
return super.onOptionsItemSelected(item);
|
2016-08-02 15:06:02 +02:00
|
|
|
}
|
2016-08-02 01:26:12 +02:00
|
|
|
}
|
2017-02-18 21:59:48 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBackPressed() {
|
|
|
|
//ignore back
|
|
|
|
}
|
2016-08-02 01:26:12 +02:00
|
|
|
}
|