Stores the read/write permission on external storage with Android 5.0

Fixed deprecated color functions
This commit is contained in:
David 2015-11-09 21:25:51 +01:00
parent b44fcdf9e9
commit 6e2a763494
9 changed files with 101 additions and 12 deletions

22
.idea/compiler.xml Normal file
View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

View file

@ -0,0 +1,7 @@
<component name="CopyrightManager">
<settings default="MIT">
<module2copyright>
<element module="All" copyright="MIT" />
</module2copyright>
</settings>
</component>

31
.idea/misc.xml Normal file
View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
</project>

11
.idea/modules.xml Normal file
View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/PlayMusicExporter.iml" filepath="$PROJECT_DIR$/PlayMusicExporter.iml" />
<module fileurl="file://$PROJECT_DIR$/framework/framework.iml" filepath="$PROJECT_DIR$/framework/framework.iml" />
<module fileurl="file://$PROJECT_DIR$/playmusicexporter/playmusicexporter.iml" filepath="$PROJECT_DIR$/playmusicexporter/playmusicexporter.iml" />
<module fileurl="file://$PROJECT_DIR$/playmusiclib/playmusiclib.iml" filepath="$PROJECT_DIR$/playmusiclib/playmusiclib.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -23,6 +23,7 @@
package de.arcus.framework.utils;
import android.support.annotation.ColorRes;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.view.ActionMode;
import android.view.View;
@ -131,9 +132,9 @@ public abstract class SelectionList<T> {
if (view != null) {
// Change the background
if (state)
view.setBackgroundColor(view.getResources().getColor(mResColorSelected));
view.setBackgroundColor(ContextCompat.getColor(view.getContext(), mResColorSelected));
else
view.setBackgroundColor(view.getResources().getColor(mResColorNormal));
view.setBackgroundColor(ContextCompat.getColor(view.getContext(), mResColorNormal));
}
}
@ -211,9 +212,9 @@ public abstract class SelectionList<T> {
public void initView(T item, View view) {
// Change the background
if (isSelected(item))
view.setBackgroundColor(view.getResources().getColor(mResColorSelected));
view.setBackgroundColor(ContextCompat.getColor(view.getContext(), mResColorSelected));
else
view.setBackgroundColor(view.getResources().getColor(mResColorNormal));
view.setBackgroundColor(ContextCompat.getColor(view.getContext(), mResColorNormal));
}
/**

View file

@ -25,6 +25,7 @@ package de.arcus.playmusicexporter2.activities;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
@ -159,6 +160,13 @@ public class SettingsActivity extends PreferenceActivity {
Logger.getInstance().logInfo("Uri", uri.toString());
// Saves the permission
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {
getContentResolver().takePersistableUriPermission(uri,
Intent.FLAG_GRANT_READ_URI_PERMISSION |
Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
}
mSettings.setUri(PlayMusicExporterSettings.PREF_EXPORT_URI, uri);
// Update the label

View file

@ -23,6 +23,7 @@
package de.arcus.playmusicexporter2.adapter;
import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
@ -108,7 +109,7 @@ public class MusicTrackListAdapter extends ArrayAdapter<MusicTrack> {
else
textView.setText("");
textView.setTextColor(mContext.getResources().getColor(musicTrack.isOfflineAvailable() ? R.color.text_music_number : R.color.text_music_disable_number));
textView.setTextColor(ContextCompat.getColor(mContext, musicTrack.isOfflineAvailable() ? R.color.text_music_number : R.color.text_music_disable_number));
// Sets the disc number
textView = (TextView)view.findViewById(R.id.text_music_track_disc_number);
@ -119,7 +120,7 @@ public class MusicTrackListAdapter extends ArrayAdapter<MusicTrack> {
else
textView.setVisibility(View.GONE);
textView.setTextColor(mContext.getResources().getColor(musicTrack.isOfflineAvailable() ? R.color.text_music_disc_number : R.color.text_music_disable_disc_number));
textView.setTextColor(ContextCompat.getColor(mContext, musicTrack.isOfflineAvailable() ? R.color.text_music_disc_number : R.color.text_music_disable_disc_number));
if (mShowArtworks) {
@ -140,12 +141,12 @@ public class MusicTrackListAdapter extends ArrayAdapter<MusicTrack> {
// Sets the title
textView = (TextView)view.findViewById(R.id.text_music_track_title);
textView.setText(musicTrack.getTitle());
textView.setTextColor(mContext.getResources().getColor(musicTrack.isOfflineAvailable() ? R.color.text_music_title : R.color.text_music_disable_title));
textView.setTextColor(ContextCompat.getColor(mContext, musicTrack.isOfflineAvailable() ? R.color.text_music_title : R.color.text_music_disable_title));
// Sets the artist
textView = (TextView)view.findViewById(R.id.text_music_track_artist);
textView.setText(musicTrack.getArtist());
textView.setTextColor(mContext.getResources().getColor(musicTrack.isOfflineAvailable() ? R.color.text_music_description : R.color.text_music_disable_description));
textView.setTextColor(ContextCompat.getColor(mContext, musicTrack.isOfflineAvailable() ? R.color.text_music_description : R.color.text_music_disable_description));
// Track is available?
view.setEnabled(musicTrack.isOfflineAvailable());

View file

@ -28,6 +28,7 @@ import android.content.res.Configuration;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
@ -211,12 +212,13 @@ public class NavigationDrawerFragment extends Fragment {
// Button is active
if (active) {
// Gets the active color
colorText = getResources().getColor(R.color.button_navigation_drawer_text_active);
colorBackground = getResources().getColor(R.color.button_navigation_drawer_active);
colorText = ContextCompat.getColor(getContext(), R.color.button_navigation_drawer_text_active);
colorBackground = ContextCompat.getColor(getContext(), R.color.button_navigation_drawer_active);
} else {
// Gets the normal color
colorText = getResources().getColor(R.color.button_navigation_drawer_text);
colorBackground = getResources().getColor(R.color.button_navigation_drawer_normal);
colorText = ContextCompat.getColor(getContext(), R.color.button_navigation_drawer_text);
colorBackground = ContextCompat.getColor(getContext(), R.color.button_navigation_drawer_normal);
}
// Sets the color