1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-23 11:32:32 +01:00

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

This commit is contained in:
Weblate 2018-02-04 03:36:15 +01:00
commit 0ab1d3fc40
6 changed files with 46 additions and 12 deletions

View File

@ -106,7 +106,7 @@ public class MainActivity extends AppCompatActivity implements HistoryListener {
final DrawerLayout drawer = findViewById(R.id.drawer_layout); final DrawerLayout drawer = findViewById(R.id.drawer_layout);
final NavigationView drawerItems = findViewById(R.id.navigation); final NavigationView drawerItems = findViewById(R.id.navigation);
drawerItems.setItemIconTintList(null); //drawerItems.setItemIconTintList(null); // Set null to use the original icon
drawerItems.getMenu().getItem(ServiceHelper.getSelectedServiceId(this)).setChecked(true); drawerItems.getMenu().getItem(ServiceHelper.getSelectedServiceId(this)).setChecked(true);
if (!BuildConfig.BUILD_TYPE.equals("release")) { if (!BuildConfig.BUILD_TYPE.equals("release")) {
@ -204,8 +204,36 @@ public class MainActivity extends AppCompatActivity implements HistoryListener {
} else super.onBackPressed(); } else super.onBackPressed();
} }
/**
* Implement the following diagram behavior for the up button:
* <pre>
* +---------------+
* | Main Screen +----+
* +-------+-------+ |
* | |
* Up | Search Button
* | |
* +----+-----+ |
* +------------+ Search |-----+
* | +----+-----+
* | Open |
* | something Up
* | |
* | +------------+-------------+
* | | |
* | | Video <-> Channel |
* +---| Channel <-> Playlist |
* | Video <-> .... |
* | |
* +--------------------------+
* </pre>
*/
private void onHomeButtonPressed() { private void onHomeButtonPressed() {
NavigationHelper.gotoMainFragment(getSupportFragmentManager()); // If search fragment wasn't found in the backstack...
if (!NavigationHelper.tryGotoSearchFragment(getSupportFragmentManager())) {
// ...go to the main fragment
NavigationHelper.gotoMainFragment(getSupportFragmentManager());
}
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -239,11 +267,6 @@ public class MainActivity extends AppCompatActivity implements HistoryListener {
return true; return true;
} }
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
return super.onPrepareOptionsMenu(menu);
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
if (DEBUG) Log.d(TAG, "onOptionsItemSelected() called with: item = [" + item + "]"); if (DEBUG) Log.d(TAG, "onOptionsItemSelected() called with: item = [" + item + "]");

View File

@ -51,6 +51,7 @@ import java.util.ArrayList;
@SuppressWarnings({"unused", "WeakerAccess"}) @SuppressWarnings({"unused", "WeakerAccess"})
public class NavigationHelper { public class NavigationHelper {
public static final String MAIN_FRAGMENT_TAG = "main_fragment_tag"; public static final String MAIN_FRAGMENT_TAG = "main_fragment_tag";
public static final String SEARCH_FRAGMENT_TAG = "search_fragment_tag";
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
// Players // Players
@ -244,11 +245,21 @@ public class NavigationHelper {
.commit(); .commit();
} }
public static boolean tryGotoSearchFragment(FragmentManager fragmentManager) {
if (MainActivity.DEBUG) {
for (int i = 0; i < fragmentManager.getBackStackEntryCount(); i++) {
Log.d("NavigationHelper", "tryGoToSearchFragment() [" + i + "] = [" + fragmentManager.getBackStackEntryAt(i) + "]");
}
}
return fragmentManager.popBackStackImmediate(SEARCH_FRAGMENT_TAG, 0);
}
public static void openSearchFragment(FragmentManager fragmentManager, int serviceId, String query) { public static void openSearchFragment(FragmentManager fragmentManager, int serviceId, String query) {
fragmentManager.beginTransaction() fragmentManager.beginTransaction()
.setCustomAnimations(R.animator.custom_fade_in, R.animator.custom_fade_out, R.animator.custom_fade_in, R.animator.custom_fade_out) .setCustomAnimations(R.animator.custom_fade_in, R.animator.custom_fade_out, R.animator.custom_fade_in, R.animator.custom_fade_out)
.replace(R.id.fragment_holder, SearchFragment.getInstance(serviceId, query)) .replace(R.id.fragment_holder, SearchFragment.getInstance(serviceId, query))
.addToBackStack(null) .addToBackStack(SEARCH_FRAGMENT_TAG)
.commit(); .commit();
} }

View File

@ -18,9 +18,9 @@ public class ServiceHelper {
public static int getIcon(int serviceId) { public static int getIcon(int serviceId) {
switch (serviceId) { switch (serviceId) {
case 0: case 0:
return R.drawable.youtube; return R.drawable.place_holder_youtube;
case 1: case 1:
return R.drawable.soundcloud; return R.drawable.place_holder_circle;
default: default:
return R.drawable.service; return R.drawable.service;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -4,11 +4,11 @@
android:id="@+id/menu_services_group"> android:id="@+id/menu_services_group">
<item <item
android:id="@+id/menu_service_youtube" android:id="@+id/menu_service_youtube"
android:icon="@drawable/youtube" android:icon="@drawable/place_holder_youtube"
android:title="@string/youtube"/> android:title="@string/youtube"/>
<item <item
android:id="@+id/menu_service_soundcloud" android:id="@+id/menu_service_soundcloud"
android:icon="@drawable/soundcloud" android:icon="@drawable/place_holder_circle"
android:title="@string/soundcloud"/> android:title="@string/soundcloud"/>
</group> </group>
</menu> </menu>