Skip to content

Commit

Permalink
setting page, adjust lyrics list view
Browse files Browse the repository at this point in the history
  • Loading branch information
blackfur committed Sep 29, 2015
1 parent 1ecd9c2 commit f155798
Show file tree
Hide file tree
Showing 20 changed files with 283 additions and 479 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
applicationId "com.shirokuma.musicplayer"
minSdkVersion 13
targetSdkVersion 22
versionCode 2
versionName "1.1"
versionCode 3
versionName "v1.2"
}

compileOptions {
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

<application
android:name=".KumalrcApplication"
android:installLocation="preferExternal"
android:allowBackup="true"
android:icon="@drawable/kumalrc_icon"
android:installLocation="preferExternal"
android:label="@string/app_name"
android:theme="@style/kumalrc_theme">
<activity
Expand All @@ -37,6 +37,9 @@
android:name=".GuideActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<activity
android:screenOrientation="portrait"
android:name=".setting.SettingActivity"/>

<service android:name=".playback.MusicService"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class MediaSetting {
private final String KEY_FIRST_INSTALL = "first_install";
private final String KEY_SHUFFLE = "shuffle";
private final String KEY_LAST_PLAY_PROGRESS = "last_play_progress";
private final String KEY_LAST_PLAY_SAVE = "last_play_save";
private final String KEY_LAST_FITER_TYPE = "last_fiter_type";
private final String KEY_LAST_FITER_ARTIST = "last_fiter_artist";
private final String KEY_LAST_FITER_ALBUM = "last_fiter_album";
Expand Down Expand Up @@ -87,4 +88,14 @@ public Filter getLastFilter() {
f.artist = mSharedPre.getString(KEY_LAST_FITER_ARTIST, null);
return f;
}

public void setSaveLast(boolean b) {
SharedPreferences.Editor editor = mSharedPre.edit();
editor.putBoolean(KEY_LAST_PLAY_SAVE, b);
editor.commit();
}

public boolean getSaveLast() {
return mSharedPre.getBoolean(KEY_LAST_PLAY_SAVE, true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.shirokuma.musicplayer.setting;

import android.app.ProgressDialog;
import android.content.pm.PackageManager;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.TextView;
import android.widget.ToggleButton;
import com.shirokuma.musicplayer.R;
import com.shirokuma.musicplayer.common.BaseActivity;

public class SettingActivity extends BaseActivity {
private View mBtnBack, btnLogin, btnScan;
private ToggleButton toggleShuffle, toggleSaveLast;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

@Override
protected void initData() {
}

@Override
protected void initView() {
mBtnBack = findViewById(R.id.btn_back);
toggleShuffle = (ToggleButton) findViewById(R.id.shuffle);
toggleSaveLast = (ToggleButton) findViewById(R.id.save_last);
btnLogin = findViewById(R.id.login);
btnScan = findViewById(R.id.scan);
final TextView version = (TextView) findViewById(R.id.version);
mBtnBack.postDelayed(new Runnable() {
@Override
public void run() {
try {
version.setText(getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
mBtnBack.setOnClickListener(mBtnListener);
toggleShuffle.setChecked(MediaSetting.getInstance(getApplicationContext()).getShuffle());
toggleSaveLast.setChecked(MediaSetting.getInstance(getApplicationContext()).getSaveLast());
btnLogin.setOnClickListener(mBtnListener);
btnScan.setOnClickListener(mBtnListener);
}
}, 200);
}

@Override
protected int setContentViewRes() {
return R.layout.activity_setting;
}

@Override
protected void onDestroy() {
MediaSetting.getInstance(getApplicationContext()).setShuffle(toggleShuffle.isChecked());
MediaSetting.getInstance(getApplicationContext()).setSaveLast(toggleSaveLast.isChecked());
super.onDestroy();
}

private ProgressDialog mProgress;
protected View.OnClickListener mBtnListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_back:
finish();
break;
case R.id.scan:
MediaScannerConnection.scanFile(getApplicationContext(), new String[]{Environment
.getExternalStorageDirectory().getAbsolutePath()}, null, new MediaScannerConnection.OnScanCompletedListener() {
@Override
public void onScanCompleted(String path, Uri uri) {
if (mProgress != null) {
mProgress.dismiss();
mProgress = null;
}
}
});
mProgress = ProgressDialog.show(SettingActivity.this, "", getString(R.string.scanning));
break;
}
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.shirokuma.musicplayer.KumalrcApplication;
import com.shirokuma.musicplayer.R;
import com.shirokuma.musicplayer.setting.MediaSetting;
import com.shirokuma.musicplayer.setting.SettingActivity;
import com.shirokuma.musicplayer.setting.TimerActivity;
import com.shirokuma.musicplayer.playback.MusicBroadcast;
import com.shirokuma.musicplayer.playback.MusicService;
Expand Down Expand Up @@ -130,6 +131,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.action_timer:
startActivity(new Intent(this, TimerActivity.class));
break;
case R.id.action_setting:
if (mMusicSrv != null && mMusicSrv.isPlaying())
mMusicSrv.stop();
startActivity(new Intent(this, SettingActivity.class));
break;
}
return super.onOptionsItemSelected(item);
}
Expand Down
228 changes: 0 additions & 228 deletions app/src/main/java/com/shirokuma/musicplayer/lyrics/Lyrics.java

This file was deleted.

Loading

0 comments on commit f155798

Please sign in to comment.