Some improvements

This commit is contained in:
Thomas 2020-10-03 11:24:26 +02:00
parent a8b17ce0b2
commit c50a587250
9 changed files with 27 additions and 9 deletions

View File

@ -1,6 +1,7 @@
<resources> <resources>
<string name="app_name" translatable="false">TubeAcad</string> <string name="app_name" translatable="false">TubeAcad</string>
<string name="title_home">Locale</string> <string name="title_home">Locale</string>
<string name="title_local">Locale</string>
<string name="title_discover">Découvrir</string> <string name="title_discover">Découvrir</string>
<string name="title_notifications">Notifications</string> <string name="title_notifications">Notifications</string>
<string name="title_instances">Instances</string> <string name="title_instances">Instances</string>

View File

@ -1,6 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools"> <resources xmlns:tools="http://schemas.android.com/tools">
<string name="app_name" translatable="false">Tubelab</string> <string name="app_name" translatable="false">Tubelab</string>
<string name="title_home">Home</string> <string name="title_home">Home</string>
<string name="title_local">Local</string>
<string name="title_discover">Discover</string> <string name="title_discover">Discover</string>
<string name="title_notifications">Notifications</string> <string name="title_notifications">Notifications</string>
<string name="title_recently_added">Recently added</string> <string name="title_recently_added">Recently added</string>

View File

@ -120,7 +120,7 @@ public class MainActivity extends AppCompatActivity {
//When the user is authenticated, the subscription entry will be added and the local one removed. //When the user is authenticated, the subscription entry will be added and the local one removed.
if (Helper.isLoggedIn(MainActivity.this)) { if (Helper.isLoggedIn(MainActivity.this)) {
appBarConfiguration = new AppBarConfiguration.Builder( appBarConfiguration = new AppBarConfiguration.Builder(
R.id.navigation_discover, R.id.navigation_subscription, R.id.navigation_trending, R.id.navigation_most_liked, R.id.navigation_recently_added) R.id.navigation_discover, R.id.navigation_subscription, R.id.navigation_trending, R.id.navigation_local, R.id.navigation_recently_added)
.build(); .build();
} else { } else {
appBarConfiguration = new AppBarConfiguration.Builder( appBarConfiguration = new AppBarConfiguration.Builder(
@ -189,6 +189,7 @@ public class MainActivity extends AppCompatActivity {
MenuItem myVideosItem = menu.findItem(R.id.action_myvideos); MenuItem myVideosItem = menu.findItem(R.id.action_myvideos);
MenuItem playslistItem = menu.findItem(R.id.action_playlist); MenuItem playslistItem = menu.findItem(R.id.action_playlist);
MenuItem historyItem = menu.findItem(R.id.action_history); MenuItem historyItem = menu.findItem(R.id.action_history);
MenuItem mostLikedItem = menu.findItem(R.id.action_most_liked);
MenuItem settingsItem = menu.findItem(R.id.action_settings); MenuItem settingsItem = menu.findItem(R.id.action_settings);
if (Helper.isLoggedIn(MainActivity.this)) { if (Helper.isLoggedIn(MainActivity.this)) {
instanceItem.setVisible(false); instanceItem.setVisible(false);
@ -197,6 +198,7 @@ public class MainActivity extends AppCompatActivity {
playslistItem.setVisible(true); playslistItem.setVisible(true);
historyItem.setVisible(true); historyItem.setVisible(true);
settingsItem.setVisible(false); settingsItem.setVisible(false);
mostLikedItem.setVisible(true);
} else { } else {
instanceItem.setVisible(true); instanceItem.setVisible(true);
uploadItem.setVisible(false); uploadItem.setVisible(false);
@ -204,6 +206,7 @@ public class MainActivity extends AppCompatActivity {
playslistItem.setVisible(false); playslistItem.setVisible(false);
historyItem.setVisible(false); historyItem.setVisible(false);
settingsItem.setVisible(true); settingsItem.setVisible(true);
mostLikedItem.setVisible(false);
} }
return true; return true;
} }
@ -248,6 +251,13 @@ public class MainActivity extends AppCompatActivity {
intent.putExtras(bundle); intent.putExtras(bundle);
startActivity(intent); startActivity(intent);
return true; return true;
} else if (item.getItemId() == R.id.action_most_liked) {
Intent intent = new Intent(MainActivity.this, MyVideosActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("type", TimelineVM.TimelineType.MOST_LIKED);
intent.putExtras(bundle);
startActivity(intent);
return true;
} else if (item.getItemId() == R.id.action_playlist) { } else if (item.getItemId() == R.id.action_playlist) {
Intent intent = new Intent(MainActivity.this, AllPlaylistsActivity.class); Intent intent = new Intent(MainActivity.this, AllPlaylistsActivity.class);
startActivity(intent); startActivity(intent);

View File

@ -47,6 +47,8 @@ public class MyVideosActivity extends AppCompatActivity {
setTitle(R.string.subscriptions); setTitle(R.string.subscriptions);
} else if (type == TimelineVM.TimelineType.HISTORY) { } else if (type == TimelineVM.TimelineType.HISTORY) {
setTitle(R.string.my_history); setTitle(R.string.my_history);
} else if (type == TimelineVM.TimelineType.MOST_LIKED) {
setTitle(R.string.title_most_liked);
} }
if (savedInstanceState == null) { if (savedInstanceState == null) {

View File

@ -184,7 +184,6 @@ public class VideoData {
boolean streamService = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL) == Helper.VIDEO_MODE_STREAMING; boolean streamService = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL) == Helper.VIDEO_MODE_STREAMING;
if (resolution != null) { if (resolution != null) {
for (File file : files) { for (File file : files) {
if (file.getResolutions().getLabel().compareTo(resolution) == 0) { if (file.getResolutions().getLabel().compareTo(resolution) == 0) {
if (streamService) { if (streamService) {
return file.getMagnetUri(); return file.getMagnetUri();

View File

@ -710,7 +710,7 @@ public class Helper {
if( files.size() < 3) { if( files.size() < 3) {
return files.get(files.size() -1); return files.get(files.size() -1);
}else{ }else{
int middle = files.size()/2; int middle = files.size()/2 -1;
return files.get(middle); return files.get(middle);
} }
} }

View File

@ -17,9 +17,9 @@
android:title="@string/title_trending" /> android:title="@string/title_trending" />
<item <item
android:id="@+id/navigation_most_liked" android:id="@+id/navigation_local"
android:icon="@drawable/ic_baseline_thumb_up_24" android:icon="@drawable/ic_home_black_24dp"
android:title="@string/title_most_liked" /> android:title="@string/title_local" />
<item <item
android:id="@+id/navigation_recently_added" android:id="@+id/navigation_recently_added"

View File

@ -40,6 +40,11 @@
android:icon="@drawable/ic_baseline_history_24" android:icon="@drawable/ic_baseline_history_24"
android:title="@string/my_history" android:title="@string/my_history"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item
android:id="@+id/action_most_liked"
android:icon="@drawable/ic_baseline_thumb_up_24"
android:title="@string/title_most_liked"
app:showAsAction="ifRoom" />
<item <item
android:id="@+id/action_settings" android:id="@+id/action_settings"
android:icon="@drawable/ic_baseline_settings_24" android:icon="@drawable/ic_baseline_settings_24"

View File

@ -37,13 +37,13 @@
</fragment> </fragment>
<fragment <fragment
android:id="@+id/navigation_most_liked" android:id="@+id/navigation_local"
android:name="app.fedilab.fedilabtube.fragment.DisplayVideosFragment" android:name="app.fedilab.fedilabtube.fragment.DisplayVideosFragment"
android:label="@string/title_most_liked" android:label="@string/title_local"
tools:layout="@layout/fragment_video"> tools:layout="@layout/fragment_video">
<argument <argument
android:name="type" android:name="type"
android:defaultValue="MOST_LIKED" android:defaultValue="LOCAL"
app:argType="app.fedilab.fedilabtube.viewmodel.TimelineVM$TimelineType" /> app:argType="app.fedilab.fedilabtube.viewmodel.TimelineVM$TimelineType" />
</fragment> </fragment>