validate peertube instance. changed peertube color

This commit is contained in:
yausername 2019-11-23 00:31:35 +05:30
parent 81658de08f
commit ac2543d0a1
27 changed files with 26 additions and 32 deletions

View File

@ -62,7 +62,7 @@ dependencies {
exclude module: 'support-annotations'
})
implementation 'com.github.yausername:NewPipeExtractor:4e0adbe'
implementation 'com.github.yausername:NewPipeExtractor:bc75c66'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.23.0'

View File

@ -24,6 +24,7 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.localization.ContentCountry;
import org.schabi.newpipe.extractor.localization.Localization;
import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance;
import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.report.UserAction;
import org.schabi.newpipe.util.FilePickerActivityHelper;
@ -45,9 +46,8 @@ import java.util.Map;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
import io.reactivex.Single;
import io.reactivex.Completable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
@ -68,8 +68,6 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
private Localization initialSelectedLocalization;
private ContentCountry initialSelectedContentCountry;
private CompositeDisposable disposables = new CompositeDisposable();
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -142,30 +140,24 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
Toast.LENGTH_SHORT).show();
} else {
pEt.setSummary("fetching instance details..");
Disposable disposable = Single.fromCallable(() -> {
ServiceList.PeerTube.setInstance(url);
return true;
Disposable disposable = Completable.fromAction(() -> {
PeertubeInstance instance = new PeertubeInstance(url);
instance.fetchInstanceMetaData();
ServiceList.PeerTube.setInstance(instance);
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {
if (result) {
pEt.setSummary(url);
pEt.setText(url);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(App.getApp().getString(R.string.peertube_instance_name_key), ServiceList.PeerTube.getServiceInfo().getName()).apply();
editor.putString(App.getApp().getString(R.string.current_service_key), ServiceList.PeerTube.getServiceInfo().getName()).apply();
NavigationHelper.openMainActivity(App.getApp());
} else {
pEt.setSummary(ServiceList.PeerTube.getBaseUrl());
Toast.makeText(getActivity(), "unable to update instance",
Toast.LENGTH_SHORT).show();
}
.subscribe(() -> {
pEt.setSummary(url);
pEt.setText(url);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(App.getApp().getString(R.string.peertube_instance_name_key), ServiceList.PeerTube.getServiceInfo().getName()).apply();
editor.putString(App.getApp().getString(R.string.current_service_key), ServiceList.PeerTube.getServiceInfo().getName()).apply();
NavigationHelper.openMainActivity(App.getApp());
}, error -> {
pEt.setSummary(ServiceList.PeerTube.getBaseUrl());
Toast.makeText(getActivity(), "unable to update instance",
Toast.LENGTH_SHORT).show();
});
disposables.add(disposable);
}
return false;
});

View File

@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance;
import java.util.concurrent.TimeUnit;
@ -140,7 +141,8 @@ public class ServiceHelper {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
String peerTubeInstanceUrl = sharedPreferences.getString(context.getString(R.string.peertube_instance_url_key), ServiceList.PeerTube.getBaseUrl());
String peerTubeInstanceName = sharedPreferences.getString(context.getString(R.string.peertube_instance_name_key), ServiceList.PeerTube.getServiceInfo().getName());
ServiceList.PeerTube.setInstance(peerTubeInstanceUrl, peerTubeInstanceName);
PeertubeInstance instance = new PeertubeInstance(peerTubeInstanceUrl, peerTubeInstanceName);
ServiceList.PeerTube.setInstance(instance);
}
}

View File

Before

Width:  |  Height:  |  Size: 208 B

After

Width:  |  Height:  |  Size: 208 B

View File

Before

Width:  |  Height:  |  Size: 206 B

After

Width:  |  Height:  |  Size: 206 B

View File

Before

Width:  |  Height:  |  Size: 475 B

After

Width:  |  Height:  |  Size: 475 B

View File

Before

Width:  |  Height:  |  Size: 460 B

After

Width:  |  Height:  |  Size: 460 B

View File

Before

Width:  |  Height:  |  Size: 166 B

After

Width:  |  Height:  |  Size: 166 B

View File

Before

Width:  |  Height:  |  Size: 166 B

After

Width:  |  Height:  |  Size: 166 B

View File

Before

Width:  |  Height:  |  Size: 311 B

After

Width:  |  Height:  |  Size: 311 B

View File

Before

Width:  |  Height:  |  Size: 312 B

After

Width:  |  Height:  |  Size: 312 B

View File

Before

Width:  |  Height:  |  Size: 235 B

After

Width:  |  Height:  |  Size: 235 B

View File

Before

Width:  |  Height:  |  Size: 226 B

After

Width:  |  Height:  |  Size: 226 B

View File

Before

Width:  |  Height:  |  Size: 597 B

After

Width:  |  Height:  |  Size: 597 B

View File

Before

Width:  |  Height:  |  Size: 588 B

After

Width:  |  Height:  |  Size: 588 B

View File

Before

Width:  |  Height:  |  Size: 291 B

After

Width:  |  Height:  |  Size: 291 B

View File

Before

Width:  |  Height:  |  Size: 284 B

After

Width:  |  Height:  |  Size: 284 B

View File

Before

Width:  |  Height:  |  Size: 856 B

After

Width:  |  Height:  |  Size: 856 B

View File

Before

Width:  |  Height:  |  Size: 835 B

After

Width:  |  Height:  |  Size: 835 B

View File

Before

Width:  |  Height:  |  Size: 344 B

After

Width:  |  Height:  |  Size: 344 B

View File

Before

Width:  |  Height:  |  Size: 345 B

After

Width:  |  Height:  |  Size: 345 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -23,13 +23,13 @@
<color name="dark_soundcloud_statusbar_color">#ff9100</color>
<!-- PeerTube -->
<color name="light_peertube_primary_color">#e65100</color>
<color name="light_peertube_dark_color">#ac1900</color>
<color name="light_peertube_primary_color">#ff6f00</color>
<color name="light_peertube_dark_color">#c43e00</color>
<color name="light_peertube_accent_color">#000000</color>
<color name="light_peertube_statusbar_color">#ff833a</color>
<color name="dark_peertube_primary_color">#e65100</color>
<color name="dark_peertube_dark_color">#ac1900</color>
<color name="dark_peertube_primary_color">#ff6f00</color>
<color name="dark_peertube_dark_color">#c43e00</color>
<color name="dark_peertube_accent_color">#FFFFFF</color>
<color name="dark_peertube_statusbar_color">#ff833a</color>

View File

@ -145,7 +145,6 @@
<string name="default_country_value">GB</string>
<string name="content_language_key" translatable="false">content_language</string>
<string name="peertube_instance_url_key" translatable="false">peertube_instance_url</string>
<string name="peertube_instance_url_help" translatable="true">Find the instance that best suits you on https://instances.joinpeertube.org</string>
<string name="peertube_instance_name_key" translatable="false">peertube_instance_name</string>
<string name="content_country_key" translatable="false">content_country</string>
<string name="show_age_restricted_content" translatable="false">show_age_restricted_content</string>

View File

@ -110,6 +110,7 @@
<string name="service_title">Service</string>
<string name="content_language_title">Default content language</string>
<string name="peertube_instance_url_title">PeerTube instance</string>
<string name="peertube_instance_url_help">Find the instance that best suits you on https://instances.joinpeertube.org</string>
<string name="settings_category_player_title">Player</string>
<string name="settings_category_player_behavior_title">Behavior</string>
<string name="settings_category_video_audio_title">Video &amp; audio</string>

View File

@ -44,8 +44,8 @@
<item name="pause">@drawable/ic_pause_black_24dp</item>
<item name="settings">@drawable/ic_settings_black_24dp</item>
<item name="ic_hot">@drawable/ic_whatshot_black_24dp</item>
<item name="ic_kiosk_local">@drawable/ic_kiosklocal_black_24dp</item>
<item name="ic_kiosk_recent">@drawable/ic_kioskrecent_black_24dp</item>
<item name="ic_kiosk_local">@drawable/ic_kiosk_local_black_24dp</item>
<item name="ic_kiosk_recent">@drawable/ic_kiosk_recent_black_24dp</item>
<item name="ic_channel">@drawable/ic_channel_black_24dp</item>
<item name="ic_bookmark">@drawable/ic_bookmark_black_24dp</item>
<item name="ic_playlist_add">@drawable/ic_playlist_add_black_24dp</item>
@ -110,8 +110,8 @@
<item name="play">@drawable/ic_play_arrow_white_24dp</item>
<item name="settings">@drawable/ic_settings_white_24dp</item>
<item name="ic_hot">@drawable/ic_whatshot_white_24dp</item>
<item name="ic_kiosk_local">@drawable/ic_kiosklocal_white_24dp</item>
<item name="ic_kiosk_recent">@drawable/ic_kioskrecent_white_24dp</item>
<item name="ic_kiosk_local">@drawable/ic_kiosk_local_white_24dp</item>
<item name="ic_kiosk_recent">@drawable/ic_kiosk_recent_white_24dp</item>
<item name="ic_channel">@drawable/ic_channel_white_24dp</item>
<item name="ic_bookmark">@drawable/ic_bookmark_white_24dp</item>
<item name="ic_playlist_add">@drawable/ic_playlist_add_white_24dp</item>