Skip to content

Commit

Permalink
Stores the read/write permission on external storage with Android 5.0
Browse files Browse the repository at this point in the history
Fixed deprecated color functions
  • Loading branch information
Arcus92 committed Nov 9, 2015
1 parent b44fcdf commit 6e2a763
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 12 deletions.
22 changes: 22 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -131,9 +132,9 @@ public void setSelected(T item, boolean state, View view) {
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));
}
}

Expand Down Expand Up @@ -211,9 +212,9 @@ public void clearActionMode() {
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));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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;
Expand Down Expand Up @@ -159,6 +160,13 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -108,7 +109,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
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);
Expand All @@ -119,7 +120,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
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) {
Expand All @@ -140,12 +141,12 @@ public View getView(int position, View convertView, ViewGroup parent) {
// 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
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;
Expand Down Expand Up @@ -211,12 +212,13 @@ public void setButtonActive(Button button, boolean active) {
// 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
Expand Down

0 comments on commit 6e2a763

Please sign in to comment.