diff --git a/README.md b/README.md new file mode 100644 index 0000000..2346ad7 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +

+ PeerTube for Android +

+ +

+

+ +## Features + +- [X] Recent Videos +- [X] Trending Videos +- [X] Endless scrolling +- [X] Pull to refresh +- [ ] Login +- [ ] Pick Server +- [ ] Video Playback via WebRTC +- [ ] Comment video +- [ ] Like/dislike video +- [ ] Lots more missing at this point... + + + diff --git a/app/src/main/java/net/schueller/peertube/activity/LoginActivity.java b/app/src/main/java/net/schueller/peertube/activity/LoginActivity.java index 840cf80..9a2fe32 100644 --- a/app/src/main/java/net/schueller/peertube/activity/LoginActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/LoginActivity.java @@ -41,11 +41,6 @@ import static android.Manifest.permission.READ_CONTACTS; */ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks { - /** - * Id to identity READ_CONTACTS permission request. - */ - private static final int REQUEST_READ_CONTACTS = 0; - /** * A dummy authentication store containing known user names and passwords. * TODO: remove after connecting to a real authentication system. @@ -70,7 +65,6 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks< setContentView(R.layout.activity_login); // Set up the login form. mEmailView = (AutoCompleteTextView) findViewById(R.id.email); - populateAutoComplete(); mPasswordView = (EditText) findViewById(R.id.password); mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() { @@ -96,49 +90,6 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks< mProgressView = findViewById(R.id.login_progress); } - private void populateAutoComplete() { - if (!mayRequestContacts()) { - return; - } - - getLoaderManager().initLoader(0, null, this); - } - - private boolean mayRequestContacts() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - return true; - } - if (checkSelfPermission(READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) { - return true; - } - if (shouldShowRequestPermissionRationale(READ_CONTACTS)) { - Snackbar.make(mEmailView, R.string.permission_rationale, Snackbar.LENGTH_INDEFINITE) - .setAction(android.R.string.ok, new View.OnClickListener() { - @Override - @TargetApi(Build.VERSION_CODES.M) - public void onClick(View v) { - requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS); - } - }); - } else { - requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS); - } - return false; - } - - /** - * Callback received when a permissions request has been completed. - */ - @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, - @NonNull int[] grantResults) { - if (requestCode == REQUEST_READ_CONTACTS) { - if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - populateAutoComplete(); - } - } - } - /** * Attempts to sign in or register the account specified by the login form. diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java index ac458e6..2a732e0 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java @@ -1,7 +1,9 @@ package net.schueller.peertube.activity; import android.app.Activity; +import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; import android.support.v4.widget.SwipeRefreshLayout; @@ -124,7 +126,7 @@ public class VideoListActivity extends AppCompatActivity { // Set an icon in the ActionBar menu.findItem(R.id.action_user).setIcon( - new IconDrawable(this, FontAwesomeIcons.fa_user) + new IconDrawable(this, FontAwesomeIcons.fa_user_o) .colorRes(R.color.cardview_light_background) .actionBarSize()); @@ -201,7 +203,11 @@ public class VideoListActivity extends AppCompatActivity { isLoading = true; - GetVideoDataService service = RetrofitInstance.getRetrofitInstance().create(GetVideoDataService.class); + SharedPreferences sharedPref = this.getPreferences(Context.MODE_PRIVATE); + String defaultApiURL = getResources().getString(R.string.api_base_url); + String apiURL = sharedPref.getString(getString(R.string.api_url_key_key), defaultApiURL); + + GetVideoDataService service = RetrofitInstance.getRetrofitInstance(apiURL).create(GetVideoDataService.class); Call call = service.getVideoData(start, count, sort); diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 2739daa..a7b4c0c 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -9,6 +9,7 @@ import android.os.Handler; import android.util.Log; import android.view.MotionEvent; import android.view.View; +import android.widget.TextView; import net.schueller.peertube.R; @@ -103,6 +104,8 @@ public class VideoPlayActivity extends AppCompatActivity { mControlsView = findViewById(R.id.fullscreen_content_controls); mContentView = findViewById(R.id.fullscreen_content); + TextView textView = findViewById(R.id.fullscreen_content); + textView.setText(videoID); // Set up the user interaction to manually show or hide the system UI. mContentView.setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/net/schueller/peertube/network/RetrofitInstance.java b/app/src/main/java/net/schueller/peertube/network/RetrofitInstance.java index 9547474..d8a6cd8 100644 --- a/app/src/main/java/net/schueller/peertube/network/RetrofitInstance.java +++ b/app/src/main/java/net/schueller/peertube/network/RetrofitInstance.java @@ -6,13 +6,13 @@ import retrofit2.converter.gson.GsonConverterFactory; public class RetrofitInstance { private static Retrofit retrofit; - private static final String BASE_URL = "https://troll.tv/api/v1/"; - - public static Retrofit getRetrofitInstance() { - if (retrofit == null) { + private static String baseUrl; + public static Retrofit getRetrofitInstance(String newBaseUrl) { + if (retrofit == null || !newBaseUrl.equals(baseUrl)) { + baseUrl = newBaseUrl; retrofit = new retrofit2.Retrofit.Builder() - .baseUrl(BASE_URL) + .baseUrl(baseUrl) .addConverterFactory(GsonConverterFactory.create()) .build(); } diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 30cc5aa..d64c6c2 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -30,6 +30,21 @@ android:layout_height="wrap_content" android:orientation="vertical"> + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 24b2339..3d6a824 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3,9 +3,10 @@ Sign in + Server Email Password (optional) - Sign in or register + Sign in Sign in This email address is invalid This password is too short @@ -23,4 +24,7 @@ Dummy Button DUMMY\nCONTENT + https://troll.tv/api/v1/ + api_url +