1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-22 02:53:09 +01:00

Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Weblate 2018-02-20 14:36:49 +01:00
commit d36c371c1d
9 changed files with 1366 additions and 22 deletions

View File

@ -8,8 +8,8 @@ android {
applicationId "org.schabi.newpipe"
minSdkVersion 15
targetSdkVersion 27
versionCode 47
versionName "0.11.6"
versionCode 48
versionName "0.12.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
@ -55,7 +55,7 @@ dependencies {
exclude module: 'support-annotations'
}
implementation 'com.github.TeamNewPipe:NewPipeExtractor:e51bc58a856dcf3'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:7716b1437815'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19'

View File

@ -37,19 +37,23 @@ import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
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;
@ -61,6 +65,9 @@ public class MainActivity extends AppCompatActivity {
public static final boolean DEBUG = !BuildConfig.BUILD_TYPE.equals("release");
private ActionBarDrawerToggle toggle = null;
private DrawerLayout drawer = null;
private NavigationView drawerItems = null;
private TextView headerServiceView = null;
/*//////////////////////////////////////////////////////////////////////////
// Activity's LifeCycle
@ -81,13 +88,12 @@ public class MainActivity extends AppCompatActivity {
setSupportActionBar(findViewById(R.id.toolbar));
setupDrawer();
setupDrawerFooter();
}
private void setupDrawer() {
final Toolbar toolbar = findViewById(R.id.toolbar);
final DrawerLayout drawer = findViewById(R.id.drawer_layout);
final NavigationView drawerItems = findViewById(R.id.navigation);
drawer = findViewById(R.id.drawer_layout);
drawerItems = findViewById(R.id.navigation);
//drawerItems.setItemIconTintList(null); // Set null to use the original icon
drawerItems.getMenu().getItem(ServiceHelper.getSelectedServiceId(this)).setChecked(true);
@ -112,18 +118,26 @@ public class MainActivity extends AppCompatActivity {
}
});
drawerItems.setNavigationItemSelectedListener(item -> {
drawerItems.setNavigationItemSelectedListener(this::changeService);
setupDrawerFooter();
setupDrawerHeader();
} else {
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
}
}
private boolean changeService(MenuItem item) {
if (item.getGroupId() == R.id.menu_services_group) {
drawerItems.getMenu().getItem(ServiceHelper.getSelectedServiceId(this)).setChecked(false);
ServiceHelper.setSelectedServiceId(this, item.getTitle().toString());
drawerItems.getMenu().getItem(ServiceHelper.getSelectedServiceId(this)).setChecked(true);
headerServiceView.setText("gurken");
} else {
return false;
}
drawer.closeDrawers();
return true;
});
} else {
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
}
}
private void setupDrawerFooter() {
@ -136,6 +150,16 @@ public class MainActivity extends AppCompatActivity {
history.setOnClickListener(view -> NavigationHelper.openHistory(this));
}
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();
drawer.closeDrawers();
});
}
@Override
protected void onDestroy() {
super.onDestroy();
@ -148,6 +172,17 @@ public class MainActivity extends AppCompatActivity {
protected void onResume() {
super.onResume();
// 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)) {
if (DEBUG) Log.d(TAG, "Theme has changed, recreating activity...");

View File

@ -13,6 +13,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import org.schabi.newpipe.MainActivity;
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.ServiceList;
@ -45,6 +46,8 @@ import java.util.Vector;
public class SelectKioskFragment extends DialogFragment {
private static final boolean DEBUG = MainActivity.DEBUG;
RecyclerView recyclerView = null;
SelectKioskAdapter selectKioskAdapter = null;
@ -122,7 +125,7 @@ public class SelectKioskFragment extends DialogFragment {
for(StreamingService service : NewPipe.getServices()) {
//TODO: Multi-service support
if (service.getServiceId() != ServiceList.YouTube.getServiceId()) continue;
if (service.getServiceId() != ServiceList.YouTube.getServiceId() && !DEBUG) continue;
for(String kioskId : service.getKioskList().getAvailableKiosks()) {
String name = String.format(getString(R.string.service_kiosk_string),

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

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

View File

@ -6,9 +6,11 @@
android:layout_width="wrap_content"
android:layout_gravity="start"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?attr/android:windowBackground">
android:background="?attr/android:windowBackground"
android:clickable="true"
android:focusable="true">
<View
<RelativeLayout
android:id="@+id/drawer_header"
android:layout_width="0dp"
android:layout_height="150dp"
@ -16,7 +18,57 @@
android:layout_alignRight="@id/navigation"
android:layout_alignStart="@id/navigation"
android:layout_alignEnd="@id/navigation"
android:background="?attr/colorPrimary"/>
android:clickable="true"
android:focusable="true">
<Button
android:id="@+id/drawer_header_action_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackground"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorPrimary"
android:src="@drawable/background_header"
android:scaleType="centerCrop"/>
<ImageView
android:id="@+id/drawer_header_np_nude_view"
android:layout_marginLeft="30dp"
android:layout_marginStart="30dp"
android:layout_marginTop="20dp"
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@drawable/np_logo_nude_shadow"/>
<TextView
android:id="@+id/drawer_header_np_text_view"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="@string/app_name"
android:layout_toRightOf="@id/drawer_header_np_nude_view"
android:layout_toEndOf="@id/drawer_header_np_nude_view"
android:layout_alignTop="@id/drawer_header_np_nude_view"
android:layout_alignBottom="@id/drawer_header_np_nude_view"
android:gravity="center"
android:textSize="30dp"
android:textStyle="bold|italic"/>
<TextView
android:id="@+id/drawer_header_service_view"
android:layout_width="100dp"
android:layout_height="100dp"
android:text="YouTube"
android:layout_below="@id/drawer_header_np_text_view"
android:layout_alignLeft="@id/drawer_header_np_text_view"
android:layout_alignStart="@id/drawer_header_np_text_view"
android:textSize="18dp"
android:textStyle="italic"/>
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation"

View File

@ -366,6 +366,7 @@
<string name="drawer_close">Close Drawer</string>
<string name="youtube" translatable="false">YouTube</string>
<string name="soundcloud" translatable="false">SoundCloud</string>
<string name="drawer_header_action_paceholder_text">Something will come here soon ;D</string>
<!-- Preferred player -->

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 102 KiB