NewPipe/app/src/main/java/org/schabi/newpipe/MainActivity.java

89 lines
3.1 KiB
Java
Raw Normal View History

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;
2017-02-27 12:55:15 +01:00
import android.os.Bundle;
2016-08-02 15:06:02 +02:00
import android.support.v4.app.Fragment;
import android.support.v4.app.NavUtils;
2017-02-27 12:55:15 +01:00
import android.support.v7.app.AppCompatActivity;
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 org.schabi.newpipe.download.DownloadActivity;
2016-08-02 21:17:54 +02:00
import org.schabi.newpipe.settings.SettingsActivity;
import org.schabi.newpipe.util.PermissionHelper;
2017-02-27 12:55:15 +01:00
import org.schabi.newpipe.util.ThemeHelper;
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-02-27 19:21:41 +01:00
public class MainActivity extends AppCompatActivity {
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);
2017-02-27 12:55:15 +01:00
ThemeHelper.setTheme(this, true);
2016-08-02 01:26:12 +02:00
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)) {
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:
return super.onOptionsItemSelected(item);
2016-08-02 15:06:02 +02:00
}
2016-08-02 01:26:12 +02:00
}
}