From 212f7dfc9349660d5f567870ef0b03228735f055 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Mon, 19 Feb 2018 21:04:13 +0100 Subject: [PATCH] fix drawer header service label noch chaning, and other things --- .../java/org/schabi/newpipe/MainActivity.java | 16 +- app/src/main/res/layout/activity_main.xml | 3 +- .../{drawer_laoyut.xml => drawer_layout.xml} | 0 assets/NewPipe_background_just1.svg | 1252 +++++++++++++++++ 4 files changed, 1268 insertions(+), 3 deletions(-) rename app/src/main/res/layout/{drawer_laoyut.xml => drawer_layout.xml} (100%) create mode 100644 assets/NewPipe_background_just1.svg diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 7ca72cff5..ac058f52c 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -47,11 +47,13 @@ import android.widget.ImageButton; import android.widget.TextView; import android.widget.Toast; +import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.fragments.BackPressable; import org.schabi.newpipe.fragments.MainFragment; import org.schabi.newpipe.fragments.detail.VideoDetailFragment; import org.schabi.newpipe.fragments.list.search.SearchFragment; +import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.ServiceHelper; @@ -151,8 +153,11 @@ public class MainActivity extends AppCompatActivity { private void setupDrawerHeader() { headerServiceView = findViewById(R.id.drawer_header_service_view); Button action = findViewById(R.id.drawer_header_action_button); - action.setOnClickListener(view -> Toast.makeText(this, - R.string.drawer_header_action_paceholder_text, Toast.LENGTH_SHORT).show()); + action.setOnClickListener(view -> { + Toast.makeText(this, + R.string.drawer_header_action_paceholder_text, Toast.LENGTH_SHORT).show(); + drawer.closeDrawers(); + }); } @Override @@ -170,6 +175,13 @@ public class MainActivity extends AppCompatActivity { // close drawer on return, and don't show animation, so its looks like the drawer isn't open // when the user returns to MainActivity drawer.closeDrawer(Gravity.START, false); + try { + String selectedServiceName = NewPipe.getService( + ServiceHelper.getSelectedServiceId(this)).getServiceInfo().getName(); + headerServiceView.setText(selectedServiceName); + } catch (Exception e) { + ErrorActivity.reportUiError(this, e); + } SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); if (sharedPreferences.getBoolean(Constants.KEY_THEME_CHANGE, false)) { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index b894c23aa..99c637389 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -6,6 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + - + \ No newline at end of file diff --git a/app/src/main/res/layout/drawer_laoyut.xml b/app/src/main/res/layout/drawer_layout.xml similarity index 100% rename from app/src/main/res/layout/drawer_laoyut.xml rename to app/src/main/res/layout/drawer_layout.xml diff --git a/assets/NewPipe_background_just1.svg b/assets/NewPipe_background_just1.svg new file mode 100644 index 000000000..dae3db6b3 --- /dev/null +++ b/assets/NewPipe_background_just1.svg @@ -0,0 +1,1252 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +