Loading app/build.gradle +50 −2 Original line number Diff line number Diff line Loading @@ -68,8 +68,13 @@ android { 'src/main/res/layouts/mastodon', 'src/main/res/layouts/peertube', 'src/main/res/layouts', 'src/main/res/drawables/mastodon', 'src/main/res/drawables/peertube', 'src/main/res/drawables', 'src/main/res/menus/mastodon', 'src/main/res/menus/peertube', 'src/main/res/menus', 'src/main/res' ] } } Loading Loading @@ -154,6 +159,49 @@ dependencies { // debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1' implementation 'com.r0adkll:slidableactivity:2.1.0' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' implementation 'androidx.vectordrawable:vectordrawable:1.1.0' implementation "androidx.fragment:fragment:1.5.5" implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.browser:browser:1.4.0' implementation 'androidx.documentfile:documentfile:1.0.1' implementation 'com.github.amoskorir:avatarimagegenerator:1.5.0' implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0' implementation 'com.google.android.exoplayer:extension-mediasession:2.18.1' implementation "com.github.mabbas007:TagsEditText:1.0.5" implementation "net.gotev:uploadservice:4.5.1" implementation "net.gotev:uploadservice-okhttp:4.5.1" implementation 'androidx.media:media:1.6.0' implementation 'com.github.ybq:Android-SpinKit:1.4.0' implementation 'com.github.mancj:MaterialSearchBar:0.8.5' implementation 'com.github.vkay94:DoubleTapPlayerView:1.0.0' //************ CAST **************/// //---> Google libs (google_full) playstoreImplementation "com.google.android.gms:play-services-cast-tv:19.0.1" playstoreImplementation "com.google.android.gms:play-services-cast:21.0.1" playstoreImplementation "androidx.mediarouter:mediarouter:1.3.0" playstoreImplementation 'com.google.android.gms:play-services-cast-framework:21.0.1' playstoreImplementation "com.google.android.gms:play-services-cast-tv:19.0.1" playstoreImplementation "com.google.android.gms:play-services-cast:21.0.1" playstoreImplementation "androidx.mediarouter:mediarouter:1.3.0" playstoreImplementation 'com.google.android.gms:play-services-cast-framework:21.0.1' //----> Other flavors fdroidImplementation 'su.litvak.chromecast:api-v2:0.11.3' fdroidImplementation 'com.fasterxml.jackson.core:jackson-core:2.12.0' fdroidImplementation 'org.slf4j:slf4j-simple:1.7.30' fdroidImplementation 'com.github.evozi:Cyanea:1.0.7' fdroidImplementation 'su.litvak.chromecast:api-v2:0.11.3' fdroidImplementation 'com.fasterxml.jackson.core:jackson-core:2.12.0' fdroidImplementation 'org.slf4j:slf4j-simple:1.7.30' } def getCurrentFlavor() { Gradle gradle = getGradle() Loading app/src/fdroid/res/layout/min_controller.xml 0 → 100644 +53 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/castMiniController" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black" android:visibility="gone"> <ImageView android:id="@+id/cast_play" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="@string/play" android:src="@drawable/ic_baseline_play_arrow_32" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/cast_loader" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"> <TextView android:id="@+id/cast_loader_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/please_wait" android:textColor="?colorAccent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/cast_loader_small" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <com.github.ybq.android.spinkit.SpinKitView android:id="@+id/cast_loader_small" android:layout_width="wrap_content" android:layout_height="18dp" android:layout_gravity="center" android:layout_marginStart="5dp" app:SpinKit_Color="?colorAccent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@+id/cast_loader_text" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout> No newline at end of file app/src/main/AndroidManifest.xml +117 −0 Original line number Diff line number Diff line Loading @@ -369,5 +369,122 @@ <action android:name="org.unifiedpush.android.connector.REGISTRATION_REFUSED" /> </intent-filter> </receiver> <activity android:name=".peertube.activities.PeertubeActivity" android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" android:launchMode="singleTask" android:resizeableActivity="true" android:supportsPictureInPicture="true" tools:targetApi="n" /> <activity android:name=".peertube.activities.PeertubeEditUploadActivity" android:configChanges="orientation|screenSize" android:exported="false" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.ShowChannelActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.ShowAccountActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.AccountActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.MyAccountActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.SearchActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.AllPlaylistsActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.AllLocalPlaylistsActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.InstancePickerActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.PlaylistsActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.LocalPlaylistsActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.VideosTimelineActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.SepiaSearchActivity" android:configChanges="orientation|screenSize" android:label="@string/sepia_search" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.ManageInstancesActivity" android:configChanges="orientation|screenSize" android:label="@string/instances_picker" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.WebviewActivity" android:configChanges="keyboardHidden|orientation|screenSize" /> <activity android:name=".peertube.activities.WebviewConnectActivity" android:configChanges="keyboardHidden|orientation|screenSize" /> <activity android:name=".peertube.activities.MastodonWebviewConnectActivity" android:configChanges="keyboardHidden|orientation|screenSize" /> <activity android:name=".peertube.activities.LoginActivity" android:configChanges="orientation|screenSize" android:exported="true" android:windowSoftInputMode="stateAlwaysHidden"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="backtotubelab" android:scheme="tubelab" /> </intent-filter> </activity> <activity android:name=".peertube.activities.SettingsActivity" android:configChanges="orientation|screenSize" android:label="@string/settings" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.PeertubeRegisterActivity" android:configChanges="orientation|screenSize" android:label="@string/register_account" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.PeertubeUploadActivity" android:configChanges="orientation|screenSize" android:label="@string/upload_video" android:windowSoftInputMode="stateAlwaysHidden" /> <service android:name=".peertube.services.RetrieveInfoService" android:exported="false" /> </application> </manifest> No newline at end of file app/src/main/java/app/fedilab/android/peertube/activities/AccountActivity.java 0 → 100644 +299 −0 Original line number Diff line number Diff line package app.fedilab.android.peertube.activities; /* Copyright 2020 Thomas Schneider * * This file is a part of TubeLab * * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU General Public License as published by the Free Software Foundation; either version 3 of the * License, or (at your option) any later version. * * TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details. * * You should have received a copy of the GNU General Public License along with TubeLab; if not, * see <http://www.gnu.org/licenses>. */ import static app.fedilab.android.peertube.activities.MainActivity.badgeCount; import android.content.Intent; import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.text.Html; import android.text.SpannableString; import android.text.Spanned; import android.text.style.ForegroundColorSpan; import android.text.style.UnderlineSpan; import android.view.Menu; import android.view.MenuItem; import android.view.View; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; import com.google.android.material.tabs.TabLayout; import org.jetbrains.annotations.NotNull; import app.fedilab.android.R; import app.fedilab.android.databinding.ActivityAccountBinding; import app.fedilab.android.mastodon.activities.BaseActivity; import app.fedilab.android.peertube.client.RetrofitPeertubeAPI; import app.fedilab.android.peertube.client.data.AccountData.Account; import app.fedilab.android.peertube.fragment.DisplayAccountsFragment; import app.fedilab.android.peertube.fragment.DisplayChannelsFragment; import app.fedilab.android.peertube.fragment.DisplayNotificationsFragment; import app.fedilab.android.peertube.helper.Helper; import app.fedilab.android.peertube.helper.SwitchAccountHelper; import app.fedilab.android.peertube.sqlite.AccountDAO; import app.fedilab.android.peertube.sqlite.Sqlite; public class AccountActivity extends BaseActivity { private ActivityAccountBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = ActivityAccountBinding.inflate(getLayoutInflater()); View view = binding.getRoot(); setContentView(view); if (getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); SpannableString content_create = new SpannableString(getString(R.string.join_peertube)); content_create.setSpan(new UnderlineSpan(), 0, content_create.length(), 0); content_create.setSpan(new ForegroundColorSpan(Helper.fetchAccentColor(AccountActivity.this)), 0, content_create.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null); Account account = new AccountDAO(AccountActivity.this, db).getAccountByToken(token); if (account == null) { Helper.logoutCurrentUser(AccountActivity.this, null); return; } setTitle(String.format("@%s", account.getUsername())); Helper.loadAvatar(AccountActivity.this, account, binding.profilePicture); binding.username.setText(String.format("@%s", account.getUsername())); binding.displayname.setText(account.getDisplayName()); binding.instance.setText(account.getHost()); binding.logoutButton.setOnClickListener(v -> { AlertDialog.Builder dialogBuilderLogoutAccount = new AlertDialog.Builder(AccountActivity.this); dialogBuilderLogoutAccount.setMessage(getString(R.string.logout_account_confirmation, account.getUsername(), account.getHost())); dialogBuilderLogoutAccount.setPositiveButton(R.string.action_logout, (dialog, id) -> { Helper.logoutCurrentUser(AccountActivity.this, account); dialog.dismiss(); }); dialogBuilderLogoutAccount.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss()); AlertDialog alertDialogLogoutAccount = dialogBuilderLogoutAccount.create(); alertDialogLogoutAccount.show(); }); binding.settings.setOnClickListener(v -> { Intent intent = new Intent(AccountActivity.this, SettingsActivity.class); startActivity(intent); }); TabLayout.Tab notificationTab = binding.accountTabLayout.newTab(); if (Helper.isLoggedIn(AccountActivity.this)) { if (badgeCount > 0) { binding.accountTabLayout.addTab(notificationTab.setText(getString(R.string.title_notifications) + " (" + badgeCount + ")")); } else { binding.accountTabLayout.addTab(notificationTab.setText(getString(R.string.title_notifications))); } binding.accountTabLayout.addTab(binding.accountTabLayout.newTab().setText(getString(R.string.title_muted))); binding.accountTabLayout.addTab(binding.accountTabLayout.newTab().setText(getString(R.string.title_channel))); binding.accountViewpager.setOffscreenPageLimit(3); binding.accountViewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { TabLayout.Tab tab = binding.accountTabLayout.getTabAt(position); if (tab != null) tab.select(); } @Override public void onPageScrollStateChanged(int state) { } }); binding.accountTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { binding.accountViewpager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(TabLayout.Tab tab) { } @Override public void onTabReselected(TabLayout.Tab tab) { Fragment fragment = null; if (binding.accountViewpager.getAdapter() != null) fragment = (Fragment) binding.accountViewpager.getAdapter().instantiateItem(binding.accountViewpager, tab.getPosition()); switch (tab.getPosition()) { case 0: if (badgeCount > 0) { android.app.AlertDialog.Builder builder; builder = new android.app.AlertDialog.Builder(AccountActivity.this); builder.setMessage(R.string.mark_all_notifications_as_read_confirm); builder.setIcon(android.R.drawable.ic_dialog_alert) .setPositiveButton(R.string.mark_all_as_read, (dialog, which) -> { new Thread(() -> { new RetrofitPeertubeAPI(AccountActivity.this).markAllAsRead(); Handler mainHandler = new Handler(Looper.getMainLooper()); badgeCount = 0; Runnable myRunnable = () -> binding.accountTabLayout.getTabAt(0).setText(getString(R.string.title_notifications)); mainHandler.post(myRunnable); }).start(); dialog.dismiss(); }) .setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss()) .show(); } else { if (fragment != null) { DisplayNotificationsFragment displayNotificationsFragment = ((DisplayNotificationsFragment) fragment); displayNotificationsFragment.scrollToTop(); } } break; case 1: if (fragment != null) { DisplayAccountsFragment displayAccountsFragment = ((DisplayAccountsFragment) fragment); displayAccountsFragment.scrollToTop(); } break; case 2: if (fragment != null) { DisplayChannelsFragment displayChannelsFragment = ((DisplayChannelsFragment) fragment); displayChannelsFragment.scrollToTop(); } break; } } }); PagerAdapter mPagerAdapter = new AccountsPagerAdapter(getSupportFragmentManager()); binding.accountViewpager.setAdapter(mPagerAdapter); } else { binding.accountTabLayout.setVisibility(View.GONE); binding.accountViewpager.setVisibility(View.GONE); binding.remoteAccount.setVisibility(View.VISIBLE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) binding.remoteAccount.setText(Html.fromHtml(getString(R.string.remote_account_from, account.getSoftware()), Html.FROM_HTML_MODE_LEGACY)); else binding.remoteAccount.setText(Html.fromHtml(getString(R.string.remote_account_from, account.getSoftware()))); } } public void updateCounter() { if (badgeCount > 0) { binding.accountTabLayout.getTabAt(0).setText(getString(R.string.title_notifications) + " (" + badgeCount + ")"); } else { binding.accountTabLayout.getTabAt(0).setText(getString(R.string.title_notifications)); } } @Override protected void onResume() { super.onResume(); } @Override public boolean onCreateOptionsMenu(@NotNull Menu menu) { getMenuInflater().inflate(R.menu.main_profile_peertube, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { finish(); overridePendingTransition(R.anim.slide_out_up, R.anim.slide_in_up_down); return true; } else if (item.getItemId() == R.id.action_add_account) { SwitchAccountHelper.switchDialog(AccountActivity.this, true); } return super.onOptionsItemSelected(item); } @Override public void onDestroy() { super.onDestroy(); } @Override public void onBackPressed() { super.onBackPressed(); overridePendingTransition(R.anim.slide_out_up, R.anim.slide_in_up_down); } /** * Pager adapter for three tabs (notifications, muted, blocked) */ private static class AccountsPagerAdapter extends FragmentStatePagerAdapter { AccountsPagerAdapter(FragmentManager fm) { super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); } @NotNull @Override public Fragment getItem(int position) { Bundle bundle = new Bundle(); switch (position) { case 1: DisplayAccountsFragment displayAccountsFragment = new DisplayAccountsFragment(); bundle.putSerializable("accountFetch", RetrofitPeertubeAPI.DataType.MUTED); displayAccountsFragment.setArguments(bundle); return displayAccountsFragment; case 2: return new DisplayChannelsFragment(); default: return new DisplayNotificationsFragment(); } } @Override public int getCount() { return 3; } } } No newline at end of file app/src/main/java/app/fedilab/android/peertube/activities/AllLocalPlaylistsActivity.java 0 → 100644 +123 −0 File added.Preview size limit exceeded, changes collapsed. Show changes Loading
app/build.gradle +50 −2 Original line number Diff line number Diff line Loading @@ -68,8 +68,13 @@ android { 'src/main/res/layouts/mastodon', 'src/main/res/layouts/peertube', 'src/main/res/layouts', 'src/main/res/drawables/mastodon', 'src/main/res/drawables/peertube', 'src/main/res/drawables', 'src/main/res/menus/mastodon', 'src/main/res/menus/peertube', 'src/main/res/menus', 'src/main/res' ] } } Loading Loading @@ -154,6 +159,49 @@ dependencies { // debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1' implementation 'com.r0adkll:slidableactivity:2.1.0' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' implementation 'androidx.vectordrawable:vectordrawable:1.1.0' implementation "androidx.fragment:fragment:1.5.5" implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.browser:browser:1.4.0' implementation 'androidx.documentfile:documentfile:1.0.1' implementation 'com.github.amoskorir:avatarimagegenerator:1.5.0' implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0' implementation 'com.google.android.exoplayer:extension-mediasession:2.18.1' implementation "com.github.mabbas007:TagsEditText:1.0.5" implementation "net.gotev:uploadservice:4.5.1" implementation "net.gotev:uploadservice-okhttp:4.5.1" implementation 'androidx.media:media:1.6.0' implementation 'com.github.ybq:Android-SpinKit:1.4.0' implementation 'com.github.mancj:MaterialSearchBar:0.8.5' implementation 'com.github.vkay94:DoubleTapPlayerView:1.0.0' //************ CAST **************/// //---> Google libs (google_full) playstoreImplementation "com.google.android.gms:play-services-cast-tv:19.0.1" playstoreImplementation "com.google.android.gms:play-services-cast:21.0.1" playstoreImplementation "androidx.mediarouter:mediarouter:1.3.0" playstoreImplementation 'com.google.android.gms:play-services-cast-framework:21.0.1' playstoreImplementation "com.google.android.gms:play-services-cast-tv:19.0.1" playstoreImplementation "com.google.android.gms:play-services-cast:21.0.1" playstoreImplementation "androidx.mediarouter:mediarouter:1.3.0" playstoreImplementation 'com.google.android.gms:play-services-cast-framework:21.0.1' //----> Other flavors fdroidImplementation 'su.litvak.chromecast:api-v2:0.11.3' fdroidImplementation 'com.fasterxml.jackson.core:jackson-core:2.12.0' fdroidImplementation 'org.slf4j:slf4j-simple:1.7.30' fdroidImplementation 'com.github.evozi:Cyanea:1.0.7' fdroidImplementation 'su.litvak.chromecast:api-v2:0.11.3' fdroidImplementation 'com.fasterxml.jackson.core:jackson-core:2.12.0' fdroidImplementation 'org.slf4j:slf4j-simple:1.7.30' } def getCurrentFlavor() { Gradle gradle = getGradle() Loading
app/src/fdroid/res/layout/min_controller.xml 0 → 100644 +53 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/castMiniController" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black" android:visibility="gone"> <ImageView android:id="@+id/cast_play" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="@string/play" android:src="@drawable/ic_baseline_play_arrow_32" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/cast_loader" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"> <TextView android:id="@+id/cast_loader_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/please_wait" android:textColor="?colorAccent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/cast_loader_small" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <com.github.ybq.android.spinkit.SpinKitView android:id="@+id/cast_loader_small" android:layout_width="wrap_content" android:layout_height="18dp" android:layout_gravity="center" android:layout_marginStart="5dp" app:SpinKit_Color="?colorAccent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@+id/cast_loader_text" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout> No newline at end of file
app/src/main/AndroidManifest.xml +117 −0 Original line number Diff line number Diff line Loading @@ -369,5 +369,122 @@ <action android:name="org.unifiedpush.android.connector.REGISTRATION_REFUSED" /> </intent-filter> </receiver> <activity android:name=".peertube.activities.PeertubeActivity" android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" android:launchMode="singleTask" android:resizeableActivity="true" android:supportsPictureInPicture="true" tools:targetApi="n" /> <activity android:name=".peertube.activities.PeertubeEditUploadActivity" android:configChanges="orientation|screenSize" android:exported="false" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.ShowChannelActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.ShowAccountActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.AccountActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.MyAccountActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.SearchActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.AllPlaylistsActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.AllLocalPlaylistsActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.InstancePickerActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.PlaylistsActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.LocalPlaylistsActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.VideosTimelineActivity" android:configChanges="orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.SepiaSearchActivity" android:configChanges="orientation|screenSize" android:label="@string/sepia_search" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.ManageInstancesActivity" android:configChanges="orientation|screenSize" android:label="@string/instances_picker" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.WebviewActivity" android:configChanges="keyboardHidden|orientation|screenSize" /> <activity android:name=".peertube.activities.WebviewConnectActivity" android:configChanges="keyboardHidden|orientation|screenSize" /> <activity android:name=".peertube.activities.MastodonWebviewConnectActivity" android:configChanges="keyboardHidden|orientation|screenSize" /> <activity android:name=".peertube.activities.LoginActivity" android:configChanges="orientation|screenSize" android:exported="true" android:windowSoftInputMode="stateAlwaysHidden"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="backtotubelab" android:scheme="tubelab" /> </intent-filter> </activity> <activity android:name=".peertube.activities.SettingsActivity" android:configChanges="orientation|screenSize" android:label="@string/settings" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.PeertubeRegisterActivity" android:configChanges="orientation|screenSize" android:label="@string/register_account" android:windowSoftInputMode="stateAlwaysHidden" /> <activity android:name=".peertube.activities.PeertubeUploadActivity" android:configChanges="orientation|screenSize" android:label="@string/upload_video" android:windowSoftInputMode="stateAlwaysHidden" /> <service android:name=".peertube.services.RetrieveInfoService" android:exported="false" /> </application> </manifest> No newline at end of file
app/src/main/java/app/fedilab/android/peertube/activities/AccountActivity.java 0 → 100644 +299 −0 Original line number Diff line number Diff line package app.fedilab.android.peertube.activities; /* Copyright 2020 Thomas Schneider * * This file is a part of TubeLab * * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU General Public License as published by the Free Software Foundation; either version 3 of the * License, or (at your option) any later version. * * TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details. * * You should have received a copy of the GNU General Public License along with TubeLab; if not, * see <http://www.gnu.org/licenses>. */ import static app.fedilab.android.peertube.activities.MainActivity.badgeCount; import android.content.Intent; import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.text.Html; import android.text.SpannableString; import android.text.Spanned; import android.text.style.ForegroundColorSpan; import android.text.style.UnderlineSpan; import android.view.Menu; import android.view.MenuItem; import android.view.View; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; import com.google.android.material.tabs.TabLayout; import org.jetbrains.annotations.NotNull; import app.fedilab.android.R; import app.fedilab.android.databinding.ActivityAccountBinding; import app.fedilab.android.mastodon.activities.BaseActivity; import app.fedilab.android.peertube.client.RetrofitPeertubeAPI; import app.fedilab.android.peertube.client.data.AccountData.Account; import app.fedilab.android.peertube.fragment.DisplayAccountsFragment; import app.fedilab.android.peertube.fragment.DisplayChannelsFragment; import app.fedilab.android.peertube.fragment.DisplayNotificationsFragment; import app.fedilab.android.peertube.helper.Helper; import app.fedilab.android.peertube.helper.SwitchAccountHelper; import app.fedilab.android.peertube.sqlite.AccountDAO; import app.fedilab.android.peertube.sqlite.Sqlite; public class AccountActivity extends BaseActivity { private ActivityAccountBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = ActivityAccountBinding.inflate(getLayoutInflater()); View view = binding.getRoot(); setContentView(view); if (getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); SpannableString content_create = new SpannableString(getString(R.string.join_peertube)); content_create.setSpan(new UnderlineSpan(), 0, content_create.length(), 0); content_create.setSpan(new ForegroundColorSpan(Helper.fetchAccentColor(AccountActivity.this)), 0, content_create.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null); Account account = new AccountDAO(AccountActivity.this, db).getAccountByToken(token); if (account == null) { Helper.logoutCurrentUser(AccountActivity.this, null); return; } setTitle(String.format("@%s", account.getUsername())); Helper.loadAvatar(AccountActivity.this, account, binding.profilePicture); binding.username.setText(String.format("@%s", account.getUsername())); binding.displayname.setText(account.getDisplayName()); binding.instance.setText(account.getHost()); binding.logoutButton.setOnClickListener(v -> { AlertDialog.Builder dialogBuilderLogoutAccount = new AlertDialog.Builder(AccountActivity.this); dialogBuilderLogoutAccount.setMessage(getString(R.string.logout_account_confirmation, account.getUsername(), account.getHost())); dialogBuilderLogoutAccount.setPositiveButton(R.string.action_logout, (dialog, id) -> { Helper.logoutCurrentUser(AccountActivity.this, account); dialog.dismiss(); }); dialogBuilderLogoutAccount.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss()); AlertDialog alertDialogLogoutAccount = dialogBuilderLogoutAccount.create(); alertDialogLogoutAccount.show(); }); binding.settings.setOnClickListener(v -> { Intent intent = new Intent(AccountActivity.this, SettingsActivity.class); startActivity(intent); }); TabLayout.Tab notificationTab = binding.accountTabLayout.newTab(); if (Helper.isLoggedIn(AccountActivity.this)) { if (badgeCount > 0) { binding.accountTabLayout.addTab(notificationTab.setText(getString(R.string.title_notifications) + " (" + badgeCount + ")")); } else { binding.accountTabLayout.addTab(notificationTab.setText(getString(R.string.title_notifications))); } binding.accountTabLayout.addTab(binding.accountTabLayout.newTab().setText(getString(R.string.title_muted))); binding.accountTabLayout.addTab(binding.accountTabLayout.newTab().setText(getString(R.string.title_channel))); binding.accountViewpager.setOffscreenPageLimit(3); binding.accountViewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { TabLayout.Tab tab = binding.accountTabLayout.getTabAt(position); if (tab != null) tab.select(); } @Override public void onPageScrollStateChanged(int state) { } }); binding.accountTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { binding.accountViewpager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(TabLayout.Tab tab) { } @Override public void onTabReselected(TabLayout.Tab tab) { Fragment fragment = null; if (binding.accountViewpager.getAdapter() != null) fragment = (Fragment) binding.accountViewpager.getAdapter().instantiateItem(binding.accountViewpager, tab.getPosition()); switch (tab.getPosition()) { case 0: if (badgeCount > 0) { android.app.AlertDialog.Builder builder; builder = new android.app.AlertDialog.Builder(AccountActivity.this); builder.setMessage(R.string.mark_all_notifications_as_read_confirm); builder.setIcon(android.R.drawable.ic_dialog_alert) .setPositiveButton(R.string.mark_all_as_read, (dialog, which) -> { new Thread(() -> { new RetrofitPeertubeAPI(AccountActivity.this).markAllAsRead(); Handler mainHandler = new Handler(Looper.getMainLooper()); badgeCount = 0; Runnable myRunnable = () -> binding.accountTabLayout.getTabAt(0).setText(getString(R.string.title_notifications)); mainHandler.post(myRunnable); }).start(); dialog.dismiss(); }) .setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss()) .show(); } else { if (fragment != null) { DisplayNotificationsFragment displayNotificationsFragment = ((DisplayNotificationsFragment) fragment); displayNotificationsFragment.scrollToTop(); } } break; case 1: if (fragment != null) { DisplayAccountsFragment displayAccountsFragment = ((DisplayAccountsFragment) fragment); displayAccountsFragment.scrollToTop(); } break; case 2: if (fragment != null) { DisplayChannelsFragment displayChannelsFragment = ((DisplayChannelsFragment) fragment); displayChannelsFragment.scrollToTop(); } break; } } }); PagerAdapter mPagerAdapter = new AccountsPagerAdapter(getSupportFragmentManager()); binding.accountViewpager.setAdapter(mPagerAdapter); } else { binding.accountTabLayout.setVisibility(View.GONE); binding.accountViewpager.setVisibility(View.GONE); binding.remoteAccount.setVisibility(View.VISIBLE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) binding.remoteAccount.setText(Html.fromHtml(getString(R.string.remote_account_from, account.getSoftware()), Html.FROM_HTML_MODE_LEGACY)); else binding.remoteAccount.setText(Html.fromHtml(getString(R.string.remote_account_from, account.getSoftware()))); } } public void updateCounter() { if (badgeCount > 0) { binding.accountTabLayout.getTabAt(0).setText(getString(R.string.title_notifications) + " (" + badgeCount + ")"); } else { binding.accountTabLayout.getTabAt(0).setText(getString(R.string.title_notifications)); } } @Override protected void onResume() { super.onResume(); } @Override public boolean onCreateOptionsMenu(@NotNull Menu menu) { getMenuInflater().inflate(R.menu.main_profile_peertube, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { finish(); overridePendingTransition(R.anim.slide_out_up, R.anim.slide_in_up_down); return true; } else if (item.getItemId() == R.id.action_add_account) { SwitchAccountHelper.switchDialog(AccountActivity.this, true); } return super.onOptionsItemSelected(item); } @Override public void onDestroy() { super.onDestroy(); } @Override public void onBackPressed() { super.onBackPressed(); overridePendingTransition(R.anim.slide_out_up, R.anim.slide_in_up_down); } /** * Pager adapter for three tabs (notifications, muted, blocked) */ private static class AccountsPagerAdapter extends FragmentStatePagerAdapter { AccountsPagerAdapter(FragmentManager fm) { super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); } @NotNull @Override public Fragment getItem(int position) { Bundle bundle = new Bundle(); switch (position) { case 1: DisplayAccountsFragment displayAccountsFragment = new DisplayAccountsFragment(); bundle.putSerializable("accountFetch", RetrofitPeertubeAPI.DataType.MUTED); displayAccountsFragment.setArguments(bundle); return displayAccountsFragment; case 2: return new DisplayChannelsFragment(); default: return new DisplayNotificationsFragment(); } } @Override public int getCount() { return 3; } } } No newline at end of file
app/src/main/java/app/fedilab/android/peertube/activities/AllLocalPlaylistsActivity.java 0 → 100644 +123 −0 File added.Preview size limit exceeded, changes collapsed. Show changes