Commit 6dc50c6b authored by Daniel Sonck's avatar Daniel Sonck
Browse files

Merge pull request #16 in THFM/fm.touhou.touhoufm from new-client to development

* commit 'b8187493':
  Various features
parents b6c47d4d b8187493
......@@ -8,5 +8,6 @@
/captures
.directory
.idea
/gradle
app/keys\.json
This diff is collapsed.
......@@ -5,7 +5,7 @@ apply plugin: 'com.github.triplet.play'
if(project.hasProperty("TouHouFM.signing")
&& new File(project.property("TouHouFM.signing") + ".gradle").exists()) {
apply from: project.property("TouHouFM.signing") + ".gradle";
apply from: project.property("TouHouFM.signing") + ".gradle"
}
ext {
......@@ -13,6 +13,51 @@ ext {
gitVersionCode = git.tag.list().size()+11 // Add the base that is still on google
gitVersionName = "${git.describe()}"
}
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'org.powermock:powermock:1.6.5'
testImplementation 'org.powermock:powermock-module-junit4:1.6.5'
testImplementation 'org.powermock:powermock-api-mockito:1.6.5'
implementation "com.android.support:support-v4:27.0.2"
implementation "com.android.support:support-v13:27.0.2"
implementation "com.android.support:cardview-v7:27.0.2"
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'org.java-websocket:Java-WebSocket:1.3.7'
implementation 'com.facebook.fresco:fresco:1.8.0'
}
// The sample build uses multiple directories to
// keep boilerplate and common code separate from
// the main sample code.
List<String> dirs = [
'main', // main sample code; look here for the interesting stuff.
'common', // components that are reused by multiple samples
'template'] // boilerplate code that is generated by the sample template process
android {
playAccountConfigs {
defaultAccountConfig {
......@@ -20,26 +65,38 @@ android {
}
}
compileSdkVersion 26
buildToolsVersion "26.0.2"
compileSdkVersion 27
sourceSets {
main {
jniLibs.srcDir 'src/main/jni'
jni.srcDirs = []
}
}
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "fm.touhou.touhoufm"
minSdkVersion 14
targetSdkVersion 26
targetSdkVersion 27
applicationId "fm.touhou.touhoufm"
versionCode gitVersionCode
versionName gitVersionName
playAccountConfig = playAccountConfigs.defaultAccountConfig
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
dirs.each { dir ->
java.srcDirs "src/${dir}/java"
res.srcDirs "src/${dir}/res"
}
}
androidTest.setRoot('tests')
androidTest.java.srcDirs = ['tests/src']
}
buildTypes {
release {
minifyEnabled false
......@@ -49,23 +106,10 @@ android {
applicationIdSuffix ".debug"
}
}
externalNativeBuild {
cmake {
path 'src/main/cpp/CMakeLists.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
testCompile 'org.powermock:powermock:1.6.5'
testCompile 'org.powermock:powermock-module-junit4:1.6.5'
testCompile 'org.powermock:powermock-api-mockito:1.6.5'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'org.java-websocket:Java-WebSocket:1.3.7'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
}
......@@ -4,7 +4,7 @@
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more artist, see
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
......@@ -15,3 +15,11 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package fm.touhou.touhoufm;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
* Copyright 2018 Daniel Sonck
*
* This file is part of fm.touhou.touhoufm.
*
* fm.touhou.touhoufm 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, version 2.
*
* fm.touhou.touhoufm 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 fm.touhou.touhoufm. If not, see <http://www.gnu.org/licenses/>.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fm.touhou.touhoufm">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name="fm.touhou.touhoufm.activity.MainActivity"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name=".TouHouFM">
<activity
android:name=".ui.MainActivity"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.touhou.fm"
android:path="/android"
android:scheme="http" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<service
android:name="fm.touhou.touhoufm.service.RadioService"
android:enabled="true"
android:exported="false" />
android:name=".service.MusicService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</service>
<!--
MediaSession, prior to API 21, uses a broadcast receiver to communicate with a
media session. It does not have to be this broadcast receiver, but it must
handle the action "android.intent.action.MEDIA_BUTTON".
Additionally, this is used to resume the service from an inactive state upon
receiving a media button event (such as "play").
-->
<receiver android:name="android.support.v4.media.session.MediaButtonReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON"/>
</intent-filter>
</receiver>
</application>
</manifest>
</manifest>
\ No newline at end of file
//
// Created by dsonck on 31-10-17.
//
/*
* Copyright 2018 Daniel Sonck
*
* This file is part of fm.touhou.touhoufm.
*
* fm.touhou.touhoufm 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, version 2.
*
* fm.touhou.touhoufm 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 fm.touhou.touhoufm. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <stdint.h>
#include <android/log.h>
......@@ -107,6 +122,8 @@ jboolean releaseDecoder(JNIEnv *env, jobject obj) {
(void) env;
(void) obj;
__android_log_write(ANDROID_LOG_DEBUG, "libopus", "Released Opus Decoder");
free(gOpusDecoder);
return 1;
......
//
// Created by dsonck on 31-10-17.
//
/*
* Copyright 2018 Daniel Sonck
*
* This file is part of fm.touhou.touhoufm.
*
* fm.touhou.touhoufm 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, version 2.
*
* fm.touhou.touhoufm 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 fm.touhou.touhoufm. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef TOUHOU_FM_OPUSJNI_HPP
#define TOUHOU_FM_OPUSJNI_HPP
......
package fm.touhou.touhoufm;
/**
* Helper class for providing sample title for user interfaces created by
* Android template wizards.
* <p/>
* TODO: Replace all uses of this class before publishing your app.
*/
public class PlaylistItem {
public final String title;
public final String artist;
public final String album;
public final String circle;
public PlaylistItem(String title, String artist,
String album, String circle) {
this.title = title;
this.artist = artist;
this.album = album;
this.circle = circle;
}
@Override
public String toString() {
return title + " - " + artist + " - " + album + " ( " + circle + " )";
}
}
package fm.touhou.touhoufm;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* Created by dsonck on 18-2-16. Part of TouHou.FM. Part of TouHou.FM.
* {@link ImageView} that always tries to be square
*/
public class SquareImageView extends android.support.v7.widget.AppCompatImageView {
public SquareImageView(Context context)
{
super(context);
}
public SquareImageView(Context context, AttributeSet attrs) {
super(context,attrs);
}
public SquareImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int minimalSize = Math.min(getMeasuredWidth(),getMeasuredHeight());
if(minimalSize != getMeasuredWidth() || minimalSize != getMeasuredHeight())
setMeasuredDimension(minimalSize,minimalSize);
}
}
/*
* Copyright 2018 Daniel Sonck
*
* This file is part of fm.touhou.touhoufm.
*
* fm.touhou.touhoufm 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, version 2.
*
* fm.touhou.touhoufm 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 fm.touhou.touhoufm. If not, see <http://www.gnu.org/licenses/>.
*
*/
package fm.touhou.touhoufm;
import android.app.Application;
import com.facebook.drawee.backends.pipeline.Fresco;
public class TouHouFM extends Application {
@Override
public void onCreate() {
super.onCreate();
Fresco.initialize(this);
}
}
package fm.touhou.touhoufm.activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatDelegate;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
* to be used with AppCompat.
*/
public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
private AppCompatDelegate mDelegate;
@Override
protected void onCreate(Bundle savedInstanceState) {
getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
getDelegate().onPostCreate(savedInstanceState);
}
@NonNull
@Override
public MenuInflater getMenuInflater() {
return getDelegate().getMenuInflater();
}
@Override
public void setContentView(@LayoutRes int layoutResID) {
getDelegate().setContentView(layoutResID);
}
@Override
public void setContentView(View view) {
getDelegate().setContentView(view);
}
@Override
public void setContentView(View view, ViewGroup.LayoutParams params) {
getDelegate().setContentView(view, params);
}
@Override
public void addContentView(View view, ViewGroup.LayoutParams params) {
getDelegate().addContentView(view, params);
}
@Override
protected void onPostResume() {
super.onPostResume();
getDelegate().onPostResume();
}
@Override
protected void onTitleChanged(CharSequence title, int color) {
super.onTitleChanged(title, color);
getDelegate().setTitle(title);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
getDelegate().onConfigurationChanged(newConfig);
}
@Override
protected void onStop() {
super.onStop();
getDelegate().onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
getDelegate().onDestroy();
}
public void invalidateOptionsMenu() {
getDelegate().invalidateOptionsMenu();
}
private AppCompatDelegate getDelegate() {
if (mDelegate == null) {
mDelegate = AppCompatDelegate.create(this, null);
}
return mDelegate;
}
}
package fm.touhou.touhoufm.activity;
import android.annotation.TargetApi;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.PagerTabStrip;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.SeekBar;
import android.widget.TextView;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import java.util.List;
import fm.touhou.touhoufm.PlaylistItem;
import fm.touhou.touhoufm.R;
import fm.touhou.touhoufm.fragments.AlbumArtFragment;
import fm.touhou.touhoufm.fragments.PlaylistFragment;
import fm.touhou.touhoufm.fragments.SongInfoFragment;
import fm.touhou.touhoufm.service.RadioService;
import static android.provider.Settings.*;
public class MainActivity extends AppCompatActivity implements RadioService.Callbacks {
private Intent serviceIntent;
private AlbumArtFragment mAlbumArt;
private SongInfoFragment mNowPlaying;
private PlaylistFragment mPlaylist;
private boolean mLoggedIn;
private boolean mPlaying = false;
RadioService radioService;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ImageLoaderConfiguration configuration = ImageLoaderConfiguration.createDefault(this);
ImageLoader loader = ImageLoader.getInstance();
loader.init(configuration);
setContentView(R.layout.activity_main);