Skip to content

Commit

Permalink
Fixed some bug in shuffle, Added ability to set cache size, added a d…
Browse files Browse the repository at this point in the history
…onate page
  • Loading branch information
deep-gaurav committed Nov 1, 2018
1 parent a022c5b commit 30e60f9
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "deep.ryd.rydplayer"
minSdkVersion 21
targetSdkVersion 28
versionCode 11
versionName "0.1.8-beta"
versionCode 12
versionName "0.1.9-beta"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".About"></activity>
<activity
android:name=".SettingsActivity"
android:label="@string/title_activity_settings"></activity>
android:label="@string/title_activity_settings" />
<activity
android:name=".PlaylistUniversal"
android:theme="@style/NoActionBarTheme" />
Expand Down
30 changes: 30 additions & 0 deletions app/src/main/java/deep/ryd/rydplayer/About.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package deep.ryd.rydplayer;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class About extends AppCompatActivity {

Button donate;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);

donate = findViewById(R.id.donate);
donate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://en.liberapay.com/deepgaurav/"));
startActivity(intent);
}
});
}
}
5 changes: 5 additions & 0 deletions app/src/main/java/deep/ryd/rydplayer/Main2Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
startActivity(i);
return true;
}
else if(id == R.id.action_donate){
Intent i = new Intent(this,About.class);
startActivity(i);
return true;
}

return super.onOptionsItemSelected(item);
}
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/deep/ryd/rydplayer/PlayerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void nextSong(){
Log.i("ryd","Old streamurl "+streamInfo.getAudioStreams().get(0).getUrl());
if(currentIndex!=queue.size()-1) {
if(getSharedPreferences("InternalSettings",Context.MODE_PRIVATE).getInt("Shuffle",0)==1)
currentIndex=new Random().nextInt()%queue.size();
currentIndex=abs(new Random().nextInt())%queue.size();
else
currentIndex++;
playfromQueue(true);
Expand Down Expand Up @@ -510,7 +510,8 @@ public void onReceive(Context context, Intent intent) {
intent1.setAction(MainActivity.MAINACTIVITYTBROADCASTACTION);
mainobj.sendBroadcast(intent1);

mainobj.stopForeground(true);
//mainobj.stopForeground(true);

mainobj.stopSelf();
mainobj.stopForeground(true);
}
Expand Down
36 changes: 35 additions & 1 deletion app/src/main/java/deep/ryd/rydplayer/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import android.preference.PreferenceManager;
import android.preference.RingtonePreference;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.MenuItem;
import android.widget.CompoundButton;
import android.widget.EditText;
Expand All @@ -32,15 +34,17 @@
public class SettingsActivity extends AppCompatActivity {

Switch audiofocus;
EditText cacheSize;

@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_layout);

audiofocus=findViewById(R.id.audioFocus);
cacheSize=findViewById(R.id.cacheS);


cacheSize.setText(String.valueOf(getSharedPreferences("Settings",Context.MODE_PRIVATE).getInt("cacheSize",100)));
audiofocus.setChecked(getSharedPreferences("Settings",Context.MODE_PRIVATE).getBoolean("respectAudioFocus",true));
audiofocus.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
Expand All @@ -52,6 +56,36 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
});

cacheSize.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {

}

@Override
public void afterTextChanged(Editable s) {
try {
String s1 = s.toString();
int cach = Integer.parseInt(s1);
if(cach>=0) {
SharedPreferences sharedPreferences = getSharedPreferences("Settings", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.remove("cacheSize");
editor.putInt("cacheSize", cach);
editor.commit();
}
}
catch (Exception e){

}
}
});

}

}
43 changes: 43 additions & 0 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".About">

<TextView
android:id="@+id/thanks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="115dp"
android:layout_marginEnd="8dp"
android:text="Thank You!"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textView6"
android:layout_width="313dp"
android:layout_height="wrap_content"
android:layout_marginTop="76dp"
android:layout_marginEnd="8dp"
android:text="Thank You all for using this app, If you like it and want to support me in further developing this and other apps, consider donating, :)"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.571"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/thanks" />

<Button
android:id="@+id/donate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="189dp"
android:text="Donate"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
28 changes: 28 additions & 0 deletions app/src/main/res/layout/settings_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,32 @@
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<EditText
android:id="@+id/cacheS"
android:layout_width="101dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:ems="10"
android:inputType="number"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.923"
app:layout_constraintStart_toEndOf="@+id/textView5"
app:layout_constraintTop_toBottomOf="@+id/audioFocus" />

<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:text="Audio Cache Size (MB) "
android:textColor="@color/DarkText"
app:layout_constraintBottom_toBottomOf="@+id/cacheS"
app:layout_constraintStart_toStartOf="@+id/audioFocus"
app:layout_constraintTop_toBottomOf="@+id/audioFocus"
app:layout_constraintVertical_bias="0.526" />

</android.support.constraint.ConstraintLayout>
5 changes: 5 additions & 0 deletions app/src/main/res/menu/new_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
<item
android:id="@+id/action_donate"
android:orderInCategory="101"
android:title="Donate"
app:showAsAction="never" />
<item
android:id="@+id/action_search"
android:icon="@android:drawable/ic_menu_search"
Expand Down

0 comments on commit 30e60f9

Please sign in to comment.