fix drawer header service label noch chaning, and other things

This commit is contained in:
Christian Schabesberger 2018-02-19 21:04:13 +01:00
parent 3e5e7f49cc
commit 212f7dfc93
4 changed files with 1268 additions and 3 deletions

View file

@ -47,11 +47,13 @@ import android.widget.ImageButton;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.fragments.BackPressable; import org.schabi.newpipe.fragments.BackPressable;
import org.schabi.newpipe.fragments.MainFragment; import org.schabi.newpipe.fragments.MainFragment;
import org.schabi.newpipe.fragments.detail.VideoDetailFragment; import org.schabi.newpipe.fragments.detail.VideoDetailFragment;
import org.schabi.newpipe.fragments.list.search.SearchFragment; 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.Constants;
import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.ServiceHelper; import org.schabi.newpipe.util.ServiceHelper;
@ -151,8 +153,11 @@ public class MainActivity extends AppCompatActivity {
private void setupDrawerHeader() { private void setupDrawerHeader() {
headerServiceView = findViewById(R.id.drawer_header_service_view); headerServiceView = findViewById(R.id.drawer_header_service_view);
Button action = findViewById(R.id.drawer_header_action_button); Button action = findViewById(R.id.drawer_header_action_button);
action.setOnClickListener(view -> Toast.makeText(this, action.setOnClickListener(view -> {
R.string.drawer_header_action_paceholder_text, Toast.LENGTH_SHORT).show()); Toast.makeText(this,
R.string.drawer_header_action_paceholder_text, Toast.LENGTH_SHORT).show();
drawer.closeDrawers();
});
} }
@Override @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 // close drawer on return, and don't show animation, so its looks like the drawer isn't open
// when the user returns to MainActivity // when the user returns to MainActivity
drawer.closeDrawer(Gravity.START, false); 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); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
if (sharedPreferences.getBoolean(Constants.KEY_THEME_CHANGE, false)) { if (sharedPreferences.getBoolean(Constants.KEY_THEME_CHANGE, false)) {

View file

@ -6,6 +6,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -20,6 +21,6 @@
<include layout="@layout/toolbar_layout" /> <include layout="@layout/toolbar_layout" />
</FrameLayout> </FrameLayout>
<include layout="@layout/drawer_laoyut"/> <include layout="@layout/drawer_layout"/>
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>

File diff suppressed because it is too large Load diff

After

Width:  |  Height:  |  Size: 102 KiB