This commit is contained in:
Stefan Schueller 2018-03-04 01:44:34 +01:00
parent 81fec069df
commit 9eff57238f
7 changed files with 58 additions and 57 deletions

22
README.md Normal file
View File

@ -0,0 +1,22 @@
<h1 align="center">
PeerTube for Android
</h1>
<h4 align="center">
</h4>
## 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...

View File

@ -41,11 +41,6 @@ import static android.Manifest.permission.READ_CONTACTS;
*/
public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<Cursor> {
/**
* 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.

View File

@ -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<VideoList> call = service.getVideoData(start, count, sort);

View File

@ -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() {

View File

@ -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();
}

View File

@ -30,6 +30,21 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="@+id/server"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_server"
android:inputType="textUri"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

View File

@ -3,9 +3,10 @@
<string name="title_activity_login">Sign in</string>
<!-- Strings related to login -->
<string name="prompt_server">Server</string>
<string name="prompt_email">Email</string>
<string name="prompt_password">Password (optional)</string>
<string name="action_sign_in">Sign in or register</string>
<string name="action_sign_in">Sign in</string>
<string name="action_sign_in_short">Sign in</string>
<string name="error_invalid_email">This email address is invalid</string>
<string name="error_invalid_password">This password is too short</string>
@ -23,4 +24,7 @@
<string name="dummy_button">Dummy Button</string>
<string name="dummy_content">DUMMY\nCONTENT</string>
<string name="api_base_url" formatted="false">https://troll.tv/api/v1/</string>
<string name="api_url_key_key">api_url</string>
</resources>