Commit c1a6f3bd authored by Daniel Sonck's avatar Daniel Sonck
Browse files

Merge pull request #2 in THFM/fm.touhou.touhoufm from development to alpha

* commit 'a1a1e22b':
  Removing obsolete/failing UI
  Bugfixes
parents 0c3ba124 a1a1e22b
......@@ -37,22 +37,6 @@
android:enabled="true"
android:exported="false" />
<activity
android:name="fm.touhou.touhoufm.activity.LoginActivity"
android:label="@string/title_activity_login"
android:parentActivityName="fm.touhou.touhoufm.activity.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="fm.touhou.touhoufm.activity.MainActivity" />
</activity>
<activity
android:name="fm.touhou.touhoufm.activity.SettingsActivity"
android:label="@string/title_activity_settings"
android:parentActivityName="fm.touhou.touhoufm.activity.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="fm.touhou.touhoufm.activity.MainActivity" />
</activity>
</application>
</manifest>
package fm.touhou.touhoufm.activity;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import fm.touhou.touhoufm.R;
import fm.touhou.touhoufm.service.RadioService;
/**
* A login screen that offers login via browser
*/
public class LoginActivity extends AppCompatActivity {
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
setupActionBar();
final WebView mWebView = (WebView) findViewById(R.id.web_view);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
final String tokenUrl = getIntent().getStringExtra("url");
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Uri uri = Uri.parse(url);
if (uri.getHost().equals("www.touhou.fm")) {
if (uri.getPathSegments().contains("granted")) {
Intent intent = new Intent(LoginActivity.this, RadioService.class);
intent.setAction("fm.touhou.touhoufm.action.GRANTED");
startService(intent);
finish();
return true;
} else if (
uri.getPathSegments().contains("authorize") ||
uri.getPathSegments().contains("register") ||
uri.getPathSegments().contains("login")
) {
return false;
} else {
mWebView.loadUrl(tokenUrl);
return true;
}
} else {
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
return true;
}
}
});
mWebView.loadUrl(tokenUrl);
}
/**
* Set up the {@link android.app.ActionBar}, if the API is available.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setupActionBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// Show the Up button in the action bar.
ActionBar actionBar = getSupportActionBar();
if (actionBar != null)
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
}
......@@ -101,8 +101,6 @@ public class MainActivity extends AppCompatActivity implements RadioService.Call
protected void onDestroy() {
super.onDestroy();
unbindService(mConnection);
loader.destroy();
}
@Override
......@@ -110,8 +108,6 @@ public class MainActivity extends AppCompatActivity implements RadioService.Call
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
mLoginItem = menu.findItem(R.id.action_login);
mLoginItem.setChecked(mLoggedIn);
return true;
}
......@@ -129,11 +125,6 @@ public class MainActivity extends AppCompatActivity implements RadioService.Call
finish();
return true;
}
if (id == R.id.action_settings) {
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
return true;
}
return super.onOptionsItemSelected(item);
}
......@@ -145,12 +136,8 @@ public class MainActivity extends AppCompatActivity implements RadioService.Call
radioService = binder.getServiceInstance();
radioService.registerClient(MainActivity.this);
ImageButton mSkipButton = (ImageButton) findViewById(R.id.skip_button);
if (mAlbumArt != null)
mAlbumArt.setOnRatingBarChangeListener(radioService.listener);
if (mSkipButton != null)
mSkipButton.setOnClickListener(radioService.listener);
}
@Override
......@@ -247,33 +234,6 @@ public class MainActivity extends AppCompatActivity implements RadioService.Call
mPlaylist.setPlaylist(playList);
}
@Override
public void authenticate(String url) {
Intent authIntent = new Intent(this, LoginActivity.class);
authIntent.putExtra("url", url);
startActivity(authIntent);
}
public void doLogin(MenuItem item) {
if (item.isChecked()) {
Toast.makeText(this, R.string.logging_in, Toast.LENGTH_SHORT).show();
mLoggedIn = false;
item.setChecked(false);
} else {
Toast.makeText(this, R.string.logging_out, Toast.LENGTH_SHORT).show();
mLoggedIn = true;
serviceIntent.setAction("fm.touhou.touhoufm.action.LOGIN");
startService(serviceIntent);
}
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("loggedIn", mLoggedIn);
editor.apply();
}
class MainPagerAdapter extends FragmentPagerAdapter {
public MainPagerAdapter(FragmentManager fm) {
......
package fm.touhou.touhoufm.activity;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.support.v7.app.ActionBar;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import fm.touhou.touhoufm.fragments.SettingsFragment;
/**
* A {@link PreferenceActivity} that presents a set of application settings. On
* handset devices, settings are presented as a single list. On tablets,
* settings are split by category, with category headers shown to the left of
* the list of settings.
* <p/>
* See <a href="http://developer.android.com/design/patterns/settings.html">
* Android Design: Settings</a> for design guidelines and the <a
* href="http://developer.android.com/guide/topics/ui/settings.html">Settings
* API Guide</a> for more information on developing a Settings UI.
*/
public class SettingsActivity extends AppCompatPreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setupActionBar();
getFragmentManager().beginTransaction()
.replace(android.R.id.content,new SettingsFragment())
.commit();
}
/**
* Set up the {@link android.app.ActionBar}, if the API is available.
*/
private void setupActionBar() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
// Show the Up button in the action bar.
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
if (!super.onMenuItemSelected(featureId, item)) {
NavUtils.navigateUpFromSameTask(this);
}
return true;
}
return super.onMenuItemSelected(featureId, item);
}
}
......@@ -84,10 +84,6 @@ public class AlbumArtFragment extends Fragment {
mAlbumArt = (ImageView)v.findViewById(R.id.album_art_view);
ImageLoader loader = ImageLoader.getInstance();
mRatingBarView = (RatingBar)v.findViewById(R.id.rating_bar);
mRatingBarView.setRating(mRating);
if(mRatingBarListener != null)
mRatingBarView.setOnRatingBarChangeListener(mRatingBarListener);
loader.displayImage(mAlbumArtUri, mAlbumArt);
......
package fm.touhou.touhoufm.fragments;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import fm.touhou.touhoufm.R;
/**
* Created by dsonck on 2/21/16. Part of TouHou.FM
* {@link PreferenceFragment} that creates the app settings.
*/
public class SettingsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
......@@ -397,8 +397,6 @@ public class RadioService extends Service implements AudioManager.OnAudioFocusCh
void setLogin(boolean loggedIn);
void setPlaylist(List<PlaylistItem> playList);
void authenticate(String url);
}
private class TouhouSocket extends WebSocketClient {
......@@ -514,7 +512,6 @@ public class RadioService extends Service implements AudioManager.OnAudioFocusCh
if (activity == null)
return;
activity.authenticate(mMessage.getString("url") + "/android");
} catch (ActivityNotFoundException e) {
Toast.makeText(RadioService.this, R.string.no_web_activity, Toast.LENGTH_LONG).show();
e.printStackTrace();
......
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:id="@+id/web_view"
tools:context="fm.touhou.touhoufm.activity.LoginActivity"/>
......@@ -13,12 +13,4 @@
android:src="@drawable/generic_album"
android:id="@+id/album_art_view"/>
<RatingBar
android:id="@+id/rating_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:numStars="7"
/>
</LinearLayout>
......@@ -53,13 +53,4 @@
android:paddingRight="2dip"
tools:ignore="SpUsage" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@null"
android:id="@+id/skip_button"
android:src="@drawable/ic_av_next"
android:contentDescription="@string/skip" />
</LinearLayout>
......@@ -2,18 +2,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".activity.MainActivity">
<item
android:id="@+id/action_login"
android:orderInCategory="1"
android:title="Login"
android:checkable="true"
android:onClick="doLogin"
/>
<item
android:id="@+id/action_settings"
android:orderInCategory="2"
android:title="Settings"/>
<item
android:id="@+id/action_exit"
......
......@@ -6,7 +6,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'org.ajoberstar:grgit:1.4.+'
classpath 'com.github.triplet.gradle:play-publisher:1.2.0'
......
#Fri Oct 20 03:09:53 CEST 2017
#Wed Nov 01 00:17:57 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment