Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request #508 from a93h/master
Browse files Browse the repository at this point in the history
Codename Engus is ready for production
  • Loading branch information
Austin H committed Sep 9, 2019
2 parents 1cca2b4 + f3a72b4 commit 4545382
Show file tree
Hide file tree
Showing 26 changed files with 742 additions and 65 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Before the release of a new version of SLS, it will be available here to test fo
* markers in scrobble cache for logged in accounts
* Store scrobbles before user is logged in
* Manual scrobbling, for example Vinyl Records, CD, Cassette and other older media machines.
* Import database

## Features

Expand Down
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 "com.adam.aslfms"
minSdkVersion 14
targetSdkVersion 26
versionCode = 52
versionName = "1.6.1"
versionCode = 53
versionName = "1.6.2"

testApplicationId "com.adam.aslfms.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/assets/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ Visit,
https://github.com/simple-last-fm-scrobbler/sls
For more details.

- 1.6.2 (2018-9-8) codename: engus
* Fixed music not being recognized immediately
* Skip permissions optionally
* Language selection

- 1.6.1 (2018-9-7) codename: dingus
* Fixed icon kitkat

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/com/adam/aslfms/ChangeThemeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@

package com.adam.aslfms;

import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;

import com.adam.aslfms.util.AppSettings;
import com.adam.aslfms.util.MyContextWrapper;

