From affce74b847f059178b1b60d88795cd4e02dd36e Mon Sep 17 00:00:00 2001 From: David Date: Mon, 2 May 2016 10:19:58 -0300 Subject: [PATCH] Added menu to download activity --- .../schabi/newpipe/download/MainActivity.java | 53 +++++++++++++++---- .../giga/ui/fragment/MissionsFragment.java | 4 +- app/src/main/res/menu/download_menu.xml | 13 +++++ 3 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 app/src/main/res/menu/download_menu.xml diff --git a/app/src/main/java/org/schabi/newpipe/download/MainActivity.java b/app/src/main/java/org/schabi/newpipe/download/MainActivity.java index 5d8295f36..e7e025701 100644 --- a/app/src/main/java/org/schabi/newpipe/download/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/download/MainActivity.java @@ -16,6 +16,8 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewTreeObserver; @@ -25,15 +27,21 @@ import android.widget.EditText; import android.widget.SeekBar; import android.widget.TextView; import android.widget.Toast; +import android.support.v7.widget.SearchView; +import org.schabi.newpipe.ErrorActivity; import org.schabi.newpipe.R; +import org.schabi.newpipe.SettingsActivity; import org.schabi.newpipe.VideoItemDetailActivity; +import org.schabi.newpipe.VideoItemListActivity; +import org.schabi.newpipe.extractor.ServiceList; import java.io.File; import java.io.IOException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; +import java.util.Vector; import us.shandian.giga.get.DownloadManager; import us.shandian.giga.service.DownloadManagerService; @@ -50,6 +58,8 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte private static final String TAG = MainActivity.class.toString(); + private Menu menu = null; + private MissionsFragment mFragment; private DownloadManager mManager; private DownloadManagerService.DMBinder mBinder; @@ -230,18 +240,43 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte } + public boolean onCreateOptionsMenu(Menu menu) { + super.onCreateOptionsMenu(menu); + this.menu = menu; + MenuInflater inflater = getMenuInflater(); + + inflater.inflate(R.menu.download_menu, menu); + + return true; + } + @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); - if (id == android.R.id.home) { - Intent intent = new Intent(this, VideoItemDetailActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - NavUtils.navigateUpTo(this, intent); - return true; - } else { - return mFragment.onOptionsItemSelected(item) || - super.onOptionsItemSelected(item); + + switch (id) { + case android.R.id.home: { + Intent intent = new Intent(this, VideoItemListActivity.class); + 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_report_error: { + ErrorActivity.reportError(MainActivity.this, new Vector(), + null, null, + ErrorActivity.ErrorInfo.make(ErrorActivity.USER_REPORT, + null, + "user_report", R.string.user_report)); + return true; + } + default: + return mFragment.onOptionsItemSelected(item) || + super.onOptionsItemSelected(item); } } - } diff --git a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java index 51927051b..1b9fe09dc 100644 --- a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java +++ b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java @@ -91,9 +91,7 @@ public abstract class MissionsFragment extends Fragment @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - inflater.inflate(R.menu.frag_mission, menu); - mSwitch = menu.findItem(R.id.switch_mode); - mSwitch.setIcon(mLinear ? R.drawable.grid : R.drawable.list); + } @Override diff --git a/app/src/main/res/menu/download_menu.xml b/app/src/main/res/menu/download_menu.xml new file mode 100644 index 000000000..a396791d0 --- /dev/null +++ b/app/src/main/res/menu/download_menu.xml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file