/**
* @author a93h
* @since 1.5.8
Expand All @@ -38,6 +42,11 @@ public class ChangeThemeActivity extends AppCompatActivity {
private static final String TAG = "ChangeThemeActivity";
private AppSettings settings;

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(MyContextWrapper.wrap(newBase));
}

@Override
public Resources.Theme getTheme() {
settings = new AppSettings(this);
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/com/adam/aslfms/MusicAppsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

package com.adam.aslfms;

import android.content.Context;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
Expand All @@ -36,6 +37,7 @@

import com.adam.aslfms.receiver.MusicAPI;
import com.adam.aslfms.util.AppSettings;
import com.adam.aslfms.util.MyContextWrapper;
import com.adam.aslfms.util.Util;
import com.example.android.supportv7.app.AppCompatPreferenceActivity;

Expand All @@ -58,6 +60,11 @@ public class MusicAppsActivity extends AppCompatPreferenceActivity {

private AppSettings settings;

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(MyContextWrapper.wrap(newBase));
}

@Override
public Resources.Theme getTheme() {
settings = new AppSettings(this);
Expand Down
42 changes: 40 additions & 2 deletions app/src/main/java/com/adam/aslfms/OptionsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

package com.adam.aslfms;

import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
Expand All @@ -34,13 +36,16 @@
import android.view.MenuItem;

import com.adam.aslfms.util.AppSettings;
import com.adam.aslfms.util.MyContextWrapper;
import com.adam.aslfms.util.Util;
import com.adam.aslfms.util.enums.AdvancedOptions;
import com.adam.aslfms.util.enums.AdvancedOptionsWhen;
import com.adam.aslfms.util.enums.NetworkOptions;
import com.adam.aslfms.util.enums.PowerOptions;
import com.example.android.supportv7.app.AppCompatPreferenceActivity;

import java.util.Arrays;

public class OptionsActivity extends AppCompatPreferenceActivity {
private static final String TAG = "OptionsGeneralScreen";

Expand All @@ -50,13 +55,23 @@ public class OptionsActivity extends AppCompatPreferenceActivity {
private static final String KEY_PLUGGED = "ao_plugged";
private static final String KEY_EXPORT_DB = "export_database";
private static final String KEY_NOTIFICATION_PRIORITY = "notification_priority";
private static final String KEY_LANGUAGES_LIST = "languages_list";
private static final String KEY_PERMISSION_SHOW = "permission_activity_show";

private AppSettings settings;

private SeekBarPreference mScrobblePoint;
private PowerSpecificPrefs mBatteryOptions;
private PowerSpecificPrefs mPluggedOptions;

Context ctx = this;


@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(MyContextWrapper.wrap(newBase));
}

@Override
public Resources.Theme getTheme() {
settings = new AppSettings(this);
Expand Down Expand Up @@ -163,6 +178,7 @@ public PowerSpecificPrefs(PowerOptions power,
private PowerOptions power;
private PreferenceCategory category;

private Preference showPermissionActivity;
private ListPreference chooser;
private CheckBoxPreference active_app;
private CheckBoxPreference scrobble;
Expand All @@ -173,6 +189,7 @@ public PowerSpecificPrefs(PowerOptions power,
private CheckBoxPreference roaming;
private Preference exportdatabase;
private ListPreference notification_priority;
private ListPreference languages_list;

public void create() {
createChooserPreference();
Expand All @@ -184,8 +201,31 @@ public void create() {
createNetPreference();
createRoamingPreference();
exportdatabase = findPreference(KEY_EXPORT_DB);
showPermissionActivity = findPreference(KEY_PERMISSION_SHOW);
notification_priority = (ListPreference) findPreference(KEY_NOTIFICATION_PRIORITY);
notification_priority.setDefaultValue(Util.notificationStringToInt(getApplicationContext()));
languages_list = (ListPreference) findPreference(KEY_LANGUAGES_LIST);
notification_priority.setOnPreferenceChangeListener((Preference preference, Object object) -> {
settings.setKeyNotificationPriority(notification_priority.getValue());
return false;
}
);
languages_list.setOnPreferenceChangeListener((Preference preference, Object object) -> {
String userSelection = (String) object;
String[] country_codes = getResources().getStringArray(R.array.language_codes);
String[] langauge_list = getResources().getStringArray(R.array.language_list);
int position = Arrays.asList(langauge_list).indexOf(userSelection);
settings.setAppLocale(country_codes[position]);
recreate();
return false;
}
);
showPermissionActivity.setOnPreferenceClickListener((Preference preference) ->{
Intent i = new Intent(ctx, PermissionsActivity.class);
startActivity(i);
return false;
}
);
}

public boolean onClick(Preference pref) {
Expand All @@ -207,8 +247,6 @@ public boolean onClick(Preference pref) {
return true;
} else if (pref == exportdatabase) {
Util.exportAllDatabases(getApplicationContext());
} else if (pref == notification_priority){
settings.setKeyNotificationPriority(notification_priority.getValue());
}
return false;
}
Expand Down
55 changes: 47 additions & 8 deletions app/src/main/java/com/adam/aslfms/PermissionsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
package com.adam.aslfms;

import android.Manifest;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
Expand All @@ -29,13 +31,15 @@
import android.os.Bundle;
import android.provider.Settings;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.adam.aslfms.util.AppSettings;
import com.adam.aslfms.util.MyContextWrapper;
import com.adam.aslfms.util.Util;
/**
* @author a93h
Expand All @@ -46,17 +50,23 @@ public class PermissionsActivity extends AppCompatActivity {
private static final String TAG = "PermissionsActivity";

int WRITE_EXTERNAL_STORAGE;
int REQUEST_READ_STORAGE;
int REQUEST_IGNORE_BATTERY_OPTIMIZATIONS;
int disabledColor = Color.argb(25, 0,0,0);
int enabledColor = Color.argb(75, 0,255,0);
int warningColor = Color.argb(80,255,0,0);

Button btnContinue = null;
AppSettings settings = null;
Button btnSkip = null;
Context ctx = this;

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(MyContextWrapper.wrap(newBase));
}

@Override
public Resources.Theme getTheme() {
AppSettings settings = new AppSettings(this);
settings = new AppSettings(this);
Resources.Theme theme = super.getTheme();
theme.applyStyle(settings.getAppTheme(), true);
Log.d(TAG, getResources().getResourceName(settings.getAppTheme()));
Expand All @@ -76,7 +86,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_permissions);

AppSettings settings = new AppSettings(this);
settings = new AppSettings(this);
setTheme(settings.getAppTheme());

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
Expand All @@ -88,7 +98,8 @@ protected void onCreate(Bundle savedInstanceState) {

public void checkCurrrentPermissions(){
boolean enabled;
btnContinue = findViewById(R.id.button_continue);
btnSkip = findViewById(R.id.button_skip);
btnSkip.setBackgroundColor(enabledColor);
Button externalPermBtn = findViewById(R.id.button_permission_external_storage);
Button notifiPermBtn = findViewById(R.id.button_permission_notification_listener);
Button batteryPermBtn = findViewById(R.id.button_permission_battery_optimizations);
Expand Down Expand Up @@ -164,6 +175,34 @@ public void checkCurrrentPermissions(){
colorPermission(true, batteryBasicPermBtn);
}
});

btnSkip.setOnClickListener((View view) -> {
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which){
case DialogInterface.BUTTON_POSITIVE:
settings.setKeyBypassNewPermissions(1);
Intent intent = new Intent(ctx, SettingsActivity.class);
ctx.startActivity(intent);
Util.runServices(ctx);
break;

case DialogInterface.BUTTON_NEGATIVE:
break;
}
}
};

AlertDialog.Builder builder = new AlertDialog.Builder(this);
String message = ctx.getResources().getString(R.string.are_you_sure);
if (Build.VERSION_CODES.O <= Build.VERSION.SDK_INT && !Util.checkNotificationListenerPermission(ctx)){
message += " " + ctx.getResources().getString(R.string.warning_will_not_scrobble);
message += "/" + ctx.getResources().getString(R.string.permission_notification_listener);
}
builder.setMessage(message).setPositiveButton(R.string.yes, dialogClickListener)
.setNegativeButton(R.string.no, dialogClickListener).show();
});
}

public void colorPermission(boolean enabled, Button button){
Expand All @@ -176,18 +215,18 @@ public void colorPermission(boolean enabled, Button button){

private void permsCheck() {
//PERMISSION CHECK

boolean allPermissionsGo = true;
allPermissionsGo = allPermissionsGo && Util.checkNotificationListenerPermission(this);
allPermissionsGo = allPermissionsGo && Util.checkExternalPermission(this);
allPermissionsGo = allPermissionsGo && Util.checkBatteryOptimizationsPermission(this);
allPermissionsGo = allPermissionsGo && Util.checkBatteryOptimizationBasicPermission(this);
Log.d(TAG,"All Permissions Go: " + allPermissionsGo);
if (allPermissionsGo) {
btnContinue.setBackgroundColor(enabledColor);
Intent intent = new Intent(this, SettingsActivity.class);
this.startActivity(intent);
} else {
btnContinue.setBackgroundColor(disabledColor);
settings.setKeyBypassNewPermissions(0);
Util.runServices(ctx);
}
}

Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/com/adam/aslfms/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.adam.aslfms.service.NetApp;
import com.adam.aslfms.service.ScrobblingService;
import com.adam.aslfms.util.AppSettings;
import com.adam.aslfms.util.MyContextWrapper;
import com.adam.aslfms.util.ScrobblesDatabase;
import com.adam.aslfms.util.Util;
import com.example.android.supportv7.app.AppCompatPreferenceActivity;
Expand Down Expand Up @@ -79,6 +80,11 @@ public class SettingsActivity extends AppCompatPreferenceActivity {

Context mCtx;

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(MyContextWrapper.wrap(newBase));
}

@Override
public Resources.Theme getTheme() {
settings = new AppSettings(this);
Expand Down Expand Up @@ -121,10 +127,9 @@ protected void onCreate(Bundle savedInstanceState) {

// TODO: VERIFY EVERYTHING BELOW IS SAFE
int v = Util.getAppVersionCode(this, getPackageName());
if (settings.getWhatsNewViewedVersion() < v) {
if (settings.getWhatsNewViewedVersion() < v && settings.getKeyBypassNewPermissions() != 2) {
new WhatsNewDialog(this).show();
settings.setWhatsNewViewedVersion(v);
mDb.rebuildDataBaseOnce(); // TODO: VERSION 1.5.9 only!
}
Util.runServices(this); // Scrobbler, Controller, Notification
}
Expand Down Expand Up @@ -252,6 +257,9 @@ private void credsCheck() {
}

private void permsCheck() {
if (settings.getKeyBypassNewPermissions() == 1){
return;
}
//PERMISSION CHECK
boolean allPermissionsGo = true;
allPermissionsGo = allPermissionsGo && Util.checkNotificationListenerPermission(this);
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/adam/aslfms/UserCredActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.adam.aslfms.service.NetApp;
import com.adam.aslfms.service.ScrobblingService;
import com.adam.aslfms.util.AppSettings;
import com.adam.aslfms.util.MyContextWrapper;
import com.adam.aslfms.util.Util;
import com.example.android.supportv7.app.AppCompatPreferenceActivity;

Expand All @@ -61,6 +62,11 @@ public class UserCredActivity extends AppCompatPreferenceActivity {
private Preference mClearCreds;
private Preference mCreateUser;

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(MyContextWrapper.wrap(newBase));
}

@Override
public Resources.Theme getTheme() {
settings = new AppSettings(this);
Expand Down

0 comments on commit 4545382

Please sign in to comment.